/* Crux light palette + type from src/design/tokens.ts and typography.ts.
   All visual styling lives here for the later polish pass. */
@font-face {
  font-family: Grotesk;
  src: url('fonts/SpaceGrotesk-Regular.ttf');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Grotesk;
  src: url('fonts/SpaceGrotesk-Bold.ttf');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: Fraunces;
  src: url('fonts/Fraunces-Regular.ttf');
  font-weight: 400;
  font-display: swap;
}
:root {
  color-scheme: light;
  --bg: #faf8f5;
  --surface: #f0eeea;
  --ink: #161616;
  --muted: #5c5c5c;
  --gold: #e6b23e;
  --gold-ink: #10130f;
  --line: #d8d4cd;
  --land: #646464;
  --sea: #f0eeea;
  --border: #faf8f5;
  --correct: #5d8c4f;
  --correct-ink: #24532c;
  --amber: #8a5212;
  --red: #c7002a;
  --radius: 18px;
  --near: #8fb573;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  font-family: Grotesk, system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  cursor: pointer;
}
button:disabled {
  cursor: default;
}
button:focus-visible,
a:focus-visible,
svg:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}
#app {
  height: 100dvh;
  min-height: 420px;
  max-width: 880px;
  margin: auto;
  display: flex;
  flex-direction: column;
  padding: 0 24px;
  position: relative;
  overflow: hidden;
}
header {
  height: 58px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  gap: 10px;
}
.wordmark {
  font-size: 14px;
  letter-spacing: 6px;
  font-weight: 700;
}
.edition {
  font-size: 11px;
  letter-spacing: 1.3px;
  color: var(--muted);
}
.icon-button {
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  font-weight: 700;
}
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}
.stage > .leaving {
  position: absolute;
  inset: 0;
  margin: auto;
  pointer-events: none;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 2.2px;
  font-weight: 700;
  color: var(--muted);
}
h1,
h2,
p {
  margin: 0;
}
h1,
h2 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 400;
}
h1 {
  font-size: clamp(30px, 5vw, 46px);
  letter-spacing: -1.4px;
  line-height: 1.1;
}
.welcome {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
}
.welcome h1 {
  font-size: clamp(38px, 6vw, 58px);
}
.map-plate {
  width: 100%;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--sea);
  aspect-ratio: 2 / 1;
  max-height: 100%;
  isolation: isolate;
}
.world {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
}
.land {
  fill: var(--land);
  stroke: var(--border);
  stroke-width: 0.5;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  transition:
    fill 240ms var(--ease),
    stroke 240ms var(--ease);
}
.grid-line {
  stroke: var(--line);
  stroke-width: 0.4;
  fill: none;
  vector-effect: non-scaling-stroke;
}
.answer {
  stroke: var(--ink);
  stroke-width: 1.6;
}
.answer.hit {
  fill: var(--correct);
}
.answer.near {
  fill: var(--near);
}
.answer.miss {
  fill: var(--gold);
}
.safe-ring {
  fill: #16161614;
  stroke: var(--ink);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.ripple {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.ripple.good {
  stroke: var(--correct);
}
.pin {
  fill: var(--ink);
  stroke: var(--bg);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.truth {
  fill: var(--bg);
  stroke: var(--ink);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}
.distance-line {
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  stroke-linecap: round;
  fill: none;
  vector-effect: non-scaling-stroke;
}
.preview {
  max-width: 580px;
  max-height: 220px;
  aspect-ratio: 2.6 / 1;
  margin: 4px 0;
}
.preview .world {
  opacity: 0.7;
}
.map-plate.handed-off {
  border-color: transparent;
  background: transparent;
}
.map-plate.handed-off .world {
  visibility: hidden;
}
.map-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-7deg);
  background: var(--gold);
  width: 86px;
  height: 86px;
  box-shadow: 0 4px 14px #16161616;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-family: Fraunces, serif;
}
.map-badge span {
  font:
    11px Grotesk,
    sans-serif;
  margin-top: 0;
}
.intro {
  font-size: 16px;
  line-height: 1.4;
}
.muted {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.primary,
.secondary {
  min-height: 52px;
  border-radius: 14px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.primary,
.secondary,
.map-control,
.icon-button,
.text-button {
  transition:
    background-color 160ms var(--ease),
    border-color 160ms var(--ease),
    color 160ms var(--ease),
    transform 120ms var(--ease),
    opacity 160ms var(--ease);
}
.primary:not(:disabled):active,
.secondary:not(:disabled):active,
.map-control:active,
.icon-button:active {
  transform: scale(0.97);
}
.primary {
  background: var(--gold);
  border: 1px solid var(--gold);
  color: var(--gold-ink);
  width: 100%;
}
.primary:disabled {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}
.primary.busy:disabled {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--gold-ink);
  opacity: 0.72;
}
.secondary.busy {
  opacity: 0.6;
}
.secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}
.welcome > .primary {
  max-width: 400px;
}
.text-button {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 4px 0;
  font-size: 12px;
  min-height: 32px;
}
.board {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hud {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.trail {
  display: flex;
  align-items: center;
  gap: 3px;
}
.pip {
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: var(--line);
  box-sizing: border-box;
  transition: background-color 240ms var(--ease);
}
.pip.now {
  background: var(--ink);
}
.pip.hit {
  background: var(--correct);
}
.pip.miss {
  background: transparent;
  border: 1.5px solid var(--amber);
}
.trail-count {
  font-size: 11px;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-left: 6px;
  white-space: nowrap;
}
.hud-stats {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}
.stat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stat-streak {
  align-items: center;
}
.stat-points {
  align-items: flex-end;
}
.stat-label {
  font-size: 10px;
  letter-spacing: 1px;
  font-weight: 700;
  color: var(--muted);
}
.stat-value {
  font-size: 16px;
  line-height: 22px;
  white-space: nowrap;
  display: inline-block;
  transition: color 240ms var(--ease);
}
.stat-value.held {
  color: var(--correct-ink);
}
.lives {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 22px;
}
.life {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--ink);
  display: block;
  transition:
    background-color 240ms var(--ease),
    border-color 240ms var(--ease);
}
.life.spent {
  background: transparent;
  border-color: var(--muted);
}
.points-float {
  position: absolute;
  right: 0;
  top: -6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--correct-ink);
  pointer-events: none;
}
.target {
  text-align: center;
  padding: 3px 0 9px;
  min-height: 72px;
}
.country {
  font-size: clamp(28px, 5vw, 40px);
  margin-top: 5px;
  line-height: 1.14;
}
.board > .map-plate {
  flex: 1;
  min-height: 120px;
  aspect-ratio: auto;
  max-height: 350px;
}
.dock {
  margin-top: auto;
  padding-top: 2px;
}
.feedback {
  min-height: 66px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 15px;
  padding-bottom: 8px;
}
.verdict {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 7px 12px 7px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
}
.verdict::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 99px;
  background: var(--amber);
}
.verdict.good::before {
  background: var(--correct);
}
.verdict-words {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.verdict strong {
  font-family: Fraunces, serif;
  font-size: 18px;
  line-height: 1.15;
  font-weight: 400;
}
.verdict.good strong {
  color: var(--correct-ink);
}
.verdict.off strong {
  color: var(--amber);
}
.distance {
  font-size: 11px;
  line-height: 1.25;
  color: var(--muted);
}
.verdict-points {
  flex-shrink: 0;
  text-align: right;
  display: flex;
  flex-direction: column;
}
.verdict-points span {
  font-size: 10px;
  color: var(--muted);
}
.round-points {
  font-size: 17px;
}
.verdict-ring {
  position: absolute;
  left: -4px;
  top: -4px;
  pointer-events: none;
  overflow: visible;
}
.verdict-ring rect {
  fill: none;
  stroke: var(--correct);
  stroke-width: 2;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
.placement {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.mini-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  height: 34px;
}
.map-controls {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 4px;
  transition: opacity 160ms var(--ease);
}
.map-controls.off {
  opacity: 0;
  visibility: hidden;
}
.map-control {
  height: 40px;
  width: 40px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 10px;
  font-size: 20px;
  box-shadow: 0 1px 3px #16161612;
}
footer {
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
  gap: 10px;
}
footer a {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  min-height: 32px;
}
.results {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}
.results h1 {
  font-size: clamp(28px, 4.5vw, 40px);
}
.score-value {
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.score {
  font-size: clamp(52px, 8vw, 76px);
  font-family: Fraunces, serif;
  line-height: 0.95;
  letter-spacing: -3px;
}
.score span {
  display: block;
  font:
    12px Grotesk,
    sans-serif;
  letter-spacing: 1px;
  margin-top: 8px;
  color: var(--muted);
}
.recap-grid {
  display: flex;
  gap: 5px;
}
.recap-cell {
  width: 24px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  font-size: 14px;
}
.safe {
  background: var(--correct);
  color: white;
}
.near {
  background: var(--gold);
  color: var(--ink);
}
.miss {
  background: var(--ink);
  color: white;
}
.empty {
  background: var(--line);
  color: var(--muted);
}
.result-stats {
  display: flex;
  justify-content: center;
  gap: 34px;
  width: 100%;
}
.result-stats > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.result-stats b {
  font-size: 22px;
}
.result-stats span {
  font-size: 11px;
  color: var(--muted);
}
.rank {
  font-size: 13px;
}
.results > .primary {
  max-width: 480px;
}
.result-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 480px;
}
.result-actions > .secondary {
  flex: 1;
  font-size: 14px;
}
.notice {
  font-size: 12px;
  line-height: 1.3;
  color: var(--amber);
  text-align: center;
  padding: 4px;
}
.notice .text-button {
  display: block;
  margin: auto;
}
.overlay {
  position: absolute;
  inset: 0;
  background: #16161675;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
  backdrop-filter: blur(4px);
}
.dialog {
  background: var(--bg);
  border-radius: 22px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.dialog h2 {
  font-size: 28px;
  letter-spacing: -0.8px;
}
.help-copy {
  display: grid;
  gap: 14px;
  font-size: 14px;
  line-height: 1.5;
}
.leaderboard {
  display: grid;
  gap: 14px;
}
.leader-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 14px;
}
.leader-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dialog textarea {
  width: 100%;
  min-height: 110px;
  margin-top: 14px;
  border: 1px solid var(--line);
  padding: 10px;
  background: var(--surface);
  color: var(--ink);
  font:
    12px Grotesk,
    sans-serif;
  resize: none;
}
.loading,
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
}
.guest .map-plate {
  max-height: 180px;
  max-width: 500px;
}
@media (min-width: 700px) {
  #app {
    padding: 0 36px;
  }
  .board {
    max-width: 760px;
    width: 100%;
    align-self: center;
  }
  .target {
    padding-top: 8px;
  }
  .dock > .primary {
    max-width: 440px;
    margin: auto;
  }
  .mini-stats {
    max-width: 440px;
    margin: auto;
    width: 100%;
  }
  .feedback {
    max-width: 440px;
    margin: auto;
    width: 100%;
  }
  .results {
    gap: 20px;
  }
  .welcome {
    gap: 18px;
  }
}
@media (max-width: 400px) {
  #app {
    padding: 0 16px;
  }
  .edition {
    font-size: 10px;
    letter-spacing: 0.6px;
  }
  .welcome {
    gap: 12px;
  }
  .intro {
    font-size: 14px;
  }
  .muted {
    font-size: 12px;
  }
  .result-stats {
    gap: 12px;
  }
  .results {
    gap: 14px;
  }
  .map-control {
    width: 44px;
    height: 44px;
  }
}
@media (max-height: 560px) {
  #app {
    padding: 0 16px;
    min-height: 360px;
  }
  header {
    height: 44px;
  }
  .welcome {
    gap: 9px;
  }
  .welcome h1 {
    font-size: 34px;
  }
  .welcome .preview {
    max-height: 130px;
  }
  .hud {
    gap: 3px;
    padding-top: 5px;
  }
  .stat-label {
    display: none;
  }
  .points-float {
    top: -13px;
  }
  .target {
    min-height: 58px;
    padding: 0;
  }
  .country {
    font-size: 28px;
  }
  .board {
    gap: 5px;
  }
  .feedback {
    min-height: 56px;
    padding-bottom: 4px;
  }
  .verdict {
    min-height: 50px;
    padding-top: 4px;
    padding-bottom: 4px;
  }
  .verdict strong {
    font-size: 16px;
  }
  .mini-stats {
    height: 28px;
  }
  .results {
    gap: 10px;
  }
  .score {
    font-size: 48px;
  }
  .results h1 {
    font-size: 28px;
  }
  .result-stats b {
    font-size: 18px;
  }
  .recap-cell {
    height: 24px;
  }
  .primary,
  .secondary {
    min-height: 48px;
  }
  footer {
    height: 30px;
  }
  .dialog {
    gap: 12px;
    padding: 18px;
  }
  .help-copy {
    gap: 10px;
    font-size: 12px;
  }
  .map-control {
    height: 34px;
    width: 34px;
  }
}
.loading::after {
  content: '';
  width: 72px;
  height: 3px;
  border-radius: 99px;
  background:
    linear-gradient(var(--gold), var(--gold)) no-repeat 50% 0 / 28px 100%,
    var(--line);
}
@media (prefers-reduced-motion: no-preference) {
  .loading::after {
    animation: loader-sweep 1.1s var(--ease) infinite alternate;
  }
  @keyframes loader-sweep {
    from {
      background-position:
        0 0,
        0 0;
    }
    to {
      background-position:
        100% 0,
        0 0;
    }
  }
}
@media (prefers-reduced-motion: reduce) {
  .land,
  .pip,
  .life,
  .stat-value,
  .primary,
  .secondary,
  .map-control,
  .icon-button,
  .text-button,
  .map-controls {
    transition: none;
  }
}

