:root {
  --bg: #070411;
  --bg-2: #10072a;
  --panel: rgba(19, 12, 45, .72);
  --panel-strong: rgba(20, 12, 49, .94);
  --line: rgba(193, 133, 255, .18);
  --line-hot: rgba(224, 80, 255, .62);
  --text: #f8f3ff;
  --muted: #9e94b4;
  --primary: #d92cff;
  --primary-2: #7428ff;
  --cyan: #44d7ff;
  --danger: #ff467d;
  --gold: #ffc768;
  --success: #55f5bd;
  --shadow: 0 24px 80px rgba(0, 0, 0, .48);
  --font-display: "Unbounded", system-ui, sans-serif;
  --font-ui: "Oxanium", system-ui, sans-serif;
}

[data-theme="frost"] {
  --bg: #030b18;
  --bg-2: #071f38;
  --panel: rgba(5, 24, 48, .76);
  --line: rgba(86, 215, 255, .2);
  --line-hot: rgba(99, 228, 255, .65);
  --primary: #31d9ff;
  --primary-2: #336dff;
  --cyan: #b1f4ff;
}

[data-theme="ember"] {
  --bg: #120308;
  --bg-2: #2c0813;
  --panel: rgba(43, 8, 23, .78);
  --line: rgba(255, 123, 89, .2);
  --line-hot: rgba(255, 102, 72, .68);
  --primary: #ff4f58;
  --primary-2: #ff6f2e;
  --cyan: #ffc25b;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

html { background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 12%, color-mix(in srgb, var(--primary) 13%, transparent), transparent 32%),
    radial-gradient(circle at 86% 72%, color-mix(in srgb, var(--primary-2) 15%, transparent), transparent 30%),
    linear-gradient(145deg, var(--bg), var(--bg-2));
  font-family: var(--font-ui);
  overflow-x: hidden;
  overscroll-behavior: none;
  transition: background .5s ease;
}

button, input { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

#fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: .7;
}

.ambient { position: fixed; z-index: 0; border-radius: 50%; filter: blur(90px); pointer-events: none; opacity: .17; }
.ambient-one { width: 380px; height: 380px; background: var(--primary); left: -180px; top: 12%; animation: drift 11s ease-in-out infinite alternate; }
.ambient-two { width: 300px; height: 300px; background: var(--cyan); right: -160px; bottom: 8%; animation: drift 14s ease-in-out infinite alternate-reverse; }

.app-shell { position: relative; z-index: 1; min-height: 100dvh; max-width: 1500px; margin: 0 auto; padding: 0 clamp(18px, 4vw, 64px); }

