:root {
  --bg: #09111f;
  --bg-soft: #111d32;
  --panel: rgba(10, 18, 33, 0.9);
  --panel-strong: #0f1a2b;
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #eff5ff;
  --muted: #9baccc;
  --accent: #f4b942;
  --accent-soft: rgba(244, 185, 66, 0.15);
  --green: #81dd8c;
  --green-soft: rgba(129, 221, 140, 0.16);
  --red-soft: rgba(237, 80, 80, 0.16);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(244, 185, 66, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(76, 122, 255, 0.2), transparent 24%),
    linear-gradient(180deg, #07101c 0%, #0b1424 100%);
}

.page-shell {
  width: min(1320px, calc(100% - 32px));
  margin: 24px auto;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 24px;
}

.info-rail,
.game-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.info-rail {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #f4b942, #ff7f50);
  color: #07101c;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-copy strong {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.1rem;
}

.brand-copy span,
.lead,
.hint-list,
.substatus,
#result-summary {
  color: var(--muted);
}

.rail-card {
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--line);
}

.rail-card h1,
.rail-card h2,
.rail-card h3,
.game-topbar h2,
.mystery-copy h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  line-height: 1.05;
}

.rail-card h1 {
  font-size: clamp(2rem, 5vw, 2.85rem);
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 800;
}

.rail-card.compact {
  display: grid;
  gap: 12px;
}

.mini-stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.mini-stat:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.mini-stat-value {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.4rem;
}

.mini-stat-label {
  color: var(--muted);
}

.hint-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.game-panel {
  padding: 24px;
  display: grid;
  gap: 22px;
}

.game-topbar,
.mystery-stage,
.guess-bar,
.feedback-strip,
.results-panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel-strong);
}

.game-topbar {
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.game-topbar h2 {
  font-size: 1.8rem;
}

.mode-switch {
  display: inline-flex;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.mode-btn,
.primary-btn {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.mode-btn {
  padding: 10px 16px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.mode-btn.active {
  background: var(--accent-soft);
  color: var(--text);
}

.mystery-stage {
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: center;
}

.mystery-copy h3 {
  font-size: 2rem;
  margin-bottom: 10px;
}

.flag-frame {
  position: relative;
  min-height: 220px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: #1f1f1f;
}

.answer-flag {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  opacity: 0;
  filter: none;
  transform: scale(1);
  transition: opacity 180ms ease, filter 180ms ease, transform 180ms ease;
}

.flag-frame.revealed .answer-flag {
  opacity: 1;
  filter: none;
  transform: scale(1);
}

.flag-shroud {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 18px;
  background: rgba(22, 22, 22, 0.92);
}

.flag-frame.revealed .flag-shroud {
  opacity: 0;
}

.palette-clues {
  width: 100%;
  display: grid;
  gap: 10px;
}

.palette-clue {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 62px;
  gap: 10px;
  align-items: center;
}

.palette-chip,
.palette-bar,
.palette-share {
  border-radius: 10px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.palette-chip,
.palette-share {
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.72);
  background: #0f0f0f;
}

.palette-bar {
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.palette-bar-fill {
  height: 100%;
  width: 0;
  background: #0f0f0f;
}

.palette-clue.revealed .palette-chip,
.palette-clue.revealed .palette-share {
  color: #f4f7ff;
}

.guess-bar {
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
}

.combo-box {
  position: relative;
}

#guess-input {
  width: 100%;
  min-width: 0;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
}

#guess-input::placeholder {
  color: #7184ab;
}

.country-options {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow: auto;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: #0d1626;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
  display: none;
  z-index: 8;
}

.country-options.open {
  display: grid;
  gap: 6px;
}

.country-option {
  width: 100%;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.country-option:hover,
.country-option.active {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.05);
}

.country-option img {
  width: 100%;
  height: 34px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.country-option strong {
  display: block;
  margin-bottom: 2px;
}

.country-option span {
  color: var(--muted);
  font-size: 0.8rem;
}

.primary-btn {
  border-radius: 16px;
  background: linear-gradient(135deg, #f4b942, #ff8b57);
  color: #07101c;
  font-weight: 800;
}

.feedback-strip {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.clue-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.clue-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.clue-card strong {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.35rem;
}

.results-panel {
  padding: 18px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 14px;
}

.results-list {
  display: grid;
  gap: 12px;
}

.empty-state {
  padding: 22px;
  border-radius: 18px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  text-align: center;
}

.guess-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) 140px 150px 76px;
  gap: 10px;
  align-items: stretch;
}

.guess-cell {
  min-height: 74px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.guess-main {
  justify-content: flex-start;
  text-align: left;
}

.guess-country {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.guess-country strong,
.score-pill,
.continent-pill {
  font-family: "Space Grotesk", sans-serif;
}

.guess-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.score-pill {
  font-size: 1.2rem;
}

.continent-pill {
  width: 100%;
  border-radius: 999px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--muted);
}

.continent-pill.match {
  background: var(--green-soft);
  border-color: rgba(129, 221, 140, 0.34);
  color: var(--green);
}

.guess-thumb {
  width: 100%;
  height: 48px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.guess-row.solved .guess-cell {
  border-color: rgba(129, 221, 140, 0.34);
  background: linear-gradient(180deg, rgba(129, 221, 140, 0.12), rgba(129, 221, 140, 0.06));
}

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

@media (max-width: 1040px) {
  .page-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .game-topbar,
  .mystery-stage,
  .results-header,
  .guess-bar,
  .feedback-strip {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .mystery-stage {
    display: grid;
  }

  .guess-bar {
    grid-template-columns: 1fr;
  }

  .feedback-strip {
    display: grid;
  }

  .guess-row {
    grid-template-columns: 1fr;
  }

  .flag-frame {
    min-height: 180px;
  }
}