.world:focus:not(:focus-visible) {
  outline: none;
}

.icon-button {
  width: 44px;
  height: 44px;
}
.map-control {
  min-width: 44px;
  min-height: 44px;
}

@media (max-height: 560px) {
  header {
    height: 48px;
  }
}

.results .rank {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.25;
}
@media (max-height: 450px) {
  .results {
    gap: 8px;
  }
  .results > .eyebrow {
    display: none;
  }
  .results h1 {
    font-size: 26px;
  }
  .results .score {
    font-size: 42px;
  }
  .results .score span {
    margin-top: 4px;
  }
  .results .recap-cell {
    height: 22px;
  }
  .result-stats span {
    line-height: 1.2;
  }
}

.mini-stats {
  flex-shrink: 0;
  min-height: 32px;
}
.feedback > .notice {
  grid-column: 1 / -1;
}
@media (max-height: 450px) {
  .board {
    gap: 4px;
  }
  .hud {
    gap: 2px;
    padding-top: 3px;
  }
  .target {
    min-height: 50px;
  }
  .board > .map-plate {
    min-height: 84px;
  }
  .notice {
    padding: 0;
    font-size: 11px;
  }
  .notice .text-button {
    min-height: 24px;
    padding: 0;
  }
  .feedback {
    min-height: 50px;
    padding-bottom: 3px;
  }
  .verdict {
    min-height: 46px;
    padding-top: 3px;
    padding-bottom: 3px;
  }
}

.result-actions > .secondary {
  padding-left: 10px;
  padding-right: 10px;
}
@media (max-width: 320px) {
  .results {
    gap: 8px;
  }
  .results > .eyebrow {
    display: none;
  }
  .results h1 {
    font-size: 24px;
  }
}
