*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #fdf8ef;
  --surface: #ffffff;
  --border: rgba(93, 64, 28, 0.14);
  --text: #2b2013;
  --muted: #8a7a64;
  --accent: #e8930c;
  --accent-soft: #fff3dc;
  --go: #2e9e6b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(93, 64, 28, 0.09);
  font-size: 16px;
}

html { background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, sans-serif; }
body { min-height: 100dvh; display: flex; flex-direction: column; touch-action: none; }

/* ── HEADER ── */
.site-header {
  background: var(--surface); border-bottom: 2px solid var(--border);
  padding: 10px 14px; display: flex; align-items: center;
  justify-content: space-between; gap: 10px;
  position: sticky; top: 0; z-index: 200;
}
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.site-header h1 { font-size: 1.12rem; font-weight: 800; white-space: nowrap; }
.exit-btn { font-size: 0.8rem; color: var(--muted); text-decoration: none;
  white-space: nowrap; padding: 6px 8px; border-radius: 8px; }
.exit-btn:hover { color: var(--accent); }
a:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ── MAIN GAME AREA ── */
#rr-main {
  flex: 1; position: relative; display: flex;
  flex-direction: column; align-items: stretch;
  min-height: 0;
}

#rr-canvas {
  display: block; width: 100%; flex: 1;
  touch-action: none; cursor: crosshair;
  background: #7ec850; /* playground green */
}

/* ── HUD ── */
#rr-hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 10px 14px; pointer-events: none; z-index: 10;
}

