/* ===== Rattle — 60s rush · colorful/lively, responsive ===== */
:root {
  --ink: #faf7ff;
  --muted: #c3b9e0;
  --card: rgba(255, 255, 255, 0.07);
  --card-solid: #241a44;
  --line: rgba(255, 255, 255, 0.14);
  --accent: #ff5db1;    /* hot pink */
  --accent2: #46e0c8;   /* mint */
  --go: #4ade80;
  --warn: #fbbf24;
  --bad: #ff6b8a;

  /* rarity bands (common -> legendary) */
  --c0: #2dd4bf; --c1: #5fd36a; --c2: #fbbf24; --c3: #fb923c; --c4: #ff6b8a; --c5: #c084fc;

  --maxw: 620px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  min-height: 100dvh;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(900px 500px at 12% 0%, rgba(255, 93, 177, 0.28), transparent 60%),
    radial-gradient(800px 520px at 92% 8%, rgba(70, 224, 200, 0.22), transparent 60%),
    radial-gradient(900px 700px at 50% 110%, rgba(124, 92, 255, 0.30), transparent 62%),
    linear-gradient(180deg, #1a1140, #140d2e 60%, #0f0a24);
  display: flex; justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)) 14px;
}
.app { width: 100%; max-width: var(--maxw); display: flex; flex-direction: column; min-height: 0; }

.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

/* ---------- START ---------- */
.start { align-items: center; justify-content: center; text-align: center; gap: 4px; }
.logo { font-size: 2.6rem; font-weight: 900; letter-spacing: 0.02em; line-height: 0.95;
  background: linear-gradient(90deg, var(--accent2), #8b7bff, var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo span { display: block; }
.tagline { color: var(--muted); max-width: 30ch; margin: 12px auto 20px; font-size: 1rem; }
.start-card { width: min(360px, 100%); min-height: 156px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 22px; backdrop-filter: blur(6px); margin: 0 auto 22px; }
.start-card .label { color: var(--muted); font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase; }
.lead { color: var(--ink); opacity: 0.92; font-weight: 700; font-size: 1rem; margin-top: -2px; }
.cat-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; }
.cat-row .category { flex: 1; text-align: center; font-size: 1.45rem; font-weight: 800; margin: 0; line-height: 1.15; }
.nav { appearance: none; flex: none; width: 42px; height: 42px; border-radius: 50%; cursor: pointer; font-family: inherit;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.07); color: var(--ink);
  font-size: 1.6rem; line-height: 1; display: grid; place-items: center; padding-bottom: 3px; }
.nav:active { transform: scale(0.9); }
.start-card .best { color: var(--accent2); font-weight: 700; font-size: 0.9rem; }
.start-card .label.daily { color: var(--warn); }
.daily-jump { margin: 0; color: var(--accent2); }

.big-btn {
  appearance: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 1.15rem; font-weight: 800; color: #1a0f2e;
  padding: 16px 30px; border-radius: 16px;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  box-shadow: 0 10px 30px rgba(255, 93, 177, 0.35);
}
.big-btn:active { transform: scale(0.96); }
.link { background: none; border: none; color: var(--muted); font-size: 0.92rem; cursor: pointer; text-decoration: underline; margin-top: 12px; font-family: inherit; }
.countdown { color: var(--muted); font-size: 0.82rem; font-weight: 600; margin: -8px 0 16px; }
.countdown b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 800; }

/* ---------- GAME ---------- */
.hud { display: flex; align-items: center; gap: 16px; padding: 4px 2px 2px; }
.timer { position: relative; width: 84px; height: 84px; flex: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.12); stroke-width: 9; }
.ring-fg { fill: none; stroke: var(--go); stroke-width: 9; stroke-linecap: round;
  transition: stroke 0.4s linear; }
.ring-fg.mid { stroke: var(--warn); }
.ring-fg.low { stroke: var(--bad); }
.time-num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.7rem; font-weight: 900; }
.timer.pulse .time-num { animation: tick 1s ease-in-out infinite; color: var(--bad); }
@keyframes tick { 0%,100% { transform: scale(1); } 50% { transform: scale(1.14); } }

