/* StudyQuest v2: design tokens evolved from the Figma variable system.
   Teal primary kept from v1; contrast fixed per audit (all text ≥ 4.5:1). */
:root {
  --scale: 1;
  --bg: #F2F6F4;
  --surface: #FFFFFF;
  --surface-2: #E8F0ED;
  --surface-3: #DCE8E4;
  --line: #D3E0DB;
  --ink: #13221F;
  --ink-2: #47605A;
  --ink-3: #5E726D;
  --primary: #1E7A71;
  --primary-press: #155E57;
  --primary-soft: #D7EEE9;
  --on-primary: #FFFFFF;
  --coin: #E8A21E;
  --gem: #7C55E6;
  --streak: #E2591F;
  --streak-soft: #FDE9DE;
  --streak-ink: #B23F0C;
  --success: #23804F;
  --danger: #C2382F;
  --danger-soft: #FBE3E1;
  --danger-ink: #A32A22; /* danger text on danger-soft: 5.9:1 */
  --primary-ink: #155E57; /* primary text on primary-soft: 6.2:1 */
  --r-common: #6E7781;
  --r-rare: #2F6FD0;
  --r-epic: #7C4DDB;
  --r-legendary: #B7790D;
  --r-legendary-ink: #8A5A06; /* legendary as text: 5.9:1 */
  --shadow-1: 0 1px 2px rgba(19,34,31,.06), 0 2px 8px rgba(19,34,31,.06);
  --shadow-2: 0 8px 28px rgba(19,34,31,.14);
  --radius: 18px;
  --font: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(.2,.8,.2,1);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0E1715;
  --surface: #16221F;
  --surface-2: #1D2B28;
  --surface-3: #253632;
  --line: #2A3B37;
  --ink: #E9F2EF;
  --ink-2: #A9BDB7;
  --ink-3: #8BA09A;
  --primary: #4CC2B4;
  --primary-press: #6FD3C7;
  --primary-soft: #183B37;
  --on-primary: #06201D;
  --coin: #F2B53A;
  --gem: #A58BFF;
  --streak: #FF8A4C;
  --streak-soft: #3A2318;
  --streak-ink: var(--streak);
  --success: #4CC283;
  --danger: #FF7A70;
  --danger-soft: #3A1E1C;
  --danger-ink: var(--danger);
  --primary-ink: var(--primary);
  --r-common: #A3ACB5;
  --r-rare: #6EA4FF;
  --r-epic: #B394FF;
  --r-legendary: #F0B640;
  --r-legendary-ink: var(--r-legendary);
  --shadow-1: 0 1px 2px rgba(0,0,0,.3);
  --shadow-2: 0 10px 30px rgba(0,0,0,.45);
  color-scheme: dark;
}
[data-contrast="high"] {
  --ink-2: var(--ink);
  --ink-3: var(--ink);
  --line: #5D706B;
  --primary: #0F5A53;
  --primary-press: #0A433E;
}
[data-theme="dark"][data-contrast="high"] {
  --line: #8FA6A0;
  --primary: #7FE3D7;
  --primary-press: #A6EFE6;
}
[data-font="hyper"] { --font: "Atkinson Hyperlegible", system-ui, sans-serif; }

