/* SuperK — dark RPG theme, mobile-first */
:root {
  --bg: #0d0f1a;
  --bg2: #11142a;
  --card: #161a2e;
  --card2: #1c2140;
  --line: #262c52;
  --text: #eef0ff;
  --muted: #9aa0c7;
  --accent: #7c5cff;
  --accent2: #22d3ee;
  --gold: #f5c542;
  --green: #34d399;
  --red: #f87171;
  --grad: linear-gradient(135deg, #7c5cff, #22d3ee);
  --radius: 16px;
  --tabbar-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #1a1f45 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}
.app-shell { max-width: 480px; margin: 0 auto; min-height: 100dvh; padding: 0 16px calc(var(--tabbar-h) + 24px); }
.app-shell.no-tabs { padding-bottom: 32px; }

/* Boot */
.boot-screen { min-height: 80dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.boot-logo { font-size: 56px; animation: pulse 1.6s ease-in-out infinite; }
.boot-title { font-size: 32px; font-weight: 800; letter-spacing: 2px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.boot-sub { color: var(--muted); font-size: 14px; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: .85; } 50% { transform: scale(1.12); opacity: 1; } }

/* Headings */
.screen { animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.screen-title { font-size: 26px; font-weight: 800; margin: 18px 0 4px; }
.screen-sub { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.section-label { font-size: 12px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card.tappable { cursor: pointer; transition: transform .12s ease, border-color .12s ease; }
.card.tappable:active { transform: scale(.985); border-color: var(--accent); }

/* Hero */
.hero { display: flex; gap: 14px; align-items: center; background: linear-gradient(160deg, #1b2050, var(--card)); border: 1px solid var(--line); border-radius: 20px; padding: 16px; margin: 14px 0; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; inset: 0; background: radial-gradient(300px 160px at 85% 0%, rgba(124,92,255,.25), transparent 70%); pointer-events: none; }
.avatar-frame { width: 96px; height: 96px; border-radius: 50%; padding: 3px; background: var(--grad); flex-shrink: 0; }
.avatar-frame img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; background: #0a0c18; }
.hero-info { flex: 1; min-width: 0; }
.hero-name { font-weight: 800; font-size: 18px; }
.hero-title { color: var(--gold); font-size: 13px; font-weight: 700; letter-spacing: .5px; }
.level-badge { display: inline-block; background: var(--grad); font-weight: 800; font-size: 13px; padding: 3px 10px; border-radius: 999px; margin-top: 6px; }
.xpbar { height: 10px; background: #0a0c18; border-radius: 999px; margin-top: 10px; overflow: hidden; border: 1px solid var(--line); }
.xpbar > div { height: 100%; background: linear-gradient(90deg, var(--gold), #ff9d3c); border-radius: 999px; transition: width .6s ease; }
.xpbar-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Stat chips */
.chips { display: flex; gap: 8px; margin: 12px 0; }
.chip { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px; text-align: center; }
.chip .v { font-weight: 800; font-size: 18px; }
.chip .l { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Quest rows */
.quest-row { display: flex; align-items: center; gap: 12px; }
.quest-icon { width: 46px; height: 46px; border-radius: 14px; background: var(--card2); display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.quest-main { flex: 1; min-width: 0; }
.quest-name { font-weight: 700; }
.quest-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.quest-xp { font-weight: 800; color: var(--gold); font-size: 15px; white-space: nowrap; }
.quest-xp small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; text-align: right; }
.done-pill { font-size: 11px; font-weight: 700; background: rgba(52,211,153,.15); color: var(--green); border: 1px solid rgba(52,211,153,.4); padding: 2px 8px; border-radius: 999px; }
.locked { opacity: .55; }
.locked .quest-icon { filter: grayscale(1); }
.lock-tag { font-size: 11px; font-weight: 700; color: var(--muted); background: #0a0c18; border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.diff { color: var(--gold); letter-spacing: 1px; font-size: 12px; }

/* Buttons */
.btn { display: block; width: 100%; border: none; border-radius: 14px; padding: 15px; font-size: 16px; font-weight: 800; cursor: pointer; color: #0b0d1c; background: var(--grad); margin: 12px 0; }
.btn:active { transform: scale(.98); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid rgba(248,113,113,.4); }
.btn.small { padding: 9px 12px; font-size: 14px; border-radius: 10px; width: auto; display: inline-block; margin: 4px 6px 4px 0; }
.btn:disabled { opacity: .5; }

/* Forms */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.input { width: 100%; background: #0a0c18; border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; color: var(--text); font-size: 16px; }
.input:focus { outline: none; border-color: var(--accent); }
.form-error { color: var(--red); font-size: 13.5px; min-height: 20px; margin: 6px 0; }
.auth-wrap { max-width: 380px; margin: 0 auto; padding-top: 8dvh; }
.auth-logo { text-align: center; font-size: 64px; }
.auth-title { text-align: center; font-size: 30px; font-weight: 800; letter-spacing: 2px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-sub { text-align: center; color: var(--muted); margin: 4px 0 24px; font-size: 14px; }
.auth-switch { text-align: center; color: var(--muted); font-size: 14px; margin-top: 8px; }
.auth-switch a { color: var(--accent2); font-weight: 700; text-decoration: none; }

/* Tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: rgba(13,15,26,.92); backdrop-filter: blur(12px); border-top: 1px solid var(--line); display: flex; z-index: 50; }
.tabbar.hidden { display: none; }
.tab { flex: 1; background: none; border: none; color: var(--muted); font-size: 10.5px; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; }
.tab .ti { font-size: 21px; }
.tab.active { color: var(--text); }
.tab.active .ti { filter: drop-shadow(0 0 6px rgba(124,92,255,.8)); }

/* Exercise list */
.exercise { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.ex-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ex-name { font-weight: 700; }
.ex-sets { color: var(--gold); font-weight: 700; font-size: 14px; white-space: nowrap; }
.ex-cue { color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.timer-box { margin-top: 10px; background: #0a0c18; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.timer-face { font-variant-numeric: tabular-nums; font-size: 26px; font-weight: 800; letter-spacing: 1px; flex: 1; }
.timer-face .target { font-size: 13px; color: var(--muted); font-weight: 400; }
.timer-btns { display: flex; gap: 6px; }
.tbtn { background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13px; font-weight: 700; cursor: pointer; }
.tbtn.primary { background: var(--grad); border: none; color: #0b0d1c; }

/* Evolution grid */
.evo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.evo-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-align: center; position: relative; }
.evo-card img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 10px; background: #0a0c18; }
.evo-card.locked img { filter: grayscale(1) brightness(.55); }
.evo-card.current { border-color: var(--gold); box-shadow: 0 0 18px rgba(245,197,66,.25); }
.evo-name { font-weight: 800; margin-top: 8px; }
.evo-tag { font-size: 12px; color: var(--muted); min-height: 32px; }
.evo-lvl { font-size: 11px; font-weight: 700; color: var(--accent2); margin-top: 4px; }
.evo-badge { position: absolute; top: 8px; left: 8px; font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: var(--grad); color: #0b0d1c; }
.evo-badge.locked-b { background: #0a0c18; color: var(--muted); border: 1px solid var(--line); }

/* Leaderboard */
.lb-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.lb-tab { flex: 1; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-weight: 700; font-size: 14px; cursor: pointer; }
.lb-tab.active { background: var(--grad); color: #0b0d1c; border: none; }
.lb-row { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.lb-row.me { border-color: var(--accent); background: #1a1f45; }
.lb-rank { font-weight: 800; width: 30px; text-align: center; color: var(--muted); }
.lb-row:nth-child(1) .lb-rank { color: var(--gold); }
.lb-ava { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #0a0c18; }
.lb-name { flex: 1; font-weight: 700; font-size: 14.5px; }
.lb-name small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.lb-xp { font-weight: 800; color: var(--gold); font-size: 14.5px; }

/* Modal */
.modal-veil { position: fixed; inset: 0; background: rgba(5,6,14,.78); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; animation: fadein .2s ease; }
.modal { background: var(--bg2); border: 1px solid var(--line); border-radius: 20px; padding: 22px; width: 100%; max-width: 420px; max-height: 88dvh; overflow-y: auto; }
.modal h3 { margin: 0 0 8px; font-size: 20px; }
.modal .big-xp { font-size: 44px; font-weight: 800; color: var(--gold); text-align: center; margin: 8px 0; }
.levelup-banner { text-align: center; background: var(--grad); border-radius: 14px; padding: 14px; margin: 12px 0; color: #0b0d1c; }
.levelup-banner .lv { font-size: 30px; font-weight: 900; }
.evo-banner { text-align: center; border: 1px solid var(--gold); border-radius: 14px; padding: 12px; margin: 12px 0; background: rgba(245,197,66,.08); }
.evo-banner img { width: 110px; height: 146px; object-fit: cover; border-radius: 12px; }
.modal-row { display: flex; gap: 8px; margin-top: 12px; }
.modal-row .btn { margin: 0; }

/* Recorder */
.rec-preview { width: 100%; border-radius: 12px; background: #000; max-height: 46dvh; }
.rec-status { text-align: center; font-size: 13px; color: var(--muted); margin: 8px 0; min-height: 20px; }
.rec-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--red); margin-right: 6px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* Toasts */
.toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + 16px); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 200; pointer-events: none; padding: 0 16px; }
.toast { background: #232848; border: 1px solid var(--line); color: var(--text); padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; max-width: 440px; animation: fadein .2s ease; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.toast.error { border-color: rgba(248,113,113,.5); }

.hidden { display: none !important; }
.mt { margin-top: 14px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Evolution trials + video proof */
.video-pill { font-size: 11px; font-weight: 700; background: rgba(96,165,250,.15); color: #60a5fa; border: 1px solid rgba(96,165,250,.4); padding: 2px 8px; border-radius: 999px; }
.trial-banner { text-align: center; border: 1px solid var(--gold); border-radius: 14px; padding: 12px; margin: 12px 0; background: rgba(245,197,66,.08); font-size: 15px; }

/* Game Master (v4) */
.review-pill { font-size: 11px; font-weight: 700; background: rgba(245,197,66,.12); color: var(--gold); border: 1px solid rgba(245,197,66,.4); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.coach-note { border-color: rgba(96,165,250,.45); background: rgba(96,165,250,.07); }
.user-pick { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; margin-top: 8px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; font-size: 15px; cursor: pointer; }
.check-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
select.input { appearance: none; }
