:root {
  color-scheme: dark;
  --ink: #f7f8ff;
  --muted: #abb7d4;
  --night: #040b1d;
  --navy: #071a45;
  --blue: #0a3d9b;
  --blue-bright: #175bd3;
  --gold: #ffd447;
  --gold-deep: #d99d16;
  --green: #28c785;
  --red: #ff6677;
  --line: rgba(255, 255, 255, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 280px;
  min-height: 100%;
  background: var(--night);
}

body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(29, 96, 224, 0.26), transparent 34rem),
    radial-gradient(circle at 92% 85%, rgba(255, 212, 71, 0.09), transparent 28rem),
    var(--night);
}

body.modal-open {
  overflow: hidden;
}

body.game-active {
  overflow: hidden;
}

body.game-active .app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

body.game-active .topbar {
  flex: 0 0 auto;
}

body.game-active main {
  flex: 1 1 auto;
  min-height: 0;
}

body.game-active .game-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

body.game-active .game-status,
body.game-active .turn-message,
body.game-active .board-hint {
  flex: 0 0 auto;
}

body.game-active .board {
  grid-template-rows: minmax(0, 0.82fr) repeat(5, minmax(0, 1fr));
  flex: 1 1 auto;
  min-height: 0;
}

body.game-active .category-heading,
body.game-active .value-card {
  min-height: 0;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid #8fc7ff;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: min(100%, 1040px);
  height: 100vh;
  min-height: 100vh;
  margin: 0 auto;
  overflow: hidden;
  padding: clamp(10px, 2.2vw, 24px);
}

main {
  flex: 1 1 auto;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 66px;
  margin-bottom: clamp(10px, 2vw, 22px);
}

.brand {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-kicker,
.eyebrow {
  color: var(--gold);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand-title {
  margin-top: 3px;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(1.25rem, 4vw, 2rem);
  letter-spacing: 0.035em;
  line-height: 1;
  white-space: nowrap;
}

.brand-title em {
  margin-left: 0.14em;
  color: var(--gold);
  font-style: normal;
}

.icon-button,
.back-button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.icon-button:hover,
.back-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.screen {
  animation: enter 280ms ease-out both;
}

@keyframes enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.setup-screen,
.finish-screen {
  display: grid;
  height: 100%;
  min-height: 0;
  place-items: center;
}

.setup-card,
.finish-card {
  width: min(100%, 520px);
  max-height: 100%;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: clamp(24px, 6vw, 46px);
  overflow-y: auto;
  background: linear-gradient(150deg, rgba(15, 48, 112, 0.94), rgba(5, 17, 46, 0.97));
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.32);
}

.setup-card h1,
.finish-card h1 {
  margin: 7px 0 10px;
  font-size: clamp(1.9rem, 7vw, 3.2rem);
  letter-spacing: -0.04em;
  line-height: 1;
}

.setup-copy {
  max-width: 41ch;
  margin: 0 0 28px;
  color: var(--muted);
  line-height: 1.55;
}

.player-picker {
  margin: 0 0 22px;
  padding: 0;
  border: 0;
}

.player-picker legend,
.name-fields label > span {
  display: block;
  margin-bottom: 8px;
  color: #dce4f8;
  font-size: 0.78rem;
  font-weight: 750;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.count-button {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.16);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.count-button:hover {
  transform: translateY(-1px);
}

.count-button strong {
  color: var(--ink);
  font-size: 1.5rem;
}

.count-button.selected {
  border-color: var(--gold);
  color: #fff4c5;
  background: rgba(255, 212, 71, 0.12);
}

.name-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.name-fields.single-player label:first-child {
  grid-column: 1 / -1;
}

.name-fields input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 13px;
  color: var(--ink);
  background: rgba(2, 10, 30, 0.55);
}

.name-fields input::placeholder {
  color: #7382a5;
}

.primary-button,
.reveal-button {
  border: 0;
  border-radius: 13px;
  color: #142044;
  background: var(--gold);
  box-shadow: 0 8px 22px rgba(217, 157, 22, 0.22);
  font-weight: 850;
  cursor: pointer;
  transition: transform 150ms ease, filter 150ms ease;
}

.primary-button:hover,
.reveal-button:hover {
  filter: brightness(1.07);
  transform: translateY(-1px);
}

.start-button,
.finish-card .primary-button {
  width: 100%;
  min-height: 52px;
  margin-top: 24px;
}

.game-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 13px;
}

