:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --panel: #ffffff;
  --ink: #0a0a0a;
  --muted: #646464;
  --soft: #e8e8e3;
  --line: #c9c9c2;
  --strong-line: #0a0a0a;
  --inverse: #ffffff;
  --shadow: 10px 10px 0 #0a0a0a;
  --soft-shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
  --sky: #eeeeea;
  --accent: #111111;
  --accent-2: #777777;
}

body.dark {
  color-scheme: dark;
  --bg: #050505;
  --panel: #101010;
  --ink: #f5f5f0;
  --muted: #a8a8a0;
  --soft: #191919;
  --line: #2f2f2f;
  --strong-line: #f5f5f0;
  --inverse: #050505;
  --shadow: 10px 10px 0 #f5f5f0;
  --soft-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  --sky: #181818;
  --accent: #f5f5f0;
  --accent-2: #8a8a8a;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(var(--soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--soft) 1px, transparent 1px),
    var(--bg);
  background-size: 34px 34px;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

button,
a {
  touch-action: manipulation;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(230px, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 76px;
  padding: 0 max(18px, calc((100vw - 1180px) / 2));
  border-bottom: 2px solid var(--strong-line);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(14px);
}

.brand {
  width: max-content;
  color: var(--ink);
  text-decoration: none;
  font-size: 26px;
  font-weight: 950;
  letter-spacing: -1px;
}

.brand::before {
  content: "";
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 9px;
  border: 2px solid var(--ink);
  background: var(--ink);
  box-shadow: 5px 5px 0 var(--bg);
  vertical-align: 1px;
}

.nav {
  display: flex;
  justify-content: center;
  gap: 0;
  border: 2px solid var(--strong-line);
  background: var(--panel);
}

.nav a {
  min-width: 88px;
  padding: 11px 16px;
  border-right: 2px solid var(--strong-line);
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.nav a:last-child {
  border-right: 0;
}

.nav a.is-active {
  background: var(--ink);
  color: var(--inverse);
}

.live-stats {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
}

.live-stats span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 10px;
  border: 2px solid var(--strong-line);
  background: var(--panel);
}

.live-stats b {
  color: var(--ink);
  font-weight: 950;
}

.live-stats i {
  width: 8px;
  height: 8px;
  background: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 12%, transparent);
}

.icon-button {
  justify-self: end;
  min-width: 48px;
  height: 42px;
  padding: 0 12px;
  border: 2px solid var(--strong-line);
  border-radius: 0;
  background: var(--panel);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.icon-button:hover,
.load-button:hover,
.game-actions button:hover,
.entry-form button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--ink);
}

main {
  width: min(1180px, calc(100% - 34px));
  margin: 0 auto;
}

.champion-strip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  margin: 20px 0 0;
  padding: 11px 16px;
  border: 2px solid var(--strong-line);
  background: var(--ink);
  color: var(--inverse);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.champion-strip span,
.champion-strip b,
.lock-line,
.board-meta span,
.game-hud,
.game-actions,
footer {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.champion-strip span {
  padding: 5px 8px;
  border: 1px solid currentColor;
  font-size: 11px;
  font-weight: 900;
}

.champion-strip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
}

.champion-strip b {
  font-size: 25px;
}

.view {
  display: none;
  padding: 34px 0 64px;
}

.view.is-active {
  display: block;
}

.entry-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 460px);
  gap: 32px;
  align-items: end;
  padding: 30px 0 22px;
}

.copy {
  min-width: 0;
}

h1 {
  max-width: 700px;
  margin: 0;
  font-size: clamp(43px, 7vw, 88px);
  line-height: 0.9;
  letter-spacing: 0;
}

.summary {
  max-width: 640px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.48;
}

.entry-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  align-self: center;
  border: 2px solid var(--strong-line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.entry-form input {
  min-width: 0;
  padding: 18px 16px;
  border: 0;
  border-right: 2px solid var(--strong-line);
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

.entry-form.is-invalid {
  box-shadow: 8px 8px 0 #d12c17;
}

.entry-form.is-invalid input {
  background: color-mix(in srgb, #d12c17 9%, var(--panel));
}

.entry-form button,
.load-button,
.game-actions button {
  border: 0;
  background: var(--ink);
  color: var(--inverse);
  font-weight: 950;
  cursor: pointer;
}

.entry-form button {
  font-size: 16px;
}

.lock-line {
  grid-column: 2;
  margin: -5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.entry-error {
  grid-column: 2;
  min-height: 28px;
  width: max-content;
  max-width: 100%;
  margin: -5px 0 0;
  padding: 4px 7px;
  background: #dcefff;
  color: #d12c17;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.35;
  visibility: hidden;
}

.entry-error.is-visible {
  visibility: visible;
}

.leaderboard {
  padding-top: 10px;
}

.board-meta {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--strong-line);
}

.board-meta h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
}

.board-meta span {
  color: var(--muted);
  font-size: 12px;
}

.podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.podium-card,
.rank-row,
.fame-card {
  border: 2px solid var(--strong-line);
  background: var(--panel);
}

.podium-card {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 13px;
  align-items: center;
  padding: 15px;
}

.podium-card:first-child {
  background: var(--ink);
  color: var(--inverse);
  box-shadow: var(--shadow);
}

.podium-card:first-child .rank-copy a,
.podium-card:first-child .rank-copy small {
  color: var(--inverse);
}

.logo-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  aspect-ratio: 1;
  border: 2px solid currentColor;
  background: var(--panel);
  color: inherit;
  overflow: hidden;
}

.logo-mark svg {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.logo-mark .real-logo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 6px;
  background: var(--panel);
  object-fit: contain;
}

.logo-mark .real-logo.is-broken {
  display: none;
}

.rank-copy {
  min-width: 0;
}

.rank-copy a,
.rank-copy strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
  font-weight: 950;
}

