:root {
  color-scheme: light;
  --ink: #171713;
  --muted: #716d63;
  --paper: #f4f0e6;
  --card: #fffdf7;
  --line: #171713;
  --accent: #d7ff3f;
  --accent-ink: #171713;
  --wrong: #e25c45;
  --correct: #378b52;
  --guess-warning: #ffd34e;
  --guess-danger: #ff8a70;
  --shadow-color: var(--ink);
  --surface-input: #ffffff;
  --surface-disabled: #f0ece3;
  --surface-button-disabled: #e4e0d6;
  --text-disabled: #878278;
  --surface-progress: #ded9cd;
  --surface-face: #dad7ce;
  --surface-chip: #ebe7dc;
  --glow: rgba(215, 255, 63, 0.28);
  --shadow: 7px 7px 0 var(--shadow-color);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f4f0e6;
  --muted: #aaa59a;
  --paper: #12120f;
  --card: #1c1c18;
  --line: #e9e4d8;
  --accent: #c9f43c;
  --accent-ink: #171713;
  --wrong: #ff846f;
  --correct: #6ed18a;
  --guess-warning: #ffd45a;
  --guess-danger: #ff846f;
  --shadow-color: #505047;
  --surface-input: #272720;
  --surface-disabled: #22221d;
  --surface-button-disabled: #35352e;
  --text-disabled: #918d84;
  --surface-progress: #393830;
  --surface-face: #292923;
  --surface-chip: #303029;
  --glow: rgba(201, 244, 60, 0.12);
}

* {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

html.hydrating body {
  visibility: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, var(--glow), transparent 24rem),
    var(--paper);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.85rem;
  color: var(--accent-ink);
  background: var(--accent);
  border: 2px solid var(--line);
  box-shadow: 3px 3px 0 var(--shadow-color);
  font-weight: 850;
  transform: translateY(calc(-100% - 1rem));
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem;
  border-bottom: 2px solid var(--line);
}

.brand {
  color: inherit;
  font-size: 1.35rem;
  font-weight: 950;
  letter-spacing: -0.06em;
  text-decoration: none;
}

.header-actions {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}

.theme-toggle {
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  place-items: center;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 999px;
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1;
}

.theme-toggle:hover {
  color: var(--accent-ink);
  background: var(--accent);
}

.theme-toggle:focus-visible,
.league-switcher a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.league-switcher {
  display: flex;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 999px;
}

.league-switcher a {
  padding: 0.35rem 0.65rem;
  color: inherit;
  font-size: 0.72rem;
  font-weight: 850;
  text-decoration: none;
}

.league-switcher a + a {
  border-left: 1px solid var(--line);
}

.league-switcher a:hover,
.league-switcher a[aria-current="page"] {
  color: var(--accent-ink);
  background: var(--accent);
}

.streak {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  padding: 0.35rem 0.7rem;
  background: var(--accent);
  border: 2px solid var(--line);
  border-radius: 999px;
}

.streak,
.streak strong {
  color: var(--accent-ink);
}

.streak strong {
  min-width: 3ch;
  visibility: hidden;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.streak strong.ready {
  visibility: visible;
}

main {
  width: min(calc(100% - 2rem), 560px);
  margin: 0 auto;
  padding: 2.5rem 0 4rem;
}

.intro {
  margin-bottom: 1.4rem;
  text-align: center;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: -0.045em;
}

h1 {
  font-size: clamp(2.4rem, 10vw, 4.7rem);
  line-height: 0.95;
}

.intro-copy {
  margin: 0.8rem 0 0;
  color: var(--muted);
}

.content-notice {
  width: fit-content;
  margin: 0.8rem auto 0;
  padding: 0.35rem 0.55rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 0.72rem;
  font-weight: 800;
}

.game,
.complete,
.error-panel {
  padding: clamp(1rem, 4vw, 1.5rem);
  background: var(--card);
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
}

.round-status {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
  gap: 0.7rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--surface-progress);
  border-radius: 0.35rem;
}

