@font-face { font-family: "Montserrat"; font-weight: 500; font-display: swap; src: url(/fonts/montserrat-500.woff2) format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 700; font-display: swap; src: url(/fonts/montserrat-700.woff2) format("woff2"); }
@font-face { font-family: "Arimo"; font-weight: 400; font-display: swap; src: url(/fonts/arimo-400.woff2) format("woff2"); }

:root {
  --bg: #0d0d0d;
  --panel: #171717;
  --line: #2a2a2a;
  --text: #f2f2f2;
  --muted: #9a9a9a;
  --accent: #ffd400;
  --accent-ink: #0d0d0d;
  --guess: #ffd400;
  --truth: #34d17a;
  --bad: #ff5a4f;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overscroll-behavior: none; }
body { font: 16px/1.4 "Arimo", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
#app { position: fixed; inset: 0; overflow: hidden; }
h1, h2, h3, .num, button, .tab { font-family: "Montserrat", system-ui, sans-serif; }
button { font: inherit; font-family: "Montserrat", sans-serif; font-weight: 700; color: inherit; background: none; border: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .35; cursor: default; }
a { color: var(--accent); }
input { font: inherit; }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(var(--safe-top) + 20px) 20px calc(var(--safe-bottom) + 24px); }
.wrap { max-width: 560px; margin: 0 auto; width: 100%; }

/* ---------- home ---------- */
.logo { font-family: "Montserrat", sans-serif; font-size: 46px; line-height: .95; font-weight: 700; letter-spacing: -1.5px; margin: 18px 0 4px; }
.logo em { font-style: normal; color: var(--accent); }
.tagline { color: var(--muted); margin: 0 0 26px; }
.daily { display: block; width: 100%; text-align: left; background: var(--accent); color: var(--accent-ink); padding: 18px 56px 16px 18px; margin-bottom: 22px; position: relative; }
.daily .k { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; font-weight: 700; opacity: .7; }
.daily .t { font-size: 26px; line-height: 1.1; margin-top: 4px; }
.daily .s { font-family: "Arimo", sans-serif; font-weight: 400; font-size: 14px; margin-top: 6px; }
.daily .go { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); font-size: 30px; }
.section-k { font-family: "Montserrat"; font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin: 6px 0 8px; }
.modes { border-top: 1px solid var(--line); margin-bottom: 26px; }
.mode { display: flex; align-items: baseline; gap: 12px; width: 100%; text-align: left; padding: 16px 2px; border-bottom: 1px solid var(--line); }
.mode .n { font-size: 22px; }
.mode .d { font-family: "Arimo"; font-weight: 400; color: var(--muted); font-size: 14px; flex: 1; }
.mode .a { color: var(--accent); font-size: 22px; }
.mode:active { background: #1c1c1c; }
.row-links { display: flex; gap: 22px; margin-bottom: 28px; }
.row-links button { font-size: 16px; color: var(--accent); padding: 6px 0; }
.me { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.me b { color: var(--text); font-family: "Montserrat"; }
.fine { color: #6c6c6c; font-size: 12px; line-height: 1.5; }
.fine a { color: #8c8c8c; }
.duel-banner { border: 2px solid var(--accent); padding: 14px 16px; margin-bottom: 20px; }
.duel-banner h3 { margin: 0 0 4px; font-size: 18px; }
.duel-banner p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 22px; background: var(--accent); color: var(--accent-ink); font-size: 17px; }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; color: var(--text); border: 2px solid var(--line); }
.btn:active { transform: translateY(1px); }

/* ---------- game ---------- */
.viewer { position: absolute; inset: 0; background: #000; touch-action: none; }
.viewer .pnlm-container { background: #000; }
.flat { position: absolute; inset: 0; overflow: hidden; }
.flat img { position: absolute; left: 50%; top: 50%; transform-origin: center; user-select: none; -webkit-user-drag: none; will-change: transform; }
.loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-family: "Montserrat"; font-size: 14px; letter-spacing: 1px; text-transform: uppercase; pointer-events: none; }
.loading::before { content: ""; width: 18px; height: 18px; border: 3px solid #333; border-top-color: var(--accent); border-radius: 50%; margin-right: 10px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hud { position: absolute; top: calc(var(--safe-top) + 10px); left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; z-index: 5; }
.hud > * { pointer-events: auto; }
.chip { background: rgba(13,13,13,.82); padding: 8px 12px; font-family: "Montserrat"; font-weight: 700; font-size: 14px; display: flex; gap: 10px; align-items: baseline; }
.chip small { color: var(--muted); font-weight: 500; font-size: 12px; }
.chip .num { color: var(--accent); }
.icon-btn { width: 44px; height: 44px; background: rgba(13,13,13,.82); font-size: 20px; display: inline-flex; align-items: center; justify-content: center; }

.walk { position: absolute; left: 10px; bottom: calc(var(--safe-bottom) + 84px); display: flex; gap: 6px; z-index: 5; }
.walk button { width: 52px; height: 52px; background: rgba(13,13,13,.82); font-size: 22px; }
.walk .hint { display: none;  align-self: center; background: rgba(13,13,13,.82); padding: 6px 10px; font-size: 12px; color: var(--muted); font-family: "Arimo"; font-weight: 400; }

/* map sheet: small in the corner, big when open */
.sheet { position: absolute; z-index: 6; right: 10px; bottom: calc(var(--safe-bottom) + 10px); width: 210px; height: 150px; background: var(--panel); border: 2px solid #000; transition: width .22s ease, height .22s ease, right .22s, bottom .22s; display: flex; flex-direction: column; }
.sheet .map { flex: 1; }
.sheet .bar { display: flex; }
.sheet .bar .btn { flex: 1; min-height: 48px; font-size: 15px; }
.sheet .bar .icon-btn { background: #222; height: 48px; width: 48px; }
.sheet.open { right: 0; bottom: 0; width: 100%; height: 62%; border: 0; border-top: 2px solid #000; padding-bottom: var(--safe-bottom); }
.sheet .grab { display: none; }
.sheet.open .grab { display: block; height: 18px; position: relative; background: var(--panel); }
.sheet.open .grab::after { content: ""; position: absolute; left: 50%; top: 7px; width: 42px; height: 4px; margin-left: -21px; background: #444; }
.peek { position: absolute; inset: 0; z-index: 2; }
.sheet.open .peek { display: none; }
@media (min-width: 900px) {
  .sheet { width: 300px; height: 210px; }
  .sheet.open { right: 14px; bottom: 14px; width: 560px; height: 420px; border: 2px solid #000; }
  .sheet.open .grab { display: none; }
}

/* ---------- round result ---------- */
.result { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg); z-index: 10; }
.result .map { flex: 1; min-height: 0; }
.result .panel { padding: 18px 20px calc(var(--safe-bottom) + 16px); background: var(--panel); }
.result .score { font-size: 52px; font-weight: 700; line-height: 1; color: var(--accent); }
.result .score small { font-size: 18px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.result .dist { font-size: 18px; margin: 6px 0 4px; font-family: "Montserrat"; font-weight: 500; }
.result .credit { color: var(--muted); font-size: 12px; margin-bottom: 14px; }
.result .credit a { color: var(--muted); }
.meter { height: 6px; background: #262626; margin: 12px 0 0; }
.meter i { display: block; height: 100%; background: var(--accent); width: 0; transition: width 1s cubic-bezier(.2,.8,.2,1); }

/* ---------- final ---------- */
.final .total { font-size: 64px; font-weight: 700; line-height: 1; color: var(--accent); margin: 8px 0 2px; letter-spacing: -1px; }
.final .of { color: var(--muted); font-size: 15px; margin-bottom: 18px; }
.final .bigmap { height: 240px; margin: 0 -20px 18px; }
.rounds { width: 100%; border-collapse: collapse; margin-bottom: 22px; font-size: 15px; }
.rounds td { padding: 10px 0; border-bottom: 1px solid var(--line); }
.rounds td.r { text-align: right; font-family: "Montserrat"; font-weight: 700; }
.rounds td.m { color: var(--muted); }
.entry { display: flex; gap: 8px; margin-bottom: 12px; }
.entry input { flex: 1; min-width: 0; height: 52px; padding: 0 14px; background: #1d1d1d; border: 2px solid var(--line); color: var(--text); border-radius: 0; }
.entry input:focus { outline: none; border-color: var(--accent); }
.rank { font-family: "Montserrat"; font-weight: 700; font-size: 18px; margin: 4px 0 16px; }
.stack { display: grid; gap: 10px; }

/* ---------- leaderboard ---------- */
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.top h2 { margin: 0; font-size: 26px; flex: 1; }
.tabs { display: flex; border-bottom: 2px solid var(--line); margin-bottom: 12px; }
.tab { flex: 1; padding: 12px 0; font-weight: 700; font-size: 15px; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.seg { display: flex; gap: 6px; margin-bottom: 14px; }
.seg button { padding: 8px 12px; font-size: 13px; border: 2px solid var(--line); color: var(--muted); }
.seg button.on { border-color: var(--accent); color: var(--text); }
.board { width: 100%; border-collapse: collapse; }
.board td { padding: 11px 4px; border-bottom: 1px solid var(--line); }
.board td.p { width: 38px; font-family: "Montserrat"; font-weight: 700; color: var(--muted); }
.board tr:nth-child(1) td.p { color: var(--accent); }
.board td.s { text-align: right; font-family: "Montserrat"; font-weight: 700; }
.board tr.me td { background: #221f0c; }
.empty { color: var(--muted); padding: 24px 0; }

.toast { position: absolute; left: 50%; top: calc(var(--safe-top) + 64px); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 14px; font-family: "Montserrat"; font-weight: 700; font-size: 14px; z-index: 50; max-width: 90%; text-align: center; }

/* leaflet tweaks */
.leaflet-container { background: #1a1a1a; font-family: "Arimo", sans-serif; }
.leaflet-control-attribution { font-size: 10px; }
.pin { width: 22px; height: 22px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 3px solid #0d0d0d; }
.pin.guess { background: var(--guess); }
.pin.truth { background: var(--truth); }
.pin-label { font-family: "Montserrat"; font-weight: 700; font-size: 11px; color: #0d0d0d; background: var(--truth); padding: 1px 5px; white-space: nowrap; }
