:root {
  --bg: #0a0f1f;
  --bg2: #121a33;
  --card: #18223f;
  --card2: #1f2b50;
  --line: #2c3a66;
  --text: #f2f5ff;
  --dim: #a8b3d6;
  --green: #3ee07a;
  --orange: #ff9d3c;
  --yellow: #ffcf3e;
  --red: #ff5d73;
  --teal: #3ed3e0;
  --violet: #8f7bff;
  --gold: #ffd54a;
  --r: 18px;
  font-size: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; touch-action: manipulation; } /* no double-tap zoom when tapping fast */
button, .scard, .sortcard { touch-action: manipulation; }
body {
  background: radial-gradient(1200px 700px at 20% -10%, #1d2b5c 0%, transparent 60%),
              radial-gradient(900px 600px at 110% 110%, #13324a 0%, transparent 60%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  line-height: 1.4;
  overflow-x: hidden;
  user-select: none; -webkit-user-select: none;
}
#app { max-width: 720px; margin: 0 auto; padding: 14px 16px calc(28px + env(safe-area-inset-bottom)); min-height: 100%; }
#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
b { color: #fff; }
sub { font-size: .7em; }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.top .back { background: var(--card); border-radius: 14px; width: 46px; height: 46px; font-size: 22px; flex: none; }
.top h2 { margin: 0; font-size: 1.25rem; flex: 1; letter-spacing: .3px; }
.pill { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 800; white-space: nowrap; }
.pill.coin { color: var(--gold); }

/* ---------- home ---------- */
.hero { background: linear-gradient(135deg, #1a2a5e, #142044 60%, #0f2a3a); border: 1px solid var(--line); border-radius: 24px; padding: 16px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: radial-gradient(circle, rgba(62,224,122,.25), transparent 70%); }
.logo { font-size: 2rem; font-weight: 900; letter-spacing: 1px; margin: 0; line-height: 1;
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--orange)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { color: var(--dim); font-size: .9rem; margin-top: 4px; }
.rankrow { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.lvl { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 1.35rem; flex: none;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), #26345f 0); position: relative; }
.lvl span { position: absolute; inset: 5px; border-radius: 50%; background: #142044; display: grid; place-items: center; }
.rankname { font-weight: 900; font-size: 1.1rem; }
.xpbar { height: 12px; background: #26345f; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.xpbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--yellow)); border-radius: 99px; transition: width .6s cubic-bezier(.2,1.4,.4,1); }
.stats { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.mastery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.mring { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 6px; text-align: center; }
.mring .ring { width: 64px; height: 64px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center; font-size: 1.5rem;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), #26345f 0); position: relative; }
.mring .ring span { position: absolute; inset: 6px; border-radius: 50%; background: var(--card); display: grid; place-items: center; }
.mring small { display: block; color: var(--dim); font-size: .75rem; line-height: 1.2; }
.mring strong { font-size: .95rem; }

.big { width: 100%; border-radius: 22px; padding: 18px; font-size: 1.4rem; font-weight: 900; letter-spacing: .5px; color: #08122a;
  background: linear-gradient(90deg, var(--green), var(--yellow)); box-shadow: 0 6px 0 #1f7a45, 0 12px 30px rgba(62,224,122,.25); margin: 4px 0 16px;
  animation: breathe 2.4s ease-in-out infinite; }
.big small { display: block; font-size: .85rem; font-weight: 700; opacity: .8; }
.big:active { transform: translateY(4px); box-shadow: 0 2px 0 #1f7a45; }
@keyframes breathe { 50% { filter: brightness(1.12); } }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 12px; text-align: left; position: relative; min-height: 96px;
  transition: transform .12s; }
.tile:active { transform: scale(.96); }
.tile .ic { font-size: 1.9rem; line-height: 1; }
.tile .tt { font-weight: 900; margin-top: 6px; font-size: 1.02rem; }
.tile .td { color: var(--dim); font-size: .8rem; line-height: 1.25; margin-top: 2px; }
.tile.wide { grid-column: span 2; }
.tile.boss { background: linear-gradient(135deg, #3b1630, #2a1650); border-color: #6a3a8a; }
.tile .badge { position: absolute; top: 8px; right: 8px; background: var(--red); color: #fff; font-weight: 900; font-size: .75rem; border-radius: 99px; padding: 2px 8px; animation: pulse 1.2s infinite; }
.tile .best { position: absolute; top: 10px; right: 10px; color: var(--gold); font-size: .75rem; font-weight: 800; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.foot { color: var(--dim); font-size: .78rem; text-align: center; margin-top: 18px; }

/* ---------- quiz ---------- */
.hud { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.hud .score { font-weight: 900; font-size: 1.3rem; flex: 1; }
.timer { height: 10px; background: #26345f; border-radius: 99px; overflow: hidden; margin-bottom: 12px; }
.timer i { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--yellow), var(--green)); background-size: 300% 100%; transition: width .25s linear; }
.combo { font-weight: 900; font-size: 1.05rem; padding: 6px 12px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); transition: all .2s; }
.combo.hot { background: linear-gradient(90deg, #ff5d1a, #ffcf3e); color: #2a0a00; border-color: transparent; animation: wobble .5s ease-in-out infinite; }
.combo.blaze { background: linear-gradient(90deg, #ff2bd6, #8f7bff, #3ed3e0); color: #fff; animation: wobble .35s ease-in-out infinite; box-shadow: 0 0 22px rgba(255,43,214,.6); }
@keyframes wobble { 25% { transform: rotate(-3deg) scale(1.05); } 75% { transform: rotate(3deg) scale(1.05); } }
.qcard { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 18px; margin-bottom: 14px; animation: slidein .28s cubic-bezier(.2,1.3,.4,1); }
@keyframes slidein { from { transform: translateX(40px) scale(.97); opacity: 0; } }
.qmeta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tag { font-size: .72rem; font-weight: 800; padding: 3px 9px; border-radius: 99px; background: #26345f; color: var(--dim); }
.qtext { font-size: 1.15rem; font-weight: 700; line-height: 1.4; }
.dt { border-collapse: collapse; margin: 6px 0 10px; font-size: .95rem; }
.dt th, .dt td { border: 1px solid var(--line); padding: 5px 10px; text-align: center; }
.dt th { background: #26345f; }
.opts { display: grid; gap: 10px; }
.opt { background: var(--card2); border: 2px solid var(--line); border-radius: 16px; padding: 14px 16px; text-align: left; font-size: 1.02rem; font-weight: 700; transition: transform .1s, background .2s, border-color .2s; }
.opt:active { transform: scale(.98); }
.opt.right { background: #164d33; border-color: var(--green); animation: pop .35s; }
.opt.wrong { background: #571c2b; border-color: var(--red); animation: shake .4s; }
.opt.dim { opacity: .45; }
@keyframes pop { 40% { transform: scale(1.05); } }
@keyframes shake { 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }
.explain { margin-top: 12px; background: #1b2e2a; border: 1px solid #2f6b55; border-radius: 16px; padding: 12px 14px; font-size: .98rem; animation: slidein .25s; }
.explain.bad { background: #2e1b24; border-color: #7a3349; }
.explain .lbl { font-weight: 900; margin-bottom: 4px; }
.next { margin-top: 12px; width: 100%; padding: 15px; border-radius: 16px; font-weight: 900; font-size: 1.1rem; background: linear-gradient(90deg, var(--teal), var(--violet)); color: #fff; }
.banner { position: fixed; left: 50%; top: 32%; transform: translate(-50%, -50%); z-index: 60; pointer-events: none; font-weight: 900; font-size: 2.6rem; text-align: center;
  text-shadow: 0 4px 0 rgba(0,0,0,.35), 0 0 30px rgba(255,200,60,.8); animation: bannerin 1.3s ease-out forwards; white-space: nowrap; }
@keyframes bannerin { 0% { transform: translate(-50%,-50%) scale(.3) rotate(-8deg); opacity: 0; } 20% { transform: translate(-50%,-50%) scale(1.15) rotate(3deg); opacity: 1; }
  70% { transform: translate(-50%,-50%) scale(1); opacity: 1; } 100% { transform: translate(-50%,-80%) scale(1); opacity: 0; } }
.floater { position: fixed; z-index: 61; pointer-events: none; font-weight: 900; font-size: 1.4rem; animation: floatup 1s ease-out forwards; text-shadow: 0 2px 0 rgba(0,0,0,.4); }
@keyframes floatup { to { transform: translateY(-70px) scale(1.2); opacity: 0; } }
.shake { animation: shake .4s; }

/* boss */
.boss { display: flex; align-items: center; gap: 12px; background: linear-gradient(135deg, #3b1630, #2a1650); border: 1px solid #6a3a8a; border-radius: 18px; padding: 10px 14px; margin-bottom: 12px; }
.boss .face { font-size: 2.6rem; transition: transform .2s; }
.boss .face.hit { animation: hit .45s; }
@keyframes hit { 20% { transform: scale(.75) rotate(-15deg); filter: brightness(3); } 60% { transform: scale(1.1) rotate(8deg); } }
.boss .hp { flex: 1; }
.boss .hpbar { height: 14px; background: #1a0d24; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.boss .hpbar i { display: block; height: 100%; background: linear-gradient(90deg, #ff2b5e, #ff9d3c); transition: width .4s; }

/* ---------- results ---------- */
.result { text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 22px 16px; animation: slidein .3s; }
.result .huge { font-size: 3.4rem; font-weight: 900; line-height: 1; background: linear-gradient(90deg, var(--green), var(--yellow)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result .grade { font-size: 1.3rem; font-weight: 900; margin: 6px 0 2px; }
.rewards { display: flex; justify-content: center; gap: 10px; margin: 14px 0; flex-wrap: wrap; }
.rewards .pill { font-size: 1.05rem; }
.newbest { display: inline-block; background: linear-gradient(90deg, #ff2bd6, var(--gold)); color: #2a0a00; font-weight: 900; padding: 6px 14px; border-radius: 99px; animation: pulse 1s infinite; margin-bottom: 8px; }
.review { text-align: left; margin-top: 14px; }
.review h3 { margin: 10px 0; }
.rv { background: var(--card2); border-radius: 14px; padding: 12px; margin-bottom: 10px; border-left: 5px solid var(--red); }
.rv .q { font-weight: 700; }
.rv .a { color: var(--green); font-weight: 800; margin-top: 6px; }
.rv .y { color: #ff9aa8; font-size: .9rem; margin-top: 2px; }
.rv .x { color: var(--dim); font-size: .92rem; margin-top: 4px; }
.breakdown { display: grid; gap: 8px; margin-top: 12px; text-align: left; }
.brow { display: flex; align-items: center; gap: 10px; }
.brow .bl { width: 120px; font-size: .85rem; font-weight: 800; }
.brow .bb { flex: 1; height: 12px; background: #26345f; border-radius: 99px; overflow: hidden; }
.brow .bb i { display: block; height: 100%; }
.brow .bp { width: 46px; text-align: right; font-weight: 800; font-size: .9rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.btn { padding: 14px; border-radius: 16px; font-weight: 900; font-size: 1.02rem; background: var(--card2); border: 1px solid var(--line); }
.btn.go { background: linear-gradient(90deg, var(--green), var(--yellow)); color: #08122a; border: 0; }

/* ---------- learn ---------- */
.lesson { background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 18px; min-height: 320px; animation: slidein .28s; }
.lesson h3 { margin: 0 0 10px; font-size: 1.35rem; }
.lesson ul { padding-left: 1.1em; margin: 0; }
.lesson li { margin: 8px 0; font-size: 1.04rem; }
.lesson li::marker { color: var(--green); }
.eq { display: inline-block; background: #0f1830; border: 1px dashed var(--line); border-radius: 12px; padding: 8px 10px; font-weight: 800; color: var(--yellow); font-size: 1rem; }
.dots { display: flex; justify-content: center; gap: 6px; margin: 12px 0; }
.dots i { width: 8px; height: 8px; border-radius: 99px; background: #33416e; transition: all .2s; }
.dots i.on { width: 22px; background: var(--green); }
.art { display: flex; justify-content: center; margin: 4px 0 10px; }
.art svg { width: 100%; max-width: 420px; height: auto; }
.topicpick { display: grid; gap: 12px; }
.topicpick .tile { min-height: 0; display: flex; align-items: center; gap: 14px; }
.topicpick .tile .ic { font-size: 2.3rem; }
.done { color: var(--green); font-weight: 900; }

/* ---------- equation forge ---------- */
.eqhead { text-align: center; margin-bottom: 8px; }
.eqhead .nm { font-weight: 900; font-size: 1.3rem; }
.eqhead .wh { color: var(--dim); font-size: .85rem; }
.eqboard { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 14px 10px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; min-height: 120px; }
.side { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; padding: 8px; border-radius: 16px; border: 2px dashed transparent; }
.side.active { border-color: var(--yellow); background: rgba(255,207,62,.06); }
.side .lab { width: 100%; text-align: center; font-size: .7rem; font-weight: 900; color: var(--dim); letter-spacing: 1px; }
.slot { min-width: 70px; height: 46px; border-radius: 12px; border: 2px dashed #3a4a7d; display: grid; place-items: center; font-weight: 900; padding: 0 8px; }
.slot.full { border-style: solid; border-color: var(--teal); background: #13324a; animation: pop .25s; }
.slot.bad { border-color: var(--red); background: #571c2b; animation: shake .4s; }
.slot.good { border-color: var(--green); background: #164d33; }
.plus { color: var(--dim); font-weight: 900; }
.arrow { font-size: 1.6rem; font-weight: 900; color: var(--yellow); }
.tiles { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }
.chip { background: var(--card2); border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; font-weight: 900; font-size: 1.05rem; transition: transform .1s; }
.chip:active { transform: scale(.94); }
.chip.used { opacity: .25; pointer-events: none; }
.hint { text-align: center; color: var(--dim); font-size: .9rem; margin-top: 10px; }

/* ---------- pyramid ---------- */
.pyr { display: flex; flex-direction: column-reverse; align-items: center; gap: 4px; margin: 10px 0 14px; }
.pyr .lv { height: 40px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .85rem; background: #26345f; color: var(--dim); transition: all .4s; padding: 0 6px; text-align: center; }
.pyr .lv.on { color: #08122a; }
.chainrow { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; min-height: 52px; margin: 8px 0; }
.chainrow .ce { background: #164d33; border: 2px solid var(--green); border-radius: 12px; padding: 6px 10px; font-weight: 800; animation: pop .3s; }
.chainrow .ar { color: var(--yellow); font-weight: 900; }

/* ---------- carbon quest ---------- */
.map { position: relative; height: 340px; background: linear-gradient(180deg, #16305a 0%, #1b3b4e 45%, #2a2a20 75%, #1d1a14 100%); border-radius: 22px; border: 1px solid var(--line); overflow: hidden; margin-bottom: 12px; }
.node { position: absolute; transform: translate(-50%, -50%); text-align: center; width: 100px; }
.node .e { font-size: 2rem; display: block; filter: drop-shadow(0 3px 4px rgba(0,0,0,.5)); }
.node .l { font-size: .7rem; font-weight: 900; background: rgba(0,0,0,.45); border-radius: 8px; padding: 1px 6px; display: inline-block; }
.node.here .e { animation: pulse .9s infinite; }
.atom { position: absolute; transform: translate(-50%, -50%); font-size: 1.5rem; transition: left 1s cubic-bezier(.5,0,.3,1), top 1s cubic-bezier(.5,0,.3,1); z-index: 3; filter: drop-shadow(0 0 10px #8ff); margin-top: -30px; }
.story { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin-bottom: 12px; animation: slidein .25s; }
.story .where { font-size: .8rem; color: var(--teal); font-weight: 900; letter-spacing: .5px; }
.path { display: flex; flex-wrap: wrap; gap: 4px; font-size: 1.3rem; justify-content: center; margin: 8px 0; }

/* ---------- sort storm ---------- */
.sortcard { background: linear-gradient(135deg, var(--card2), var(--card)); border: 2px solid var(--line); border-radius: 22px; min-height: 150px; display: grid; place-items: center; text-align: center; padding: 18px;
  font-size: 1.45rem; font-weight: 900; margin: 6px 0 16px; animation: dropin .3s cubic-bezier(.2,1.4,.4,1); }
@keyframes dropin { from { transform: translateY(-40px) scale(.9); opacity: 0; } }
.sortcard.flyl { animation: flyl .35s forwards; } .sortcard.flyr { animation: flyr .35s forwards; } .sortcard.flyd { animation: flyd .35s forwards; }
@keyframes flyl { to { transform: translate(-60%, 120px) scale(.3); opacity: 0; } }
@keyframes flyr { to { transform: translate(60%, 120px) scale(.3); opacity: 0; } }
@keyframes flyd { to { transform: translate(0, 140px) scale(.3); opacity: 0; } }
.bins { display: grid; gap: 10px; }
.bins.b3 { grid-template-columns: repeat(3, 1fr); } .bins.b2 { grid-template-columns: repeat(2, 1fr); }
.bin { padding: 18px 6px; border-radius: 18px; font-weight: 900; font-size: 1rem; color: #08122a; min-height: 84px; }
.bin.flash { animation: pop .3s; outline: 4px solid #fff; }

/* ---------- packs & cards ---------- */
.packs { text-align: center; }
.pack { width: 190px; height: 260px; margin: 10px auto; border-radius: 22px; background: linear-gradient(135deg, #3ee07a, #3ed3e0 40%, #8f7bff); display: grid; place-items: center; font-size: 4rem;
  box-shadow: 0 10px 40px rgba(143,123,255,.4); animation: float 2.4s ease-in-out infinite; position: relative; }
.pack::after { content: "SPECIMEN PACK"; position: absolute; bottom: 18px; font-size: .8rem; font-weight: 900; letter-spacing: 2px; color: #fff; }
.pack.rip { animation: rip .6s forwards; }
@keyframes float { 50% { transform: translateY(-10px) rotate(2deg); } }
@keyframes rip { 30% { transform: scale(1.15) rotate(-6deg); } 100% { transform: scale(0); opacity: 0; } }
.cardrow { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 14px 0; }
.scard { width: 104px; height: 150px; perspective: 600px; }
.scard .in { position: relative; width: 100%; height: 100%; transition: transform .6s; transform-style: preserve-3d; }
.scard.flip .in { transform: rotateY(180deg); }
.scard .fa, .scard .ba { position: absolute; inset: 0; border-radius: 14px; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px; text-align: center; }
.scard .ba { background: repeating-linear-gradient(45deg, #26345f 0 10px, #1f2b50 10px 20px); border: 2px solid var(--line); font-size: 2rem; }
.scard .fa { transform: rotateY(180deg); background: var(--card2); border: 3px solid var(--rc); box-shadow: 0 0 18px var(--rc); }
.scard .fa .e { font-size: 2.4rem; }
.scard .fa .n { font-size: .78rem; font-weight: 900; line-height: 1.15; margin-top: 4px; }
.scard .fa .rr { font-size: .62rem; font-weight: 900; color: var(--rc); letter-spacing: 1px; margin-top: 3px; }
.scard .fa .dup { font-size: .6rem; color: var(--gold); margin-top: 2px; }
.album { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.acard { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 10px 4px; text-align: center; min-height: 112px; }
.acard .e { font-size: 2rem; }
.acard .n { font-size: .74rem; font-weight: 900; line-height: 1.15; margin-top: 4px; }
.acard.lock .e { filter: grayscale(1) brightness(.2); }
.acard .ct { font-size: .65rem; color: var(--dim); }

/* ---------- modal & toasts ---------- */
.modal { position: fixed; inset: 0; background: rgba(5,8,20,.78); display: grid; place-items: center; z-index: 70; padding: 16px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal .box { background: var(--bg2); border: 1px solid var(--line); border-radius: 24px; padding: 22px 18px; max-width: 420px; width: 100%; text-align: center; animation: slidein .3s cubic-bezier(.2,1.4,.4,1); }
.modal .box h3 { margin: 6px 0; font-size: 1.5rem; }
.modal .emoji { font-size: 3.4rem; }
#toasts { position: fixed; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: linear-gradient(90deg, #2a1650, #13324a); border: 1px solid var(--violet); border-radius: 16px; padding: 10px 14px; font-weight: 800; display: flex; gap: 10px; align-items: center; animation: toastin 3.2s forwards; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.toast .e { font-size: 1.6rem; }
@keyframes toastin { 0% { transform: translateY(-30px); opacity: 0; } 10%, 85% { transform: none; opacity: 1; } 100% { transform: translateY(-20px); opacity: 0; } }

/* ---------- lists ---------- */
.list { display: grid; gap: 10px; }
.li { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; }
.li .e { font-size: 1.8rem; }
.li.lock { opacity: .45; }
.li .t { font-weight: 900; }
.li .d { color: var(--dim); font-size: .85rem; }
.sheet h3 { margin: 18px 0 8px; }
.sheet .lesson { min-height: 0; margin-bottom: 10px; animation: none; }
.std { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-bottom: 8px; font-size: .9rem; }
.std b { color: var(--teal); }
.toggle { display: flex; justify-content: space-between; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 10px; font-weight: 800; }
.sw { width: 58px; height: 32px; border-radius: 99px; background: #33416e; position: relative; transition: background .2s; }
.sw::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .2s; }
.sw.on { background: var(--green); } .sw.on::after { left: 30px; }
.danger { background: #571c2b; border: 1px solid var(--red); color: #fff; }

@media (max-width: 380px) {
  :root { font-size: 16.5px; }
  .tile { min-height: 88px; padding: 12px 10px; }
  .scard { width: 92px; height: 136px; }
}
@media print {
  body { background: #fff; color: #000; }
  .top, .foot, #fx, #toasts { display: none !important; }
  .lesson, .sheet .lesson { background: #fff; border: 1px solid #999; color: #000; break-inside: avoid; }
  b { color: #000; } .eq { color: #000; background: #fff; }
}

/* ---------- dopamine layer: golden questions, mystery drops, beat pulse, double or nothing ---------- */
.qcard.golden { border: 2px solid var(--gold); background: linear-gradient(135deg, #3a2e0c, #18223f 55%, #3a2e0c); box-shadow: 0 0 26px rgba(255,213,74,.45); position: relative; overflow: hidden; }
.qcard.golden::before { content: ""; position: absolute; top: 0; left: -60%; width: 40%; height: 100%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.22), transparent); animation: shine 1.8s infinite; pointer-events: none; }
@keyframes shine { to { left: 130%; } }
.tag.gold { background: var(--gold); color: #2a1a00; }
.drop { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 65; text-align: center; pointer-events: none; }
.drop .chest { font-size: 5rem; animation: chestshake .42s ease-in-out; }
.drop .loot { font-size: 4.5rem; display: none; animation: lootup .5s cubic-bezier(.2,1.6,.4,1); filter: drop-shadow(0 0 24px #ffd54a); }
.drop .dl { display: none; margin-top: 6px; font-weight: 900; font-size: 1.05rem; background: rgba(10,15,31,.9); border: 2px solid var(--gold); border-radius: 16px; padding: 8px 14px; white-space: nowrap; }
.drop.open .chest { display: none; } .drop.open .loot, .drop.open .dl { display: block; }
@keyframes chestshake { 20%, 60% { transform: rotate(-12deg) scale(1.1); } 40%, 80% { transform: rotate(12deg) scale(1.1); } }
@keyframes lootup { from { transform: scale(0) translateY(40px); } }
.thump { animation: thump .18s ease-out; display: inline-block; }
@keyframes thump { 30% { transform: scale(1.12); } }
#pulse { position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: 0; background: radial-gradient(circle at 50% 60%, transparent 40%, rgba(255,43,214,.28) 100%); }
#pulse.go { animation: pz .32s ease-out; }
@keyframes pz { 0% { opacity: 1; } 100% { opacity: 0; } }
.btn.dbl { width: 100%; margin-top: 12px; background: linear-gradient(90deg, #ff2bd6, #ffd54a); color: #2a0a00; border: 0; font-size: 1.1rem; animation: pulse 1.4s infinite; }
.btn.dbl small { display: block; font-size: .8rem; font-weight: 800; opacity: .85; }
/* slide-in animations must never widen the phone layout */
html { overflow-x: hidden; }
#app { overflow-x: clip; }
.eq { white-space: normal; max-width: 100%; }

/* ---------- boss fight ---------- */
.boss .bn { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.boss .hearts { font-size: .8rem; letter-spacing: -1px; white-space: nowrap; }
.boss .meter { display: flex; align-items: center; gap: 6px; margin-top: 5px; font-size: .62rem; font-weight: 900; color: var(--gold); }
.boss .mbar { flex: 1; height: 7px; background: #1a0d24; border-radius: 99px; overflow: hidden; }
.boss .mbar i { display: block; height: 100%; background: linear-gradient(90deg, #ffd54a, #fff); transition: width .3s; }
.boss.ph1 { background: linear-gradient(135deg, #5a1424, #3a1250); border-color: #ff5d73; box-shadow: 0 0 20px rgba(255,93,115,.35); }
.boss.ph2 { background: linear-gradient(135deg, #2a0606, #4a0a2a, #1a0630); border-color: #ff2b5e; box-shadow: 0 0 34px rgba(255,43,94,.6); animation: menace 1.6s ease-in-out infinite; }
@keyframes menace { 50% { box-shadow: 0 0 50px rgba(255,43,94,.9); } }
.boss .face.lunge { animation: lunge .5s cubic-bezier(.3,1.6,.5,1); }
@keyframes lunge { 40% { transform: scale(1.7) translateY(18px); filter: drop-shadow(0 0 12px #f00); } }
.opt.fog { animation: fog 1.3s ease-out; }
@keyframes fog { 0% { filter: blur(7px); opacity: .55; } 100% { filter: blur(0); opacity: 1; } }
.curse { height: 8px; background: #2a0a12; border-radius: 99px; overflow: hidden; margin: -4px 0 12px; }
.curse i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff2b5e, #ff9d3c); }
#pulse.red { background: radial-gradient(circle at 50% 50%, transparent 30%, rgba(255,30,60,.55) 100%); }
#pulse.gold { background: radial-gradient(circle at 50% 30%, rgba(255,213,74,.45), transparent 75%); }
#pulse.go.red, #pulse.go.gold { animation: pz .5s ease-out; z-index: 62; }
.phase { position: fixed; inset: 0; z-index: 66; background: rgba(10,0,8,.82); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; animation: fade .2s; pointer-events: none; }
.phase .pf { font-size: 6rem; animation: rise .7s cubic-bezier(.2,1.6,.4,1); filter: drop-shadow(0 0 30px #ff2b5e); }
.phase .pt { font-size: 2.6rem; font-weight: 900; color: #ff2b5e; letter-spacing: 3px; text-shadow: 0 0 24px rgba(255,43,94,.8); animation: slam .5s .15s both; }
.phase .pn { font-size: 1.2rem; font-weight: 900; margin-top: 4px; }
.phase .pi { color: var(--dim); margin-top: 8px; max-width: 340px; }
.phase.finale .pt { color: var(--gold); text-shadow: 0 0 24px rgba(255,213,74,.8); }
.phase .pf.boom { animation: boom 1.6s ease-in forwards; }
.phase .pf.flee { animation: flee 2s ease-in forwards; }
@keyframes rise { from { transform: scale(.2) translateY(60px); opacity: 0; } }
@keyframes slam { from { transform: scale(3); opacity: 0; } }
@keyframes boom { 50% { transform: scale(1.4) rotate(-10deg); filter: brightness(3); } 100% { transform: scale(3); opacity: 0; filter: brightness(5) blur(6px); } }
@keyframes flee { to { transform: translateY(-60vh) scale(.4); opacity: 0; } }
.sortcard.golden { border-color: var(--gold); background: linear-gradient(135deg, #3a2e0c, #1f2b50 55%, #3a2e0c); box-shadow: 0 0 26px rgba(255,213,74,.45); }