.scoreboard {
  display: flex;
  flex: 1 1 auto;
  gap: 8px;
  min-width: 0;
}

.player-score {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 260px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
}

.player-score.active {
  border-color: rgba(255, 212, 71, 0.66);
  color: var(--ink);
  background: rgba(255, 212, 71, 0.09);
}

.player-turn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5d6a89;
}

.player-score.active .player-turn-dot {
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(255, 212, 71, 0.12);
}

.player-name {
  overflow: hidden;
  font-size: 0.8rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-value {
  color: var(--gold);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.round-progress {
  flex: 0 0 115px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-align: right;
}

.progress-track {
  height: 4px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--gold);
  transition: width 250ms ease;
}

.turn-message {
  min-height: 21px;
  margin: 0 0 10px;
  color: #eef2ff;
  font-size: 0.82rem;
  font-weight: 750;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(4px, 1vw, 9px);
  padding: clamp(5px, 1vw, 9px);
  border: 1px solid rgba(93, 145, 255, 0.2);
  border-radius: 17px;
  background: rgba(0, 5, 18, 0.72);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
}

.category-heading {
  display: grid;
  min-width: 0;
  min-height: clamp(58px, 10vw, 92px);
  place-items: center;
  padding: 8px 4px;
  overflow-wrap: anywhere;
  color: white;
  background: linear-gradient(145deg, #1558ca, #092c77);
  font-size: clamp(0.58rem, 1.8vw, 0.9rem);
  font-weight: 900;
  letter-spacing: 0.045em;
  line-height: 1.12;
  text-align: center;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

.category-heading:first-child {
  border-radius: 9px 0 0 0;
}

.category-heading:nth-child(5) {
  border-radius: 0 9px 0 0;
}

.value-card {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: clamp(55px, 9vw, 82px);
  border: 0;
  place-items: center;
  color: var(--gold);
  background: linear-gradient(150deg, #0c43ac, #072568);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(1.05rem, 3.5vw, 2rem);
  letter-spacing: 0.035em;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.32);
  cursor: pointer;
  transition: transform 130ms ease, filter 130ms ease;
}

.value-card:hover:not(:disabled) {
  z-index: 1;
  filter: brightness(1.14);
  transform: translateY(-2px);
}

.value-card.used {
  color: rgba(151, 174, 224, 0.36);
  background: #081a48;
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.32);
  cursor: default;
  text-shadow: none;
}

.board-hint {
  margin: 12px 0 0;
  color: #7f8dab;
  font-size: 0.7rem;
  text-align: center;
}

.board-hint span {
  color: var(--gold);
}

.modal-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  overflow-y: auto;
  place-items: center;
  padding: 14px;
  background: rgba(1, 5, 16, 0.86);
  backdrop-filter: blur(8px);
  animation: fade-in 180ms ease-out both;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.clue-card {
  width: min(100%, 580px);
  max-height: calc(100vh - 28px);
  overflow-y: auto;
  border: 1px solid rgba(117, 159, 255, 0.35);
  border-radius: 22px;
  padding: clamp(18px, 4vw, 32px);
  background:
    radial-gradient(circle at 90% 10%, rgba(31, 101, 241, 0.28), transparent 18rem),
    #071a45;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.56);
}

.clue-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.clue-category {
  color: #b8c7ec;
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.clue-value {
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 900;
}

.clue-body {
  padding: clamp(28px, 7vh, 58px) 0 clamp(18px, 4vh, 32px);
  text-align: center;
}

.clue-instruction {
  margin: 0 0 12px;
  color: #8496bd;
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.clue-prompt {
  margin: 0 auto;
  color: white;
  font-size: clamp(1.35rem, 5.2vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.24;
}

.reveal-button {
  min-height: 48px;
  margin-top: clamp(30px, 7vh, 54px);
  padding: 0 22px;
}

.answer-panel {
  margin-top: clamp(26px, 6vh, 48px);
  border: 1px solid rgba(40, 199, 133, 0.32);
  border-radius: 15px;
  padding: 16px;
  background: rgba(40, 199, 133, 0.08);
  animation: enter 220ms ease-out both;
}

.answer-label {
  color: var(--green);
  font-size: 0.67rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.answer-panel p {
  margin: 7px 0 0;
  font-size: clamp(1rem, 3.8vw, 1.35rem);
  font-weight: 750;
  line-height: 1.4;
}

.answer-panel .answer-note {
  color: #b9c8e9;
  font-size: 0.8rem;
  font-weight: 600;
}

.clue-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.grade-button {
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: white;
  font-weight: 850;
  cursor: pointer;
}

.grade-button span {
  margin-right: 4px;
  font-size: 1.2em;
}

.incorrect-button {
  border-color: rgba(255, 102, 119, 0.38);
  background: rgba(255, 102, 119, 0.14);
}

.correct-button {
  border-color: rgba(40, 199, 133, 0.45);
  background: rgba(40, 199, 133, 0.22);
}

.grade-button:hover {
  filter: brightness(1.17);
}

.back-button {
  display: block;
  margin: 12px auto 0;
  border-color: transparent;
  color: #98a7ca;
  background: transparent;
  font-size: 0.78rem;
}

.toast {
  position: fixed;
  z-index: 40;
  right: 50%;
  bottom: 20px;
  min-width: 170px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 18px;
  opacity: 0;
  color: white;
  background: #12234e;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.38);
  font-weight: 850;
  text-align: center;
  pointer-events: none;
  transform: translate(50%, 14px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(50%, 0);
}

.toast.positive {
  border-color: rgba(40, 199, 133, 0.5);
}

.toast.negative {
  border-color: rgba(255, 102, 119, 0.5);
}

.finish-card {
  text-align: center;
}

.trophy {
  display: grid;
  width: 66px;
  height: 66px;
  margin: 0 auto 18px;
  border: 1px solid rgba(255, 212, 71, 0.52);
  border-radius: 50%;
  place-items: center;
  color: var(--gold);
  background: rgba(255, 212, 71, 0.1);
  font-size: 2rem;
}

.winner-message {
  margin: 12px 0 24px;
  color: var(--gold);
  font-size: 1.15rem;
  font-weight: 850;
}

.final-scores {
  display: grid;
  gap: 8px;
}

.final-score-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.05);
}

.final-score-row strong {
  color: var(--gold);
}

.fatal-error {
  width: min(100% - 32px, 600px);
  margin: 40px auto;
  border: 1px solid var(--red);
  border-radius: 16px;
  padding: 24px;
  background: #27101b;
}

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

noscript {
  display: block;
  padding: 20px;
  color: white;
  background: #5b1721;
  text-align: center;
}

@media (max-width: 620px) {
  .app-shell {
    padding: 9px;
  }

  .topbar {
    min-height: 54px;
    margin-bottom: 8px;
  }

  .brand-kicker {
    font-size: 0.58rem;
  }

  .icon-button {
    padding: 8px 11px;
    font-size: 0.72rem;
  }

  .game-status {
    align-items: stretch;
    gap: 8px;
    margin-bottom: 8px;
  }

  .player-score {
    gap: 5px;
    padding: 7px 8px;
  }

  .round-progress {
    flex-basis: 82px;
    font-size: 0.58rem;
  }

  .board {
    border-radius: 11px;
    padding: 4px;
  }

  .category-heading {
    min-height: 58px;
    padding-inline: 2px;
  }

  .value-card {
    min-height: clamp(50px, 13vw, 72px);
  }
}

@media (max-height: 680px) {
  body.game-active .app-shell {
    padding-block: 6px;
  }

  body.game-active .topbar {
    min-height: 42px;
    margin-bottom: 4px;
  }

  body.game-active .brand-kicker {
    display: none;
  }

  body.game-active .game-status {
    margin-bottom: 5px;
  }

  body.game-active .player-score {
    padding-block: 5px;
  }

  body.game-active .turn-message {
    min-height: 17px;
    margin-bottom: 5px;
    font-size: 0.75rem;
  }

  body.game-active .board-hint {
    margin-top: 5px;
  }
}

@media (max-height: 760px) {
  body:not(.game-active) .app-shell {
    padding-block: 8px;
  }

  body:not(.game-active) .topbar {
    min-height: 44px;
    margin-bottom: 6px;
  }

  .setup-card,
  .finish-card {
    padding: 20px 26px;
  }

  .setup-card h1,
  .finish-card h1 {
    font-size: 2rem;
  }

  .setup-copy {
    margin-bottom: 14px;
    line-height: 1.38;
  }

  .player-picker {
    margin-bottom: 12px;
  }

  .count-button {
    min-height: 48px;
  }

  .name-fields input {
    min-height: 42px;
  }

  .start-button,
  .finish-card .primary-button {
    min-height: 44px;
    margin-top: 14px;
  }

  .trophy {
    width: 52px;
    height: 52px;
    margin-bottom: 10px;
    font-size: 1.5rem;
  }

  .winner-message {
    margin-block: 8px 14px;
  }
}

@media (max-height: 560px) {
  body:not(.game-active) .app-shell {
    padding-block: 5px;
  }

  body:not(.game-active) .topbar {
    min-height: 36px;
    margin-bottom: 3px;
  }

  body:not(.game-active) .brand-kicker {
    display: none;
  }

  .setup-card,
  .finish-card {
    padding: 13px 20px;
  }

  .setup-card h1,
  .finish-card h1 {
    margin-block: 4px 6px;
    font-size: 1.6rem;
  }

  .setup-copy {
    margin-bottom: 9px;
    font-size: 0.84rem;
    line-height: 1.28;
  }

  .player-picker {
    margin-bottom: 8px;
  }

  .player-picker legend,
  .name-fields label > span {
    margin-bottom: 4px;
  }

  .count-button {
    min-height: 40px;
  }

  .count-button strong {
    font-size: 1.2rem;
  }

  .name-fields input {
    min-height: 36px;
  }

  .start-button,
  .finish-card .primary-button {
    min-height: 38px;
    margin-top: 9px;
  }
}

@media (max-height: 520px) {
  body.game-active .topbar {
    min-height: 34px;
  }

  body.game-active .brand-title {
    font-size: 1rem;
  }

  body.game-active .icon-button {
    padding-block: 5px;
  }

  body.game-active .player-score {
    padding-block: 3px;
  }

  body.game-active .round-progress,
  body.game-active .board-hint {
    display: none;
  }

  body.game-active .category-heading {
    padding-block: 3px;
    font-size: 0.55rem;
  }

  body.game-active .value-card {
    font-size: clamp(0.85rem, 3vw, 1.35rem);
  }
}

@media (max-width: 430px) {
  .brand-title {
    font-size: 1.05rem;
  }

  .brand-kicker {
    display: none;
  }

  .name-fields {
    grid-template-columns: 1fr;
  }

  .name-fields label {
    grid-column: 1;
  }

  .game-status {
    flex-wrap: wrap;
  }

  .scoreboard {
    width: 100%;
  }

  .player-score {
    flex: 1 1 0;
  }

  .round-progress {
    display: flex;
    flex: 1 1 100%;
    align-items: center;
    gap: 8px;
    text-align: left;
  }

  .progress-track {
    flex: 1;
    margin-top: 0;
  }

  .category-heading {
    min-height: 52px;
    font-size: 0.52rem;
    letter-spacing: 0;
  }

  .value-card {
    min-height: 48px;
    font-size: 0.92rem;
  }

  .clue-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
