/* Reset that the artifact host used to provide. */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }

/* Layout: one-screen app. Thin top bar, the map fills the rest, a floating "Finde:" card sits on the map. */
:root {
  --ocean: #cfdde6;
  --ocean-line: #b9ccd8;
  --land: #f3f1e8;
  --land-hover: #e6e2d1;
  --land-off: #e3e6e3;
  --border: #8d9ea8;
  --ink: #14232c;
  --muted: #566a75;
  --panel: #ffffff;
  --panel-line: #d5dfe5;
  --accent: #e2581f;
  --good: #2f8f4e;
  --bad: #c9373a;
  --good-fill: #8fd3a2;
  --bad-fill: #f0a3a3;
  --reveal-fill: #ffc76a;
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ocean: #0f1c25; --ocean-line: #1a2a35; --land: #2c3a42; --land-hover: #3a4b55; --land-off: #1f2a31;
    --border: #556a76; --ink: #e8eef1; --muted: #93a6b0; --panel: #16242d; --panel-line: #2a3b46;
    --accent: #ff7a3d; --good: #5cc983; --bad: #f07074; --good-fill: #2f7a4b; --bad-fill: #8a3539; --reveal-fill: #b07a1c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ocean: #0f1c25; --ocean-line: #1a2a35; --land: #2c3a42; --land-hover: #3a4b55; --land-off: #1f2a31;
  --border: #556a76; --ink: #e8eef1; --muted: #93a6b0; --panel: #16242d; --panel-line: #2a3b46;
  --accent: #ff7a3d; --good: #5cc983; --bad: #f07074; --good-fill: #2f7a4b; --bad-fill: #8a3539; --reveal-fill: #b07a1c;
  color-scheme: dark;
}
html, body { height: 100%; }
body { background: var(--ocean); color: var(--ink); font-family: var(--font-body); display: flex; flex-direction: column; overflow: hidden; }
button, select { font: inherit; color: inherit; }
button:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  padding-block: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--panel); border-bottom: 1px solid var(--panel-line);
  position: relative; z-index: 3;
}
.brand { font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.brand svg { width: 22px; height: 22px; }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.controls label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
select { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 8px; padding: 6px 10px; }
.btn { border: 1px solid var(--panel-line); background: var(--panel); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-weight: 500; }
.btn:hover { border-color: var(--border); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.stats { margin-left: auto; display: flex; gap: 18px; font-family: var(--font-mono); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.stat span { display: block; font-family: var(--font-body); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

#mapwrap { position: relative; flex: 1; min-height: 0; }
#map { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#map:active { cursor: grabbing; }
.graticule { fill: none; stroke: var(--ocean-line); stroke-width: 0.6; vector-effect: non-scaling-stroke; }
.country { fill: var(--land); stroke: var(--border); stroke-width: 0.5; vector-effect: non-scaling-stroke; cursor: pointer; transition: fill .15s; }
.country.off { fill: var(--land-off); cursor: default; }
/* A result colour must stay visible under the mouse. */
@media (hover: hover) { .country:not(.off, .wrong, .right, .reveal):hover { fill: var(--land-hover); } }
.country.wrong { fill: var(--bad-fill); }
.country.right { fill: var(--good-fill); }
.country.reveal { fill: var(--reveal-fill); animation: pulse 1s ease-in-out infinite alternate; }
.dot { fill: var(--land); stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; cursor: pointer; }
.dot.wrong { fill: var(--bad-fill); stroke: var(--bad); }
.dot.right { fill: var(--good-fill); stroke: var(--good); }
.dot.reveal { fill: var(--reveal-fill); stroke: var(--accent); stroke-width: 2; }
.clickmark { fill: var(--accent); stroke: var(--panel); stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: none; }
@keyframes pulse { from { opacity: 1; } to { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .country.reveal { animation: none; } }

.prompt {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: 14px; z-index: 2;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 14px;
  box-shadow: 0 6px 24px rgb(0 0 0 / .12);
  padding: 12px 18px; min-width: min(360px, calc(100vw - 32px)); max-width: calc(100vw - 32px);
  text-align: center;
}
.prompt .eyebrow { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.prompt .target { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.5rem, 5vw, 2.2rem); line-height: 1.1; color: var(--accent); text-wrap: balance; }
.prompt .tries { display: flex; justify-content: center; gap: 6px; margin-top: 6px; }
.pip { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.pip.used { background: var(--panel-line); }
.feedback { min-height: 1.3em; margin-top: 6px; font-size: 0.92rem; }
.feedback.bad { color: var(--bad); }
.feedback.good { color: var(--good); font-weight: 600; }
.feedback .km { font-family: var(--font-mono); font-size: 0.82rem; color: var(--muted); }
.prompt .next { margin-top: 8px; }

.zoombar { position: absolute; right: max(12px, env(safe-area-inset-right, 0px)); bottom: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.zoombar .btn { width: 36px; height: 36px; padding: 0; font-size: 1.1rem; }
.hint { position: absolute; left: max(12px, env(safe-area-inset-left, 0px)); bottom: 14px; font-size: 0.75rem; color: var(--muted); z-index: 2; max-width: 60%; }

.overlay { position: absolute; inset: 0; background: rgb(10 20 28 / .45); display: grid; place-items: center; z-index: 5; padding: 16px; }
.card { background: var(--panel); border-radius: 16px; border: 1px solid var(--panel-line); padding: 22px; width: min(440px, 100%); max-height: 100%; overflow: auto; }
.card h2 { font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; margin: 0 0 4px; text-wrap: balance; }
.card .big { font-family: var(--font-mono); font-size: 2.4rem; color: var(--accent); }
.card .sub { color: var(--muted); font-size: 0.9rem; }
.card ol { padding: 0; margin: 14px 0; list-style: none; display: grid; gap: 4px; }
.card li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--panel-line); font-size: 0.92rem; }
.card li b { font-family: var(--font-mono); font-weight: 500; }
.card li .p0 { color: var(--bad); } .card li .p3 { color: var(--good); }
.card .row { display: flex; gap: 8px; flex-wrap: wrap; }
.card p { margin: 8px 0; line-height: 1.5; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }

@media (max-width: 560px) {
  .stats { margin-left: 0; gap: 14px; }
  .brand { font-size: 1.1rem; }
  .hint { display: none; }
  .controls label { display: none; }
  header { gap: 8px 14px; }
  .prompt { top: 10px; padding: 10px 14px; }
}

/* Highscore form on the end screen. */
input { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 8px; padding: 6px 10px; min-width: 0; }
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card h3 { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; margin: 14px 0 0; }
.card #hsname { flex: 1; }

/* Start screen and shared parts of the multiplayer page. */
a.brand { color: inherit; text-decoration: none; }
a.btn { color: inherit; text-decoration: none; text-align: center; }
a.btn.primary { color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 3px 9px; font-size: 0.8rem; }
.btn.wide { display: block; width: 100%; padding-block: 10px; }
.grow { flex: 1; min-width: 0; }
.choices { display: grid; gap: 10px; margin-top: 16px; }
.choices .btn { padding-block: 12px; font-size: 1.02rem; }
.field { display: grid; gap: 4px; margin: 12px 0; font-size: 0.82rem; color: var(--muted); min-width: 0; }
.field input, .field select { color: var(--ink); font-size: 0.95rem; width: 100%; }
.or { text-align: center; color: var(--muted); font-size: 0.82rem; margin: 10px 0; }
#code { width: 8.5em; text-transform: uppercase; font-family: var(--font-mono); letter-spacing: 0.1em; }
#code::placeholder { text-transform: none; font-family: var(--font-body); letter-spacing: 0; }
.tag { font-size: 0.7rem; color: var(--muted); border: 1px solid var(--panel-line); border-radius: 99px; padding: 1px 8px; white-space: nowrap; }
.tag.host { color: var(--accent); border-color: currentColor; }
.swatch { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; }

/* Lobby */
.roomcode { font-family: var(--font-mono); font-size: clamp(2.6rem, 13vw, 3.6rem); line-height: 1.1; letter-spacing: 0.12em; color: var(--accent); margin-bottom: 10px; }
.playerlist { list-style: none; padding: 0; margin: 8px 0; }
.playerlist li { display: flex; align-items: center; gap: 8px; min-height: 38px; border-bottom: 1px solid var(--panel-line); font-size: 0.95rem; }
.playerlist .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
.settings .field { margin: 8px 0; }

/* Round */
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 8px max(12px, env(safe-area-inset-left, 0px)); background: var(--panel); border-bottom: 1px solid var(--panel-line); position: relative; z-index: 3; }
.chip { display: flex; align-items: center; gap: 6px; border: 1px solid var(--panel-line); border-radius: 99px; padding: 3px 10px; font-size: 0.82rem; max-width: 100%; }
.chip .name { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip b { font-family: var(--font-mono); font-weight: 500; font-variant-numeric: tabular-nums; }
.chip.found { background: var(--good-fill); border-color: var(--good); }
.chip.out { border-color: var(--bad); color: var(--bad); }
.chip.left { opacity: .5; text-decoration: line-through; }
.timer { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.timer .track { flex: 1; height: 6px; border-radius: 3px; background: var(--panel-line); overflow: hidden; }
#timebar { height: 100%; background: var(--accent); transform-origin: left; transition: transform .1s linear; }
#timeleft { min-width: 2.6em; text-align: right; }
.prompt[data-state="countdown"] .target { font-size: 3rem; }
.prompt[data-state="ended"] :is(.timer, .tries) { display: none; }
.pin circle { stroke: var(--panel); stroke-width: 1.5; }
.pin text { font: 600 11px var(--font-body); fill: var(--ink); stroke: var(--panel); stroke-width: 3; paint-order: stroke; }
.pins { pointer-events: none; }

/* Round end and results */
.roundend { position: absolute; z-index: 2; right: 12px; top: 14px; width: min(340px, calc(100% - 24px)); max-height: calc(100% - 28px); overflow: auto; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 14px; box-shadow: 0 6px 24px rgb(0 0 0 / .12); padding: 10px 14px; }
.roundend p { margin: 8px 0 0; text-align: center; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
#mapwrap table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
#mapwrap :is(th, td) { padding: 6px 5px; border-bottom: 1px solid var(--panel-line); text-align: left; white-space: nowrap; }
#mapwrap th { font-size: 0.72rem; font-weight: 500; color: var(--muted); }
#mapwrap tr.me { font-weight: 600; }
#mapwrap .number { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
#mapwrap td.total { color: var(--accent); }
#mapwrap td.detail { color: var(--muted); font-size: 0.78rem; font-weight: 400; }
#mapwrap td.name .swatch, #mapwrap td.name .tag { margin-right: 6px; }
#mapwrap td.name .tag { margin-left: 6px; }
.card.large { width: min(720px, 100%); }
.tablewrap { overflow-x: auto; margin-bottom: 16px; }
.card .podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin: 16px 0; }
.card .podium .place { flex: 1; max-width: 170px; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; justify-items: center; border: 0; padding: 0; }
.podium .name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.podium .step { width: 100%; display: grid; place-items: center; margin-top: 4px; border-radius: 10px 10px 0 0; background: var(--panel-line); font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; }
.podium .place1 .step { height: 92px; background: var(--accent); color: #fff; }
.podium .place2 .step { height: 64px; }
.podium .place3 .step { height: 44px; }

@media (max-width: 700px) {
  /* The map and everyone's clicks stay visible above the table. */
  .roundend { top: auto; bottom: 12px; left: 12px; right: 12px; width: auto; max-height: 42%; }
  .roundend:not([hidden]) ~ .zoombar { display: none; }
  .card { padding: 18px; }
}