.round-status-group {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.round-status-label {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.round-status-divider {
  width: 1px;
  height: 1.35rem;
  background: var(--surface-progress);
}

.progress {
  display: flex;
  gap: 0.42rem;
  align-items: center;
}

.progress-dot {
  position: relative;
  width: 0.7rem;
  height: 0.7rem;
  flex: 0 0 auto;
  background: var(--surface-progress);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.guess-counter {
  min-width: 3.5rem;
  padding: 0.15rem 0.4rem;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  text-align: center;
  transition: background-color 180ms ease;
}

.guess-counter[data-remaining="2"] {
  background: var(--guess-warning);
}

.guess-counter[data-remaining="1"] {
  background: var(--guess-danger);
}

.guess-counter[data-remaining="0"] {
  background: var(--wrong);
}

.progress-dot.current {
  background: var(--accent);
}

.progress-dot.solved {
  background: var(--correct);
}

.progress-dot.revealed {
  background:
    repeating-linear-gradient(
      135deg,
      var(--wrong) 0,
      var(--wrong) 4px,
      var(--card) 4px,
      var(--card) 6px
    );
}

.face-stage {
  position: relative;
  margin-bottom: 1.4rem;
}

.face-frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  margin: 0;
  background: var(--surface-face);
  border: 2px solid var(--line);
}

.face-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.face-image-large {
  transform: scale(var(--face-zoom, 1.45));
  transition: transform 320ms ease;
}

.face-image-tight {
  opacity: 1;
  transition: opacity 220ms ease;
}

.face-frame.show-large .face-image-tight,
.face-viewer-frame.show-large .face-image-tight {
  opacity: 0;
}

.face-frame figcaption {
  position: absolute;
  right: 0.65rem;
  bottom: 0.65rem;
  padding: 0.25rem 0.5rem;
  color: white;
  background: rgba(23, 23, 19, 0.84);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 750;
  z-index: 1;
}

.face-zoom-button,
.face-viewer-close {
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  place-items: center;
  color: white;
  background: rgba(23, 23, 19, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  line-height: 1;
}

.face-zoom-button {
  position: absolute;
  z-index: 2;
  top: 0.55rem;
  right: 0.55rem;
}

.face-zoom-button:hover,
.face-viewer-close:hover {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--line);
}

.face-zoom-button svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.face-viewer-close svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}

label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
  font-weight: 800;
}

.guess-label-row {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.guess-label-row label {
  margin-bottom: 0;
}

.guess-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.45rem;
}

.guess-field {
  position: relative;
  min-width: 0;
}

input,
.guess-submit,
.primary-button {
  min-height: 3rem;
  border: 2px solid var(--line);
}

input {
  min-width: 0;
  padding: 0 0.9rem;
  color: var(--ink);
  background: var(--surface-input);
  border-radius: 0;
}

.guess-field input {
  width: 100%;
}

#guess-input:focus-visible {
  outline-offset: -5px;
}

.guess-submit,
.primary-button {
  padding: 0 1.1rem;
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 900;
}

.guess-submit {
  width: 100%;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.guess-submit:disabled {
  color: var(--text-disabled);
  background: var(--surface-button-disabled);
  cursor: not-allowed;
}

input:disabled {
  color: var(--muted);
  background: var(--surface-disabled);
  cursor: not-allowed;
}

.autocomplete-results {
  position: absolute;
  z-index: 10;
  top: calc(100% - 2px);
  right: 0;
  left: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  max-height: min(18rem, 40dvh);
  padding: 0.3rem;
  background: var(--card);
  border: 2px solid var(--line);
  box-shadow: 4px 4px 0 var(--ink);
}

.autocomplete-results[hidden] {
  display: none;
}

.autocomplete-option {
  display: block;
  width: 100%;
  min-height: 3rem;
  padding: 0.6rem 0.7rem;
  color: var(--ink);
  background: transparent;
  border: 0;
  text-align: left;
  touch-action: pan-y;
}

.autocomplete-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.autocomplete-name {
  min-width: 0;
  font-weight: 850;
}

.autocomplete-name mark {
  color: inherit;
  background: transparent;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--ink) 45%, transparent);
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.12em;
}

