: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(1240px, 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:
    radial-gradient(circle at 58% 42%, var(--coral) 0 5px, transparent 5.5px),
    linear-gradient(var(--sky), var(--sky)) 8px 12px / 26px 18px 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; }

.info-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-family: Fraunces, Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
  font-style: italic;
  line-height: 1;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(27, 21, 48, 0.12);
}

.info-btn-sm {
  width: 22px;
  height: 22px;
  border-width: 1.5px;
  font-size: 0.78rem;
  box-shadow: 2px 2px 0 rgba(27, 21, 48, 0.1);
}

.info-btn:hover {
  background: var(--butter);
}

.eyebrow .info-btn {
  margin-left: 8px;
  vertical-align: middle;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-row .status {
  margin: 10px 0 0;
}

.status-row .info-btn {
  margin-top: 10px;
  flex: none;
}

.map-note-card {
  width: min(440px, 100%);
  text-align: left;
}

.map-note-card .leave-actions {
  justify-content: flex-end;
}

.map-note-card p + p {
  margin-top: 10px;
}

#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: 36rem;
  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;
}

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

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

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

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

.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;
  gap: 10px;
  margin-top: 8px;
}

.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%, 480px);
  margin-inline: auto;
  text-align: center;
}

#play.stage { width: min(100%, 1240px); }

.board-row {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(240px, 280px);
  justify-content: center;
  column-gap: 22px;
  align-items: start;
  margin-top: 22px;
}

.map-wrap {
  position: relative;
  z-index: 2;
  min-width: 0;
}

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

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

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

.round-score {
  margin: 4px 0 12px;
  text-align: center;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#round-players[hidden] {
  display: none;
}

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

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

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

.leaderboard .list-scroll { max-height: 29rem; }

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

.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 {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.leaderboard .time,
.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);
}

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

.map-card {
  position: relative;
  width: 100%;
  margin: 0 auto;
  aspect-ratio: 2 / 1;
  padding: 12px;
  overflow: hidden;
  background: var(--sky);
  border: 2.5px solid var(--ink);
  border-radius: 28px;
  box-shadow: 8px 8px 0 var(--ink);
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.map-card.is-locked {
  cursor: default;
}

.map-card.is-panning {
  cursor: grabbing;
}

.map-card.is-zoomed:not(.is-locked):not(.is-panning) {
  cursor: grab;
}

.map-card.is-zoomed:not(.is-locked):not(.is-panning).can-place {
  cursor: crosshair;
}

.map-card svg {
  width: 100%;
  height: 100%;
  display: block;
}

.map-finish {
  position: absolute;
  inset: 12px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  border-radius: 20px;
  background: rgba(27, 21, 48, 0.55);
  text-align: center;
  pointer-events: auto;
  touch-action: manipulation;
}

.map-finish[hidden] {
  display: none;
}

.map-finish-text {
  margin: 0;
  max-width: 18rem;
  color: #fff;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(1.35rem, 3.5vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.map-finish .btn {
  position: relative;
  z-index: 1;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 4px 4px 0 #fff;
}

.zoom-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.zoom-controls button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
}

.zoom-controls button:hover {
  background: var(--peach);
}

.zoom-controls button:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}

#ocean {
  fill: var(--sky);
}

#world {
  fill: var(--mint);
  stroke: rgba(27, 21, 48, 0.35);
  stroke-width: 0.4;
  stroke-linejoin: round;
  pointer-events: none;
}

#target-shape {
  fill: rgba(242, 123, 98, 0.55);
  stroke: var(--ink);
  stroke-width: 1.1;
  stroke-linejoin: round;
  pointer-events: none;
}

#link-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-dasharray: 6 5;
  pointer-events: none;
}

.pin {
  pointer-events: none;
}

.pin-guess,
.pin-hit {
  fill: #3aaa5a;
  stroke: var(--ink);
  stroke-width: 1.4;
}

.pin-miss {
  fill: var(--coral);
  stroke: var(--ink);
  stroke-width: 1.4;
}

.pin-other {
  fill: var(--lilac);
  stroke: var(--ink);
  stroke-width: 1.2;
}

.hit-yes { color: #2f8a4a; font-weight: 700; }
.hit-no { color: var(--coral); font-weight: 700; }

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

.guess-form {
  position: relative;
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.guess-field {
  position: relative;
  flex: 1;
}

.guess-field input {
  width: 100%;
  padding: 14px 46px 14px 16px;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  background: var(--bg);
  font-size: 1.08rem;
}

.list-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transform: translateY(-50%);
}

.list-toggle svg { width: 18px; height: 18px; }

.list-toggle:hover,
.guess-field:focus-within .list-toggle { background: var(--peach); }

.country-list {
  position: absolute;
  z-index: 6;
  top: calc(100% + 12px);
  bottom: auto;
  left: 0;
  right: 0;
  max-height: 200px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  list-style: none;
  text-align: left;
  background: var(--bg);
  border: 2.5px solid var(--ink);
  border-radius: 20px;
  box-shadow: 7px 7px 0 var(--ink);
}

.country-list[hidden] { display: none; }

.country-list button {
  width: 100%;
  padding: 16px 18px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  font-size: 1.22rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.country-list button:hover,
.country-list button.is-on {
  background: var(--peach);
}

.country-list .empty {
  margin: 0;
  padding: 16px 18px;
  color: var(--muted);
  font-weight: 700;
}

.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:disabled {
  opacity: 0.55;
  cursor: default;
}

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

.history {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 2px;
  border-bottom: 2px solid rgba(27, 21, 48, 0.12);
  font-weight: 700;
  text-align: left;
}

.history li > span:first-child {
  min-width: 0;
}

.history li:last-child { border-bottom: 0; }

.distance, .hit { color: var(--muted); }

.bearing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 4.2rem;
  justify-content: flex-end;
}

.arrow {
  display: inline-block;
  transform: rotate(var(--turn));
}

#again { margin-top: 0; }

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

@media (max-width: 900px) {
  .board-row { grid-template-columns: minmax(0, 1fr); }
  .side { margin-top: 16px; }
}

@media (max-width: 800px) {
  .rules, .how ol, .online-forms { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .guess-form, .round-actions, .leave-actions { flex-direction: column; }
}