.rank-copy small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.score {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 30px;
  font-weight: 950;
}

.rank-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rank-row {
  display: grid;
  grid-template-columns: 50px 46px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.rank-row:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--ink);
}

.rank-number {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 950;
  text-align: center;
}

.rank-row .logo-mark {
  width: 46px;
  font-size: 13px;
}

.load-button {
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  border: 2px solid var(--strong-line);
  font-size: 15px;
}

.rules-view,
.fame-view {
  max-width: 860px;
}

.rules-intro {
  max-width: 520px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
}

.rules-list {
  display: grid;
  gap: 10px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}

.rules-list li,
.fame-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  padding: 18px;
  border: 2px solid var(--strong-line);
  background: var(--panel);
}

.rules-list li {
  counter-increment: rule;
  grid-template-columns: 48px 1fr;
}

.rules-list li::before {
  content: counter(rule);
  grid-row: 1 / 3;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 24px;
  font-weight: 950;
}

.rules-list b {
  font-size: 19px;
}

.rules-list span {
  color: var(--muted);
  line-height: 1.5;
}

.fame-list {
  display: grid;
  gap: 12px;
  margin-top: 28px;
}

.fame-card {
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
}

.game-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(rgba(0, 0, 0, 0.66), rgba(0, 0, 0, 0.66)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 18px);
}

.game-modal.is-open {
  display: grid;
}

.game-shell {
  width: min(100%, 1030px);
  overflow: hidden;
  border: 2px solid var(--strong-line);
  background: var(--panel);
  box-shadow: 14px 14px 0 rgba(0, 0, 0, 0.8);
}

.game-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 18px;
  border-bottom: 2px solid var(--strong-line);
}

.game-topbar span {
  display: block;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  font-weight: 900;
}

.game-topbar h2 {
  margin: 4px 0 0;
  font-size: 26px;
  line-height: 1;
}

.game-hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 2px solid var(--strong-line);
}

.game-hud span {
  padding: 12px 14px;
  border-right: 2px solid var(--strong-line);
  background: var(--panel);
  font-size: 13px;
}

.game-hud span:last-child {
  border-right: 0;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: var(--sky);
  image-rendering: pixelated;
}

.game-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-top: 2px solid var(--strong-line);
  color: var(--muted);
  font-size: 12px;
}

.game-actions button {
  min-width: 130px;
  min-height: 42px;
  border: 2px solid var(--strong-line);
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: min(1180px, calc(100% - 34px));
  margin: 0 auto;
  padding: 22px 0 30px;
  border-top: 2px solid var(--strong-line);
  color: var(--muted);
  font-size: 12px;
}

footer a {
  color: var(--ink);
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

@media (max-width: 860px) {
  .site-header {
    grid-template-columns: 1fr auto;
    padding: 0 14px 12px;
  }

  .nav {
    grid-column: 1 / -1;
    order: 3;
    width: 100%;
  }

  .live-stats {
    grid-column: 1 / -1;
    order: 4;
    justify-self: stretch;
  }

  .live-stats span {
    flex: 1;
    justify-content: center;
  }

  .nav a {
    flex: 1;
    min-width: 0;
  }

  .entry-panel {
    grid-template-columns: 1fr;
    padding-top: 24px;
  }

  .lock-line {
    grid-column: auto;
    margin-top: -12px;
  }

  .entry-error {
    grid-column: auto;
  }

  .podium {
    grid-template-columns: 1fr;
  }

  .board-meta,
  footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .rank-row {
    grid-template-columns: 34px 40px minmax(0, 1fr) auto;
    gap: 9px;
  }

  .rank-row .logo-mark {
    width: 40px;
  }

  .score {
    font-size: 20px;
  }

  .game-hud {
    grid-template-columns: 1fr;
  }

  .game-hud span {
    border-right: 0;
    border-bottom: 2px solid var(--strong-line);
  }

  .game-hud span:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 540px) {
  main,
  footer {
    width: min(100% - 22px, 1180px);
  }

  .champion-strip {
    grid-template-columns: 1fr auto;
    box-shadow: 6px 6px 0 var(--ink);
  }

  .champion-strip span {
    grid-column: 1 / -1;
    width: max-content;
  }

  .entry-form {
    grid-template-columns: 1fr;
  }

  .entry-form input {
    border-right: 0;
    border-bottom: 2px solid var(--strong-line);
  }

  .entry-form button {
    min-height: 48px;
  }

  .fame-card,
  .podium-card {
    grid-template-columns: 46px minmax(0, 1fr) auto;
  }

  .logo-mark {
    width: 46px;
  }

  h1 {
    font-size: clamp(40px, 13vw, 58px);
  }
}