.autocomplete-detail {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.autocomplete-reason {
  display: block;
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.autocomplete-option + .autocomplete-option {
  border-top: 1px solid var(--surface-progress);
}

.autocomplete-option:hover,
.autocomplete-option.active {
  color: var(--accent-ink);
  background: var(--accent);
}

.autocomplete-option:hover .autocomplete-detail,
.autocomplete-option:hover .autocomplete-reason,
.autocomplete-option.active .autocomplete-detail,
.autocomplete-option.active .autocomplete-reason {
  color: var(--accent-ink);
}

.autocomplete-empty {
  margin: 0;
  padding: 0.7rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.message {
  min-height: 1.25rem;
  margin: 0 0 0.45rem;
  font-weight: 750;
}

.message.correct {
  color: var(--correct);
}

.message.wrong {
  color: var(--wrong);
}

.guess-history {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.guess-chip {
  padding: 0.2rem 0.5rem;
  background: var(--surface-chip);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.75rem;
}

.pass-chip {
  color: var(--muted);
  border-style: dashed;
  font-style: italic;
}

.round-footer {
  margin-top: 0.55rem;
}

.round-feedback {
  min-width: 0;
  margin-bottom: 0.75rem;
}

.game-actions {
  display: block;
}

.pass-button {
  width: 100%;
  min-height: 3rem;
  margin-top: 0.45rem;
  padding: 0 1rem;
  color: var(--ink);
  background: transparent;
  border: 2px solid var(--line);
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pass-button:hover {
  color: var(--accent-ink);
  background: var(--accent);
}

.text-button {
  padding: 0.3rem 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  text-decoration: underline;
}

.reveal-choice {
  text-align: center;
}

.action-separator {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 0.15rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.action-separator::before,
.action-separator::after {
  height: 1px;
  flex: 1;
  background: var(--surface-progress);
  content: "";
}

.primary-button {
  width: 100%;
  min-width: 8rem;
}

.reveal-dialog {
  width: min(calc(100% - 2rem), 24rem);
  padding: 1.25rem;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
}

.reveal-dialog::backdrop {
  background: rgba(23, 23, 19, 0.72);
}

.reveal-dialog h2 {
  margin-bottom: 0.45rem;
  font-size: 1.8rem;
}

.reveal-dialog p {
  margin: 0 0 1.1rem;
  color: var(--muted);
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.dialog-actions button {
  min-height: 3rem;
  padding: 0.45rem 0.65rem;
  border: 2px solid var(--line);
  font-weight: 850;
}

.dialog-danger {
  color: var(--wrong);
  background: var(--card);
}

.dialog-cancel {
  color: var(--accent-ink);
  background: var(--accent);
}

.face-viewer {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 1rem;
  color: var(--ink);
  background: rgba(23, 23, 19, 0.94);
  border: 0;
}

.face-viewer[open] {
  display: grid;
  place-items: center;
}

.face-viewer::backdrop {
  background: rgba(23, 23, 19, 0.94);
}

.face-viewer-frame {
  position: relative;
  overflow: hidden;
  width: min(calc(100vw - 2rem), calc(100dvh - 2rem));
  aspect-ratio: 1;
  background: var(--surface-face);
  border: 2px solid white;
}

.face-viewer-close {
  position: fixed;
  z-index: 2;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
}

.complete,
.error-panel {
  text-align: center;
}

.complete h2,
.error-panel h2 {
  margin-bottom: 0.8rem;
  font-size: 2.4rem;
}

footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  justify-content: space-between;
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  color: var(--muted);
  border-top: 2px solid var(--line);
  font-size: 0.78rem;
}

footer p {
  margin: 0;
}

footer nav {
  display: flex;
  gap: 1rem;
}

footer a,
.legal a {
  color: inherit;
}

.legal {
  width: min(calc(100% - 2rem), 720px);
  margin: 0 auto;
  padding: 3rem 0 5rem;
}

.legal h1 {
  margin-bottom: 1.5rem;
}

.legal h2 {
  margin-top: 2rem;
  font-size: 1.45rem;
}

.legal p,
.legal li {
  max-width: 68ch;
  line-height: 1.65;
}

[hidden] {
  display: none !important;
}

@media (max-width: 520px) {
  main {
    width: min(calc(100% - 1rem), 560px);
    padding: 1rem 0 3rem;
  }

  .site-header {
    flex-wrap: wrap;
    gap: 0.8rem;
    padding: 1rem;
  }

  .league-switcher {
    order: 3;
    width: 100%;
  }

  .league-switcher a {
    flex: 1;
    text-align: center;
  }

  .game {
    padding: 0.85rem;
    box-shadow: 4px 4px 0 var(--ink);
  }

  .face-stage {
    margin-bottom: 1rem;
  }

  .guess-label-row {
    gap: 0.5rem;
    align-items: baseline;
  }

  .guess-submit {
    padding: 0 0.8rem;
  }

  .round-footer {
    margin-top: 0.55rem;
  }

  .game-actions .primary-button {
    width: 100%;
  }

  footer {
    padding-bottom: calc(2.5rem + env(safe-area-inset-bottom));
  }

  body.mobile-round {
    overflow-anchor: none;
  }

  body.mobile-round .site-header,
  body.mobile-round .intro,
  body.mobile-round > footer {
    display: none;
  }

  body.mobile-round main {
    width: 100%;
    padding: 0.35rem;
  }

  body.mobile-round .game {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.5rem;
    align-items: center;
    padding: 0.55rem;
    box-shadow: none;
    scroll-margin-top: 0.35rem;
  }

  body.mobile-round .round-status {
    width: 100%;
    margin-bottom: 0;
    padding: 0.45rem 0.55rem;
  }

  body.mobile-round .face-stage {
    display: grid;
    grid-template-columns: 2.75rem auto 2.75rem;
    align-items: start;
    justify-content: center;
    width: 100%;
    margin: 0;
  }

  body.mobile-round .face-frame {
    grid-column: 2;
    grid-row: 1;
    width: clamp(10.5rem, 48vw, 12rem);
    margin: 0;
  }

  body.mobile-round .face-zoom-button {
    position: static;
    grid-column: 3;
    grid-row: 1;
    margin: 0.15rem 0 0 0.5rem;
  }

  body.mobile-round .face-frame figcaption {
    right: 0.35rem;
    bottom: 0.35rem;
    padding: 0.18rem 0.35rem;
    font-size: 0.68rem;
  }

  body.mobile-round #guess-form {
    width: 100%;
    min-width: 0;
  }

  body.mobile-round .guess-label-row {
    margin-bottom: 0.3rem;
    font-size: 0.75rem;
  }

  body.mobile-round input,
  body.mobile-round .guess-submit,
  body.mobile-round .pass-button {
    min-height: 2.75rem;
  }

  body.mobile-round input {
    padding: 0 0.65rem;
  }

  body.mobile-round .guess-submit {
    padding: 0 0.65rem;
    font-size: 0.78rem;
  }

  body.mobile-round .autocomplete-results {
    top: auto;
    right: 0;
    bottom: calc(100% - 2px);
    left: 0;
    width: 100%;
    max-height: min(9.25rem, 38dvh);
    box-shadow: 4px -4px 0 var(--ink);
  }

  body.mobile-round .autocomplete-option {
    min-height: 3rem;
    padding: 0.5rem 0.6rem;
    font-size: 0.82rem;
  }

  body.mobile-round .autocomplete-detail {
    font-size: 0.68rem;
  }

  body.mobile-round .round-footer {
    display: block;
    margin-top: 0;
  }

  body.mobile-round .game-actions {
    margin-top: 0.5rem;
  }

  body.mobile-round .game.resolved #guess-form {
    display: none;
  }

  body.mobile-round .game.resolved .game-actions {
    margin-top: 0.5rem;
  }

  body.mobile-round .message {
    min-height: 0;
    margin: 0;
    font-size: 0.78rem;
  }

  body.mobile-round .guess-history {
    margin-top: 0.25rem;
  }

}

@media (max-width: 360px) {
  .round-status {
    gap: 0.4rem;
    padding-right: 0.4rem;
    padding-left: 0.4rem;
  }

  .round-status-group {
    gap: 0.35rem;
  }

  .round-status-label {
    font-size: 0.58rem;
  }

  .progress {
    gap: 0.28rem;
  }

  .progress-dot {
    width: 0.62rem;
    height: 0.62rem;
  }

  .guess-counter {
    min-width: 3rem;
    padding-right: 0.3rem;
    padding-left: 0.3rem;
    font-size: 0.68rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .face-image-large,
  .face-image-tight,
  .guess-counter,
  .skip-link {
    transition: none;
  }
}
