:root {
  --ink: #f7fbff;
  --muted: #9fb6c7;
  --night: #04101b;
  --navy: #071726;
  --panel: rgba(9, 31, 49, 0.84);
  --line: rgba(180, 221, 240, 0.16);
  --cyan: #48d9ff;
  --cyan-soft: rgba(72, 217, 255, 0.18);
  --gold: #ffcf4a;
  --red: #ff5c53;
  --green: #50e19a;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 42%, rgba(22, 100, 137, 0.26), transparent 35%),
    linear-gradient(145deg, #02070c 0%, var(--navy) 52%, #081e2d 100%);
  font-family: Bahnschrift, "Trebuchet MS", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

.ambient {
  position: fixed;
  width: 38vw;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.16;
  pointer-events: none;
}

.ambient-one {
  top: -20vw;
  right: -10vw;
  background: var(--cyan);
}

.ambient-two {
  bottom: -26vw;
  left: -8vw;
  background: var(--red);
}

.game-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(14px, 2vh, 28px);
  width: min(96vw, 2200px);
  height: 100dvh;
  margin: 0 auto;
  padding: clamp(18px, 2.5vh, 42px) clamp(18px, 2.8vw, 58px);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 650ms ease, transform 650ms ease;
}

body.is-ready .game-shell {
  opacity: 1;
  transform: translateY(0);
}

.topbar,
.control-deck {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: clamp(0.72rem, 0.75vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.24em;
}

.brand-block h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 4.5rem);
  font-weight: 900;
  letter-spacing: -0.055em;
  line-height: 0.9;
}

.brand-block h1 span {
  color: var(--gold);
}

.scoreboard {
  display: flex;
  align-items: stretch;
  gap: clamp(8px, 1vw, 18px);
}

.scoreboard > div {
  display: grid;
  min-width: clamp(92px, 7vw, 150px);
  padding: clamp(9px, 1vh, 14px) clamp(12px, 1.2vw, 20px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(8, 27, 42, 0.62);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.score-label {
  color: var(--muted);
  font-size: clamp(0.68rem, 0.7vw, 0.9rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.scoreboard strong {
  font-size: clamp(1.25rem, 1.6vw, 2.2rem);
  line-height: 1.1;
}

.scoreboard .progress-block {
  min-width: clamp(150px, 15vw, 290px);
  align-content: center;
  gap: 9px;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.09);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  box-shadow: 0 0 18px rgba(72, 217, 255, 0.42);
  transition: width 500ms ease;
}

.game-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--line);
  border-radius: clamp(24px, 2vw, 42px);
  background:
    linear-gradient(180deg, rgba(12, 39, 59, 0.92), rgba(3, 14, 24, 0.94)),
    var(--night);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  perspective: 1600px;
}

.stage-grid {
  position: absolute;
  inset: 0;
  z-index: -2;
  opacity: 0.16;
  background-image:
    linear-gradient(rgba(100, 195, 229, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100, 195, 229, 0.18) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, transparent, black 22%, black 78%, transparent);
}

.stage-glow {
  position: absolute;
  top: 8%;
  left: 50%;
  z-index: -1;
  width: min(36vw, 680px);
  height: 84%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(72, 217, 255, 0.17), transparent 64%);
  filter: blur(12px);
}

.selection-gate {
  position: absolute;
  inset: 5% auto 5% 50%;
  z-index: 3;
  width: clamp(260px, 24vw, 500px);
  transform: translateX(-50%);
  border-inline: 1px solid rgba(72, 217, 255, 0.55);
  background: linear-gradient(90deg, transparent, rgba(72, 217, 255, 0.05), transparent);
  pointer-events: none;
}

.selection-gate::before,
.selection-gate::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 18px;
  height: 18px;
  transform: translateX(-50%) rotate(45deg);
  border: 2px solid var(--cyan);
  background: var(--navy);
  box-shadow: 0 0 18px rgba(72, 217, 255, 0.55);
}

.selection-gate::before {
  top: -8px;
}

.selection-gate::after {
  bottom: -8px;
}

