:root {
  --paper: #f6f2e9;
  --ink: #1d1d1f;
  --muted: #7a776f;
  --gold: #b8975a;
  --red: #e5484d;
  --green: #2fa36b;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink); font-family: var(--sans); }
body { overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }

#map { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; cursor: crosshair; }

/* HUD */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-left { display: flex; align-items: center; gap: 18px; min-width: 0; }
.hud-right { display: flex; align-items: center; gap: 8px; }
.back { font-family: var(--mono); font-size: 11.5px; letter-spacing: .06em; color: var(--muted); text-decoration: none; white-space: nowrap; }
.back:hover { color: var(--ink); }
.score { display: flex; align-items: baseline; gap: 6px; font-family: var(--serif); white-space: nowrap; }
.score b { font-size: 28px; font-weight: 500; font-variant-numeric: lining-nums tabular-nums; }
.score span { font-size: 15px; color: var(--muted); }
.pg-icon { width: 26px; height: 19px; align-self: center; }
.score.bump b { animation: bump .25s ease-out; }
@keyframes bump { 40% { color: var(--green); } }
.clock { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; color: var(--muted); margin-right: 6px; white-space: nowrap; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid #d8d2c4; background: rgba(255,255,255,.7);
  font-family: var(--mono); font-size: 12px; display: grid; place-items: center;
}
.icon-btn:hover { border-color: var(--ink); }

/* dock */
.dock {
  position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 10;
  display: flex; align-items: center; gap: 12px; padding: 8px 16px;
  background: rgba(255,255,255,.75); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 1px solid #e4dccb; border-radius: 999px; box-shadow: 0 6px 24px rgba(60,50,30,.10);
  white-space: nowrap;
}
.dot { width: 28px; height: 28px; border-radius: 50%; border: 0; padding: 0; transition: transform .12s; }
.dot.free { background: transparent; border: 2.5px dashed currentColor; opacity: .55; cursor: default; }
.dot.sel { transform: scale(1.22); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); }
.trash { border: 0; background: var(--ink); color: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; animation: pop .15s ease-out; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.sep { width: 1px; height: 22px; background: #e1d9c8; }
.inv { display: flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.inv svg { display: block; }

/* overlays */
.overlay {
  position: fixed; inset: 0; z-index: 30; display: none; place-items: center; padding: 16px;
  background: rgba(246,242,233,.72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.overlay.open { display: grid; animation: fade .25s ease-out; }
@keyframes fade { from { opacity: 0; } }
.overlay .card {
  width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: #fffdf8; border: 1px solid #e4dccb; border-radius: 14px; padding: 30px 30px 26px;
  box-shadow: 0 30px 80px rgba(60,50,30,.18);
}
.eyebrow { font-size: 11.5px; font-weight: 500; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); margin: 0 0 10px; }
.eyebrow.alert { color: var(--red); }
h1, h2 { font-family: var(--serif); font-weight: 500; line-height: 1.05; margin: 0; }
h1 { font-size: clamp(34px, 7vw, 46px); }
h2 { font-size: clamp(28px, 6vw, 38px); }
.lede { color: #55524b; font-size: 15.5px; line-height: 1.55; margin: 12px 0 0; }
.howto { margin: 16px 0 0; padding: 0 0 0 18px; color: #55524b; font-size: 14.5px; line-height: 1.7; }
.howto b { color: var(--ink); font-weight: 600; }
.actions { display: flex; align-items: center; gap: 14px; margin-top: 24px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--ink); background: var(--ink); color: #fff; padding: 11px 22px; border-radius: 999px;
  font-size: 13px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; text-decoration: none;
  transition: transform .08s, opacity .15s;
}
.btn:hover { opacity: .88; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink); border-color: #cfc7b6; }
.best { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.fine { font-size: 13px; color: var(--muted); margin: 16px 0 0; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.choice {
  text-align: left; border: 1.5px solid #e4dccb; background: #fff; border-radius: 12px; padding: 16px;
  transition: border-color .12s, transform .12s;
}
.choice:hover { border-color: var(--ink); transform: translateY(-2px); }
.choice .ic { height: 34px; display: flex; align-items: center; margin-bottom: 10px; }
.choice b { display: block; font-family: var(--serif); font-size: 22px; font-weight: 600; }
.choice span { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.4; }

.results { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px; }
.results div { background: var(--paper); border-radius: 10px; padding: 12px; text-align: center; }
.results b { display: block; font-family: var(--serif); font-size: 32px; font-weight: 500; font-variant-numeric: lining-nums tabular-nums; }
.results span { font-size: 11.5px; color: var(--muted); letter-spacing: .04em; }

#toasts { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.18); animation: toast-in .2s ease-out; max-width: calc(100vw - 32px); text-align: center; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 560px) {
  .hud { padding-left: 12px; padding-right: 12px; }
  .hud-left { gap: 10px; }
  .back span, .score span { display: none; }
  .score b { font-size: 24px; }
  .clock { font-size: 10px; margin-right: 2px; }
  .icon-btn { width: 32px; height: 32px; }
  .dock { gap: 8px; padding: 7px 11px; }
  .dot { width: 26px; height: 26px; }
  .overlay .card { padding: 24px 20px 20px; }
  .choices { grid-template-columns: 1fr; }
}
@media (max-width: 360px) {
  .clock { display: none; }
}
