/* Layout: full-bleed night globe; one floating "chronometer" card (bottom sheet on phones, left dock on desktop). Single deliberate dark look. */
:root {
  --space: #060a19;
  --ocean: #0d1d42;
  --land: #7fa3dc;
  --ink: #e8ecf8;
  --muted: #8f99bb;
  --line: rgba(160, 180, 230, 0.16);
  --card: rgba(11, 18, 42, 0.86);
  --guess: #f6b445;
  --truth: #8be3ff;
  --great: #7be3a5;
  --bad: #ff8a7a;
  --f-display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --f-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  color-scheme: dark;
}
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden;
  background: var(--space); color: var(--ink);
  font-family: var(--f-body); font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}
#stars { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
#globe { position: fixed; inset: 0; z-index: 1; cursor: crosshair; }
#globe.locked { cursor: grab; }

/* top bar */
.top {
  position: fixed; z-index: 5; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 14px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  pointer-events: none;
}
.brand { font-family: var(--f-display); font-weight: 900; font-size: 18px; letter-spacing: 0.04em; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--guess); box-shadow: 0 0 12px var(--guess); }
.hud { display: flex; align-items: center; gap: 14px; font-family: var(--f-mono); font-size: 13px; color: var(--muted); }
.hud b { color: var(--ink); font-variant-numeric: tabular-nums; }
.pips { display: flex; gap: 5px; }
.pip { width: 9px; height: 9px; border-radius: 3px; background: var(--line); border: 1px solid rgba(160,180,230,.25); }
.pip.now { background: var(--guess); border-color: var(--guess); }