.selection-gate span {
  position: absolute;
  top: 14px;
  left: 50%;
  padding: 5px 11px;
  transform: translateX(-50%);
  border-radius: 999px;
  color: var(--cyan);
  background: rgba(2, 14, 23, 0.84);
  font-size: clamp(0.62rem, 0.6vw, 0.78rem);
  font-weight: 700;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.card-cylinder {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.flag-card {
  position: absolute;
  top: 50%;
  left: 50%;
  width: clamp(210px, 20vw, 430px);
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border: clamp(4px, 0.35vw, 8px) solid rgba(238, 250, 255, 0.94);
  border-radius: clamp(14px, 1.2vw, 26px);
  background: #dbeaf2;
  box-shadow: 0 24px 55px rgba(0, 0, 0, 0.55);
  transform-origin: center;
  will-change: transform, opacity, filter;
}

.flag-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.16), inset 0 14px 30px rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

.flag-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stage-vignette {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: linear-gradient(90deg, rgba(2, 9, 15, 0.94), transparent 18%, transparent 82%, rgba(2, 9, 15, 0.94));
  pointer-events: none;
}

.control-deck {
  min-height: clamp(76px, 9vh, 116px);
  padding: 0 clamp(4px, 1vw, 16px);
}

.instruction-copy {
  display: flex;
  align-items: center;
  gap: 16px;
}

.instruction-copy p {
  margin: 0 0 3px;
  font-size: clamp(1rem, 1.15vw, 1.5rem);
  font-weight: 700;
}

.instruction-copy span:not(.status-dot) {
  color: var(--muted);
  font-size: clamp(0.8rem, 0.82vw, 1.05rem);
}

.status-dot {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 7px rgba(255, 207, 74, 0.11), 0 0 24px rgba(255, 207, 74, 0.5);
}

.status-dot.is-live {
  background: var(--green);
  box-shadow: 0 0 0 7px rgba(80, 225, 154, 0.1), 0 0 24px rgba(80, 225, 154, 0.5);
  animation: pulse 1.6s ease-in-out infinite;
}

.actions,
.reveal-actions {
  display: flex;
  gap: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: clamp(48px, 5.5vh, 68px);
  padding: 0 clamp(18px, 1.6vw, 30px);
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--ink);
  font-size: clamp(0.85rem, 0.85vw, 1.12rem);
  font-weight: 800;
  letter-spacing: 0.025em;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, filter 160ms ease;
}

.button:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.button:active {
  transform: translateY(0);
}

.button:focus-visible {
  outline: 3px solid white;
  outline-offset: 4px;
}

.button-primary {
  color: #03131d;
  background: linear-gradient(135deg, var(--cyan), #9eeaff);
  box-shadow: 0 12px 34px rgba(72, 217, 255, 0.22);
}

.button-ghost {
  border-color: var(--line);
  background: rgba(10, 31, 46, 0.72);
}

.keycap {
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.76em;
  letter-spacing: 0.08em;
}

.keycap-dark {
  border-color: rgba(0, 0, 0, 0.18);
  background: rgba(0, 0, 0, 0.1);
}

.reveal-layer,
.finish-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: clamp(18px, 3vw, 54px);
}

.reveal-layer[hidden],
.finish-layer[hidden],
[hidden] {
  display: none !important;
}

.reveal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(1, 7, 12, 0.84);
  backdrop-filter: blur(18px);
}

.reveal-panel {
  position: relative;
  width: min(94vw, 1760px);
  max-height: 92vh;
  overflow: auto;
  padding: clamp(22px, 2.5vw, 52px);
  border: 1px solid rgba(130, 221, 255, 0.24);
  border-radius: clamp(24px, 2vw, 40px);
  background:
    radial-gradient(circle at 28% 50%, rgba(72, 217, 255, 0.1), transparent 34%),
    linear-gradient(145deg, rgba(9, 33, 51, 0.98), rgba(4, 15, 25, 0.98));
  box-shadow: 0 40px 110px rgba(0, 0, 0, 0.66);
  animation: reveal-in 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(16px, 2vh, 30px);
}

.reveal-step,
.reveal-tag {
  color: var(--cyan);
  font-size: clamp(0.72rem, 0.72vw, 0.95rem);
  font-weight: 800;
  letter-spacing: 0.18em;
}

.reveal-tag {
  padding: 7px 12px;
  border: 1px solid rgba(72, 217, 255, 0.2);
  border-radius: 999px;
  background: var(--cyan-soft);
}

.reveal-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1.15fr) minmax(360px, 0.85fr);
  align-items: center;
  gap: clamp(34px, 5vw, 90px);
}

.flag-spotlight {
  position: relative;
  display: grid;
  place-items: center;
  min-height: min(55vh, 600px);
}

.flag-spotlight img {
  position: relative;
  z-index: 2;
  display: block;
  width: min(100%, 900px);
  max-height: 56vh;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border: clamp(7px, 0.7vw, 13px) solid #f5fbff;
  border-radius: clamp(18px, 1.5vw, 32px);
  box-shadow: 0 36px 90px rgba(0, 0, 0, 0.55), 0 0 60px rgba(72, 217, 255, 0.12);
  animation: flag-pop 650ms cubic-bezier(0.16, 1, 0.3, 1);
}

.spotlight-ring {
  position: absolute;
  width: 78%;
  aspect-ratio: 1;
  border: 1px solid rgba(72, 217, 255, 0.22);
  border-radius: 50%;
  box-shadow: 0 0 70px rgba(72, 217, 255, 0.14), inset 0 0 70px rgba(72, 217, 255, 0.08);
}

.reveal-kicker {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: clamp(0.8rem, 0.85vw, 1.05rem);
  font-weight: 800;
  letter-spacing: 0.22em;
}