#rr-score-wrap { display: flex; align-items: baseline; gap: 6px; }
#rr-score {
  font-size: 2rem; font-weight: 900; color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,.35), 0 0 0 2px rgba(0,0,0,.2);
  line-height: 1;
}
.rr-multi-badge {
  font-size: 0.85rem; font-weight: 900; color: #fff;
  background: var(--accent); border-radius: 12px; padding: 2px 8px;
  animation: rr-multi-pop 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes rr-multi-pop { from { transform: scale(0.7); } to { transform: scale(1); } }

#rr-right-hud { display: flex; align-items: center; gap: 10px; }
.rr-timer {
  font-size: 1.5rem; font-weight: 900; color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,.35); min-width: 40px; text-align: right;
}
.rr-timer.urgent { color: #ff6b6b; animation: rr-urgent 0.5s ease-in-out infinite alternate; }
@keyframes rr-urgent { from { opacity: 1; } to { opacity: 0.6; } }
#rr-lives { font-size: 1.3rem; }

/* Power-up bar */
#rr-powerup-bar {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; z-index: 10; pointer-events: none;
}
.rr-pu-chip {
  background: rgba(255,255,255,.88); border-radius: 20px;
  padding: 4px 10px; font-size: 0.85rem; font-weight: 800;
  display: flex; align-items: center; gap: 5px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.rr-pu-bar {
  width: 48px; height: 5px; background: rgba(0,0,0,.12); border-radius: 3px; overflow: hidden;
}
.rr-pu-fill { height: 100%; border-radius: 3px; transition: width 0.1s linear; }
.pu-speed  .rr-pu-fill { background: #f3c774; }
.pu-magnet .rr-pu-fill { background: #b39ddb; }
.pu-freeze .rr-pu-fill { background: #90caf9; }

/* Go In button (LITTLE) */
#rr-goin-btn {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  z-index: 10; pointer-events: auto;
  min-width: 180px; min-height: 60px;
  font-size: 1.15rem; font-weight: 900; font-family: inherit;
  background: var(--go); color: #fff; border: none; border-radius: var(--radius);
  box-shadow: 0 4px 18px rgba(46,158,107,.4);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  animation: rr-goin-pulse 1.2s ease-in-out infinite;
}
@keyframes rr-goin-pulse {
  0%, 100% { box-shadow: 0 4px 18px rgba(46,158,107,.4); }
  50% { box-shadow: 0 4px 28px rgba(46,158,107,.7); }
}

/* ── OVERLAYS ── */
.rr-overlay {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(43,32,19,.55); backdrop-filter: blur(4px);
}
.rr-overlay[hidden] { display: none; }

.rr-end-box {
  background: var(--surface); border-radius: var(--radius);
  padding: 28px 24px; max-width: 340px; width: 90%;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.28); text-align: center;
}
.rr-end-icon { font-size: 3rem; line-height: 1; animation: rr-icon-pop 0.5s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes rr-icon-pop { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.rr-end-box h2 { font-size: 1.5rem; font-weight: 900; }
.rr-end-score { font-size: 2.2rem; font-weight: 900; color: var(--accent); }
.rr-end-streak { font-size: 0.9rem; font-weight: 800; color: var(--muted); }

.rr-end-how {
  font-size: 0.82rem; color: var(--muted); line-height: 1.6;
  background: var(--bg); border-radius: var(--radius-sm);
  padding: 10px 14px; text-align: left; max-width: 100%;
}
.rr-end-how code { font-family: ui-monospace, "SF Mono", monospace; font-size: 0.8rem; color: var(--text); }

.rr-end-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; }

/* Shared button style */
.rr-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 10px 20px;
  border: 2.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 1rem; font-weight: 800; font-family: inherit; cursor: pointer;
  text-decoration: none; -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s, background 0.15s;
}
.rr-btn:active { transform: scale(0.96); }
.rr-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.rr-btn.primary:hover { background: #cf8005; }
/* Pause button sits inside the dark HUD overlay — override with transparent style */
#rr-hud .rr-btn { background: transparent; color: #fff; border-color: rgba(255,255,255,0.55); }
#rr-hud .rr-btn:hover { background: rgba(255,255,255,0.15); }

/* Action button (same base) */
.rr-action-btn {
  min-height: 56px; padding: 12px 28px;
  border: none; border-radius: var(--radius);
  font-size: 1.1rem; font-weight: 900; font-family: inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ── HI-SCORE ENTRY ── */
.rr-initials-row { display: flex; gap: 10px; justify-content: center; }
.rr-letter-slot {
  width: 56px; height: 72px; font-size: 2rem; font-weight: 900;
  background: var(--bg); border: 3px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; font-family: inherit; transition: border-color 0.15s;
}
.rr-letter-slot.active { border-color: var(--accent); background: var(--accent-soft); }
.rr-letter-btns { display: flex; gap: 8px; align-items: center; justify-content: center; }
.rr-hs-sub { color: var(--muted); font-size: 0.95rem; font-weight: 700; }
.rr-hs-tip { font-size: 0.78rem; color: var(--muted); }

/* ── HI-SCORE TABLE ── */
.rr-hs-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.rr-hs-table th { text-align: left; padding: 6px 8px; font-weight: 800; color: var(--muted);
  font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase;
  border-bottom: 2px solid var(--border); }
.rr-hs-table td { padding: 8px 8px; border-bottom: 1px solid var(--border); }
.rr-hs-table tr:last-child td { border-bottom: none; }
.hs-rank { font-weight: 900; color: var(--accent); }
.hs-initials { font-weight: 900; font-size: 1.1rem; font-family: ui-monospace, monospace; }
.hs-score { font-weight: 800; color: var(--text); text-align: right; }
.hs-you { background: var(--accent-soft); }

/* ── BIG-ONLY visibility ── */
.big-only { display: none !important; }
body[data-mode="big"] .big-only { display: revert !important; }

/* ── FOOTER ── */
.showcase-footer {
  text-align: center; padding: 16px 16px 30px;
  font-size: 0.82rem; color: var(--muted);
  border-top: 1.5px solid var(--border); line-height: 2;
}
.sf-note { font-size: 0.78rem; }
.sf-link { color: var(--muted); text-decoration: none; }
.sf-link:hover { color: var(--accent); }
.sf-link strong { color: var(--text); }
.sf-sep { margin: 0 10px; opacity: 0.4; }

/* ── NARROW HEADER ── */
@media (max-width: 430px) {
  .site-header { padding: 8px 10px; gap: 6px; }
  .site-header h1 { font-size: 0.98rem; }
  .exit-btn { font-size: 0.7rem; padding: 4px 4px; }
  .kc-header-actions { gap: 3px; }
  .kc-hbtn { min-width: 40px; min-height: 40px; font-size: 1rem; }
}

/* ── REDUCED MOTION ── */
@media (prefers-reduced-motion: reduce) {
  .rr-multi-badge, .rr-end-icon, .rr-timer.urgent,
  #rr-goin-btn, .rr-pu-fill { animation: none !important; transition: none !important; }
}