.scorebox { flex: 1; min-width: 0; }
.score { font-size: 3rem; font-weight: 900; line-height: 1; letter-spacing: -0.01em;
  background: linear-gradient(90deg, #fff, #ffd7ef); -webkit-background-clip: text; background-clip: text; color: transparent; }
.score.bump { animation: bump 0.28s ease; }
@keyframes bump { 0% { transform: scale(1); } 45% { transform: scale(1.09); } 100% { transform: scale(1); } }
.score-label { color: var(--muted); font-size: 0.85rem; margin-top: 2px; font-weight: 600; }

#form { margin: 12px 0 0; }
#guess {
  width: 100%; font-family: inherit; font-size: 16px; font-weight: 600;
  padding: 16px 18px; border-radius: 15px; border: 2px solid var(--line);
  background: rgba(0, 0, 0, 0.22); color: var(--ink); outline: none;
}
#guess:focus { border-color: var(--accent2); box-shadow: 0 0 0 4px rgba(70, 224, 200, 0.18); }
.feedback { min-height: 22px; text-align: center; font-weight: 700; font-size: 0.92rem; margin: 8px 0 4px; color: var(--muted); }
.feedback.good { color: var(--accent2); }
.feedback.bad { color: var(--bad); }
.feedback.warn { color: var(--warn); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; overflow-y: auto; padding: 4px 2px 8px; flex: 1; min-height: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 13px; border-radius: 999px; font-weight: 700; font-size: 0.95rem;
  background: color-mix(in srgb, var(--chip) 24%, #241a44);
  border: 1.5px solid color-mix(in srgb, var(--chip) 60%, transparent);
  color: #fff; animation: popin 0.3s cubic-bezier(.2,.9,.3,1.4);
}
.chip .pts { font-size: 0.78rem; font-weight: 800; color: var(--chip); background: rgba(0,0,0,0.25); padding: 2px 7px; border-radius: 999px; }
@keyframes popin { 0% { transform: scale(0.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* floating +points */
.float-layer { position: fixed; inset: 0; pointer-events: none; z-index: 30; }
.floatpt { position: absolute; font-weight: 900; font-size: 1.5rem; text-shadow: 0 2px 10px rgba(0,0,0,0.4);
  animation: floatup 0.9s ease-out forwards; }
@keyframes floatup { 0% { transform: translateY(0) scale(0.8); opacity: 0; } 15% { opacity: 1; transform: translateY(-6px) scale(1.1); } 100% { transform: translateY(-70px) scale(1); opacity: 0; } }

/* ---------- RESULTS ---------- */
.results { align-items: center; justify-content: center; text-align: center; position: relative; }
.results-inner { width: 100%; }
.r-title { font-size: 1.1rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.r-score { font-size: 4.4rem; font-weight: 900; line-height: 1; margin: 2px 0 2px;
  background: linear-gradient(90deg, var(--accent2), #fff, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: bump 0.5s ease; }
.r-sub { color: var(--muted); font-weight: 600; margin-bottom: 16px; }
.breakdown { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px 16px; max-width: 360px; margin: 0 auto 14px; text-align: left; }
.brow { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-weight: 600; }
.brow:last-child { border-bottom: none; }
.brow.total { font-weight: 900; font-size: 1.1rem; color: var(--accent2); }
.brow .v { font-variant-numeric: tabular-nums; font-weight: 800; }
.brow .tag { color: var(--muted); font-size: 0.75rem; font-weight: 600; }
.haul { font-size: 1.05rem; letter-spacing: 2px; margin: 4px auto 14px; font-weight: 700; }

/* leaderboard */
.big-btn.sm { font-size: 0.95rem; padding: 12px 18px; border-radius: 13px; box-shadow: none; }
.lb-wrap { width: min(380px, 100%); margin: 2px auto 14px; text-align: left; }
.lb-wrap.muted { opacity: 0.65; }
.lb-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.lb-title { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; }
.lb-tabs { display: flex; gap: 3px; background: rgba(0, 0, 0, 0.25); border-radius: 999px; padding: 3px; }
.lb-tab { appearance: none; border: none; background: transparent; color: var(--muted); font-family: inherit; font-size: 0.76rem; font-weight: 800; padding: 5px 11px; border-radius: 999px; cursor: pointer; }
.lb-tab.active { background: var(--accent2); color: #10121a; }
.lb-entry { display: flex; gap: 8px; margin-bottom: 10px; }
#nameInput { flex: 1; font-family: inherit; font-size: 16px; padding: 12px 14px; border-radius: 13px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.22); color: var(--ink); outline: none; }
#nameInput:focus { border-color: var(--accent2); }
.lb-list { list-style: none; margin: 0; padding: 0; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 11px; background: var(--card); margin-bottom: 6px; }
.lb-row.me { background: linear-gradient(90deg, color-mix(in srgb, var(--accent2) 26%, var(--card)), var(--card)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent2) 45%, transparent); }
.lb-rank { width: 22px; color: var(--muted); font-weight: 800; font-variant-numeric: tabular-nums; }
.lb-name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--accent2); }
.lb-note { text-align: center; color: var(--muted); font-size: 0.82rem; margin-top: 6px; min-height: 1em; }

.r-actions { display: flex; flex-direction: column; align-items: center; gap: 2px; }

/* confetti */
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; opacity: 0.9; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(115vh) rotate(540deg); opacity: 0.6; } }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(10, 6, 24, 0.66); backdrop-filter: blur(5px); display: grid; place-items: center; padding: 18px; z-index: 40; }
.modal[hidden] { display: none; }
.sheet { background: var(--card-solid); border: 1px solid var(--line); border-radius: 20px; padding: 22px; max-width: 420px; width: 100%; }
.sheet h3 { margin: 0 0 10px; font-size: 1.3rem; }
.sheet p, .sheet li { color: var(--muted); line-height: 1.55; font-size: 0.95rem; }
.sheet ul { padding-left: 18px; }
.sheet .close { width: 100%; margin-top: 12px; }

footer { text-align: center; color: var(--muted); font-size: 0.72rem; padding-top: 10px; opacity: 0.8; }
footer a { color: var(--muted); }

@media (max-width: 380px) {
  .score { font-size: 2.5rem; }
  .timer { width: 74px; height: 74px; }
  .logo { font-size: 2.2rem; }
}