.reveal-content h2 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 6.2rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.guess-prompt {
  max-width: 660px;
  margin: clamp(16px, 2vh, 28px) 0 clamp(22px, 3vh, 40px);
  color: var(--muted);
  font-size: clamp(1rem, 1.15vw, 1.5rem);
  line-height: 1.55;
}

.answer-panel {
  margin: 18px 0 28px;
  padding: clamp(18px, 1.8vw, 30px);
  border-left: 5px solid var(--gold);
  border-radius: 0 18px 18px 0;
  background: rgba(255, 207, 74, 0.07);
  animation: answer-in 380ms ease;
}

.answer-region {
  margin: 0 0 3px;
  color: var(--gold);
  font-size: clamp(0.75rem, 0.75vw, 0.95rem);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.answer-panel h3 {
  margin: 0 0 18px;
  font-size: clamp(2.1rem, 3.2vw, 4.8rem);
  line-height: 1;
}

.answer-panel dl {
  display: grid;
  gap: 11px;
  margin: 0;
}

.answer-panel dl div {
  display: grid;
  grid-template-columns: minmax(90px, 0.35fr) 1fr;
  gap: 18px;
}

.answer-panel dt {
  color: var(--muted);
  font-size: clamp(0.8rem, 0.78vw, 1rem);
  text-transform: uppercase;
}

.answer-panel dd {
  margin: 0;
  font-size: clamp(1rem, 1vw, 1.28rem);
  line-height: 1.4;
}

.button-answer {
  min-width: min(100%, 310px);
  color: #1c1300;
  background: linear-gradient(135deg, var(--gold), #ffe28a);
  box-shadow: 0 14px 36px rgba(255, 207, 74, 0.2);
}

.button-continue {
  min-width: min(100%, 350px);
  color: #00160c;
  background: linear-gradient(135deg, var(--green), #a0ffd0);
  box-shadow: 0 14px 36px rgba(80, 225, 154, 0.18);
}

.finish-layer {
  background:
    radial-gradient(circle at center, rgba(72, 217, 255, 0.16), transparent 36%),
    rgba(2, 9, 15, 0.94);
  backdrop-filter: blur(18px);
}

.finish-card {
  width: min(92vw, 900px);
  padding: clamp(34px, 5vw, 82px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 34px;
  text-align: center;
  background: linear-gradient(145deg, rgba(10, 39, 58, 0.98), rgba(4, 17, 27, 0.98));
  box-shadow: var(--shadow);
  animation: reveal-in 500ms cubic-bezier(0.16, 1, 0.3, 1);
}

.finish-mark {
  display: grid;
  place-items: center;
  width: clamp(80px, 8vw, 130px);
  aspect-ratio: 1;
  margin: 22px auto;
  border: 2px solid var(--green);
  border-radius: 50%;
  color: var(--green);
  font-size: clamp(2.8rem, 4.5vw, 6rem);
  box-shadow: 0 0 48px rgba(80, 225, 154, 0.2);
}

.finish-card h2 {
  margin: 0;
  font-size: clamp(2rem, 3.8vw, 5.5rem);
  line-height: 1.02;
}

.finish-card > p:not(.eyebrow) {
  max-width: 660px;
  margin: 20px auto 32px;
  color: var(--muted);
  font-size: clamp(1rem, 1.15vw, 1.4rem);
  line-height: 1.55;
}

@keyframes pulse {
  50% {
    transform: scale(0.8);
    opacity: 0.7;
  }
}

@keyframes reveal-in {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.97);
  }
}

@keyframes flag-pop {
  from {
    opacity: 0;
    transform: scale(0.76) rotate(-2deg);
  }
}

@keyframes answer-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .game-shell {
    min-height: 100dvh;
    height: auto;
  }

  .topbar,
  .control-deck {
    align-items: flex-start;
  }

  .scoreboard .progress-block {
    display: none;
  }

  .game-stage {
    min-height: 55vh;
  }

  .reveal-layout {
    grid-template-columns: 1fr;
  }

  .flag-spotlight {
    min-height: auto;
  }

  .flag-spotlight img {
    max-height: 42vh;
  }

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

  .guess-prompt {
    margin-inline: auto;
  }

  .reveal-actions {
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .game-shell {
    width: 100%;
    padding: 14px;
  }

  .topbar,
  .control-deck {
    flex-direction: column;
  }

  .scoreboard {
    width: 100%;
  }

  .scoreboard > div {
    flex: 1;
    min-width: 0;
  }

  .game-stage {
    min-height: 58vh;
  }

  .selection-gate {
    width: 52vw;
  }

  .actions,
  .reveal-actions {
    width: 100%;
    flex-direction: column;
  }

  .button {
    width: 100%;
  }

  .instruction-copy {
    align-items: flex-start;
  }

  .reveal-panel {
    max-height: 96vh;
    padding: 20px;
  }

  .reveal-tag {
    display: none;
  }

  .answer-panel dl div {
    grid-template-columns: 1fr;
    gap: 3px;
    text-align: left;
  }
}

@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;
  }
}
