:root {
    --ink: #070812;
    --night: #0d1024;
    --panel: rgba(12, 15, 38, .78);
    --panel-strong: rgba(10, 12, 31, .94);
    --line: rgba(174, 196, 255, .22);
    --gold: #ffd37a;
    --gold-deep: #b86e24;
    --violet: #9c7cff;
    --cyan: #63e4ff;
    --green: #74efb1;
    --red: #ff647f;
    --white: #f5f3ff;
    --muted: #aaa9c7;
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--ink);
    color: var(--white);
    overscroll-behavior: none;
}

body { touch-action: none; -webkit-user-select: none; user-select: none; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

#game {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 35%, rgba(56, 44, 112, .26), transparent 42%),
        linear-gradient(#0d1024, #05060d);
}

#gameCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 42%, rgba(0, 0, 0, .3) 78%, rgba(0, 0, 0, .65));
    mix-blend-mode: multiply;
}

.hidden { display: none !important; }
.glass-panel {
    background: linear-gradient(145deg, rgba(26, 30, 63, .84), rgba(9, 11, 29, .7));
    border: 1px solid var(--line);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.09), 0 8px 24px rgba(0,0,0,.3);
    backdrop-filter: blur(12px);
}

.hud {
    position: absolute;
    z-index: 10;
    top: max(10px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    display: grid;
    grid-template-columns: minmax(180px, 290px) 1fr minmax(170px, 260px);
    align-items: start;
    gap: 12px;
    pointer-events: none;
}

.vitals { min-height: 66px; padding: 8px 12px 8px 8px; border-radius: 18px; display: flex; align-items: center; gap: 9px; }
.portrait { width: 48px; height: 48px; flex: none; position: relative; border-radius: 50%; overflow: hidden; background: radial-gradient(circle at 45% 38%, #f6cfa3 0 24%, #263064 25% 100%); border: 2px solid rgba(255,211,122,.65); box-shadow: 0 0 18px rgba(156,124,255,.35); }
.portrait-face { position: absolute; left: 15px; top: 19px; width: 18px; height: 18px; border-radius: 45% 45% 52% 52%; background: #f5cda5; box-shadow: inset 4px 0 rgba(189,96,70,.15); }
.portrait-face::after { content: ""; position: absolute; left: 4px; top: 7px; width: 3px; height: 3px; border-radius: 50%; background: #273459; box-shadow: 8px 0 #273459; }
.portrait-hat { position: absolute; z-index: 2; left: 6px; top: 4px; width: 37px; height: 19px; background: #543bb3; clip-path: polygon(5% 100%, 48% 0, 70% 16%, 100% 100%); transform: rotate(-5deg); }
.portrait-hat::after { content: ""; position: absolute; left: 2px; bottom: 0; width: 36px; height: 5px; border-radius: 50%; background: #8168e8; }
.bars { flex: 1; min-width: 0; display: grid; gap: 7px; }
.bar-row { display: flex; align-items: center; gap: 6px; }
.bar-icon { width: 16px; text-align: center; font-size: 14px; text-shadow: 0 0 9px currentColor; }
.bar-icon.heart { color: var(--red); }
.bar-icon.mana { color: var(--cyan); }
.bar { position: relative; height: 16px; flex: 1; border-radius: 8px; overflow: hidden; background: rgba(0,0,0,.42); box-shadow: inset 0 1px 4px rgba(0,0,0,.7); }
.bar i { display: block; width: 100%; height: 100%; border-radius: inherit; transition: width .18s ease; }
.health-bar i { background: linear-gradient(90deg, #a82b56, #ff647f 55%, #ff9e9e); box-shadow: 0 0 10px rgba(255,100,127,.55); }
.mana-bar i { background: linear-gradient(90deg, #356cd3, #5edcff 58%, #b8f4ff); box-shadow: 0 0 10px rgba(94,220,255,.5); }
.bar b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 9px; letter-spacing: .03em; color: white; text-shadow: 0 1px 2px #000; }

.chapter { justify-self: center; min-width: min(350px, 42vw); padding: 10px 20px; border-radius: 0 0 18px 18px; text-align: center; border-top: 0; }
.chapter strong { display: block; color: var(--gold); font-family: Georgia, serif; font-size: 17px; letter-spacing: .04em; }
.chapter span { display: block; margin-top: 2px; color: #c8c7df; font-size: 11px; }

.stats { justify-self: end; min-height: 52px; padding: 8px 8px 8px 14px; border-radius: 16px; display: flex; align-items: center; gap: 12px; font-size: 11px; color: var(--muted); }
.stats span { white-space: nowrap; }
.stats b { display: block; color: white; font-size: 14px; }
.icon-button { pointer-events: auto; width: 37px; height: 37px; border: 1px solid var(--line); border-radius: 11px; color: white; background: rgba(255,255,255,.07); cursor: pointer; }

.boss-hud { position: absolute; z-index: 9; top: 92px; left: 50%; width: min(520px, 68vw); transform: translateX(-50%); pointer-events: none; text-align: center; filter: drop-shadow(0 5px 10px rgba(0,0,0,.7)); }
.boss-title { display: flex; justify-content: center; gap: 10px; align-items: baseline; margin-bottom: 5px; text-shadow: 0 2px 5px #000; }
.boss-title span { color: var(--gold); font-size: 9px; letter-spacing: .22em; }
.boss-title strong { font-family: Georgia, serif; font-size: 16px; }
.boss-title .weakness-badge { --weakness-color: #6de7ff; min-height: 22px; padding: 2px 7px; border: 1px solid color-mix(in srgb, var(--weakness-color) 48%, transparent); border-radius: 11px; display: inline-flex; align-items: center; gap: 4px; color: var(--weakness-color); background: color-mix(in srgb, var(--weakness-color) 11%, rgba(8,9,23,.8)); letter-spacing: 0; box-shadow: 0 0 10px color-mix(in srgb, var(--weakness-color) 15%, transparent); }
.boss-title .weakness-badge i { font-style: normal; font-size: 13px; text-shadow: 0 0 8px currentColor; }
.boss-title .weakness-badge b { color: #e8e7f4; font-size: 8px; letter-spacing: .04em; }
.boss-bar { height: 13px; padding: 3px; border-radius: 10px; border: 1px solid rgba(255,211,122,.5); background: #140d20; }
.boss-bar i { display: block; width: 100%; height: 100%; border-radius: 5px; background: linear-gradient(90deg, #87274d, #e45174, #ff967e); box-shadow: 0 0 10px rgba(228,81,116,.6); transition: width .2s; }

.touch-controls { position: absolute; z-index: 12; inset: 0; pointer-events: none; }
.move-pad { position: absolute; pointer-events: auto; left: max(14px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); width: clamp(225px, 29vw, 330px); height: clamp(102px, 19vh, 136px); padding: 7px; display: grid; grid-template-columns: 1fr .96fr 1fr; border-radius: 34px; }
.control-button { position: relative; border: 0; color: white; background: transparent; cursor: pointer; text-shadow: 0 2px 10px rgba(0,0,0,.5); }
.control-button::after { content: ""; position: absolute; inset: 3px; z-index: -1; border-radius: 25px; border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.035); opacity: 0; transform: scale(.85); transition: .12s; }
.control-button.pressed::after, .control-button:active::after { opacity: 1; transform: scale(1); background: rgba(99,228,255,.15); border-color: rgba(99,228,255,.4); }
.move-button { font: 300 clamp(52px, 8vh, 78px)/.8 Georgia, serif; padding-bottom: 8px; }
.center-actions { min-width: 0; display: grid; grid-template-rows: 1fr 1fr; border-inline: 1px solid rgba(255,255,255,.12); }
.jump-button, .duck-button { min-width: 0; display: grid; align-content: center; justify-items: center; grid-template-columns: 22px auto; gap: 3px; }
.jump-button { border-bottom: 1px solid rgba(255,255,255,.1); }
.jump-button small, .duck-button small, .fire-button small { font-size: 7px; letter-spacing: .12em; color: #c9c9dc; }
.jump-symbol { color: #eafaff; font: 700 23px/1 Georgia, serif; text-shadow: 0 0 10px var(--cyan); transform: translateY(-1px); }
.duck-symbol { position: relative; width: 28px; height: 19px; border-bottom: 3px solid #eef4ff; }
.duck-symbol::before { content: ""; position: absolute; left: 2px; top: 0; width: 10px; height: 10px; border-radius: 50%; background: #eef4ff; box-shadow: 12px 7px 0 -2px #eef4ff; }
.duck-symbol::after { content: ""; position: absolute; left: 8px; top: 9px; width: 18px; height: 3px; border-radius: 4px; background: #eef4ff; transform: rotate(-15deg); transform-origin: left center; }

.combat-controls { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); width: clamp(106px, 13vw, 134px); height: clamp(288px, 50vh, 360px); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 9px; pointer-events: auto; }
.spell-wheel { width: clamp(102px, 12vw, 126px); height: clamp(178px, 31vh, 218px); padding: 8px 6px; border-radius: 22px; display: grid; grid-template-columns: 1fr; grid-template-rows: 1fr 1.28fr 1fr; gap: 5px; overflow: hidden; touch-action: none; }
.spell-slot { border: 0; border-radius: 16px; color: rgba(255,255,255,.58); background: rgba(255,255,255,.025); display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 5px; min-width: 0; cursor: pointer; transition: .15s ease; }
.spell-slot .spell-glyph { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; font-size: 17px; background: color-mix(in srgb, var(--spell-color) 18%, transparent); border: 1px solid color-mix(in srgb, var(--spell-color) 42%, transparent); text-shadow: 0 0 9px var(--spell-color); }
.spell-slot .spell-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: left; font-size: 9px; letter-spacing: .03em; }
.spell-slot.active { color: white; background: linear-gradient(145deg, color-mix(in srgb, var(--spell-color) 24%, transparent), rgba(255,255,255,.04)); border: 1px solid color-mix(in srgb, var(--spell-color) 48%, transparent); box-shadow: 0 0 18px color-mix(in srgb, var(--spell-color) 18%, transparent); }
.spell-slot.active .spell-glyph { transform: scale(1.18); box-shadow: 0 0 14px color-mix(in srgb, var(--spell-color) 45%, transparent); }
.spell-slot.side { opacity: .66; }
.spell-slot.side:first-child { transform: perspective(100px) rotateX(-7deg); }
.spell-slot.side:last-child { transform: perspective(100px) rotateX(7deg); }

.fire-button { position: relative; width: clamp(88px, 15vh, 126px); height: clamp(88px, 15vh, 126px); flex: none; border: 2px solid color-mix(in srgb, var(--active-spell, #9c7cff) 70%, white); border-radius: 50%; color: white; background: radial-gradient(circle at 38% 30%, color-mix(in srgb, var(--active-spell, #9c7cff) 75%, white), var(--active-spell, #6d4de0) 42%, #20194b 72%); box-shadow: inset 0 0 0 5px rgba(255,255,255,.11), inset 0 -12px 22px rgba(0,0,0,.22), 0 0 0 7px rgba(14,13,37,.75), 0 0 28px color-mix(in srgb, var(--active-spell, #9c7cff) 42%, transparent); display: grid; place-content: center; gap: 2px; cursor: pointer; transition: transform .1s, filter .1s; overflow: hidden; }
.fire-button > span { font-size: clamp(30px, 5vh, 44px); line-height: .9; text-shadow: 0 0 12px #fff; }
.fire-button small { color: rgba(255,255,255,.85); }
.fire-button.pressed, .fire-button:active { transform: scale(.92); filter: brightness(1.18); }
.fire-button.unavailable { filter: grayscale(.5) brightness(.65); }
.fire-button > i { position: absolute; inset: -2px; border-radius: 50%; background: conic-gradient(rgba(8,8,20,.78) var(--cooldown, 0%), transparent 0); pointer-events: none; }

.screen { position: absolute; z-index: 30; inset: 0; display: none; place-items: center; padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); background: rgba(4,5,14,.62); backdrop-filter: blur(9px); overflow: auto; touch-action: pan-y; }
.screen.active { display: grid; }
.start-screen { text-align: center; align-content: center; background: radial-gradient(circle at 50% 30%, rgba(59,45,126,.24), transparent 36%), linear-gradient(180deg, rgba(5,7,18,.62), rgba(5,6,14,.9)); }
.start-screen::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: .26; background: linear-gradient(90deg, transparent 49.8%, rgba(164,184,255,.22) 50%, transparent 50.2%), linear-gradient(0deg, transparent 49.8%, rgba(164,184,255,.12) 50%, transparent 50.2%); background-size: 70px 70px; transform: perspective(500px) rotateX(65deg) scale(1.5) translateY(25%); mask-image: linear-gradient(transparent, black); }
.start-particles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.start-particles::before, .start-particles::after { content: "✦  ·  ✧  ·  ✦  ·  ✧  ·  ✦"; position: absolute; left: 10%; right: 10%; top: 17%; color: rgba(148,207,255,.25); letter-spacing: 6vw; font-size: 14px; animation: drift 7s ease-in-out infinite alternate; }
.start-particles::after { top: auto; bottom: 20%; color: rgba(255,211,122,.16); animation-delay: -3s; }
@keyframes drift { to { transform: translate3d(2vw,-12px,0); opacity: .55; } }
.logo-mark { position: relative; width: 70px; height: 70px; margin: 0 auto 7px; display: grid; place-items: center; filter: drop-shadow(0 0 18px rgba(99,228,255,.5)); }
.logo-mark i { position: absolute; inset: 6px; border: 1px solid rgba(99,228,255,.55); transform: rotate(45deg); box-shadow: inset 0 0 18px rgba(99,228,255,.15), 0 0 16px rgba(99,228,255,.15); }
.logo-mark i::after { content: ""; position: absolute; inset: 7px; border: 1px solid rgba(255,211,122,.6); }
.logo-mark b { position: relative; font-size: 29px; color: #effcff; text-shadow: 0 0 14px var(--cyan); }
.eyebrow { margin: 0 0 6px; color: var(--gold); font-size: 10px; font-weight: 800; letter-spacing: .28em; text-transform: uppercase; }
h1 { margin: 0; font: 700 clamp(48px, 10vw, 96px)/.82 Georgia, "Times New Roman", serif; letter-spacing: -.055em; color: #fff8e9; text-shadow: 0 5px 0 #311d50, 0 0 35px rgba(153,120,255,.38); }
h1 span { display: block; margin: 0 0 7px; font: 500 clamp(17px, 3vw, 28px)/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: .24em; text-transform: uppercase; color: #b8b7d4; text-shadow: none; }
.subtitle { margin: 18px 0 15px; color: #bebcd1; font: 15px/1.45 Georgia, serif; }
.name-field { width: min(340px, 80vw); margin: 0 auto 12px; display: grid; gap: 5px; text-align: left; }
.name-field span { padding-left: 12px; color: #aaa9c7; font-size: 9px; letter-spacing: .12em; text-transform: uppercase; }
.name-field input { width: 100%; height: 42px; padding: 0 15px; border: 1px solid rgba(177,194,255,.25); border-radius: 12px; outline: 0; color: white; background: rgba(12,14,34,.75); text-align: center; font-family: Georgia, serif; font-size: 18px; box-shadow: inset 0 1px 0 rgba(255,255,255,.06); user-select: text; }
.name-field input:focus { border-color: rgba(99,228,255,.65); box-shadow: 0 0 0 3px rgba(99,228,255,.08); }
.menu-buttons { width: min(380px, 86vw); margin: auto; display: grid; gap: 8px; }
.primary-button, .secondary-button { border-radius: 14px; cursor: pointer; transition: transform .12s, filter .12s, border-color .12s; }
.primary-button { min-height: 50px; padding: 8px 22px; border: 1px solid rgba(255,222,157,.75); color: #27162e; background: linear-gradient(135deg, #ffe1a0, #d8903e); box-shadow: inset 0 1px 0 rgba(255,255,255,.65), 0 7px 18px rgba(109,55,18,.28); font-weight: 800; }
.primary-button span { display: block; }
.primary-button small { display: block; margin-top: 2px; color: rgba(44,24,38,.65); font-size: 9px; font-weight: 700; letter-spacing: .04em; }
.secondary-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.secondary-button { min-height: 42px; padding: 8px 15px; border: 1px solid rgba(177,194,255,.21); color: #dbdaeb; background: rgba(24,27,59,.72); }
.primary-button:active, .secondary-button:active { transform: scale(.97); filter: brightness(1.12); }
.keyboard-hint { margin: 13px 0 0; color: rgba(180,179,202,.55); font-size: 9px; letter-spacing: .02em; }

.modal-card, .talent-card, .parchment { position: relative; width: min(720px, 94vw); padding: 31px; border: 1px solid rgba(168,188,255,.25); border-radius: 24px; background: linear-gradient(145deg, rgba(27,29,65,.98), rgba(9,11,29,.98)); box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 30px 90px rgba(0,0,0,.55); text-align: center; }
.modal-card::before, .talent-card::before { content: ""; position: absolute; inset: 7px; border: 1px solid rgba(255,211,122,.1); border-radius: 18px; pointer-events: none; }
.modal-card h2, .talent-card h2, .parchment h2 { margin: 0 0 11px; font: 700 clamp(26px, 4vw, 40px)/1 Georgia, serif; color: #fff4dd; }
.modal-card p, .parchment p { color: #c1c0d5; line-height: 1.55; }
.close-button { position: absolute; z-index: 2; right: 13px; top: 12px; width: 38px; height: 38px; border: 0; border-radius: 50%; color: #c9c8dd; background: rgba(255,255,255,.06); font-size: 25px; cursor: pointer; }
.wide-card { width: min(960px, 95vw); }
.tutorial-grid { margin: 22px 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tutorial-grid article { padding: 18px 13px; border: 1px solid rgba(176,195,255,.14); border-radius: 16px; background: rgba(255,255,255,.035); }
.tutorial-grid h3 { margin: 10px 0 5px; font-family: Georgia, serif; font-size: 16px; }
.tutorial-grid p { margin: 0; font-size: 11px; line-height: 1.45; }
.tutorial-icon { height: 45px; display: grid; place-items: center; color: var(--cyan); font-size: 26px; letter-spacing: 4px; text-shadow: 0 0 12px currentColor; }
.cast-icon { color: var(--violet); font-size: 39px; }
.stone-icon { color: var(--gold); font-size: 40px; }
.wheel-icon { font-size: 15px; line-height: .72; }
.tutorial-close { min-width: 180px; }
.compact-card { width: min(430px, 92vw); display: grid; gap: 10px; }
.compact-card .primary-button, .compact-card .secondary-button { width: 100%; }

.parchment { width: min(610px, 92vw); border-color: rgba(255,211,122,.35); background: radial-gradient(circle at top, rgba(91,58,90,.25), transparent 40%), linear-gradient(145deg, #1d1932, #0b0d20); }
.parchment p:not(.eyebrow) { font-family: Georgia, serif; font-size: 16px; }
.parchment .primary-button { margin-top: 8px; }

.talent-screen { align-items: center; padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); overflow: hidden; }
.talent-card { width: min(980px, calc(100vw - 16px)); height: min(650px, calc(100vh - 16px)); height: min(650px, calc(100dvh - 16px)); max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); padding: 25px; overflow: hidden; display: flex; flex-direction: column; text-align: left; }
.talent-header { display: flex; align-items: center; justify-content: space-between; gap: 13px; padding: 0 5px 16px; border-bottom: 1px solid rgba(175,194,255,.16); }
.talent-header > div:first-of-type { flex: 1; min-width: 0; }
.talent-close-button { position: relative; z-index: 3; width: 42px; height: 42px; flex: none; border: 1px solid rgba(177,194,255,.25); border-radius: 13px; color: #e8e6f4; background: rgba(255,255,255,.055); font-size: 27px; line-height: 1; cursor: pointer; box-shadow: inset 0 1px rgba(255,255,255,.06); }
.talent-close-button:active { transform: scale(.94); background: rgba(99,228,255,.13); }
.talent-header h2 { margin-bottom: 5px; }
.talent-header p:not(.eyebrow) { margin: 0; color: #aaa9c4; font-size: 12px; }
.xp-orb { width: 76px; height: 76px; flex: none; border: 2px solid rgba(99,228,255,.6); border-radius: 50%; display: grid; place-content: center; text-align: center; background: radial-gradient(circle, rgba(99,228,255,.18), rgba(30,38,81,.65)); box-shadow: inset 0 0 17px rgba(99,228,255,.16), 0 0 20px rgba(99,228,255,.18); }
.xp-orb b { font: 700 26px/1 Georgia, serif; }
.xp-orb span { margin-top: 2px; color: var(--cyan); font-size: 9px; letter-spacing: .16em; }
.talent-tree { position: relative; flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; padding: 18px 5px 18px 1px; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; scrollbar-color: rgba(99,228,255,.35) transparent; scrollbar-width: thin; }
.talent-tree::-webkit-scrollbar { width: 5px; }
.talent-tree::-webkit-scrollbar-thumb { border-radius: 5px; background: rgba(99,228,255,.3); }
.talent-node { --node-color: #9c7cff; position: relative; min-height: 114px; padding: 13px 13px 12px 61px; border: 1px solid rgba(174,190,236,.15); border-radius: 16px; color: #d8d7e7; background: rgba(255,255,255,.035); text-align: left; cursor: pointer; transition: .16s; }
.talent-node:hover:not(:disabled) { transform: translateY(-2px); border-color: color-mix(in srgb, var(--node-color) 60%, transparent); }
.talent-node:disabled { cursor: not-allowed; opacity: .52; }
.talent-node.unlocked { border-color: color-mix(in srgb, var(--node-color) 65%, transparent); background: linear-gradient(135deg, color-mix(in srgb, var(--node-color) 15%, transparent), rgba(255,255,255,.035)); box-shadow: inset 0 0 20px color-mix(in srgb, var(--node-color) 8%, transparent); }
.talent-node.can-buy { animation: talentPulse 1.8s ease-in-out infinite; }
@keyframes talentPulse { 50% { box-shadow: 0 0 18px color-mix(in srgb, var(--node-color) 19%, transparent); } }
.talent-node .node-icon { position: absolute; left: 13px; top: 15px; width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid color-mix(in srgb, var(--node-color) 46%, transparent); border-radius: 12px; color: var(--node-color); background: color-mix(in srgb, var(--node-color) 12%, transparent); font-size: 21px; text-shadow: 0 0 10px var(--node-color); }
.talent-node h3 { margin: 0 0 4px; font: 700 16px/1.1 Georgia, serif; color: white; }
.talent-node p { margin: 0; font-size: 10px; line-height: 1.35; color: #aaa9c1; }
.talent-node .node-cost { position: absolute; right: 10px; top: 10px; padding: 3px 7px; border-radius: 8px; color: var(--gold); background: rgba(0,0,0,.28); font-size: 9px; font-weight: 800; }
.talent-node .node-state { position: absolute; left: 61px; bottom: 9px; color: color-mix(in srgb, var(--node-color) 80%, white); font-size: 8px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.talent-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-top: 15px; border-top: 1px solid rgba(175,194,255,.16); }
.talent-footer > span { color: #8f90aa; font-size: 10px; }
.talent-footer .primary-button { min-width: 220px; }

.score-card { width: min(520px, 93vw); }
.highscore-list { margin: 20px 0 0; padding: 0; list-style: none; counter-reset: rank; display: grid; gap: 7px; }
.highscore-list li { counter-increment: rank; min-height: 45px; padding: 8px 12px; border: 1px solid rgba(174,192,243,.12); border-radius: 12px; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; background: rgba(255,255,255,.03); text-align: left; }
.highscore-list li::before { content: counter(rank); width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: var(--gold); background: rgba(255,211,122,.09); font: 700 14px Georgia, serif; }
.highscore-list li:nth-child(1)::before { color: #23150a; background: linear-gradient(#ffe8a6, #d48d32); box-shadow: 0 0 12px rgba(255,211,122,.35); }
.highscore-list strong { font-family: Georgia, serif; }
.highscore-list span { color: #a6a5bd; font-size: 10px; }
.highscore-list b { color: white; }
.highscore-list .loading { display: block; padding: 20px; color: #a6a5bd; text-align: center; }
.highscore-list .loading::before { display: none; }

.result-rune { width: 80px; height: 80px; margin: auto; display: grid; place-items: center; border: 2px solid rgba(99,228,255,.48); border-radius: 50%; color: var(--cyan); font-size: 42px; text-shadow: 0 0 15px currentColor; box-shadow: inset 0 0 22px rgba(99,228,255,.12), 0 0 28px rgba(99,228,255,.13); }
.danger-rune { color: var(--red); border-color: rgba(255,100,127,.45); }
.result-stats { margin: 0 0 5px; }
.victory-card { border-color: rgba(255,211,122,.46); }

.message-banner { position: absolute; z-index: 15; left: 50%; top: 27%; min-width: min(450px, 80vw); padding: 13px 22px; border-block: 1px solid rgba(255,211,122,.32); color: white; background: linear-gradient(90deg, transparent, rgba(8,10,27,.92) 15% 85%, transparent); text-align: center; pointer-events: none; opacity: 0; transform: translate(-50%, 12px); transition: .32s; text-shadow: 0 2px 5px #000; }
.message-banner.show { opacity: 1; transform: translate(-50%, 0); }
.message-banner strong { display: block; color: var(--gold); font: 700 23px Georgia, serif; }
.message-banner span { color: #c3c2d5; font-size: 10px; letter-spacing: .05em; }
.toast { position: absolute; z-index: 45; left: 50%; bottom: 18px; max-width: min(480px, 88vw); padding: 10px 16px; border: 1px solid rgba(174,193,255,.26); border-radius: 13px; color: white; background: rgba(11,13,32,.94); box-shadow: 0 9px 30px rgba(0,0,0,.45); opacity: 0; transform: translate(-50%, 15px); transition: .25s; pointer-events: none; font-size: 11px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.fullscreen-button.active { color: var(--cyan); border-color: rgba(99,228,255,.5); box-shadow: 0 0 12px rgba(99,228,255,.2); }
#game:fullscreen, #game:-webkit-full-screen { width: 100vw; height: 100vh; background: var(--ink); }
#game::backdrop { background: var(--ink); }
.rotate-hint { position: absolute; z-index: 40; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 30px; color: white; background: rgba(5,6,16,.93); text-align: center; }
.rotate-hint span { font-size: 54px; color: var(--cyan); animation: rotatePhone 1.8s ease-in-out infinite; }
.rotate-hint b { max-width: 270px; font-family: Georgia, serif; font-size: 19px; }
@keyframes rotatePhone { 50% { transform: rotate(90deg); } }

@media (max-width: 800px), (max-height: 560px) {
    .hud { top: max(5px, env(safe-area-inset-top)); left: max(6px, env(safe-area-inset-left)); right: max(6px, env(safe-area-inset-right)); grid-template-columns: minmax(160px, 230px) 1fr minmax(120px, 180px); gap: 6px; }
    .vitals { min-height: 48px; padding: 5px 8px 5px 5px; border-radius: 14px; }
    .portrait { width: 38px; height: 38px; }
    .portrait-hat { transform: scale(.8) rotate(-5deg); transform-origin: top left; }
    .portrait-face { transform: scale(.8); transform-origin: top left; }
    .bar { height: 12px; }
    .bar b { font-size: 7px; }
    .chapter { min-width: 220px; padding: 6px 12px; }
    .chapter strong { font-size: 13px; }
    .chapter span { font-size: 8px; }
    .stats { min-height: 42px; padding: 4px 5px 4px 9px; gap: 7px; font-size: 8px; }
    .stats b { font-size: 11px; }
    .icon-button { width: 32px; height: 32px; }
    .boss-hud { top: 57px; }
    .move-pad { width: 235px; height: 110px; bottom: max(7px, env(safe-area-inset-bottom)); left: max(7px, env(safe-area-inset-left)); }
    .combat-controls { width: 108px; height: 266px; right: max(7px, env(safe-area-inset-right)); bottom: max(7px, env(safe-area-inset-bottom)); gap: 7px; }
    .spell-wheel { width: 104px; height: 177px; }
    .spell-slot { grid-template-columns: 25px 1fr; padding: 2px; }
    .spell-slot .spell-glyph { width: 25px; height: 25px; font-size: 14px; }
    .fire-button { width: 82px; height: 82px; }
    .fire-button > span { font-size: 29px; }
    .tutorial-grid { grid-template-columns: repeat(2, 1fr); }
    .modal-card { padding: 24px; }
    .talent-card { padding: 14px 18px; }
    .talent-header { padding-bottom: 10px; }
    .talent-close-button { width: 36px; height: 36px; border-radius: 11px; font-size: 24px; }
    .xp-orb { width: 58px; height: 58px; }
    .xp-orb b { font-size: 21px; }
    .talent-tree { gap: 8px; padding: 10px 0; }
    .talent-node { min-height: 91px; padding: 10px 8px 8px 48px; }
    .talent-node .node-icon { left: 8px; top: 11px; width: 32px; height: 32px; }
    .talent-node h3 { font-size: 13px; }
    .talent-node p { font-size: 8px; }
    .talent-node .node-state { left: 48px; bottom: 6px; }
    .keyboard-hint { display: none; }
    .logo-mark { width: 50px; height: 50px; }
    .logo-mark b { font-size: 22px; }
    h1 { font-size: clamp(42px, 11vh, 70px); }
    h1 span { font-size: 14px; }
    .subtitle { margin: 10px 0; font-size: 12px; }
    .name-field { margin-bottom: 8px; }
    .name-field input { height: 36px; font-size: 15px; }
    .primary-button { min-height: 43px; }
}

@media (max-width: 610px) and (orientation: landscape) {
    .chapter { display: none; }
    .hud { grid-template-columns: minmax(150px, 220px) 1fr; }
    .stats { grid-column: 2; }
    .spell-slot .spell-label { display: none; }
    .spell-slot { grid-template-columns: 1fr; justify-items: center; }
}

@media (max-width: 500px) {
    .secondary-row { grid-template-columns: 1fr 1fr; }
    #fullscreenMenuButton { grid-column: 1 / -1; }
}

@media (max-width: 660px) {
    .tutorial-grid { grid-template-columns: 1fr; }
    .talent-tree { grid-template-columns: 1fr 1fr; }
    .talent-footer { flex-direction: column; align-items: stretch; }
    .talent-footer .primary-button { width: 100%; }
    .talent-footer > span { text-align: center; }
}

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