:root {
  color-scheme: light;
  --bg: #f6f0e8;
  --ink: #1b1530;
  --muted: #655d73;
  --coral: #f27b62;
  --paper: #fffdf9;
  --peach: #fde4d4;
  --sky: #d7eefc;
  --butter: #fff3c4;
  --lilac: #e7e0f8;
  --mint: #dcf3df;
  font-family: Outfit, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(rgba(27, 21, 48, 0.16) 1.1px, transparent 1.2px),
    linear-gradient(115deg, rgba(246, 240, 232, 0.2), rgba(214, 228, 244, 0.85));
  background-size: 22px 22px, 100% 100%;
}

button, a, input { font: inherit; color: inherit; }

.nav, main {
  width: min(1080px, calc(100% - 32px));
  margin-inline: auto;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 22px;
  padding: 22px 0 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  text-decoration: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand strong {
  font-size: 1.2rem;
  letter-spacing: -0.03em;
}

.brand-text span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.mark {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 14px;
  background:
    linear-gradient(#fffdf9, #fffdf9) 12px 9px / 2.5px 22px no-repeat,
    linear-gradient(var(--coral), var(--coral)) 16px 11px / 16px 11px no-repeat,
    var(--ink);
}

.hub-back {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--coral);
}

.hub-back .arrow {
  display: block;
  width: 1em;
  line-height: 1;
  text-align: center;
}

main { flex: 1; padding: 18px 0 36px; }

.exit-game {
  padding: 0.45rem 0.9rem;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  color: var(--coral);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(27, 21, 48, 0.12);
}

.nav .exit-game.hidden { display: none; }

#landing { padding-top: 18px; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 6px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3aaa5a;
}

h1 {
  margin: 0;
  max-width: 12ch;
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  font-size: clamp(3.2rem, 7vw, 5.4rem);
  letter-spacing: -0.045em;
  line-height: 0.95;
}

h1 em {
  font-style: italic;
  font-weight: 620;
  color: var(--coral);
}

.lede {
  max-width: 38rem;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.5;
}

.rules {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 28px;
}

.rule {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-height: 180px;
  padding: 18px;
  text-align: left;
  border: 2.5px solid var(--ink);
  border-radius: 24px;
  box-shadow: 6px 6px 0 var(--ink);
}

.rule strong {
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}

.rule span:last-child {
  color: var(--muted);
  line-height: 1.4;
}

.rule-index {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.tone-peach { background: var(--peach); }
.tone-mint { background: var(--mint); }
.tone-lilac { background: var(--lilac); }

.how { margin-top: 28px; }

.section-head h2 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  letter-spacing: -0.03em;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.how ol {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 0;
  padding: 0;
  counter-reset: step;
}

.how li {
  margin: 0;
  padding: 16px 14px;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  box-shadow: 4px 4px 0 var(--ink);
  font-weight: 700;
  line-height: 1.35;
}

.how li::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero);
  display: block;
  margin-bottom: 8px;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.how li:nth-child(1) { background: var(--peach); }
.how li:nth-child(2) { background: var(--sky); }
.how li:nth-child(3) { background: var(--butter); }
.how li:nth-child(4) { background: var(--mint); }

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.tone-sky { background: var(--sky); }

.stage h2 {
  margin: 8px 0 0;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(2.6rem, 6vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 0.95;
}

.stage h2 em {
  font-style: italic;
  font-weight: 620;
  color: var(--coral);
}

.online-forms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
  margin-top: 22px;
}

.panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 18px;
  text-align: left;
  border: 2.5px solid var(--ink);
  border-radius: 24px;
  box-shadow: 6px 6px 0 var(--ink);
}

.panel h3 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.panel label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.92rem;
  font-weight: 700;
}

.panel input {
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  padding: 12px 14px;
  font: inherit;
}

.panel .btn { width: 100%; }

.online-error {
  min-height: 1.4em;
  margin: 14px 0 8px;
  color: var(--coral);
  font-weight: 700;
}

.share-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(100%, 420px);
  margin-top: 22px;
  padding: 22px 18px;
  border: 2.5px solid var(--ink);
  border-radius: 28px;
  background: var(--peach);
  box-shadow: 6px 6px 0 var(--ink);
}

.share-card span {
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(2rem, 5vw, 2.8rem);
  letter-spacing: 0.12em;
  line-height: 1;
}

#copy-room {
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  padding: 8px 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
}

.lobby-players {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(100%, 420px);
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.lobby-players li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  font-weight: 700;
}