/* card */
.card {
  position: fixed; z-index: 6;
  left: max(16px, env(safe-area-inset-left, 0px)); bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  width: min(400px, calc(100% - 32px));
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  padding: 18px 20px 20px;
  display: flex; flex-direction: column; gap: 12px;
}
@media (max-width: 640px) {
  .card {
    left: 0; right: 0; bottom: 0; width: auto; border-radius: 18px 18px 0 0; border-bottom: 0;
    padding: 16px max(18px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 16px) max(18px, env(safe-area-inset-left, 0px));
  }
  .brand { font-size: 15px; }
  .hud .lbl { display: none; }
}
@media (max-width: 480px) {
  .brand .word { display: none; }
  .hud { gap: 10px; }
}
.eyebrow { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.year {
  font-family: var(--f-display); font-weight: 900; line-height: .9;
  font-size: clamp(54px, 13vw, 76px); letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 10px;
}
.year small { font-size: 16px; font-weight: 700; color: var(--guess); letter-spacing: .08em; }
.city { font-family: var(--f-display); font-weight: 500; font-size: 20px; text-wrap: balance; }
.hint { color: var(--muted); font-size: 14px; line-height: 1.45; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
button, .btn {
  font: 700 15px var(--f-body); border: 0; border-radius: 12px; padding: 13px 18px; cursor: pointer;
  background: var(--guess); color: #1b1203; transition: transform .12s, opacity .2s, background .2s;
}
button:hover:not(:disabled) { transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .35; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.wide { flex: 1 1 auto; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--truth); outline-offset: 2px; }

/* result */
.result { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: end; }
.pts { font-family: var(--f-display); font-weight: 900; font-size: 44px; line-height: 1; font-variant-numeric: tabular-nums; }
.km { font-family: var(--f-mono); font-size: 15px; color: var(--ink); text-align: right; }
.verdict { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.fact { font-size: 14px; line-height: 1.5; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }
.fact b { color: var(--ink); font-weight: 700; }

/* overlays */
.overlay {
  position: fixed; inset: 0; z-index: 10; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; overflow-y: auto; overflow-x: hidden;
  background: radial-gradient(ellipse at 50% 40%, rgba(6,10,25,.55), rgba(6,10,25,.92) 70%);
  padding: calc(env(safe-area-inset-top, 0px) + 24px) max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 24px) max(16px, env(safe-area-inset-left, 0px));
}
.panel { width: min(520px, 100%); display: flex; flex-direction: column; gap: 18px; }
.logo { font-family: var(--f-display); font-weight: 900; font-size: clamp(40px, 11vw, 68px); letter-spacing: -0.02em; line-height: .95; text-wrap: balance; }
.logo span { color: var(--guess); }
.tag { font-size: 17px; line-height: 1.5; color: var(--ink); max-width: 44ch; }
.rules { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; color: var(--muted); padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(13,29,66,.45); }
.rules b { font-family: var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.code-row { display: flex; gap: 8px; }
.code-row input {
  flex: 1; min-width: 0; font: 500 14px var(--f-mono); color: var(--ink); background: rgba(13,29,66,.6);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.err { color: var(--bad); font-size: 13px; min-height: 1em; }

.total { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.total .big { font-family: var(--f-display); font-weight: 900; font-size: clamp(52px, 14vw, 80px); line-height: 1; font-variant-numeric: tabular-nums; color: var(--guess); }
.total .of { font-family: var(--f-mono); color: var(--muted); font-size: 16px; }
.rank { font-family: var(--f-display); font-weight: 500; font-size: 18px; }
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.li { display: grid; grid-template-columns: 22px 74px 1fr auto auto; gap: 10px; align-items: center; padding: 10px 14px; font-size: 14px; border-top: 1px solid var(--line); }
.li:first-child { border-top: 0; }
.li > span:first-child { line-height: 1; }
.li .y { font-family: var(--f-mono); color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.li .n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .d { font-family: var(--f-mono); color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.li .p { font-family: var(--f-mono); font-weight: 700; text-align: right; min-width: 44px; font-variant-numeric: tabular-nums; }
@media (max-width: 480px) { .li { grid-template-columns: 20px 58px minmax(0, 1fr) auto; gap: 8px; padding: 10px 12px; } .li .d { display: none; } }
textarea#shareText {
  width: 100%; box-sizing: border-box; resize: none; min-height: 120px;
  font: 500 13px/1.5 var(--f-mono); color: var(--ink); background: rgba(13,29,66,.6);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
}
.toast { font-size: 13px; color: var(--great); min-height: 1em; }

/* pins */
.pin { width: 0; height: 0; position: relative; pointer-events: none; }
.pin .head {
  position: absolute; left: -11px; bottom: 6px; width: 22px; height: 22px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); box-shadow: 0 4px 14px rgba(0,0,0,.5); border: 2px solid rgba(255,255,255,.85);
  animation: drop .35s cubic-bezier(.3,1.6,.5,1);
}
.pin .head::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: rgba(6,10,25,.75); }
.pin .base { position: absolute; left: -4px; bottom: 0; width: 8px; height: 4px; border-radius: 50%; background: rgba(0,0,0,.5); }
.pin.guess .head { background: var(--guess); }
.pin.truth .head { background: var(--truth); }
.pin .tagl {
  position: absolute; left: 16px; bottom: 22px; white-space: nowrap; font: 700 11px var(--f-body); letter-spacing: .06em;
  background: rgba(6,10,25,.85); color: var(--ink); padding: 3px 7px; border-radius: 6px; border: 1px solid var(--line);
}
@keyframes drop { from { transform: translateY(-18px) rotate(-45deg); opacity: 0; } to { transform: rotate(-45deg); opacity: 1; } }
.loading { position: fixed; inset: 0; z-index: 2; display: grid; place-items: center; color: var(--muted); font-family: var(--f-mono); font-size: 13px; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .pin .head { animation: none; } button { transition: none; } }
.city.event { font-size: 18px; line-height: 1.3; }
.pin .tagl { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

/* Start screen: lighter backdrop so the sample reveals on the globe show through.
   On wide screens the panel sits left and the globe shows on the right. */
#intro { background: linear-gradient(180deg, rgba(6,10,25,.55), rgba(6,10,25,.35) 40%, rgba(6,10,25,.75)); }
@media (min-width: 900px) {
  #intro, #summary {
    place-items: center start;
    background: linear-gradient(90deg, rgba(6,10,25,.92) 0%, rgba(6,10,25,.7) 38%, rgba(6,10,25,0) 62%);
    padding-left: max(6vw, env(safe-area-inset-left, 0px));
  }
}
#globe { transition: transform .9s cubic-bezier(.4, 0, .2, 1); }
@media (min-width: 900px) { body.side #globe { transform: translateX(20vw); } }
@media (prefers-reduced-motion: reduce) { #globe { transition: none; } }

/* top bar: mute toggle sits at the far right */
.top { justify-content: flex-start; }
.hud { margin-left: auto; }
.icon-btn {
  pointer-events: auto; margin-left: 12px; width: 36px; height: 36px; padding: 0; border-radius: 10px;
  display: grid; place-items: center; background: rgba(13,29,66,.6); color: var(--ink); border: 1px solid var(--line);
}
.hud[hidden] + .icon-btn { margin-left: auto; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .off, .icon-btn.off .on { display: none; }
.icon-btn.off .off { display: block; }
.icon-btn.off { color: var(--muted); }

/* friend challenge banner on the start screen */
.challenge {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 14px; border: 1px solid rgba(246,180,69,.45); background: rgba(246,180,69,.12);
  font-weight: 700;
}
.challenge button { padding: 10px 16px; }
button.install { align-self: flex-start; font-size: 13px; padding: 9px 14px; }

/* Wikipedia links */
a.wiki { color: var(--truth); font-weight: 700; text-decoration: none; white-space: nowrap; }
a.wiki:hover, a.wiki:focus-visible { text-decoration: underline; }
.li a.n { color: var(--ink); text-decoration: none; }
.li a.n:hover, .li a.n:focus-visible { color: var(--truth); text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--truth); outline-offset: 2px; border-radius: 4px; }

/* results map */
.pin.small { transform: scale(.72); }
.map-back {
  position: fixed; z-index: 11; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.map-back:hover:not(:disabled) { transform: translateX(-50%) translateY(-1px); }
/* keep overlay panels clear of the top bar */
.overlay { padding-top: calc(env(safe-area-inset-top, 0px) + 68px); }
