:root {
  --bg: #1a0f1f; --bg2: #24152b; --card: #2e1c37; --line: #4a3157;
  --ink: #fff4fa; --dim: #c9b3d1;
  --pink: #ff5fa8; --pink2: #ff8cc6; --flame: #ff9a3d; --gold: #ffd23f;
  --good: #4ee6a0; --bad: #ff5b6e; --warn: #ffc24d;
  --r: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); overflow-x: clip; }
body { font-family: "Nunito", "Segoe UI Rounded", "Trebuchet MS", system-ui, sans-serif; font-size: 17px; line-height: 1.4;
  -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
#app { max-width: 640px; margin: 0 auto; padding: 0 14px 110px; min-height: 100vh; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h3 { margin: 22px 0 8px; color: var(--pink2); }
p { margin: 0 0 10px; }
.fine { color: var(--dim); font-size: 14px; }
svg.char { display: block; width: 100%; height: 100%; overflow: visible; }

/* buttons */
.btn { padding: 13px 20px; border-radius: 14px; font-weight: 800; background: var(--card); border: 2px solid var(--line);
  box-shadow: 0 4px 0 #0008; transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #0008; }
.btn.primary { background: var(--pink); border-color: #ff8cc6; color: #2a0a1c; box-shadow: 0 4px 0 #b02f72; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.wide { display: block; width: 100%; margin-top: 10px; }
.btn:disabled { opacity: .45; cursor: default; }
.x { width: 40px; height: 40px; border-radius: 50%; font-size: 20px; color: var(--dim); flex: none; }
.x:hover { background: var(--card); }

/* welcome */
.welcome { text-align: center; padding-top: 24px; }
.welcome h1 { font-size: 44px; color: var(--pink); letter-spacing: -1px; margin-bottom: 14px; }
.welcome-art { width: 210px; height: 270px; margin: 0 auto; }
.name-form { display: flex; gap: 8px; margin: 14px 0; }
.name-form input, .cb-form input { flex: 1; min-width: 0; padding: 13px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg2); }
.bubble { background: var(--card); border: 2px solid var(--line); border-radius: var(--r); padding: 12px 14px; text-align: left; position: relative; }
.diva-b { border-color: var(--pink); }
.pink-b { border-color: #ff4fa0; background: #4a1836; }

/* hover / float */
.hover, .float svg.char { animation: hover 2.6s ease-in-out infinite; }
.hover-shadow { animation: shadow 2.6s ease-in-out infinite; transform-origin: 100px 252px; }
.float .hover { animation: none; }
@keyframes hover { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes shadow { 0%, 100% { transform: scaleX(1); opacity: 1; } 50% { transform: scaleX(.8); opacity: .6; } }
.tear { animation: tear 1s linear infinite; }
.tear.t2 { animation-delay: .5s; }
@keyframes tear { from { transform: translateY(0); opacity: 1; } to { transform: translateY(26px); opacity: 0; } }
.blink { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .3; } }
.smoke { animation: smoke 1.6s ease-out infinite; }
@keyframes smoke { from { transform: translateY(0); opacity: .8; } to { transform: translateY(-24px); opacity: 0; } }

/* home */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 0; background: linear-gradient(var(--bg) 80%, transparent); }
.brand { font-weight: 900; font-size: 21px; color: var(--pink); white-space: nowrap; }
.stats { display: flex; align-items: center; gap: 6px; }
.stats.big { flex-wrap: wrap; gap: 8px; }
.stat { background: var(--card); border-radius: 999px; padding: 5px 10px; font-weight: 800; font-size: 14px; white-space: nowrap; }
.stat.gem { color: #8fe3ff; }
.me-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--pink); overflow: hidden; padding: 0; border: 2px solid var(--pink2); flex: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; }
.chip { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--card); border: 2px solid var(--line); font-weight: 900; }
.chip.on { background: var(--flame); color: #2a1200; border-color: #ffc08a; }
.session-head { background: linear-gradient(135deg, #ff5fa8, #ff9a3d); color: #2a0a1c; border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.session-head p { margin: 4px 0 8px; font-weight: 700; }
.bar { height: 12px; background: #0005; border-radius: 99px; overflow: hidden; flex: 1; }
.bar i { display: block; height: 100%; background: var(--gold); border-radius: 99px; transition: width .3s; }
.unit { background: var(--bg2); border: 2px solid var(--line); border-radius: var(--r); margin-bottom: 10px; overflow: hidden; }
.unit.open { border-color: var(--pink); }
.unit.fin .unit-prog { color: var(--good); }
.unit.locked .unit-head { opacity: .6; }
.unit-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 14px; text-align: left; }
.unit-no { font-weight: 900; color: var(--flame); font-size: 13px; text-transform: uppercase; flex: none; width: 62px; }
.unit-title { flex: 1; font-weight: 800; min-width: 0; }
.unit-title small { display: block; color: var(--dim); font-weight: 600; font-size: 13px; }
.unit-prog { font-size: 13px; font-weight: 800; color: var(--dim); flex: none; }
.unit-body { padding: 4px 10px 22px; }
.jump { background: var(--card); border-radius: 14px; padding: 12px; margin: 6px 0 14px; font-size: 15px; }

.path { display: flex; flex-direction: column; align-items: center; gap: 16px; padding-top: 22px; }
.node-row { position: relative; transform: translateX(var(--x)); display: flex; flex-direction: column; align-items: center; }
.node { width: 74px; height: 74px; border-radius: 50%; background: var(--pink); border: 4px solid #ffb3d6; box-shadow: 0 6px 0 #b02f72;
  display: grid; place-items: center; overflow: hidden; padding: 0; transition: transform .08s; }
.node:active { transform: translateY(4px); }
.node-num { font-weight: 900; font-size: 26px; color: #2a0a1c; }
.node.done { background: var(--gold); border-color: #fff0a8; box-shadow: 0 6px 0 #a67c00; }
.node.locked { background: #3a2a44; border-color: #54405f; box-shadow: 0 6px 0 #1f1426; filter: saturate(.35); }
.node.locked .node-num { color: #8a7694; }
.node.now { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 6px 0 #b02f72, 0 0 0 0 #ff5fa888; } 50% { box-shadow: 0 6px 0 #b02f72, 0 0 0 14px #ff5fa800; } }
.node.k-bully, .node.k-penny, .node.k-rapper, .node.k-robot, .node.k-tag, .node.k-boss { width: 88px; height: 88px; background: #3b2547; border-color: var(--flame); box-shadow: 0 6px 0 #8a4a12; }
.node.k-boss { width: 104px; height: 104px; border-color: var(--gold); }
.node.done.k-bully, .node.done.k-penny, .node.done.k-rapper, .node.done.k-robot, .node.done.k-tag, .node.done.k-boss { border-color: var(--good); box-shadow: 0 6px 0 #1d7a52; }
.node-duo { display: flex; width: 100%; height: 100%; }
.node-duo svg.char { width: 50%; }
.node-label { margin-top: 8px; font-size: 12px; font-weight: 900; color: var(--flame); text-transform: uppercase; letter-spacing: .5px; }
.start-tag { position: absolute; top: -24px; background: #fff; color: var(--pink); font-weight: 900; font-size: 12px; padding: 3px 9px; border-radius: 8px; z-index: 1; animation: hover 1.4s ease-in-out infinite; }

/* corner button */
.fab { position: fixed; right: 14px; bottom: 14px; z-index: 20; padding: 14px 18px; border-radius: 999px; font-weight: 900;
  background: var(--flame); color: #2a1200; box-shadow: 0 5px 0 #a8540f, 0 8px 24px #0008; }
.fab:active { transform: translateY(3px); box-shadow: 0 2px 0 #a8540f; }

/* lesson */
.l-top { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.hearts { display: flex; gap: 2px; font-size: 20px; flex: none; }
.heart { color: var(--bad); }
.heart.gone { color: #54405f; }
.l-body { padding: 6px 0 20px; }
.teach { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.art { width: 170px; height: 220px; }
.art.small { width: 110px; height: 150px; }
.duo-art { display: flex; justify-content: center; align-items: flex-end; gap: 10px; }
.card { background: var(--card); border: 2px solid var(--line); border-radius: var(--r); padding: 16px; width: 100%; }
.card h2 { margin: 6px 0 8px; color: var(--pink2); }
.card .big, .big { font-size: 20px; font-weight: 800; }
.tag { display: inline-block; background: var(--flame); color: #2a1200; font-weight: 900; font-size: 12px; text-transform: uppercase; padding: 3px 9px; border-radius: 8px; }
.tag.pink { background: #ff4fa0; }
.demo { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.msg { margin: 0; padding: 10px 13px; border-radius: 18px; max-width: 86%; background: #45304f; align-self: flex-start; border-bottom-left-radius: 5px; overflow-wrap: anywhere; }
.msg.me, .row.me .msg { background: var(--pink); color: #2a0a1c; font-weight: 700; align-self: flex-end; border-radius: 18px; border-bottom-right-radius: 5px; }
.msg.me.bad { background: #6b2c3a; color: var(--ink); }
.msg.me.warn { background: #6b5422; color: var(--ink); }
.prompt { font-size: 21px; font-weight: 900; margin: 6px 0 14px; }
.says { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 16px; }
.mini { width: 68px; height: 68px; flex: none; border-radius: 50%; overflow: hidden; background: var(--card); }
.stem { font-size: 22px; font-weight: 800; background: var(--card); border-radius: var(--r); padding: 16px; }
.blank { color: var(--flame); }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt { text-align: left; padding: 13px 15px; border-radius: 14px; background: var(--bg2); border: 2px solid var(--line); box-shadow: 0 4px 0 #0007; font-weight: 700; overflow-wrap: anywhere; }
.opt:hover:not(:disabled) { border-color: var(--pink); }
.opt:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #0007; }
.opt.right { border-color: var(--good); background: #173d2f; }
.opt.wrong { border-color: var(--bad); background: #4a1c26; }
.l-foot { position: sticky; bottom: 0; padding: 12px 0 16px; background: var(--bg); }
.l-foot.good, .l-foot.bad { margin: 0 -14px; padding: 14px 14px 18px; border-top: 3px solid; }
.l-foot.good { background: #143326; border-color: var(--good); }
.l-foot.bad { background: #3d1620; border-color: var(--bad); }
.fb { font-weight: 700; }
.tile-answer { min-height: 64px; border-bottom: 2px solid var(--line); padding: 8px 0; display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tile-bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tile { padding: 9px 13px; border-radius: 12px; background: var(--card); border: 2px solid var(--line); box-shadow: 0 3px 0 #0007; font-weight: 800; }
.tile.used { opacity: .25; }

/* results */
.result, .review { text-align: center; padding-top: 18px; display: flex; flex-direction: column; align-items: center; }
.result h2 { font-size: 30px; margin: 8px 0 12px; }
.rewards { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0; }
.rewards span { background: var(--card); border-radius: 999px; padding: 7px 13px; font-weight: 800; }
.gemwin { color: #8fe3ff; font-size: 20px; animation: pop .5s; }
@keyframes pop { from { transform: scale(.3); } 70% { transform: scale(1.2); } to { transform: scale(1); } }
.review .l-top { width: 100%; justify-content: space-between; }
.rev-art { width: 130px; height: 170px; }
.review .demo { width: 100%; text-align: left; }
.verdict { text-align: left; margin-top: 12px; }
.verdict.good { border-color: var(--good); } .verdict.bad { border-color: var(--bad); } .verdict.warn { border-color: var(--warn); }
.best { background: #173d2f; border-radius: 12px; padding: 10px; font-weight: 800; }
.count { color: var(--dim); font-weight: 800; }

/* battle */
.battle { display: flex; flex-direction: column; height: 100dvh; margin: 0 -14px; padding: 0 14px; overflow-x: clip; }
.b-title { flex: 1; font-weight: 900; color: var(--flame); min-width: 0; }
.stage { display: flex; justify-content: center; align-items: flex-end; gap: 14px; padding: 4px 0 8px; flex: none; }
.foe { width: 130px; text-align: center; transition: transform 1.1s ease-in, opacity 1.1s; }
.foe-art { width: 100px; height: 132px; margin: 0 auto; }
.foe.runaway { transform: translateX(120vw) rotate(12deg); opacity: 0; }
.foe.shutdown { filter: grayscale(1) brightness(.5); transform: translateY(8px) rotate(-6deg); }
.meter { height: 14px; background: #0006; border-radius: 99px; overflow: hidden; border: 2px solid var(--line); }
.meter i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #6fd0ff, #3d8bff); transition: width .5s; }
.k-bully .meter i { background: linear-gradient(90deg, var(--flame), var(--bad)); }
.k-robot .meter i { background: linear-gradient(90deg, var(--gold), var(--bad)); }
.k-rapper .meter i { background: linear-gradient(90deg, var(--good), var(--gold)); }
.meter-label { font-size: 11px; font-weight: 900; text-transform: uppercase; color: var(--dim); }
.friends { display: grid; grid-template-columns: 44px 44px; gap: 4px; align-self: center; text-align: center; }
.friends div { width: 44px; height: 46px; }
.friends span { grid-column: 1 / 3; font-size: 11px; font-weight: 800; color: var(--dim); }
.thread { flex: 1; min-height: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px;
  background: var(--bg2); border-radius: var(--r); border: 2px solid var(--line); }
.row { display: flex; align-items: flex-end; gap: 6px; }
.row.me { justify-content: flex-end; }
.row.them .msg { animation: in .2s; }
@keyframes in { from { transform: translateY(8px); opacity: 0; } }
.ava { width: 34px; height: 34px; border-radius: 50%; overflow: hidden; background: var(--card); flex: none; }
.row.friend .msg { background: #2d3d5c; font-size: 14px; font-weight: 800; }
.row.verse .msg { font-style: italic; font-weight: 800; border-left: 4px solid var(--gold); }
.k-robot .row.them .msg, .row.them.bot .msg { font-family: Consolas, "Courier New", monospace; background: #10231c; color: #59f0a0; font-size: 15px; }
.k-bully .thread { background: #0f1420; border-color: #2a3550; }
.k-bully .row.them .msg { background: #2a3142; }
.note { text-align: center; color: var(--dim); font-size: 13px; font-weight: 700; margin: 2px 0; }
.dots i { display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: var(--dim); animation: dot 1s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }
.tray { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 10px 0 14px; min-height: 96px; }
.tray .opt { padding: 10px 13px; font-size: 15.5px; }
.timer { height: 8px; background: #0006; border-radius: 99px; overflow: hidden; }
.timer i { display: block; height: 100%; width: 100%; background: var(--flame); }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-7px); } 50% { transform: translateX(7px); } 75% { transform: translateX(-4px); } }

/* modal sheets */
.modal { position: fixed; inset: 0; z-index: 40; background: #000a; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; height: min(560px, 86dvh); background: var(--bg); border-radius: 22px 22px 0 0; border: 2px solid var(--pink); border-bottom: 0;
  display: flex; flex-direction: column; padding: 12px 14px 14px; }
.sheet.tall { height: 92dvh; }
.sheet header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 8px; }
.sheet h2 { color: var(--pink); }
.worn { font-size: 13px; background: var(--gold); color: #2a1a00; padding: 2px 8px; border-radius: 8px; vertical-align: middle; }
.sheet-body { overflow-y: auto; flex: 1; }
.cb-thread { flex: 1; }
.cb-form { display: flex; gap: 8px; padding-top: 10px; }
.titles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.title-item { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 10px 12px; border-radius: 14px; background: var(--card); border: 2px solid var(--line); }
.title-item.on { border-color: var(--gold); }
.title-item span { font-size: 13px; color: var(--dim); font-weight: 800; }
.cast-item { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 14px; padding: 8px 12px; margin-bottom: 8px; }
.cast-art { width: 74px; height: 98px; flex: none; }
.cast-item p { margin: 2px 0 0; color: var(--dim); font-size: 14px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 20px); background: #fff; color: #2a0a1c; font-weight: 800; padding: 10px 16px;
  border-radius: 12px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 400px) {
  .stat { padding: 4px 7px; font-size: 13px; }
  .brand { font-size: 18px; }
  .foe { width: 112px; } .foe-art { width: 84px; height: 110px; }
}
@media (max-height: 640px) { .foe-art { width: 70px; height: 92px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
#app:has(.battle) { padding-bottom: 0; }
