:root {
  --bg: #2b1055;
  --bg2: #4a1a7a;
  --panel: rgba(255, 255, 255, 0.08);
  --ink: #2b1055;
  --text: #fff;
  --muted: rgba(255, 255, 255, 0.7);
  --yellow: #ffd23f;
  --green: #3ddc84;
  --red: #ff5470;
  --accent: #ffd23f;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%) fixed;
  color: var(--text);
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}

.screen { display: none; }
.screen.active { display: block; animation: pop-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.screen.center.active { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; }

@keyframes pop-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }

#bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; font-weight: 800; letter-spacing: 0.02em;
  background: rgba(0, 0, 0, 0.25);
}
#bar[hidden] { display: none; }
#bar-name { color: var(--accent); text-transform: uppercase; }

.logo {
  font-size: 56px; line-height: 0.95; text-align: center; margin: 32px 0 28px;
  text-transform: uppercase; font-weight: 900; color: var(--yellow);
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.3);
  transform: rotate(-3deg);
}

form { display: flex; flex-direction: column; gap: 16px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
input {
  font: inherit; font-size: 28px; font-weight: 800; letter-spacing: 0.05em;
  padding: 12px 14px; border-radius: 14px; border: 3px solid transparent;
  background: #fff; color: var(--ink); text-transform: uppercase; user-select: text; -webkit-user-select: text;
}
input:focus { outline: none; border-color: var(--yellow); }

button { font: inherit; cursor: pointer; touch-action: manipulation; }

.big-btn {
  width: 100%; padding: 18px; border: none; border-radius: 18px;
  background: var(--yellow); color: var(--ink);
  font-size: 24px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.04em;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3);
  transition: transform 0.08s, box-shadow 0.08s;
}
.big-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); }
.big-btn:disabled { opacity: 0.5; cursor: default; }
.big-btn[hidden] { display: none; }

.host-link { text-align: center; color: var(--muted); font-size: 14px; margin-top: 32px; }
.host-link a { color: var(--yellow); font-weight: 800; }

.error { color: var(--red); font-weight: 700; min-height: 1.2em; margin: 0; text-align: center; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-weight: 800; color: var(--muted); margin: 0; }
.huge { font-size: 52px; font-weight: 900; margin: 0; color: var(--yellow); text-shadow: 0 4px 0 rgba(0, 0, 0, 0.3); word-break: break-word; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- Question ---------- */
.q-top { display: flex; justify-content: space-between; align-items: center; font-weight: 800; color: var(--muted); }
#q-timer {
  min-width: 56px; text-align: center; padding: 6px 12px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.3); color: #fff; font-variant-numeric: tabular-nums;
}
#q-timer.urgent { background: var(--red); animation: pulse 0.5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.12); } }

#q-text { font-size: 22px; font-weight: 800; line-height: 1.25; margin: 14px 0 10px; }

#range-display {
  display: flex; justify-content: center; align-items: baseline; gap: 12px;
  font-size: 44px; font-weight: 900; font-variant-numeric: tabular-nums; margin: 6px 0 14px;
}
#range-display .dash { font-size: 18px; color: var(--muted); text-transform: uppercase; }

#slider { position: relative; height: 56px; margin: 0 22px; touch-action: none; }
#track { position: absolute; left: 0; right: 0; top: 22px; height: 12px; border-radius: 6px; background: rgba(0, 0, 0, 0.35); }
#fill { position: absolute; top: 16px; height: 24px; border-radius: 12px; background: var(--yellow); min-width: 6px; box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.25); }
.thumb {
  position: absolute; top: 0; width: 44px; height: 56px; margin-left: -22px;
  display: flex; align-items: center; justify-content: center;
}
.thumb span { width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 4px solid var(--ink); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); pointer-events: none; }

.scale { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; color: var(--muted); margin: 4px 0 14px; font-variant-numeric: tabular-nums; }

.nudges { display: flex; justify-content: space-between; gap: 8px; }
.nudge-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--panel); border-radius: 14px; padding: 8px 4px; }
.nudge-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.nudge-group div { display: flex; gap: 6px; }
.nudge-group button {
  width: 44px; height: 44px; border-radius: 12px; border: none;
  background: rgba(255, 255, 255, 0.9); color: var(--ink); font-size: 22px; font-weight: 900;
}
.nudge-group button:active { background: var(--yellow); }

#stakes { display: flex; gap: 10px; margin: 16px 0; }
#stakes > div { flex: 1; border-radius: 14px; padding: 10px; text-align: center; font-weight: 800; text-transform: uppercase; font-size: 13px; letter-spacing: 0.08em; }
#stakes b { display: block; font-size: 30px; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.worth { background: rgba(61, 220, 132, 0.18); color: var(--green); }
.risk { background: rgba(255, 84, 112, 0.18); color: var(--red); }

#screen-question.locked #slider,
#screen-question.locked .nudges { opacity: 0.4; pointer-events: none; }
#screen-question.locked #lock-btn { background: var(--green); }

/* ---------- Result ---------- */
.delta { font-size: 48px; font-weight: 900; margin: 8px 0; }
.delta.good { color: var(--green); }
.delta.bad { color: var(--red); }
#result-rank { font-weight: 800; font-size: 20px; }

/* ---------- Status ---------- */
.spinner { width: 48px; height: 48px; border-radius: 50%; border: 6px solid rgba(255, 255, 255, 0.2); border-top-color: var(--yellow); animation: spin 0.8s linear infinite; }
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 150%);
  background: #111; color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 700;
  max-width: calc(100% - 32px); transition: transform 0.25s; pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); }
