:root {
  --bg: #060a14;
  --panel: rgba(13, 20, 38, 0.86);
  --panel-solid: #0d1426;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f4efe4;
  --muted: #9aa6bf;
  --accent: #ff6b35;
  --great: #2ee59d;
  --good: #ffd23f;
  --meh: #ff9f1c;
  --bad: #ff4d6d;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: radial-gradient(ellipse at 50% 40%, #0e1830 0%, var(--bg) 70%);
  color: var(--text);
  font: 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }

#globe { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; cursor: crosshair; }

/* Header */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 8;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand { display: flex; align-items: baseline; gap: 10px; }
.logo { font: 600 26px/1 var(--serif); letter-spacing: 0.02em; }
.logo::after { content: "."; color: var(--accent); }
.logo.big { font-size: 64px; margin: 0; }
.num { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
nav { display: flex; gap: 8px; }
.icon {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font: 600 14px var(--sans); cursor: pointer;
}
.icon.heart { color: var(--accent); font-size: 17px; }
.icon:hover { border-color: rgba(255, 255, 255, 0.3); }

/* Clue card */
.card {
  position: fixed; z-index: 4; left: 50%; transform: translateX(-50%);
  width: min(620px, calc(100% - 32px));
  background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px 16px;
}
.clue { top: 62px; pointer-events: none; }
.clue .meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.clue p { margin: 6px 0 0; font: 21px/1.35 var(--serif); }
@media (max-width: 520px) { .clue p { font-size: 18px; } }

/* Bottom bar */
.bar {
  position: fixed; z-index: 4; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + var(--safe-b));
  width: min(620px, calc(100% - 32px));
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 10px 10px 16px;
}
.hint { margin: 0; color: var(--muted); font-size: 14px; }
@media (max-width: 420px) { .hint { font-size: 12px; } }
.dots { display: flex; gap: 6px; }
.dots span { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); }
.dots span.current { background: transparent; box-shadow: inset 0 0 0 2px var(--text); }

/* Buttons */
button, .secondary { font: 600 16px var(--sans); }
.primary {
  border: 0; border-radius: 12px; padding: 12px 18px; cursor: pointer;
  background: var(--accent); color: #1a0b03;
}
.primary:disabled { background: rgba(255, 255, 255, 0.12); color: var(--muted); cursor: default; }
.secondary {
  display: inline-block; text-decoration: none; text-align: center;
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 16px; cursor: pointer;
  background: rgba(255, 255, 255, 0.06); color: var(--text);
}
.secondary:hover { border-color: rgba(255, 255, 255, 0.3); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--good); outline-offset: 2px; }

/* Bottom sheets */
.sheet {
  position: fixed; z-index: 6; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + var(--safe-b));
  width: min(520px, calc(100% - 32px)); max-height: calc(100% - 140px); overflow: auto;
  background: var(--panel-solid); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: rise 0.35s ease-out;
}
@keyframes rise { from { transform: translate(-50%, 24px); opacity: 0; } }
@keyframes rise-side { from { transform: translateY(24px); opacity: 0; } }
@media (min-width: 900px) {
  .sheet { left: auto; right: 24px; bottom: 24px; transform: none; width: 400px; animation-name: rise-side; }
}
.sheet h2 { margin: 6px 0 4px; font: 600 22px/1.25 var(--serif); }
.score-line { display: flex; align-items: baseline; gap: 12px; }
.score { font: 700 40px/1 var(--sans); font-variant-numeric: tabular-nums; }
.dist { color: var(--muted); }
.fact { margin: 6px 0 4px; color: #d9d2c3; }
.source { color: var(--muted); font-size: 13px; }
.sheet .primary { width: 100%; margin-top: 14px; }

.results { text-align: center; }
.results .total { font: 700 64px/1 var(--sans); font-variant-numeric: tabular-nums; margin: 6px 0; }
.results .total small { font-size: 22px; color: var(--muted); font-weight: 500; }
.emoji { font-size: 26px; letter-spacing: 4px; }
.review { text-align: left; margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.review summary { cursor: pointer; color: var(--muted); }
.review ol { padding-left: 20px; margin: 8px 0 0; }
.review li { margin: 8px 0; font-size: 14px; }
.review li b { font-variant-numeric: tabular-nums; }
.support { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.small { color: var(--muted); font-size: 13px; }

/* Start overlay */
.overlay {
  position: fixed; inset: 0; z-index: 7; display: grid; place-items: center;
  background: linear-gradient(180deg, rgba(6, 10, 20, 0.2), rgba(6, 10, 20, 0.85) 65%);
  padding: 16px;
}
.start-box { text-align: center; max-width: 420px; margin-top: 30vh; }
.tagline { font: 22px/1.3 var(--serif); margin: 8px 0; }
.howto { color: var(--muted); margin: 0 0 18px; }
.start-box .primary { font-size: 18px; padding: 14px 28px; }

/* Dialogs */
dialog {
  width: min(460px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel-solid); color: var(--text); padding: 20px 22px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin-top: 0; font: 600 24px var(--serif); }
dialog form { margin-top: 14px; }
dialog form .primary { width: 100%; }
#dlg-pix { text-align: center; }
#pix-qr { background: #fff; border-radius: 12px; padding: 8px; width: 240px; height: 240px; }

.toast {
  position: fixed; z-index: 10; left: 50%; top: 70px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-weight: 600;
}
.loading { position: fixed; inset: 0; z-index: 9; display: grid; place-items: center; background: var(--bg); transition: opacity 0.4s; }
.loading.done { opacity: 0; pointer-events: none; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.15); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.great { color: var(--great); } .good { color: var(--good); } .meh { color: var(--meh); } .bad { color: var(--bad); }