* { box-sizing: border-box; }
html { font-size: calc(16px * var(--scale)); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: #E6ECEA; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Stage + device frame (desktop) ---------- */
.stage { min-height: 100dvh; display: flex; align-items: center; justify-content: center; gap: 72px; padding: 32px; }
.notes { width: 340px; color: #1d2a27; font-family: "Nunito", system-ui, sans-serif; }
.notes-kicker { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #1E7A71; margin: 0 0 10px; }
.notes h1 { font-size: 34px; line-height: 1.05; letter-spacing: -.02em; margin: 0 0 14px; font-weight: 900; }
.notes h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; margin: 26px 0 8px; color: #47605A; }
.notes p, .notes li { font-size: 15px; line-height: 1.55; color: #33433F; }
.notes ol, .notes ul { padding-left: 20px; margin: 0; }
.notes li { margin: 4px 0; }
.notes-foot { margin-top: 26px; font-weight: 700; }
.notes a, .linklike { color: #1E7A71; background: none; border: 0; padding: 0; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.device { width: 414px; height: 868px; border-radius: 62px; padding: 12px; background: #101514; box-shadow: 0 0 0 2px #2a302f inset, 0 40px 80px rgba(16,30,27,.28), 0 12px 24px rgba(16,30,27,.18); flex: none; }
.app { position: relative; width: 390px; height: 844px; border-radius: 50px; overflow: hidden; background: var(--bg); display: flex; flex-direction: column; isolation: isolate; font-family: var(--font); }

/* embedded (portfolio iframe) and real phones: app fills the viewport */
.embed body, .embed { background: transparent; }
.embed .stage { padding: 0; min-height: 0; display: block; }
.embed .notes { display: none; }
.embed .device { width: 100vw; height: 100dvh; padding: 0; border-radius: 0; background: none; box-shadow: none; }
.embed .app { width: 100%; height: 100%; border-radius: 0; }
@media (max-width: 860px) {
  .stage { padding: 0; display: block; }
  .notes { display: none; }
  .device { width: 100vw; height: 100dvh; padding: 0; border-radius: 0; background: none; box-shadow: none; }
  .app { width: 100%; height: 100%; border-radius: 0; }
}

/* ---------- Status bar ---------- */
.statusbar { height: 50px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 6px 30px 0 34px; font-weight: 800; font-size: 16px; color: var(--ink); position: relative; z-index: 5; font-family: "Nunito", system-ui, sans-serif; }
.statusbar .island { position: absolute; left: 50%; top: 11px; width: 120px; height: 34px; margin-left: -60px; background: #000; border-radius: 20px; }
.sb-icons { display: flex; gap: 6px; align-items: center; }
.sb-icons svg { fill: currentColor; }
.focus-mode .statusbar, .editing-mode .statusbar { color: var(--ink); }

/* ---------- Screen + tab bar ---------- */
.screen { flex: 1; overflow-y: auto; overflow-x: hidden; outline: none; scrollbar-width: none; overscroll-behavior: contain; }
.screen::-webkit-scrollbar { display: none; }
.tabbar { flex: none; height: 84px; display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px 10px 26px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(16px); border-top: 1px solid var(--line); position: relative; z-index: 4; }
.tabbar[hidden] { display: none; }
.tab { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: .72rem; font-weight: 800; color: var(--ink-2); border-radius: 14px; min-height: 48px; position: relative; }
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--primary); }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: -7px; width: 28px; height: 4px; border-radius: 0 0 4px 4px; background: var(--primary); }
.tab .dot { position: absolute; top: 6px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--streak); border: 2px solid var(--surface); }

/* ---------- Generic UI ---------- */
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pad { padding: 4px 18px 28px; }
.h-title { font-size: 1.75rem; font-weight: 900; letter-spacing: -.02em; margin: 6px 0 2px; }
.h-sub { color: var(--ink-2); font-weight: 600; margin: 0 0 16px; font-size: .95rem; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; margin: 24px 2px 10px; }
.sec-head h2 { font-size: 1.1rem; font-weight: 900; margin: 0; letter-spacing: -.01em; }
.sec-head span { color: var(--ink-2); font-size: .82rem; font-weight: 700; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1); border: 1px solid var(--line); }
[data-theme="dark"] .card { border-color: var(--line); }
.btn { min-height: 48px; border-radius: 14px; border: 0; padding: 0 18px; font-weight: 900; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .12s var(--ease-out), background .15s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 3px 0 var(--primary-press); }
.btn-primary:active { box-shadow: 0 1px 0 var(--primary-press); transform: translateY(2px); }
.btn-soft { background: var(--surface-2); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-danger { background: var(--danger-soft); color: var(--danger-ink); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-sm { min-height: 44px; padding: 0 14px; font-size: .9rem; border-radius: 12px; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--surface-2); display: inline-grid; place-items: center; color: var(--ink); flex: none; }
.icon-btn[disabled] { opacity: .35; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border-radius: 99px; background: var(--surface); font-weight: 900; font-size: .85rem; box-shadow: var(--shadow-1); border: 1px solid var(--line); white-space: nowrap; }
.chip svg { width: 16px; height: 16px; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width .6s var(--ease-out); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); padding: 4px; border-radius: 14px; gap: 4px; }
.seg button { border: 0; background: none; min-height: 40px; border-radius: 10px; font-weight: 800; color: var(--ink-2); font-size: .9rem; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* rarity badge: shape + label, never color alone */
.rar { display: inline-flex; align-items: center; gap: 4px; font-size: .7rem; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; }
.rar svg { width: 12px; height: 12px; fill: currentColor; stroke: none; }
.rar-common { color: var(--r-common); } .rar-rare { color: var(--r-rare); } .rar-epic { color: var(--r-epic); } .rar-legendary { color: var(--r-legendary-ink); }

/* ---------- Room screen ---------- */
.room-screen { height: 100%; display: flex; flex-direction: column; background:
  radial-gradient(120% 60% at 50% 38%, color-mix(in srgb, var(--primary) 9%, transparent), transparent 70%), var(--bg); }
.hud { display: flex; align-items: center; gap: 10px; padding: 2px 16px 0; }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: linear-gradient(140deg, #2A9C90, #1A6A63); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 1.15rem; position: relative; flex: none; border: 3px solid var(--surface); box-shadow: var(--shadow-1); }
.avatar .lv { position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); background: var(--streak-ink); color: #fff; font-size: .62rem; padding: 1px 6px; border-radius: 99px; border: 2px solid var(--surface); white-space: nowrap; }
[data-theme="dark"] .avatar .lv { color: #1A0E08; }
.hud-xp { flex: 1; min-width: 0; }
.hud-xp b { font-size: .85rem; font-weight: 900; display: flex; justify-content: space-between; }
.hud-xp b span { color: var(--ink-2); font-weight: 800; font-size: .75rem; }
.hud-xp .bar { margin-top: 5px; }
.hud-chips { display: flex; gap: 6px; padding: 12px 16px 0; }
.hud-chips .chip:last-child { margin-left: auto; }
.coin { color: var(--coin); } .gem { color: var(--gem); } .flame { color: var(--streak); }
.pop { animation: pop .5s var(--ease-spring); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }

.room-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
#room { width: 100%; height: 100%; max-height: 420px; display: block; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.editing #room { touch-action: none; }
#room [data-uid] { cursor: pointer; }
.editing #room [data-uid] { cursor: grab; }
.editing #room.dragging, .editing #room.dragging [data-uid] { cursor: grabbing; }
#room .sel-glow { filter: drop-shadow(0 0 0 var(--primary)) drop-shadow(0 4px 10px rgba(0,0,0,.18)); }
#room .is-ghost { opacity: .55; }
#room .hop { animation: hop .45s var(--ease-out); }
@keyframes hop { 0%,100% { transform: translateY(0); } 45% { transform: translateY(-7px); } }
.room-hint { position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); font-size: .78rem; font-weight: 800; color: var(--ink-2); background: color-mix(in srgb, var(--surface) 85%, transparent); padding: 6px 12px; border-radius: 99px; white-space: nowrap; box-shadow: var(--shadow-1); }
.edit-fab { position: absolute; right: 14px; top: 8px; }
.hearts { position: absolute; pointer-events: none; font-size: 20px; animation: float 1.1s var(--ease-out) forwards; }
@keyframes float { from { opacity: 1; transform: translate(-50%, 0) scale(.6); } to { opacity: 0; transform: translate(-50%, -48px) scale(1.15); } }

.home-panel { padding: 0 16px 14px; display: grid; gap: 10px; }
.quest-strip { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); text-align: left; width: 100%; background: var(--surface); }
.ring { width: 44px; height: 44px; flex: none; }
.ring circle { fill: none; stroke-width: 5; }
.ring .trk { stroke: var(--surface-3); } .ring .val { stroke: var(--primary); stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; transition: stroke-dashoffset .6s var(--ease-out); }
.quest-strip .t { font-weight: 900; font-size: .98rem; }
.quest-strip .s { color: var(--ink-2); font-weight: 700; font-size: .8rem; }
.quest-strip .icon { margin-left: auto; color: var(--ink-3); }
.focus-cta { min-height: 58px; font-size: 1.08rem; border-radius: 16px; }
.focus-cta small { font-weight: 800; opacity: .85; font-size: .8rem; }

/* edit mode */
.edit-top { display: flex; align-items: center; justify-content: space-between; padding: 0 12px; gap: 8px; }
.edit-top h1 { font-size: 1.05rem; font-weight: 900; margin: 0; }
.edit-top .grp { display: flex; gap: 6px; }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; min-height: 60px; }
.toolbar .name { flex: 1; min-width: 0; }
.toolbar .name b { display: block; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toolbar .name span { font-size: .78rem; color: var(--ink-2); font-weight: 700; }
.toolbar .tool { min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 900; display: inline-flex; gap: 6px; align-items: center; padding: 0 12px; font-size: .88rem; }
.toolbar .tool.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.toolbar .hint { color: var(--ink-2); font-weight: 700; font-size: .85rem; padding: 0 4px; }
.tray { background: var(--surface); border-radius: 26px 26px 0 0; box-shadow: 0 -6px 24px rgba(19,34,31,.1); padding: 10px 0 26px; flex: none; }
.tray .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--surface-3); margin: 0 auto 10px; }
.tray .seg { margin: 0 14px 12px; }
.tray-row { display: flex; gap: 10px; overflow-x: auto; padding: 4px 14px 6px; scroll-snap-type: x proximity; scrollbar-width: none; }
.tray-row::-webkit-scrollbar { display: none; }
.titem { flex: none; width: 96px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--surface); padding: 6px 6px 8px; text-align: center; position: relative; scroll-snap-align: start; touch-action: pan-x; user-select: none; -webkit-user-select: none; }
.titem .th { height: 64px; display: grid; place-items: center; }
.titem .th svg { width: 78px; height: 62px; pointer-events: none; }
.titem b { display: block; font-size: .76rem; font-weight: 900; line-height: 1.15; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titem .cnt { position: absolute; top: 6px; right: 6px; background: var(--primary); color: var(--on-primary); font-size: .68rem; font-weight: 900; border-radius: 99px; min-width: 22px; height: 20px; display: grid; place-items: center; padding: 0 5px; }
.titem.none { opacity: .55; }
.titem.locked .th { filter: grayscale(1); opacity: .45; }
.titem .lock { position: absolute; top: 6px; right: 6px; color: var(--ink-3); }
.titem .lock svg { width: 16px; height: 16px; }
.titem .sub { font-size: .66rem; font-weight: 800; color: var(--ink-2); }
.swatch { flex: none; width: 76px; border: 2px solid transparent; border-radius: 16px; background: var(--surface-2); padding: 6px; text-align: center; font-size: .72rem; font-weight: 900; position: relative; }
.swatch[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.swatch i { display: block; height: 48px; border-radius: 11px; margin-bottom: 4px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.swatch .lock { position: absolute; top: 10px; right: 10px; background: var(--surface); border-radius: 99px; padding: 2px 6px; font-size: .66rem; display: flex; gap: 3px; align-items: center; }
.swatch .lock svg { width: 12px; height: 12px; }
.tray-label { font-size: .72rem; font-weight: 900; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; padding: 4px 16px 2px; }
.drag-ghost { position: fixed; z-index: 999; pointer-events: none; width: 92px; height: 72px; margin: -36px 0 0 -46px; border-radius: 16px; background: color-mix(in srgb, var(--surface) 70%, transparent); box-shadow: var(--shadow-2); display: grid; place-items: center; transition: opacity .12s; }
.drag-ghost.over { opacity: 0; }
.drag-ghost svg { width: 80px; height: 64px; }

/* ---------- Study ---------- */
.focus-card { padding: 18px; background: linear-gradient(150deg, #1F7F75, #145750); color: #fff; border: 0; position: relative; overflow: hidden; }
[data-contrast="high"] .focus-card { background: #0C4741; }
.focus-card h3 { margin: 0; font-size: 1.25rem; font-weight: 900; }
.focus-card p { margin: 4px 0 14px; opacity: .92; font-weight: 700; font-size: .88rem; }
.focus-card .seg { background: rgba(255,255,255,.14); }
.focus-card .seg button { color: rgba(255,255,255,.9); }
.focus-card .seg button[aria-pressed="true"] { background: #fff; color: #145750; }
.focus-card .btn { margin-top: 12px; background: #fff; color: #145750; box-shadow: 0 3px 0 rgba(0,0,0,.2); }
.focus-card .deco { position: absolute; right: -18px; top: -14px; width: 120px; opacity: .22; }
.crate-prog { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: .8rem; font-weight: 800; }
.crate-prog .pips { display: flex; gap: 4px; }
.crate-prog .pips i { width: 22px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.25); }
.crate-prog .pips i.on { background: #FFD27A; }
.list { display: grid; gap: 0; }
.qrow { display: flex; gap: 12px; align-items: center; padding: 14px; border-bottom: 1px solid var(--line); }
.qrow:last-child { border-bottom: 0; }
.qicon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.qbody { flex: 1; min-width: 0; }
.qbody b { display: block; font-weight: 900; font-size: .95rem; }
.qbody .meta { display: flex; justify-content: space-between; font-size: .76rem; font-weight: 800; color: var(--ink-2); margin: 3px 0 6px; }
.reward-pill { display: inline-flex; align-items: center; gap: 4px; font-weight: 900; font-size: .78rem; padding: 4px 8px; border-radius: 10px; background: var(--surface-2); white-space: nowrap; }
.reward-pill svg { width: 14px; height: 14px; }
.claim { min-height: 44px; }
.done-check { color: var(--success); font-weight: 900; font-size: .8rem; display: inline-flex; align-items: center; gap: 4px; }
.deck { display: flex; gap: 12px; align-items: center; padding: 14px; }
.deck + .deck { border-top: 1px solid var(--line); }
.deck .swt { width: 10px; align-self: stretch; border-radius: 6px; flex: none; }
.deck .due { font-size: .76rem; font-weight: 900; color: var(--streak-ink); background: var(--streak-soft); padding: 3px 8px; border-radius: 8px; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; padding: 14px; }
.week .d { display: grid; gap: 6px; justify-items: center; font-size: .72rem; font-weight: 800; color: var(--ink-2); }
.week .d i { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-3); }
.week .d.on i { background: var(--streak); color: #fff; }
.week .d.fz i { background: #CDE7F7; color: #2C6E99; }
.week .d.today i { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--streak); }
.week .d i svg { width: 16px; height: 16px; }
.streak-foot { display: flex; align-items: center; gap: 10px; padding: 0 14px 14px; font-size: .84rem; font-weight: 700; color: var(--ink-2); }

/* ---------- Overlays: focus + review ---------- */
.overlay { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; background: var(--bg); animation: slideUp .35s var(--ease-out); }
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.ov-top { display: flex; align-items: center; justify-content: space-between; padding: 56px 16px 0; }
.ov-top b { font-weight: 900; }
.focus-ov { background: linear-gradient(180deg, #13302C 0%, #0D1F1C 100%); color: #EAF5F2; }
.focus-ov .icon-btn { background: rgba(255,255,255,.1); color: #fff; }
.focus-room { height: 230px; margin-top: 8px; }
.focus-room svg { width: 100%; height: 100%; }
.timer { position: relative; width: 236px; height: 236px; margin: 4px auto 0; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 10; }
.timer .trk { stroke: rgba(255,255,255,.1); }
.timer .val { stroke: #6FE0CF; stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.timer .read { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.timer .read b { font-size: 3.2rem; font-weight: 900; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.timer .read span { font-weight: 800; opacity: .75; font-size: .85rem; }
.focus-ctrl { display: flex; gap: 10px; justify-content: center; padding: 18px 20px 0; }
.focus-ctrl .btn-soft { background: rgba(255,255,255,.12); color: #fff; }
.ambient { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }
.ambient button { min-height: 40px; border-radius: 99px; border: 1px solid rgba(255,255,255,.2); background: transparent; color: #DDEFEA; padding: 0 14px; font-weight: 800; font-size: .82rem; display: inline-flex; gap: 6px; align-items: center; }
.ambient button[aria-pressed="true"] { background: #DDEFEA; color: #13302C; }
.demo-skip { margin: 14px auto 0; display: block; background: none; border: 1px dashed rgba(255,255,255,.35); color: rgba(255,255,255,.8); border-radius: 10px; padding: 8px 12px; font-weight: 800; font-size: .78rem; min-height: 40px; }

.review { padding: 0 18px; flex: 1; display: flex; flex-direction: column; }
.review .bar { margin: 14px 0 18px; }
.flash { flex: 1; max-height: 380px; perspective: 1200px; border: 0; background: none; padding: 0; width: 100%; text-align: left; }
.flash .inner { position: relative; width: 100%; height: 100%; transition: transform .5s var(--ease-out); transform-style: preserve-3d; }
.flash.flipped .inner { transform: rotateY(180deg); }
.flash .face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 24px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-2); padding: 24px; display: flex; flex-direction: column; }
.flash .back { transform: rotateY(180deg); background: var(--primary-soft); }
.flash .lbl { font-size: .72rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); }
.flash .txt { margin: auto 0; font-size: 1.45rem; font-weight: 800; line-height: 1.3; }
.flash .tap { color: var(--ink-2); font-weight: 700; font-size: .85rem; text-align: center; }
[data-motion="reduce"] .flash .inner { transition: none; }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 18px 0 30px; }
.rate button { border: 0; border-radius: 14px; min-height: 62px; font-weight: 900; display: grid; place-content: center; gap: 2px; font-size: .92rem; }
.rate button small { font-weight: 800; font-size: .7rem; opacity: .8; }
.rate .r1 { background: var(--danger-soft); color: var(--danger-ink); }
.rate .r2 { background: var(--streak-soft); color: var(--streak-ink); }
.rate .r3 { background: var(--primary-soft); color: var(--primary); }
.rate .r4 { background: color-mix(in srgb, var(--r-rare) 16%, var(--surface)); color: var(--r-rare); }
.reveal-row { padding: 18px 0 30px; }

/* ---------- Sheets ---------- */
.sheet-wrap { position: absolute; inset: 0; z-index: 40; display: flex; align-items: flex-end; }
.backdrop { position: absolute; inset: 0; background: rgba(8,18,16,.45); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: relative; width: 100%; background: var(--surface); border-radius: 28px 28px 0 0; padding: 10px 20px 34px; max-height: 88%; overflow-y: auto; animation: sheetUp .32s var(--ease-out); box-shadow: var(--shadow-2); }
@keyframes sheetUp { from { transform: translateY(100%); } }
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--surface-3); margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 4px; font-size: 1.35rem; font-weight: 900; letter-spacing: -.01em; }
.sheet p { color: var(--ink-2); font-weight: 600; margin: 0 0 16px; line-height: 1.45; }
.sheet .actions { display: grid; gap: 10px; margin-top: 18px; }
.center { text-align: center; }
.reward-list { display: grid; gap: 8px; margin: 14px 0 4px; }
.reward-list div { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface-2); border-radius: 14px; font-weight: 800; }
.reward-list div b { margin-left: auto; font-weight: 900; font-size: 1.05rem; }
.reward-list svg { width: 22px; height: 22px; }
.burst { width: 128px; height: 128px; margin: 6px auto 8px; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--coin) 35%, transparent), transparent 70%); }
.burst svg { width: 112px; height: 100px; }
.reveal-card { margin: 4px auto 0; width: 220px; border-radius: 24px; padding: 18px; text-align: center; background: var(--surface-2); border: 2px solid var(--line); animation: reveal .6s var(--ease-spring); }
.reveal-card.rare { border-color: var(--r-rare); } .reveal-card.epic { border-color: var(--r-epic); box-shadow: 0 0 40px color-mix(in srgb, var(--r-epic) 35%, transparent); } .reveal-card.legendary { border-color: var(--r-legendary); box-shadow: 0 0 50px color-mix(in srgb, var(--r-legendary) 40%, transparent); }
.reveal-card svg { width: 150px; height: 120px; }
@keyframes reveal { from { transform: scale(.6) rotate(-4deg); opacity: 0; } }
.shake { animation: shake .7s ease-in-out 2; }
@keyframes shake { 0%,100% { transform: rotate(0); } 20% { transform: rotate(-6deg); } 40% { transform: rotate(5deg); } 60% { transform: rotate(-3deg); } 80% { transform: rotate(2deg); } }

/* ---------- Rewards ---------- */
.banner { padding: 16px; display: flex; gap: 14px; align-items: center; background: linear-gradient(135deg, #22264A, #3A2E6E); color: #fff; border: 0; position: relative; overflow: hidden; }
.banner .ev { font-size: .7rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: #FFD27A; }
.banner h3 { margin: 2px 0 4px; font-size: 1.15rem; font-weight: 900; }
.banner p { margin: 0; font-size: .8rem; font-weight: 700; opacity: .85; }
.banner svg.art { width: 104px; height: 88px; flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.icard { padding: 10px; text-align: left; display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--line); background: var(--surface); border-radius: 18px; min-height: 0; position: relative; }
.icard .th { height: 92px; display: grid; place-items: center; background: var(--surface-2); border-radius: 12px; margin-bottom: 4px; }
.icard .th svg { width: 112px; height: 84px; }
.icard b { font-weight: 900; font-size: .92rem; }
.icard .row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 4px; }
.icard .own { position: absolute; top: 14px; left: 14px; font-size: .68rem; font-weight: 900; background: var(--surface); padding: 2px 7px; border-radius: 8px; }
.price { display: inline-flex; align-items: center; gap: 4px; font-weight: 900; min-height: 36px; padding: 0 10px; border-radius: 10px; background: var(--primary-soft); color: var(--primary-ink); border: 0; font-size: .86rem; }
.price svg { width: 15px; height: 15px; }
.price[disabled] { background: var(--surface-2); color: var(--ink-3); }
.lockline { font-size: .74rem; font-weight: 800; color: var(--ink-2); display: inline-flex; gap: 4px; align-items: center; }
.lockline svg { width: 13px; height: 13px; }
.crate-hero { padding: 18px; text-align: center; }
.crate-hero > svg { width: 190px; height: 160px; }
.crate-hero h3 { margin: 4px 0 2px; font-size: 1.3rem; font-weight: 900; }
.crate-hero p { margin: 0 0 14px; color: var(--ink-2); font-weight: 700; font-size: .9rem; }
.odds { padding: 6px 14px; }
.odds div { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-weight: 800; font-size: .9rem; }
.odds div:last-child { border: 0; }
.pity { margin: 0 0 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: center; font-size: .84rem; font-weight: 700; color: var(--ink-2); }
.pity b { color: var(--ink); }
.note { font-size: .78rem; color: var(--ink-2); font-weight: 700; padding: 10px 4px 0; line-height: 1.45; }
.setrow { padding: 14px; }
.setrow + .setrow { border-top: 1px solid var(--line); }
.setrow .top { display: flex; justify-content: space-between; font-weight: 900; margin-bottom: 8px; }
.setrow .top span { color: var(--ink-2); font-size: .82rem; }
.mini-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; }
.mini-grid div { aspect-ratio: 1; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; }
.mini-grid svg { width: 90%; height: 90%; }

/* ---------- Profile & settings ---------- */
.prof-head { padding: 18px; display: flex; gap: 14px; align-items: center; }
.prof-head .avatar { width: 64px; height: 64px; font-size: 1.5rem; }
.prof-head h2 { margin: 0; font-size: 1.3rem; font-weight: 900; }
.prof-head p { margin: 2px 0 0; color: var(--ink-2); font-weight: 700; font-size: .85rem; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { padding: 14px; }
.stat b { display: block; font-size: 1.35rem; font-weight: 900; letter-spacing: -.01em; }
.stat span { font-size: .78rem; font-weight: 800; color: var(--ink-2); }
.chart { padding: 16px 14px 12px; }
.chart .bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 110px; }
.chart .bars div { display: grid; gap: 6px; justify-items: center; font-size: .7rem; font-weight: 800; color: var(--ink-2); height: 100%; align-content: end; }
.chart .bars i { width: 100%; max-width: 26px; border-radius: 7px 7px 3px 3px; background: var(--primary); opacity: .85; }
.chart .bars div.today i { opacity: 1; background: var(--streak); }
.badges { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.badge { flex: none; width: 92px; padding: 12px 6px; text-align: center; font-size: .74rem; font-weight: 900; }
.badge .em { width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 6px; display: grid; place-items: center; }
.badge .em svg { width: 26px; height: 26px; }
.badge small { display: block; color: var(--ink-2); font-weight: 800; }
.badge.locked .em { background: var(--surface-2) !important; color: var(--ink-3) !important; }
.league .lrow { display: flex; gap: 12px; align-items: center; padding: 10px 14px; font-weight: 800; }
.league .lrow + .lrow { border-top: 1px solid var(--line); }
.league .rank { width: 22px; text-align: center; font-weight: 900; color: var(--ink-2); }
.league .av { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 900; font-size: .8rem; }
.league .lrow.me { background: var(--primary-soft); }
.league .xp { margin-left: auto; color: var(--ink-2); font-size: .85rem; }
.league .zone { font-size: .72rem; font-weight: 900; color: var(--success); padding: 8px 14px; background: color-mix(in srgb, var(--success) 10%, transparent); display: flex; gap: 6px; align-items: center; }
.set-group { margin-bottom: 8px; }
.set-group h3 { font-size: .74rem; font-weight: 900; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); margin: 22px 4px 8px; }
.srow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 60px; }
.srow + .srow { border-top: 1px solid var(--line); }
.srow .qicon { width: 36px; height: 36px; border-radius: 11px; }
.srow .qicon svg { width: 18px; height: 18px; }
.srow .lab { flex: 1; min-width: 0; }
.srow .lab b { display: block; font-weight: 900; font-size: .95rem; }
.srow .lab span { font-size: .78rem; color: var(--ink-2); font-weight: 700; }
.switch { appearance: none; -webkit-appearance: none; width: 52px; height: 32px; border-radius: 99px; background: var(--surface-3); position: relative; flex: none; cursor: pointer; transition: background .2s; border: 1px solid var(--line); margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--ease-out); }
.switch:checked { background: var(--primary); border-color: transparent; }
.switch:checked::after { transform: translateX(20px); }
.range { width: 100%; accent-color: var(--primary); height: 32px; }
.preview-text { padding: 12px 14px; border-top: 1px solid var(--line); font-weight: 700; color: var(--ink-2); font-size: .95rem; }
.back-btn { display: inline-flex; align-items: center; gap: 2px; border: 0; background: none; color: var(--primary); font-weight: 900; min-height: 44px; padding: 0 6px 0 0; }

/* ---------- Toasts ---------- */
.toasts { position: absolute; top: 54px; left: 0; right: 0; display: grid; justify-items: center; gap: 8px; z-index: 60; pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: center; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 16px; font-weight: 800; font-size: .88rem; box-shadow: var(--shadow-2); max-width: 340px; animation: toastIn .35s var(--ease-spring); }
.toast svg { width: 18px; height: 18px; }
.toast.out { animation: toastOut .25s ease-in forwards; }
@keyframes toastIn { from { transform: translateY(-16px) scale(.96); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-10px); opacity: 0; } }

[data-motion="reduce"] *, [data-motion="reduce"] *::before, [data-motion="reduce"] *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