.lobby-players .tag {
  color: var(--coral);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#online[hidden],
#lobby[hidden] { display: none; }

.btn-lg {
  padding: 16px 28px;
  font-size: 1.15rem;
}

#landing[hidden],
#play[hidden] { display: none; }

.btn {
  padding: 12px 18px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--coral);
}

.btn.btn-quiet,
.btn.btn-exit {
  background: var(--paper);
  box-shadow: 3px 3px 0 rgba(27, 21, 48, 0.12);
}

.btn.btn-quiet { color: var(--ink); }
.btn.btn-exit { color: var(--coral); }

.round-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.game-over {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 0;
  padding: 18px;
  text-align: center;
  background: var(--paper);
  border-radius: inherit;
}

.game-over p {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.8rem;
  letter-spacing: -0.03em;
}

.game-over .wait-line {
  font-family: Outfit, "Segoe UI", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--muted);
}

.game-over[hidden] { display: none; }

.leave-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(27, 21, 48, 0.45);
}

.leave-modal.hidden { display: none; }

.leave-card {
  width: min(400px, 100%);
  padding: 22px 20px 18px;
  text-align: center;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  box-shadow: 7px 7px 0 var(--ink);
}

.leave-card h3 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
}

.leave-card p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.leave-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.stage {
  width: min(100%, 920px);
  margin-inline: auto;
  text-align: center;
}

.board-row {
  display: grid;
  grid-template-columns: minmax(0, 460px) minmax(260px, 320px);
  justify-content: center;
  column-gap: 36px;
  align-items: start;
  margin-top: 22px;
}

.flag-wrap { min-width: 0; }

.side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.score-card,
.leaderboard {
  margin: 0;
  padding: 16px 16px 12px;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 24px;
  box-shadow: 6px 6px 0 var(--ink);
  text-align: left;
}

.score-card h2,
.leaderboard h2 {
  margin: 0 0 8px;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  text-align: center;
}

.progress {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.score-count {
  margin: 4px 0 8px;
  font-family: Fraunces, Georgia, serif;
  font-size: 2.4rem;
  letter-spacing: -0.04em;
  text-align: center;
}

.empty-line {
  margin: 0;
  padding: 8px 2px 12px;
  color: var(--muted);
  font-weight: 700;
}

.empty-line[hidden] { display: none; }

.leaderboard .list-scroll {
  max-height: 29rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(27, 21, 48, 0.45) transparent;
}

.leaderboard .list-scroll::-webkit-scrollbar { width: 8px; }

.leaderboard .list-scroll::-webkit-scrollbar-thumb {
  background: rgba(27, 21, 48, 0.38);
  border-radius: 99px;
}

.leaderboard table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard th,
.leaderboard td {
  padding: 0.65rem 0.2rem;
  text-align: left;
  border-bottom: 2px solid rgba(27, 21, 48, 0.12);
  font-weight: 700;
}

.leaderboard th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.leaderboard tr:last-child td { border-bottom: 0; }

.leaderboard .count {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#board-table[hidden] { display: none; }

.mode-label {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.status {
  margin: 10px 0 0;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 0.95;
}

.status.is-result {
  font-style: italic;
  color: var(--coral);
}

.flag-card {
  position: relative;
  width: min(100%, 440px);
  margin: 14px auto 0;
  aspect-ratio: 3 / 2;
  padding: 18px;
  display: grid;
  place-items: center;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 28px;
  box-shadow: 8px 8px 0 var(--ink);
}

.flag-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 0 0 2px var(--ink);
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.choice {
  min-height: 64px;
  padding: 14px 16px;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  font-size: 1.05rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.choice:hover:not(:disabled) { background: var(--peach); }

.choice:disabled { cursor: default; }

.choice.is-mine { background: var(--butter); }

.choice.is-right { background: var(--mint); }

.choice.is-wrong { background: #f8cfc6; }

.verdict-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
}

.verdict-row[hidden] { display: none; }

.verdict {
  margin: 0;
  text-align: center;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.verdict.is-right { color: #1e7a46; }
.verdict.is-wrong { color: var(--coral); }

.countdown {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.countdown[hidden] { display: none; }

.note {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--coral);
  font-weight: 700;
}

@media (max-width: 860px) {
  .rules, .how ol, .online-forms { grid-template-columns: 1fr; }
  .board-row { grid-template-columns: minmax(0, 460px); }
  .side { margin-top: 16px; }
}

@media (max-width: 560px) {
  .choices, .leave-actions { grid-template-columns: 1fr; }
  .leave-actions { display: flex; flex-direction: column; }
}
