/* =========================================================================
 * styles.css — Speed Run. Mobile-first dark indigo theme, centered as a
 * phone frame on desktop so it previews like the eventual app.
 * ========================================================================= */
:root {
  --bg: #0a0b1e;
  --bg-2: #12143a;
  --panel: #1c1f57;
  --panel-2: #262a72;
  --btn: #3b3fb0;
  --btn-hi: #6d5cff;
  --text: #f2f3ff;
  --muted: #a6a9d8;
  --gold: #ffcf3f;
  --ok: #3ddc84;
  --bad: #ff5d6c;
  --line: #33377e;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  background: #05060f;
  color: var(--text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, system-ui, sans-serif;
  overscroll-behavior: none;
}
a { color: var(--btn-hi); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

#app {
  position: relative; max-width: 480px; margin: 0 auto;
  height: 100dvh; overflow: hidden;
  background: radial-gradient(120% 80% at 50% 0%, var(--bg-2) 0%, var(--bg) 60%);
}
@media (min-width: 500px) {
  body { display: grid; place-items: center; }
  #app {
    height: min(920px, 96dvh); border-radius: 26px;
    box-shadow: 0 30px 90px rgba(0,0,0,.7); overflow: hidden;
  }
}

/* ---------- HOME ---------- */
.home-scroll { height: 100%; overflow-y: auto; padding: 26px 18px 40px; position: relative; }
.gear { position: absolute; top: 16px; right: 18px; font-size: 22px; }
.title {
  text-align: center; color: var(--gold); font-size: 40px; font-weight: 900;
  letter-spacing: 2px; margin: 8px 0 4px; text-shadow: 0 3px 0 rgba(0,0,0,.35);
}
.subtitle { text-align: center; color: var(--muted); margin: 0 0 22px; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 16px; display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px;
}
.opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.opt-label { font-weight: 700; font-size: 14px; }
.seg { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg-btn {
  border: 0; background: transparent; color: var(--muted); font-weight: 700;
  padding: 7px 13px; border-radius: 8px; font-size: 14px; min-width: 40px;
}
.seg-btn.on { background: var(--btn-hi); color: #fff; }

.section { text-align: center; color: var(--gold); font-size: 15px; letter-spacing: 1px; text-transform: uppercase; margin: 22px 0 12px; }

.cat-list { display: flex; flex-direction: column; gap: 12px; }
.cat {
  position: relative; display: flex; align-items: center; gap: 12px;
  background: var(--btn); border: 1px solid var(--btn-hi); border-radius: 14px;
  padding: 16px 16px; color: #fff; font-size: 16px; font-weight: 700; text-align: left;
  transition: transform .05s, background .15s;
}
.cat:active { transform: scale(.98); }
.cat:hover { background: var(--btn-hi); }
.cat-emoji { font-size: 22px; }
.cat-name { flex: 1; }
.cat-best { font-size: 11px; font-weight: 600; color: rgba(255,255,255,.7); }
.cat-custom { background: #2b2170; border-color: #7c5cff; }
.cat-del { position: absolute; top: 6px; right: 8px; font-size: 12px; color: rgba(255,255,255,.6); padding: 4px; }

.ai-form { display: flex; gap: 8px; }
.ai-form input {
  flex: 1; background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 12px 14px; font-size: 15px;
}
.btn-ai { background: var(--gold); color: #241a00; border: 0; border-radius: 12px; padding: 0 18px; font-weight: 800; }
.ai-hint { text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; }

/* ---------- QUIZ ---------- */
.view-quiz { height: 100%; display: flex; flex-direction: column; }
.quiz-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 14px 10px; flex-wrap: wrap; position: relative;
}
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-k { font-size: 10px; letter-spacing: .5px; color: var(--muted); font-weight: 700; }
.stat-v { font-size: 18px; font-weight: 800; }
.stat-v.score { color: var(--gold); }
.stat-v .ok { color: var(--ok); }
.stat-v .bad { color: var(--bad); }
.badge { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700; }
.life { min-width: 90px; }
.lifebar { width: 90px; height: 10px; background: #3a1220; border-radius: 999px; overflow: hidden; }
.lifebar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff5d6c, #ff2e63); transition: width .3s; }
.quit { position: absolute; top: 12px; right: 12px; font-size: 16px; color: var(--muted); }

.timer { height: 6px; background: var(--bg); margin: 0 14px; border-radius: 999px; overflow: hidden; }
.timer i { display: block; height: 100%; width: 100%; background: var(--ok); }

.quiz-body { flex: 1; overflow-y: auto; padding: 18px 16px 24px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.q-card {
  background: var(--panel); border: 1px solid var(--btn-hi); border-radius: 18px;
  padding: 22px 20px; font-size: 20px; font-weight: 800; text-align: center; line-height: 1.35;
  width: 100%;
}
.q-img {
  width: 130px; height: 130px; display: grid; place-items: center; font-size: 74px;
  background: #fff; border-radius: 14px;
}
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.ans {
  background: var(--btn); border: 1px solid var(--btn-hi); border-radius: 14px;
  color: #fff; font-size: 16px; font-weight: 700; padding: 18px 10px; min-height: 64px;
  transition: transform .05s, background .15s;
}
.ans:active { transform: scale(.97); }
.ans:hover:not(:disabled) { background: var(--btn-hi); }
.ans.correct { background: var(--ok); border-color: var(--ok); color: #05240f; }
.ans.wrong { background: var(--bad); border-color: var(--bad); color: #2a0409; }
.ans:disabled { cursor: default; }

/* ---------- RESULTS ---------- */
.view-results { height: 100%; display: grid; place-items: center; padding: 20px; }
.results-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px;
  padding: 28px 22px; text-align: center; width: 100%; max-width: 380px;
}
.verdict { font-size: 60px; }
.results-card h1 { margin: 6px 0 2px; font-size: 26px; }
.r-sub { color: var(--muted); margin: 0 0 16px; }
.r-score { font-size: 60px; font-weight: 900; color: var(--gold); line-height: 1; }
.r-scorelabel { color: var(--muted); font-size: 13px; margin-top: 6px; margin-bottom: 20px; }
.r-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 22px; }
.r-stat { background: var(--bg); border-radius: 12px; padding: 14px 6px; display: flex; flex-direction: column; gap: 4px; }
.r-stat b { font-size: 24px; }
.r-stat .ok { color: var(--ok); }
.r-stat .bad { color: var(--bad); }
.r-stat span { font-size: 11px; color: var(--muted); }

/* ---------- Shared buttons ---------- */
.btn-primary { background: var(--btn-hi); color: #fff; border: 0; border-radius: 999px; padding: 15px; font-weight: 800; font-size: 16px; width: 100%; margin-bottom: 10px; }
.btn-ghost { display: block; background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 13px; font-weight: 700; text-align: center; width: 100%; }
.btn-danger { background: #3a1216; color: #ff9aa6; border: 1px solid #5a1c22; border-radius: 999px; padding: 13px; font-weight: 800; width: 100%; }

/* ---------- Settings ---------- */
.sub-top { height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--line); }
.back { font-size: 30px; color: var(--text); }
.sub-title { font-weight: 800; font-size: 18px; }
.settings { height: calc(100% - 56px); overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.s-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.s-panel h3 { margin: 0; font-size: 16px; }
.hint { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 700; }
input, select { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 12px 13px; font-size: 15px; width: 100%; }
.key-row { display: flex; gap: 8px; }
.key-row #reveal { width: 46px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; color: var(--text); }
.status { font-size: 13px; padding: 9px 12px; border-radius: 10px; }
.status.ok { background: #10281c; color: #6ee7b7; }
.status.warn { background: #2a2410; color: #ffd27a; }
.test-result { font-size: 13px; min-height: 18px; color: var(--muted); }
.test-result.ok { color: #6ee7b7; }
.test-result.err { color: #ff9aa6; }
.test-result.warn { color: #ffd27a; }
.about p { color: var(--muted); font-size: 14px; margin: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #fff; color: #111; padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 60; box-shadow: 0 8px 30px rgba(0,0,0,.5);
  max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