.topbar { height: 86px; display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; border: 0; padding: 0; background: transparent; cursor: pointer; }
.brand img { width: 39px; height: 39px; object-fit: contain; filter: drop-shadow(0 0 12px color-mix(in srgb, var(--primary) 60%, transparent)); }
.brand span { text-transform: uppercase; letter-spacing: .02em; font-size: 17px; font-weight: 500; }
.brand b { font-weight: 800; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.resource-pill, .icon-button { height: 40px; border: 1px solid var(--line); background: rgba(10, 6, 25, .62); backdrop-filter: blur(16px); }
.resource-pill { display: flex; align-items: center; gap: 8px; border-radius: 999px; padding: 0 14px; }
.shard-icon { color: var(--cyan); text-shadow: 0 0 10px var(--cyan); }
.icon-button { min-width: 42px; border-radius: 12px; cursor: pointer; transition: .2s ease; }
.icon-button:hover { border-color: var(--line-hot); transform: translateY(-1px); }
.is-hidden { display: none !important; }

.screen { display: none; }
.screen.is-active { display: block; animation: screen-in .55s cubic-bezier(.2,.8,.2,1) both; }

.menu-screen { min-height: calc(100dvh - 86px); }
.menu-grid { min-height: calc(100dvh - 132px); display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(320px, .7fr); align-items: center; gap: clamp(36px, 7vw, 110px); padding: 26px 0 46px; }
.hero-copy { position: relative; padding-left: clamp(0px, 5vw, 66px); }
.eyebrow, .card-kicker, .modal-kicker { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; }
.eyebrow { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.eyebrow span { width: 28px; height: 1px; background: linear-gradient(90deg, transparent, var(--primary)); }
.hero-mark-wrap { position: absolute; width: clamp(290px, 34vw, 520px); right: -6%; top: 44%; transform: translateY(-50%); opacity: .29; pointer-events: none; z-index: -1; }
.hero-mark { display: block; width: 100%; height: auto; object-fit: contain; filter: saturate(1.15) drop-shadow(0 0 35px color-mix(in srgb, var(--primary) 42%, transparent)); animation: mark-breathe 5s ease-in-out infinite; }
.hero-rune { position: absolute; inset: 7%; border: 1px solid var(--line); border-radius: 50%; animation: rune-spin 22s linear infinite; }
.hero-rune::before, .hero-rune::after { content: ""; position: absolute; inset: 12%; border: 1px dashed var(--line); border-radius: 50%; }
.hero-rune::after { inset: 30%; border-style: solid; box-shadow: 0 0 50px color-mix(in srgb, var(--primary) 25%, transparent); }
h1 { margin: 0; max-width: 760px; font-family: var(--font-display); text-transform: uppercase; font-size: clamp(50px, 7.2vw, 112px); line-height: .88; letter-spacing: -.06em; text-wrap: balance; }
h1 span { display: block; color: transparent; -webkit-text-stroke: 1px color-mix(in srgb, var(--text) 80%, transparent); text-shadow: 0 0 35px color-mix(in srgb, var(--primary) 28%, transparent); }
.hero-lead { max-width: 560px; margin: 25px 0 30px; color: #c7bdd8; font-size: clamp(17px, 1.5vw, 21px); line-height: 1.55; }
.hero-actions { display: flex; align-items: center; gap: 13px; }
.primary-button, .secondary-button, .rewarded-button { border-radius: 14px; min-height: 52px; padding: 0 20px; border: 1px solid transparent; cursor: pointer; font-weight: 700; transition: transform .2s ease, border-color .2s, box-shadow .2s, opacity .2s; }
.primary-button { display: inline-flex; align-items: center; justify-content: space-between; gap: 24px; min-width: 230px; color: white; background: linear-gradient(115deg, var(--primary-2), var(--primary)); border-color: color-mix(in srgb, white 18%, transparent); box-shadow: 0 14px 40px color-mix(in srgb, var(--primary) 26%, transparent), inset 0 1px rgba(255,255,255,.2); }
.primary-button:hover, .rewarded-button:hover { transform: translateY(-2px); box-shadow: 0 18px 50px color-mix(in srgb, var(--primary) 35%, transparent); }
.primary-button kbd { padding: 4px 7px; border: 1px solid rgba(255,255,255,.25); background: rgba(0,0,0,.15); border-radius: 6px; font: 600 10px var(--font-ui); text-transform: uppercase; }
.secondary-button { background: rgba(255,255,255,.035); border-color: var(--line); color: #d9d2e6; }
.secondary-button:hover { transform: translateY(-2px); border-color: var(--line-hot); background: rgba(255,255,255,.06); }
.difficulty-row { display: flex; gap: 8px; margin-top: 18px; }
.difficulty-chip { display: flex; flex-direction: column; align-items: flex-start; min-width: 110px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 11px; background: rgba(10, 6, 25, .46); cursor: pointer; }
.difficulty-chip span { font-weight: 700; font-size: 12px; }
.difficulty-chip small { color: var(--muted); text-transform: uppercase; font-size: 9px; letter-spacing: .1em; }
.difficulty-chip.is-selected { border-color: var(--line-hot); background: color-mix(in srgb, var(--primary) 11%, transparent); box-shadow: inset 0 0 22px color-mix(in srgb, var(--primary) 8%, transparent); }

.menu-rail { display: grid; gap: 13px; width: 100%; max-width: 430px; justify-self: end; }
.glass-card { position: relative; overflow: hidden; padding: 21px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(145deg, rgba(255,255,255,.045), transparent), var(--panel); backdrop-filter: blur(18px); box-shadow: var(--shadow); }
.glass-card::after { content: ""; position: absolute; width: 120px; height: 1px; background: linear-gradient(90deg, transparent, var(--primary), transparent); top: 0; left: 18%; }
.record-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.record-grid div { min-width: 0; }
.record-grid b { display: block; color: white; font: 700 clamp(20px, 2vw, 28px) var(--font-display); overflow: hidden; text-overflow: ellipsis; }
.record-grid span { color: var(--muted); font-size: 11px; }
.daily-top { display: flex; align-items: center; gap: 13px; }
.daily-icon { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 12px; color: var(--cyan); background: color-mix(in srgb, var(--cyan) 11%, transparent); border: 1px solid color-mix(in srgb, var(--cyan) 22%, transparent); }
.glass-card h2 { margin: 3px 0 0; font: 700 16px var(--font-display); letter-spacing: -.02em; }
.daily-card p { color: #bdb3cd; font-size: 13px; line-height: 1.45; margin: 15px 0 12px; }
.mini-progress { height: 5px; border-radius: 9px; background: rgba(255,255,255,.07); overflow: hidden; }
.mini-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--primary-2), var(--cyan)); box-shadow: 0 0 9px var(--cyan); transition: width .4s; }
.daily-reward { display: flex; justify-content: space-between; margin-top: 9px; font-size: 11px; color: var(--muted); }
.daily-reward b { color: var(--gold); }
.theme-heading { display: flex; align-items: center; justify-content: space-between; }
.text-button { border: 0; background: transparent; padding: 8px 0; color: var(--cyan); font-weight: 700; cursor: pointer; }
.theme-swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.theme-swatch { position: relative; display: flex; align-items: center; gap: 7px; padding: 7px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.025); cursor: pointer; font-weight: 600; font-size: 11px; }
.theme-swatch i { width: 20px; height: 20px; border-radius: 7px; }
.theme-swatch i.void { background: linear-gradient(135deg, #762aff, #f03bff); }
.theme-swatch i.frost { background: linear-gradient(135deg, #1f72ff, #53efff); }
.theme-swatch i.ember { background: linear-gradient(135deg, #ff343e, #ffad40); }
.theme-swatch.is-selected { border-color: var(--line-hot); }
.theme-swatch.is-locked::after { content: "◆"; position: absolute; right: 6px; top: 4px; color: var(--muted); font-size: 8px; }
.ad-slot { min-height: 72px; border: 1px dashed var(--line); border-radius: 14px; padding: 8px; text-align: center; color: var(--muted); font-size: 9px; letter-spacing: .13em; text-transform: uppercase; }
.menu-footer { display: flex; align-items: center; justify-content: space-between; min-height: 46px; color: #756c89; font-size: 11px; }
.menu-footer nav { display: flex; gap: 18px; }
.menu-footer a { color: inherit; text-decoration: none; }
.menu-footer a:hover { color: var(--text); }
.footer-link { border: 0; padding: 0; color: inherit; background: transparent; cursor: pointer; font-size: inherit; }
.footer-link:hover { color: var(--text); }

/* Game */
.game-screen { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.hud-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 720px; margin: 0 auto 9px; border: 1px solid var(--line); border-radius: 15px; background: rgba(8,4,22,.64); overflow: hidden; backdrop-filter: blur(13px); }
.hud-block { position: relative; text-align: center; padding: 9px 14px; border-right: 1px solid var(--line); }
.hud-block:last-child { border: 0; }
.hud-block > span { display: block; color: var(--muted); font-size: 9px; letter-spacing: .16em; text-transform: uppercase; }
.hud-block b { font: 700 19px var(--font-display); }
.combo-block b { color: var(--primary); }
.combo-block b i { font-style: normal; font-size: 12px; }
.vitals-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 950px; margin: 0 auto 10px; }
.vital { border: 1px solid var(--line); border-radius: 11px; padding: 7px 11px 9px; background: rgba(8,4,22,.56); }
.vital-label { display: flex; justify-content: space-between; margin-bottom: 5px; color: #bdb3ce; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.vital-label i { font-style: normal; }
.health-vital .vital-label i { color: var(--danger); }
.fire-vital .vital-label i { color: var(--primary); }
.bar { height: 6px; border-radius: 20px; background: rgba(255,255,255,.06); overflow: hidden; }
.bar i { display: block; width: 100%; height: 100%; border-radius: inherit; transition: width .25s; }
.health-vital .bar i { background: linear-gradient(90deg, #ff315f, #ff629a); box-shadow: 0 0 10px rgba(255,49,95,.6); }
.fire-vital .bar i { width: 0; background: linear-gradient(90deg, var(--primary-2), var(--primary), var(--cyan)); box-shadow: 0 0 12px var(--primary); }
.fire-vital.is-ready { border-color: var(--line-hot); animation: ready-pulse 1.1s ease-in-out infinite; }

.arena { position: relative; height: clamp(380px, calc(100dvh - 320px), 660px); min-height: 380px; max-width: 1180px; margin: 0 auto; overflow: hidden; border: 1px solid var(--line); border-radius: 25px; background:
  radial-gradient(circle at 50% 105%, color-mix(in srgb, var(--primary) 24%, transparent), transparent 33%),
  radial-gradient(circle at 50% -8%, color-mix(in srgb, var(--cyan) 8%, transparent), transparent 25%),
  linear-gradient(180deg, color-mix(in srgb, var(--bg-2) 75%, black), var(--bg));
  box-shadow: 0 30px 90px rgba(0,0,0,.5), inset 0 0 80px rgba(0,0,0,.42);
  touch-action: manipulation;
}
.arena::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 49.7%, rgba(255,255,255,.022) 50%, transparent 50.3%); pointer-events: none; }
.depth-grid { position: absolute; left: -25%; right: -25%; height: 55%; bottom: -23%; transform: perspective(400px) rotateX(58deg); background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 54px 35px; mask-image: linear-gradient(to bottom, transparent, black); opacity: .45; }
.moon { position: absolute; width: 75px; height: 75px; left: 50%; top: 12%; transform: translateX(-50%); border-radius: 50%; background: var(--cyan); filter: blur(.2px); opacity: .09; box-shadow: 0 0 60px var(--cyan), 0 0 120px var(--primary); }
.mountains { position: absolute; left: -5%; right: -5%; bottom: 17%; height: 43%; opacity: .34; clip-path: polygon(0 100%,0 66%,8% 48%,13% 65%,22% 33%,28% 61%,36% 44%,42% 67%,51% 28%,58% 60%,65% 42%,72% 66%,81% 34%,88% 55%,94% 43%,100% 67%,100% 100%); }
.mountains-back { background: color-mix(in srgb, var(--primary-2) 32%, #07050c); filter: blur(1px); transform: scale(1.08); }
.mountains-front { background: #07050e; bottom: 8%; transform: scaleX(1.06); opacity: .72; }
.enemy-layer { position: absolute; inset: 0; }
.enemy { position: absolute; z-index: 5; left: var(--enemy-x); top: 0; width: 0; height: 0; transform: translate(-50%, -50%); will-change: transform; }
.enemy-visual { position: absolute; left: 50%; top: 50%; width: var(--enemy-size, 42px); height: var(--enemy-size, 42px); transform: translate(-50%, -50%) rotate(45deg); border-radius: 36% 50% 34% 50%; background: radial-gradient(circle at 32% 27%, rgba(255,255,255,.55) 0 4%, var(--enemy-color, var(--primary)) 5% 17%, #150a28 19% 60%, #05040a 68%); border: 1px solid color-mix(in srgb, var(--enemy-color, var(--primary)) 74%, white); box-shadow: 0 0 13px color-mix(in srgb, var(--enemy-color, var(--primary)) 55%, transparent), inset 0 0 12px rgba(255,255,255,.16); animation: enemy-float 1.7s ease-in-out infinite alternate; }
.enemy-visual::before, .enemy-visual::after { content: ""; position: absolute; width: 34%; height: 48%; top: 13%; background: color-mix(in srgb, var(--enemy-color, var(--primary)) 55%, #090512); border: 1px solid var(--enemy-color, var(--primary)); clip-path: polygon(0 0,100% 50%,0 100%); }
.enemy-visual::before { left: -27%; transform: rotate(-45deg); }
.enemy-visual::after { right: -27%; transform: rotate(135deg); }
.enemy.elite .enemy-visual { --enemy-size: 56px; border-width: 2px; }
.enemy.boss .enemy-visual { --enemy-size: 88px; border-radius: 48% 48% 34% 55%; animation-duration: 1s; box-shadow: 0 0 28px var(--danger), inset 0 0 30px rgba(255,255,255,.18); }
.enemy.boss .enemy-visual::before, .enemy.boss .enemy-visual::after { width: 55%; height: 55%; }
.enemy.frozen { filter: hue-rotate(120deg) brightness(1.3); }
.enemy.targeted .enemy-visual { border-color: white; box-shadow: 0 0 20px var(--cyan), 0 0 40px var(--primary); }
.enemy-word { position: absolute; left: 50%; top: calc(var(--enemy-size, 42px) / 2 + 15px); transform: translateX(-50%); white-space: nowrap; padding: 6px 9px; border: 1px solid rgba(255,255,255,.12); border-radius: 8px; background: rgba(5,3,13,.89); box-shadow: 0 5px 18px rgba(0,0,0,.4); color: white; font: 600 14px var(--font-ui); letter-spacing: .03em; }
.elite .enemy-word { border-color: color-mix(in srgb, var(--gold) 45%, transparent); }
.boss .enemy-word { top: 60px; padding: 8px 12px; font-size: 17px; border-color: color-mix(in srgb, var(--danger) 55%, transparent); }
.enemy-word .typed { color: var(--cyan); text-shadow: 0 0 8px var(--cyan); }
.enemy-word .next { color: white; border-bottom: 2px solid var(--primary); }
.enemy-hp { position: absolute; top: -58px; left: 50%; transform: translateX(-50%); width: 80px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.1); overflow: hidden; }
.enemy-hp i { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, var(--danger), var(--gold)); transition: width .2s; }
.danger-line { position: absolute; left: 0; right: 0; bottom: 16%; height: 1px; background: linear-gradient(90deg, transparent, rgba(255,55,105,.55), transparent); box-shadow: 0 0 12px rgba(255,55,105,.25); }
.danger-line span { position: absolute; left: 14px; bottom: 5px; color: rgba(255,80,120,.52); font-size: 7px; letter-spacing: .2em; }
.player-sanctum { position: absolute; z-index: 7; left: 50%; bottom: 0; width: 110px; height: 94px; transform: translateX(-50%); display: grid; place-items: end center; }
.player-sanctum img { position: relative; z-index: 2; width: 78px; height: 78px; object-fit: contain; filter: drop-shadow(0 0 14px var(--primary)); }
.player-glow { position: absolute; width: 120px; height: 40px; bottom: -8px; border-radius: 50%; background: var(--primary); filter: blur(18px); opacity: .38; }
.shield-ring { position: absolute; z-index: 1; width: 108px; height: 108px; bottom: -8px; border-radius: 50%; border: 2px solid transparent; opacity: 0; transform: scale(.75); }
.shield-ring.is-active { opacity: .82; transform: scale(1); border-color: var(--cyan); box-shadow: 0 0 20px var(--cyan), inset 0 0 20px var(--primary); animation: shield-spin 3s linear infinite; }
.announcement { position: absolute; z-index: 12; top: 38%; left: 50%; transform: translate(-50%, -50%); pointer-events: none; text-align: center; opacity: 0; font: 800 clamp(20px,3vw,38px) var(--font-display); text-transform: uppercase; text-shadow: 0 0 25px var(--primary); }
.announcement.show { animation: announce 1.3s ease both; }
.double-tap-hint { display: none; position: absolute; right: 10px; bottom: 18%; color: rgba(255,255,255,.28); font-size: 9px; }
.arena.is-hit { animation: arena-hit .35s ease; }
.arena.is-fire { animation: arena-fire .75s ease; }

.spell-deck { display: grid; grid-template-columns: 1fr 1fr 1fr minmax(260px, 1.6fr); gap: 9px; max-width: 1180px; margin: 10px auto 0; }
.spell-card, .typing-focus { min-height: 58px; border: 1px solid var(--line); border-radius: 13px; background: rgba(10,6,26,.72); backdrop-filter: blur(14px); }
.spell-card { display: flex; align-items: center; gap: 10px; padding: 8px 11px; text-align: left; }
button.spell-card { cursor: pointer; }
.spell-icon { display: grid; place-items: center; flex: 0 0 37px; height: 37px; border: 1px solid var(--line); border-radius: 10px; color: var(--primary); font-size: 21px; background: color-mix(in srgb, var(--primary) 9%, transparent); }
.spell-copy { min-width: 0; }
.spell-copy b, .spell-copy small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spell-copy b { font-size: 12px; }
.spell-copy small { color: var(--muted); font-size: 9px; }
.fire-spell kbd { margin-left: auto; color: var(--muted); font: 600 9px var(--font-ui); border: 1px solid var(--line); border-radius: 6px; padding: 4px; }
.fire-spell.is-ready { border-color: var(--line-hot); background: color-mix(in srgb, var(--primary) 12%, rgba(10,6,26,.72)); box-shadow: 0 0 22px color-mix(in srgb, var(--primary) 16%, transparent); }
.typing-focus { position: relative; display: flex; flex-direction: column; justify-content: center; padding: 8px 14px; overflow: hidden; cursor: text; }
.typing-focus::before { content: ""; position: absolute; left: 0; top: 20%; bottom: 20%; width: 2px; background: var(--primary); box-shadow: 0 0 10px var(--primary); }
.focus-label { color: var(--muted); font-size: 8px; letter-spacing: .16em; text-transform: uppercase; }
.focus-value { min-height: 22px; color: white; font-size: 16px; font-weight: 600; }
.typing-focus input { position: absolute; width: 1px; height: 1px; opacity: .01; left: -20px; bottom: 0; }

/* Modals */
.modal-backdrop { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(3,1,9,.77); backdrop-filter: blur(13px); }
.modal-backdrop[hidden] { display: none; }
.modal { position: relative; width: min(760px, 100%); max-height: min(850px, calc(100dvh - 40px)); overflow-y: auto; padding: clamp(25px, 4vw, 42px); border: 1px solid var(--line-hot); border-radius: 24px; background: linear-gradient(150deg, rgba(255,255,255,.05), transparent 35%), var(--panel-strong); box-shadow: 0 30px 100px rgba(0,0,0,.7), 0 0 55px color-mix(in srgb, var(--primary) 12%, transparent); animation: modal-in .35s cubic-bezier(.2,.8,.2,1); }
.modal h2 { margin: 7px 0 12px; font: 700 clamp(23px, 4vw, 38px) var(--font-display); letter-spacing: -.04em; }
.modal > p { color: var(--muted); }
.modal-close { position: absolute; right: 15px; top: 15px; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.04); cursor: pointer; }
.lesson-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 27px 0; }
.lesson-grid article { position: relative; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.025); }
.lesson-grid article > span { color: var(--primary); font: 700 10px var(--font-display); }
.lesson-grid h3 { margin: 8px 0 5px; font-size: 15px; }
.lesson-grid p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.modal-action { width: 100%; }
.compact-modal { width: min(440px, 100%); text-align: center; }
.compact-modal .primary-button, .compact-modal .secondary-button { width: 100%; justify-content: center; margin-top: 9px; }
.reward-grid, .vault-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 24px; }
.reward-card, .vault-item { position: relative; min-height: 180px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.03); text-align: left; cursor: pointer; transition: .2s ease; }
.reward-card:hover, .vault-item:hover { transform: translateY(-4px); border-color: var(--line-hot); box-shadow: 0 15px 40px rgba(0,0,0,.25); }
.reward-card .rune-icon { display: grid; place-items: center; width: 47px; height: 47px; border-radius: 13px; color: var(--cyan); background: color-mix(in srgb, var(--primary) 12%, transparent); border: 1px solid var(--line); font-size: 21px; }
.reward-card h3, .vault-item h3 { margin: 18px 0 6px; font-size: 15px; }
.reward-card p, .vault-item p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.reward-card small { display: block; color: var(--primary); margin-top: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.results-modal { width: min(560px, 100%); text-align: center; }
.result-crest { width: 92px; height: 92px; margin: -3px auto 12px; border-radius: 50%; border: 1px solid var(--line); background: radial-gradient(circle, color-mix(in srgb,var(--primary) 16%, transparent), transparent 65%); }
.result-crest img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 0 12px var(--primary)); }
.result-stats { display: grid; grid-template-columns: repeat(4, 1fr); margin: 25px 0 13px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.result-stats div { padding: 13px 6px; border-right: 1px solid var(--line); }
.result-stats div:last-child { border: 0; }
.result-stats b, .result-stats span { display: block; }
.result-stats b { font: 700 17px var(--font-display); }
.result-stats span { margin-top: 3px; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.earned-shards { display: flex; justify-content: space-between; padding: 11px 14px; border-radius: 10px; color: var(--muted); background: rgba(255,255,255,.035); font-size: 12px; }
.earned-shards b { color: var(--gold); }
.rewarded-button { width: 100%; display: flex; justify-content: space-between; align-items: center; margin: 13px 0; color: white; background: linear-gradient(120deg, rgba(99,35,180,.72), rgba(199,39,255,.7)); border-color: var(--line-hot); text-align: left; }
.rewarded-button span b, .rewarded-button span small { display: block; }
.rewarded-button small { margin-top: 2px; color: rgba(255,255,255,.65); font-weight: 500; }
.rewarded-button:disabled { cursor: not-allowed; filter: grayscale(.8); opacity: .45; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result-actions .primary-button { min-width: 0; justify-content: center; }
.vault-item { min-height: 210px; }
.vault-preview { height: 75px; border-radius: 11px; border: 1px solid rgba(255,255,255,.13); }
.vault-preview.void { background: radial-gradient(circle at 70% 30%, #f033ff, transparent 22%), linear-gradient(145deg,#080412,#30105c); }
.vault-preview.frost { background: radial-gradient(circle at 70% 30%, #a5f6ff, transparent 22%), linear-gradient(145deg,#03111f,#075b92); }
.vault-preview.ember { background: radial-gradient(circle at 70% 30%, #ffd457, transparent 22%), linear-gradient(145deg,#140307,#811c12); }
.vault-cost { display: inline-block; margin-top: 12px; color: var(--gold); font-size: 11px; font-weight: 700; }
.vault-item.is-equipped::after { content: "Equipped"; position: absolute; right: 12px; top: 12px; padding: 4px 7px; color: var(--cyan); background: rgba(0,0,0,.5); border-radius: 6px; font-size: 8px; text-transform: uppercase; }
.vault-item.is-locked::after { content: "Locked"; position: absolute; right: 12px; top: 12px; padding: 4px 7px; color: var(--muted); background: rgba(0,0,0,.5); border-radius: 6px; font-size: 8px; text-transform: uppercase; }

.toast { position: fixed; z-index: 80; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 30px); padding: 11px 16px; border: 1px solid var(--line-hot); border-radius: 10px; background: var(--panel-strong); box-shadow: var(--shadow); color: white; font-size: 12px; opacity: 0; pointer-events: none; transition: .3s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.rotate-notice { display: none; position: fixed; z-index: 100; inset: 0; place-items: center; align-content: center; gap: 8px; padding: 25px; background: var(--bg); text-align: center; }
.rotate-notice img { filter: drop-shadow(0 0 15px var(--primary)); }
.rotate-notice span { max-width: 280px; color: var(--muted); font-size: 13px; }
.noscript { position: fixed; z-index: 200; inset: 0; display: grid; place-items: center; background: var(--bg); }

.particle { position: fixed; z-index: 40; width: 5px; height: 5px; border-radius: 50%; background: var(--particle, var(--primary)); box-shadow: 0 0 8px var(--particle, var(--primary)); pointer-events: none; animation: burst .7s ease-out forwards; }
.damage-number { position: absolute; z-index: 20; color: var(--cyan); font: 700 15px var(--font-display); text-shadow: 0 0 10px var(--cyan); pointer-events: none; animation: damage-float .8s ease forwards; }

@keyframes drift { to { transform: translate(80px, 45px) scale(1.2); } }
@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(15px) scale(.97); } }
@keyframes mark-breathe { 50% { transform: scale(1.025); filter: saturate(1.3) drop-shadow(0 0 55px color-mix(in srgb,var(--primary) 56%,transparent)); } }
@keyframes rune-spin { to { transform: rotate(360deg); } }
@keyframes enemy-float { to { margin-top: 5px; transform: translate(-50%,-50%) rotate(55deg) scale(1.04); } }
@keyframes ready-pulse { 50% { box-shadow: 0 0 18px color-mix(in srgb,var(--primary) 42%,transparent); } }
@keyframes shield-spin { to { transform: rotate(360deg); } }
@keyframes announce { 0% { opacity: 0; transform: translate(-50%,-35%) scale(.75); } 18%,68% { opacity: 1; transform: translate(-50%,-50%) scale(1); } 100% { opacity: 0; transform: translate(-50%,-70%) scale(1.08); } }
@keyframes arena-hit { 25% { transform: translateX(-5px); filter: saturate(1.7); } 60% { transform: translateX(4px); } }
@keyframes arena-fire { 30% { box-shadow: inset 0 0 180px var(--primary), 0 0 70px var(--primary); } }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; } }
@keyframes damage-float { to { transform: translateY(-35px) scale(1.2); opacity: 0; } }

@media (max-width: 980px) {
  .app-shell { padding: 0 20px; }
  .menu-grid { grid-template-columns: 1fr; padding-top: 30px; }
  .hero-copy { padding-left: 0; text-align: center; }
  .eyebrow, .hero-actions, .difficulty-row { justify-content: center; }
  .hero-lead { margin-left: auto; margin-right: auto; }
  .hero-mark-wrap { left: 50%; right: auto; transform: translate(-50%,-48%); }
  .menu-rail { max-width: 680px; justify-self: center; grid-template-columns: 1fr 1fr; }
  .record-card, .theme-card { grid-column: span 1; }
  .daily-card { grid-row: span 2; }
  .menu-footer { margin-top: 25px; }
  .spell-deck { grid-template-columns: repeat(3, 1fr); }
  .typing-focus { grid-column: 1 / -1; order: -1; }
  .arena { height: clamp(390px, calc(100dvh - 375px), 650px); }
}

@media (max-width: 650px) {
  .app-shell { padding: 0 11px; }
  .topbar { height: 62px; }
  .brand img { width: 32px; height: 32px; }
  .brand span { font-size: 13px; }
  .resource-pill, .icon-button { height: 36px; }
  .menu-grid { min-height: calc(100dvh - 105px); padding: 20px 6px 35px; }
  h1 { font-size: clamp(43px, 15vw, 70px); }
  .hero-mark-wrap { width: min(92vw, 420px); top: 40%; }
  .hero-lead { margin-top: 20px; font-size: 16px; }
  .hero-actions { flex-direction: column; }
  .hero-actions .primary-button, .hero-actions .secondary-button { width: min(330px, 100%); }
  .difficulty-row { flex-wrap: wrap; }
  .difficulty-chip { min-width: 92px; }
  .menu-rail { grid-template-columns: 1fr; }
  .daily-card { grid-row: auto; }
  .menu-footer { flex-direction: column; gap: 10px; padding: 15px; }
  .hud-row { margin-bottom: 6px; }
  .hud-block { padding: 7px 4px; }
  .hud-block > span { font-size: 7px; }
  .hud-block b { font-size: 14px; }
  .vitals-row { gap: 5px; margin-bottom: 6px; }
  .vital { padding: 5px 7px 7px; }
  .vital-label { font-size: 8px; }
  .arena { height: calc(100dvh - 294px); min-height: 335px; border-radius: 17px; }
  .enemy-word { font-size: 13px; }
  .double-tap-hint { display: block; }
  .spell-deck { gap: 5px; margin-top: 6px; }
  .spell-card, .typing-focus { min-height: 49px; border-radius: 10px; }
  .spell-card { padding: 6px; gap: 5px; }
  .spell-icon { flex-basis: 31px; height: 31px; }
  .spell-copy b { font-size: 10px; }
  .fire-spell kbd { display: none; }
  .typing-focus { padding: 5px 11px; }
  .focus-value { font-size: 14px; }
  .modal { padding: 26px 19px; border-radius: 19px; }
  .lesson-grid, .reward-grid, .vault-grid { grid-template-columns: 1fr; }
  .reward-card { min-height: 120px; }
  .result-stats { grid-template-columns: repeat(2, 1fr); }
  .result-stats div:nth-child(2) { border-right: 0; }
  .result-stats div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-height: 560px) and (orientation: landscape) and (max-width: 900px) {
  .rotate-notice { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
