:root {
  --bg: #0d1117;
  --surface: #161b26;
  --surface-2: #1f2633;
  --fg: #e6e8f0;
  --muted: #9aa3bf;
  --accent: #b68d40;
  --accent-fg: #1a1206;
  --ok: #5fce9b;
  --err: #ff8a8a;
  --radius: 14px;
  --maxw: 560px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--fg);
  line-height: 1.5; overscroll-behavior-y: none;
}
h1, h2, h3 { font-family: 'Cinzel', Georgia, serif; line-height: 1.2; }

#rr-app {
  max-width: var(--maxw); margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; gap: 14px;
  padding: calc(14px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right))
           calc(14px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
}

/* Header */
.rr-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.rr-title { font-family: 'Cinzel', serif; font-weight: 700; font-size: 17px; }
.rr-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.clock { font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--ok); } .dot.off { background: var(--err); }
.queued { background: var(--surface-2); padding: 1px 6px; border-radius: 10px; color: var(--accent); }

/* Cards */
.rr-card { background: var(--surface); border: 1px solid #232a3a; border-radius: var(--radius); padding: 20px; flex: 1; }
.rr-card h2 { font-size: 22px; margin-bottom: 10px; color: var(--accent); }
.rr-card p { color: var(--fg); }
.rr-card.center { text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.muted { color: var(--muted); font-size: 14px; }

/* Buttons + inputs */
.btn { background: var(--accent); color: var(--accent-fg); border: none; border-radius: 10px; padding: 13px 22px; font-size: 16px; font-weight: 600; cursor: pointer; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; }
.btn.big { width: 100%; margin-top: 8px; padding: 15px; }
input { width: 100%; padding: 13px; font-size: 16px; border-radius: 10px; border: 1px solid #2c3548; background: #0e1420; color: var(--fg); }
input:focus { outline: 2px solid var(--accent); }
.rr-row { display: flex; gap: 8px; margin-top: 10px; }
.rr-row input { flex: 1; }

.rr-msg { min-height: 20px; margin-top: 10px; font-size: 14px; color: var(--err); }
.rr-msg.err { background: rgba(255,138,138,.1); padding: 8px 10px; border-radius: 8px; }

/* GPS */
.rr-gps { margin: 18px 0; text-align: center; }
.dist { font-size: 20px; font-weight: 600; margin-bottom: 10px; }
.meter { height: 10px; background: #0e1420; border-radius: 6px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--ok)); transition: width .4s; }
.rr-fallback { margin-top: 16px; border-top: 1px solid #232a3a; padding-top: 12px; }
.rr-fallback summary { cursor: pointer; color: var(--accent); font-size: 14px; }

/* Choices + hints */
.rr-choices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.choice { background: var(--surface-2); color: var(--fg); border: 1px solid #2c3548; border-radius: 10px; padding: 13px; font-size: 16px; cursor: pointer; text-align: left; }
.choice:active { border-color: var(--accent); }
.rr-hints { margin-top: 20px; border-top: 1px solid #232a3a; padding-top: 14px; }
.rr-hints h3 { font-size: 15px; margin-bottom: 8px; color: var(--muted); }
.hint-btn { display: block; width: 100%; background: transparent; color: var(--accent); border: 1px dashed #3a445e; border-radius: 8px; padding: 10px; margin-bottom: 6px; cursor: pointer; font-size: 14px; }
.hint.shown { background: var(--surface-2); border-radius: 8px; padding: 10px; margin-bottom: 6px; font-size: 14px; }

/* Finish */
.finish .trophy, .trophy { font-size: 56px; color: var(--accent); }
.finish .time, .time { font-size: 20px; font-weight: 600; }

/* Inventory + progress */
.inv-item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid #232a3a; }
.inv-item i { font-size: 26px; color: var(--accent); }
.prog-row { padding: 10px 0; border-bottom: 1px solid #232a3a; }
.prog-row i.done { color: var(--ok); } .prog-row i.locked { color: var(--muted); } .prog-row i.open { color: var(--accent); }

/* Welcome / readiness */
.welcome .logo img { width: 84px; height: 84px; }
.welcome input { text-align: center; letter-spacing: 1px; }

/* Segmented code input */
.rr-code { display: flex; gap: 6px; justify-content: center; align-items: center; width: 100%; }
.rr-code-cell {
  flex: 1 1 0; min-width: 0; max-width: 46px; aspect-ratio: 3 / 4;
  text-align: center; font-size: clamp(18px, 6vw, 24px); font-weight: 700; text-transform: uppercase;
  padding: 0; border: 1px solid #2c3548; background: #0e1420; color: var(--fg); border-radius: 10px;
  caret-color: var(--accent); transition: border-color .12s, box-shadow .12s;
}
.rr-code-cell:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(182,141,64,.2); }
.rr-code-sep { color: var(--muted); font-size: 22px; font-weight: 700; }
.ready-list { width: 100%; display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.ready-row { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--surface-2); border-radius: 10px; padding: 12px; }
.ready-row > i:first-child { font-size: 22px; color: var(--accent); }
.ready-row div { flex: 1; }
.ready-row .done { color: var(--ok); font-size: 22px; }
.mini { background: var(--accent); color: var(--accent-fg); border: none; border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; }

/* Install walkthrough */
.install-banner { background: var(--surface-2); border: 1px solid #2c3548; border-radius: 12px; padding: 16px; margin-bottom: 14px; text-align: left; }
.install-banner.ok { border-color: rgba(95,206,155,.4); background: rgba(95,206,155,.08); color: var(--ok); }
.install-banner.warn { border-color: rgba(240,165,0,.4); background: rgba(240,165,0,.08); }
.install-banner > strong { display: block; margin-bottom: 6px; font-size: 15px; color: var(--fg); }
.install-banner p { margin-bottom: 8px; }
.install-banner .btn.big { margin-top: 8px; }
.install-steps { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.install-step { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.45; }
.install-step .n { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-fg); font-weight: 700; font-size: 12px; display: grid; place-items: center; margin-top: 1px; }
.ghost-btn { background: transparent; border: none; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 14px; }

/* Bottom nav */
.rr-nav { position: sticky; bottom: 0; display: flex; background: var(--surface); border: 1px solid #232a3a; border-radius: var(--radius); overflow: hidden; padding-bottom: env(safe-area-inset-bottom); }
.rr-nav button { flex: 1; background: transparent; border: none; color: var(--muted); padding: 10px 4px; font-size: 11px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.rr-nav button i { font-size: 20px; }
.rr-nav button.active { color: var(--accent); }

/* Toast */
#rr-toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px); background: #000a; color: #fff; padding: 10px 18px; border-radius: 20px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .3s; z-index: 50; }
#rr-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
