:root {
    --bg-0: #06070d;
    --bg-1: #0b0f1a;
    --bg-2: #131a2c;
    --line: #1f2942;
    --text: #e7ecf7;
    --muted: #8995b3;
    --accent: #ff8a3d;
    --accent-2: #ffb46b;
    --good: #6cf2a6;
    --bad: #ff5d6c;
    --warn: #ffd166;
    --info: #6ec1ff;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    --pixel: "Press Start 2P", "VT323", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(255, 138, 61, 0.08), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(110, 193, 255, 0.06), transparent 60%),
        linear-gradient(180deg, var(--bg-0), var(--bg-1) 60%, var(--bg-0));
    color: var(--text);
    font-family: var(--pixel);
    font-size: 12px;
    line-height: 1.5;
    letter-spacing: 0.02em;
}

.app {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100%;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 22px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
    backdrop-filter: blur(6px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 18px;
    height: 18px;
    background:
        radial-gradient(circle at 35% 35%, #fff3b0 0 30%, transparent 31%),
        radial-gradient(circle at 50% 50%, var(--accent) 0 60%, transparent 61%);
    border-radius: 4px;
    box-shadow: 0 0 18px rgba(255, 138, 61, 0.65);
}

.brand h1 {
    margin: 0;
    font-size: 14px;
    letter-spacing: 0.12em;
    color: var(--text);
}

.brand-tag {
    color: var(--muted);
    font-size: 10px;
    padding: 4px 6px;
    border: 1px solid var(--line);
    border-radius: 4px;
    text-transform: uppercase;
}

.topbar-actions {
    display: flex;
    gap: 8px;
}

.stage {
    padding: 18px 22px;
}

[hidden] {
    display: none !important;
}

.screen-host {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.canvas-host {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 18px;
    align-items: start;
}

@media (max-width: 980px) {
    .canvas-host {
        grid-template-columns: minmax(0, 1fr);
    }
    .sidebar {
        order: 2;
    }
}

.game-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    max-height: min(85vh, calc(100dvh - 9rem));
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    background: #050811;
}

.canvas-host.is-gameplay .game-viewport {
    max-height: min(88vh, calc(100dvh - 8rem));
}

@media (display-mode: fullscreen) {
    body.in-game .game-viewport {
        max-height: calc(
            100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 7.5rem
        );
    }
}

.canvas-wrap {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: #050811;
    overflow: hidden;
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.45);
}

.hud,
#hud {
    position: absolute;
    inset: 0;
    z-index: 8;
    pointer-events: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
        "left center right"
        "buffs hint action";
    gap: 8px;
    padding:
        max(12px, env(safe-area-inset-top, 0px))
        max(12px, env(safe-area-inset-right, 0px))
        max(16px, env(safe-area-inset-bottom, 0px))
        max(12px, env(safe-area-inset-left, 0px));
    box-sizing: border-box;
}

.hud[hidden],
#hud[hidden] {
    display: none !important;
}

.hud-top-center {
    grid-area: center;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-width: 0;
    pointer-events: none;
}

.canvas-overlays {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 9;
    display: grid;
    place-items: center;
}

.canvas-overlays .hud-toast {
    align-self: center;
    justify-self: center;
}

.canvas-overlays .door-hint {
    align-self: end;
    justify-self: center;
    margin-bottom: 12px;
}

.canvas-wrap::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.35);
    z-index: 2;
    transition: box-shadow 0.25s ease;
}

.canvas-wrap.room-clear-flash::after {
    box-shadow: inset 0 0 100px rgba(108, 242, 166, 0.35);
}

.canvas-wrap.low-hp-danger::after {
    box-shadow: inset 0 0 120px rgba(255, 40, 60, 0.45);
    animation: low-hp-vignette 1.1s ease-in-out infinite;
}

@keyframes low-hp-vignette {
    0%, 100% { box-shadow: inset 0 0 100px rgba(255, 40, 60, 0.35); }
    50% { box-shadow: inset 0 0 140px rgba(255, 40, 60, 0.55); }
}

.canvas-wrap.hp-danger::after {
    box-shadow: inset 0 0 80px 24px rgba(255, 93, 108, 0.45);
    background: radial-gradient(ellipse at center, transparent 40%, rgba(120, 10, 24, 0.35) 100%);
}

.canvas-wrap.spell-success-flash::after {
    box-shadow: inset 0 0 100px rgba(255, 209, 102, 0.55);
    animation: spell-flash-pulse 0.4s ease-out;
}

@keyframes spell-flash-pulse {
    0% { box-shadow: inset 0 0 140px rgba(255, 209, 102, 0.7); }
    100% { box-shadow: inset 0 0 60px rgba(255, 209, 102, 0.2); }
}

#game {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: #050811;
}

.sidebar {
    border: 1px solid var(--line);
    background: rgba(11, 15, 26, 0.7);
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: var(--shadow);
}

.sidebar h3 {
    margin: 12px 0 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--muted);
}

.sidebar h3:first-child {
    margin-top: 0;
}

.sidebar ul {
    margin: 0;
    padding-left: 14px;
}

.sidebar p,
.sidebar li {
    color: var(--text);
}

.sidebar code {
    color: var(--accent-2);
    background: rgba(255, 138, 61, 0.08);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 11px;
}

.footer {
    display: flex;
    justify-content: space-between;
    padding: 12px 22px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 10px;
}

/* ====== HUD (overlay on canvas) ====== */

.hud-kill-feed {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-width: 100%;
    margin: 0 0 2px;
    padding: 0;
    list-style: none;
    pointer-events: none;
}

.kill-feed-line {
    font-size: 9px;
    letter-spacing: 0.1em;
    color: var(--muted);
    text-shadow: 0 2px 0 #000;
    opacity: 0;
    animation: kill-feed-in 0.2s ease forwards;
}

.kill-feed-line.elite {
    color: #ffd166;
}

.kill-feed-line.boss,
.kill-feed-item.kill-boss {
    color: var(--bad);
}

.kill-feed-item {
    font-size: 9px;
    letter-spacing: 0.1em;
    color: var(--muted);
    text-shadow: 0 2px 0 #000;
    list-style: none;
}

.kill-feed-item.kill-elite {
    color: #ffd166;
}

.kill-feed-item.kill-champion {
    color: #ff8a3d;
}

.hud-quest {
    width: 100%;
    max-width: 240px;
    margin-top: 4px;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(5, 8, 17, 0.95);
    pointer-events: auto;
    isolation: isolate;
}

.hud-quest-title {
    display: list-item;
    font-size: 9px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent-2);
    margin-bottom: 0;
    cursor: pointer;
    list-style: none;
}

.hud-quest-title::-webkit-details-marker {
    display: none;
}

.hud-quest[open] .hud-quest-title {
    margin-bottom: 6px;
}

.hud-quest-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.quest-item {
    font-size: 9px;
    letter-spacing: 0.06em;
    color: var(--muted);
    text-shadow: none;
}

.quest-item.done {
    color: var(--good);
}

@keyframes kill-feed-in {
    from { opacity: 0; transform: translateX(-6px); }
    to { opacity: var(--kf-alpha, 0.85); transform: translateX(0); }
}

.hud-left {
    grid-area: left;
    align-self: start;
    justify-self: start;
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-shadow: 0 2px 0 #000;
    max-width: min(240px, 100%);
    max-height: min(58vh, calc(100% - 7rem));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    pointer-events: none;
}

.hud-left > * {
    pointer-events: auto;
    flex-shrink: 0;
}

@media (max-height: 720px) {
    .hud-quest:not([open]) .hud-quest-list {
        display: none;
    }
}

.hp-bar,
.mp-bar {
    position: relative;
    width: min(220px, 100%);
    height: 16px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.55);
    border-radius: 4px;
    overflow: hidden;
    backdrop-filter: blur(2px);
}

.hp-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff5d6c, #ff8a3d);
    transition: width 0.18s ease;
}

.hp-bar.hp-low .hp-bar-fill {
    animation: hp-pulse 0.9s ease-in-out infinite;
}

.hp-bar.hp-critical .hp-bar-fill {
    animation: hp-critical-pulse 0.55s ease-in-out infinite;
}

@keyframes hp-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.35); box-shadow: 0 0 8px rgba(255, 93, 108, 0.6); }
}

@keyframes hp-critical-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.5); box-shadow: 0 0 12px rgba(255, 40, 60, 0.85); }
}

.mp-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #4f8cff, #6ec1ff);
    transition: width 0.18s ease;
}

.hp-bar-label,
.mp-bar-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #fff;
    letter-spacing: 0.08em;
}

.level-pill {
    align-self: flex-start;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(255, 209, 102, 0.15);
    border: 1px solid rgba(255, 209, 102, 0.45);
    color: var(--warn);
    font-size: 10px;
    letter-spacing: 0.1em;
}

.typing-tier-pill {
    align-self: flex-start;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(178, 155, 255, 0.12);
    border: 1px solid rgba(178, 155, 255, 0.4);
    color: #d4c4ff;
    font-size: 9px;
    letter-spacing: 0.08em;
    max-width: 100%;
}

.rooms-pill {
    align-self: flex-start;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(110, 193, 255, 0.08);
    border: 1px solid rgba(110, 193, 255, 0.35);
    color: #9eb8d8;
    font-size: 9px;
    letter-spacing: 0.08em;
}

.rooms-pill.all-clear {
    color: var(--good);
    border-color: rgba(108, 242, 166, 0.55);
    background: rgba(108, 242, 166, 0.12);
}

.seed-pill {
    align-self: flex-start;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 9px;
    letter-spacing: 0.12em;
}

.home-seed {
    margin: 0 0 12px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.35);
    font-size: 10px;
    letter-spacing: 0.14em;
    color: var(--muted);
}

.home-seed strong {
    color: var(--accent-2);
    font-weight: normal;
}

.mp-bar.mp-low .mp-bar-fill {
    animation: mp-pulse 1.1s ease-in-out infinite;
}

@keyframes mp-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.25); box-shadow: 0 0 6px rgba(110, 193, 255, 0.55); }
}

.boss-hp-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 240px;
    padding: 4px 8px;
    border: 1px solid rgba(255, 93, 108, 0.5);
    border-radius: 4px;
    background: rgba(40, 8, 16, 0.75);
}

.boss-hp-label {
    font-size: 9px;
    letter-spacing: 0.2em;
    color: var(--bad);
}

.boss-hp-track {
    flex: 1;
    height: 8px;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 2px;
    overflow: hidden;
}

.boss-hp-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #7a1c2a, #ff5d6c);
    transition: width 0.15s ease;
}

.boss-hp-pct {
    font-size: 9px;
    color: var(--text);
    min-width: 32px;
    text-align: right;
}

.dash-cooldown-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 240px;
}

.dash-cooldown-label {
    font-size: 9px;
    letter-spacing: 0.18em;
    color: var(--info);
    min-width: 36px;
}

.dash-cooldown {
    flex: 1;
    height: 8px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.55);
    overflow: hidden;
}

.dash-cooldown-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #6cf2a6, #6ec1ff);
    transition: width 0.08s linear;
}

.dash-cooldown.ready .dash-cooldown-fill,
.dash-cooldown-wrap.ready .dash-cooldown-fill {
    box-shadow: 0 0 8px rgba(108, 242, 166, 0.5);
}

.hud-sound-btn.is-muted {
    color: var(--bad);
    opacity: 0.8;
}

.hp-bar.hp-low .hp-bar-fill {
    animation: hp-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes hp-pulse {
    from { filter: brightness(1); }
    to { filter: brightness(1.35); }
}

.hud-minimap {
    border: 1px solid var(--line);
    border-radius: 4px;
    background: rgba(5, 8, 17, 0.92);
    image-rendering: pixelated;
}

.hud-right {
    grid-area: right;
    align-self: start;
    justify-self: end;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    text-shadow: 0 2px 0 #000;
    max-width: min(200px, 100%);
    pointer-events: none;
}

.hud-right > * {
    pointer-events: auto;
}

.score-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.score-ghost {
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 0.14em;
}

.hud-combo {
    font-size: 14px;
    font-weight: bold;
    color: #ffd166;
    letter-spacing: 0.12em;
    text-shadow: 0 0 8px rgba(255, 209, 102, 0.6);
    animation: combo-pop 0.2s ease;
}

@keyframes combo-pop {
    from { transform: scale(1.3); }
    to { transform: scale(1); }
}

.hud-boss-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 140px;
    padding: 4px 8px;
    border: 1px solid rgba(255, 93, 108, 0.5);
    border-radius: 4px;
    background: rgba(20, 6, 12, 0.85);
}

.hud-boss-label {
    font-size: 9px;
    letter-spacing: 0.2em;
    color: #ff5d6c;
}

.hud-boss-track {
    flex: 1;
    height: 8px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 2px;
    overflow: hidden;
}

.hud-boss-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff5d6c, #ff8a3d);
    transition: width 0.15s ease;
}

.hud-minimap {
    display: block;
    width: 108px;
    height: 108px;
    border: 1px solid rgba(255, 209, 102, 0.35);
    border-radius: 6px;
    background: rgba(5, 8, 17, 0.92);
    image-rendering: pixelated;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.score-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.score-ghost {
    font-size: 11px;
    letter-spacing: 0.12em;
    color: rgba(255, 209, 102, 0.55);
}

.score {
    font-size: 24px;
    color: var(--accent-2);
    letter-spacing: 0.18em;
    transition: transform 0.15s ease, color 0.15s ease;
}

.score.score-pop {
    animation: score-pop 0.35s ease;
}

@keyframes score-pop {
    0% { transform: scale(1); color: var(--accent-2); }
    40% { transform: scale(1.18); color: #fff3b0; }
    100% { transform: scale(1); color: var(--accent-2); }
}

.hud-sound-btn {
    pointer-events: auto;
    align-self: flex-end;
    padding: 4px 8px;
    font-family: var(--pixel);
    font-size: 9px;
    letter-spacing: 0.12em;
    color: var(--muted);
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid var(--line);
    border-radius: 4px;
    cursor: pointer;
}

.hud-sound-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

.hud-sound-btn.muted,
.hud-sound-btn.is-muted {
    color: var(--bad);
    opacity: 0.75;
}

.hud-dash {
    width: 72px;
    height: 6px;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.hud-dash::after {
    content: "";
    display: block;
    height: 100%;
    width: var(--dash-pct, 100%);
    background: linear-gradient(90deg, #6cf2a6, #6ec1ff);
    transition: width 0.08s linear;
}

.hud-dash.ready {
    box-shadow: 0 0 8px rgba(108, 242, 166, 0.45);
}

.best {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.2em;
}

.best span {
    color: var(--text);
}

.hud-buffs {
    grid-area: buffs;
    align-self: end;
    justify-self: start;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-right: auto;
    pointer-events: none;
}

.hud-buffs > * {
    pointer-events: auto;
}

.buff-icon {
    position: relative;
    width: 56px;
    height: 56px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    overflow: hidden;
}

.buff-icon .buff-name {
    position: absolute;
    top: 4px;
    left: 6px;
    font-size: 10px;
    letter-spacing: 0.1em;
    color: var(--text);
    text-shadow: 0 2px 0 #000;
}

.buff-icon .buff-time {
    position: absolute;
    bottom: 4px;
    right: 6px;
    font-size: 10px;
    color: var(--accent-2);
    text-shadow: 0 2px 0 #000;
}

.buff-icon .buff-fill {
    position: absolute;
    inset: auto 0 0 0;
    background: rgba(255, 255, 255, 0.08);
}

.hud-timer {
    font-size: clamp(18px, 3.5vw, 28px);
    color: var(--bad);
    text-shadow: 0 2px 0 #000;
    letter-spacing: 0.2em;
    background: rgba(0, 0, 0, 0.4);
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 93, 108, 0.35);
}

.hud-toast {
    z-index: 10;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 18px;
    color: var(--text);
    font-size: 14px;
    letter-spacing: 0.2em;
    text-shadow: 0 2px 0 #000;
}

/* ====== Overlays / Cards ====== */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 8, 17, 0.75);
    backdrop-filter: blur(6px);
    padding: 24px;
    z-index: 12;
    pointer-events: auto;
}

.overlay[hidden] {
    display: none;
}

#overlay-pause {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.overlay-card {
    width: min(420px, 100%);
    background: linear-gradient(180deg, rgba(19, 26, 44, 0.95), rgba(11, 15, 26, 0.95));
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 22px 22px 18px;
    box-shadow: var(--shadow);
}

.overlay-card.wide {
    width: min(560px, 100%);
}

.overlay-title {
    margin: 0 0 4px;
    font-size: 18px;
    letter-spacing: 0.12em;
    color: var(--accent-2);
}

.overlay-title.bad {
    color: var(--bad);
}

.overlay-sub {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 11px;
}

.overlay-h3 {
    margin: 14px 0 6px;
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
}

.field {
    display: block;
    color: var(--muted);
    margin-bottom: 4px;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.field-input {
    width: 100%;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--pixel);
    font-size: 14px;
    letter-spacing: 0.08em;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.18);
}

.gameover-hint {
    margin: 0 0 14px;
    text-align: center;
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.gameover-hint kbd {
    font-family: var(--pixel);
    padding: 2px 6px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.45);
    color: var(--text);
}

.overlay-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
    cursor: pointer;
    font-family: var(--pixel);
    font-size: 11px;
    letter-spacing: 0.16em;
    padding: 10px 16px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: transform 0.04s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    text-transform: uppercase;
}

.primary-btn {
    background: linear-gradient(180deg, #ff8a3d, #f37320);
    color: #1a0e02;
    border-color: #f37320;
    box-shadow: 0 4px 0 #5e2d0a, 0 0 0 0 rgba(255, 138, 61, 0.4);
}

.primary-btn:hover {
    box-shadow: 0 4px 0 #5e2d0a, 0 0 0 4px rgba(255, 138, 61, 0.25);
}

.primary-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #5e2d0a, 0 0 0 4px rgba(255, 138, 61, 0.2);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    border-color: var(--line);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: #2c3a5e;
}

.ghost-btn {
    background: transparent;
    color: var(--muted);
    border-color: var(--line);
}

.ghost-btn:hover {
    color: var(--text);
    border-color: #2c3a5e;
}

.ghost-btn.danger:hover {
    color: var(--bad);
    border-color: rgba(255, 93, 108, 0.6);
}

.footnote {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 10px;
}

.result-grid {
    display: grid;
    gap: 6px;
    margin: 8px 0 4px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.4);
    font-size: 12px;
}

.result-row span {
    color: var(--muted);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-size: 10px;
}

.result-row strong {
    color: var(--text);
    font-weight: normal;
}

.result-row strong.good {
    color: var(--good);
}

.howto-list {
    margin: 6px 0 0;
    padding-left: 16px;
    line-height: 1.7;
}

kbd {
    display: inline-block;
    padding: 2px 6px;
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.45);
    color: var(--text);
    font-size: 10px;
    margin: 0 2px;
}

.pickup {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid currentColor;
    margin-right: 2px;
    font-size: 10px;
}

.pickup-h {
    color: #6cf2a6;
}

.pickup-s {
    color: #ffb46b;
}

.pickup-i {
    color: #b29bff;
}

/* ====== Leaderboard ====== */
.leaderboard-table {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    margin: 8px 0 4px;
    max-height: 320px;
    overflow-y: auto;
}

.lb-row {
    display: grid;
    grid-template-columns: 60px 1fr 90px;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
}

.lb-row:last-child {
    border-bottom: none;
}

.lb-row.head {
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.lb-rank-1 {
    color: #ffd166;
}

.lb-rank-2 {
    color: #c0c0c0;
}

.lb-rank-3 {
    color: #cd7f32;
}

.lb-empty {
    padding: 18px;
    text-align: center;
    color: var(--muted);
}

#footer-name {
    color: var(--accent-2);
}

/* ====== Screens (login, home, etc.) ====== */
.screen {
    width: 100%;
    max-width: 720px;
    background: linear-gradient(180deg, rgba(19, 26, 44, 0.95), rgba(11, 15, 26, 0.95));
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 28px 32px;
    box-shadow: var(--shadow);
}

.screen.wide {
    max-width: 960px;
}

.screen h2 {
    margin: 0 0 6px;
    font-size: 18px;
    letter-spacing: 0.12em;
    color: var(--accent-2);
}

.screen .screen-sub {
    color: var(--muted);
    font-size: 11px;
    margin: 0 0 22px;
}

.screen .form-grid {
    display: grid;
    gap: 14px;
}

.screen .form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.screen .form-row label {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.screen .form-row input {
    width: 100%;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--pixel);
    font-size: 14px;
    letter-spacing: 0.08em;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.screen .form-row input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.18);
}

.screen .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 22px;
}

.screen .links {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    font-size: 11px;
}

.screen .links a {
    color: var(--accent-2);
    text-decoration: none;
    cursor: pointer;
    border-bottom: 1px dotted rgba(255, 180, 107, 0.5);
}

.screen .links a:hover {
    color: var(--accent);
}

.screen .status {
    margin-top: 14px;
    font-size: 11px;
    min-height: 16px;
}

.screen .status.good {
    color: var(--good);
}

.screen .status.bad {
    color: var(--bad);
}

.screen .welcome {
    color: var(--accent-2);
    margin: 0 0 6px;
    font-size: 12px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.daily-seed {
    margin: -8px 0 18px;
    font-size: 11px;
    letter-spacing: 0.14em;
    color: var(--accent-2);
}

.home-section-title {
    margin: 20px 0 8px;
    font-size: 12px;
    letter-spacing: 0.2em;
    color: var(--muted);
    text-transform: uppercase;
}

.achievement-list {
    list-style: none;
    margin: 0 0 20px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.35);
    display: grid;
    gap: 6px;
}

.achievement-list .achievement {
    font-size: 11px;
    letter-spacing: 0.06em;
}

.achievement-list .achievement.unlocked {
    color: var(--good);
}

.achievement-list .achievement.locked {
    color: var(--muted);
    opacity: 0.65;
}

.screen .home-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 18px;
}

@media (max-width: 600px) {
    .screen .home-actions {
        grid-template-columns: 1fr;
    }
}

.home-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 8px 0 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
}

.home-stats .home-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.home-stats .home-stat span {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.home-stats .home-stat strong {
    color: var(--text);
    font-weight: normal;
    font-size: 14px;
    letter-spacing: 0.08em;
}

.typing-tier-panel {
    margin: 14px 0 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.4);
}

.typing-tier-panel.compact {
    margin: 0 0 16px;
}

.typing-tier-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 8px;
}

.typing-tier-pills.compact {
    margin: 8px 0 6px;
}

.typing-tier-pill-btn {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.45);
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.typing-tier-pill-btn:hover {
    color: var(--text);
    border-color: rgba(178, 155, 255, 0.55);
}

.typing-tier-pill-btn.active {
    color: #f0e8ff;
    border-color: rgba(178, 155, 255, 0.75);
    background: rgba(178, 155, 255, 0.18);
}

.typing-tier-legend {
    margin: 0;
    font-size: 9px;
    line-height: 1.5;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.spell-tier-line {
    margin: 0 0 12px;
    font-size: 9px;
    letter-spacing: 0.08em;
    color: var(--muted);
    text-align: center;
    line-height: 1.5;
}

/* ====== Slots picker ====== */
.slots-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin: 6px 0 4px;
}

@media (max-width: 720px) {
    .slots-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.slot-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.4);
    cursor: pointer;
    text-align: left;
    color: var(--text);
    font-family: var(--pixel);
    transition: border-color 0.15s ease, transform 0.05s ease, background 0.15s ease;
}

.slot-card:hover {
    border-color: var(--accent);
    background: rgba(255, 138, 61, 0.06);
}

.slot-card:active {
    transform: translateY(1px);
}

.slot-card.empty {
    opacity: 0.55;
    cursor: default;
}

.slot-card.empty:hover {
    border-color: var(--line);
    background: rgba(0, 0, 0, 0.4);
}

.slot-title {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 11px;
    color: var(--accent-2);
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.slot-meta {
    display: grid;
    gap: 4px;
    font-size: 11px;
    color: var(--muted);
}

.slot-meta b {
    color: var(--text);
    font-weight: normal;
}

.slot-tier {
    margin-top: 2px;
    color: var(--accent-2);
}

.slot-tier-pending {
    color: var(--muted);
    font-size: 10px;
}

/* ====== Stats screen ====== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 12px 0;
}

.stats-grid .stat {
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 14px;
}

.stats-grid .stat span {
    display: block;
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.stats-grid .stat strong {
    font-size: 18px;
    color: var(--text);
    font-weight: normal;
}

/* ====== Admin panel ====== */
.admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 18px;
    margin-top: 6px;
}

@media (max-width: 740px) {
    .admin-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.admin-list {
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    padding: 8px;
    max-height: 360px;
    overflow-y: auto;
}

.admin-user {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text);
    font-family: var(--pixel);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.admin-user:hover {
    background: rgba(255, 138, 61, 0.08);
    border-color: rgba(255, 138, 61, 0.3);
}

.admin-user.active {
    background: rgba(255, 138, 61, 0.18);
    border-color: var(--accent);
    color: var(--text);
}

.admin-user .role {
    margin-left: 8px;
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.admin-detail {
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    padding: 18px;
}

.admin-detail h3 {
    margin: 0 0 4px;
    color: var(--accent-2);
    letter-spacing: 0.12em;
    font-size: 14px;
}

.admin-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}

.admin-controls .danger {
    background: rgba(255, 93, 108, 0.1);
    border-color: rgba(255, 93, 108, 0.45);
    color: #ffbcc3;
}

.admin-controls .danger:hover {
    background: rgba(255, 93, 108, 0.18);
}

/* ====== Tutorial ====== */
.tutorial-grid {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 12px 18px;
    margin: 8px 0;
}

@media (max-width: 600px) {
    .tutorial-grid {
        grid-template-columns: 1fr;
    }
    .tutorial-grid .tutorial-key {
        margin-top: 8px;
    }
}

.tutorial-key {
    color: var(--info);
    text-align: right;
    font-size: 12px;
}

.tutorial-action {
    color: var(--text);
    font-size: 12px;
}

/* ====== Action bar (potions + spells) ====== */
.hud-action-bar {
    grid-area: action;
    align-self: end;
    justify-self: end;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    pointer-events: none;
    margin-bottom: 0;
}

.hud-action-bar > * {
    pointer-events: auto;
}

.hud-potion-bar {
    display: flex;
    gap: 6px;
}

.hud-spell-row {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.hud-fireball-count {
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent-2);
    text-shadow: 0 2px 0 #000;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.55);
}

.hud-fireball-count.has-charges {
    border-color: var(--accent);
    color: #fff3b0;
    box-shadow: 0 0 10px rgba(255, 209, 102, 0.35);
}

.potion-slot {
    width: 52px;
    height: 52px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    font-family: inherit;
    color: var(--text);
    padding: 0;
}

.potion-slot:hover:not(:disabled) {
    border-color: var(--accent);
}

.potion-slot:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.potion-slot .potion-key {
    position: absolute;
    top: 3px;
    left: 5px;
    color: var(--muted);
    font-size: 9px;
    letter-spacing: 0.08em;
}

.potion-slot .potion-glyph {
    font-size: 16px;
    line-height: 1;
    text-shadow: 0 2px 0 #000;
}

.potion-slot .potion-label {
    font-size: 7px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 2px;
}

.potion-slot .potion-count {
    position: absolute;
    bottom: 3px;
    right: 5px;
    font-size: 10px;
    font-weight: bold;
    color: var(--accent-2);
    text-shadow: 0 1px 0 #000;
}

.potion-slot.health { border-color: rgba(108, 242, 166, 0.45); }
.potion-slot.health .potion-glyph { color: #6cf2a6; }
.potion-slot.strength { border-color: rgba(255, 180, 107, 0.45); }
.potion-slot.strength .potion-glyph { color: #ffb46b; }
.potion-slot.invincibility { border-color: rgba(178, 155, 255, 0.45); }
.potion-slot.invincibility .potion-glyph { color: #b29bff; }

/* ====== Hotbar ====== */
.hud-hotbar {
    display: flex;
    gap: 6px;
}

.hotbar-slot {
    width: 56px;
    height: 56px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: var(--text);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-shadow: 0 2px 0 #000;
    position: relative;
}

.hotbar-slot.has-spell {
    border-color: var(--accent);
    background: rgba(255, 138, 61, 0.1);
}

.hotbar-slot.has-charge {
    box-shadow: 0 0 12px rgba(255, 209, 102, 0.45);
    animation: charge-glow 1.4s ease-in-out infinite;
}

@keyframes charge-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 209, 102, 0.35); }
    50% { box-shadow: 0 0 16px rgba(255, 209, 102, 0.65); }
}

.hotbar-slot .hotbar-num {
    position: absolute;
    top: 3px;
    left: 5px;
    color: var(--muted);
    font-size: 9px;
}

.hotbar-slot .hotbar-name {
    color: var(--accent-2);
    text-align: center;
    padding: 0 4px;
    line-height: 1.2;
    font-size: 9px;
}

.hotbar-slot .hotbar-badge {
    position: absolute;
    bottom: 3px;
    right: 4px;
    font-size: 8px;
    color: #fff3b0;
    font-weight: bold;
}

.hud-hint {
    grid-area: hint;
    justify-self: center;
    align-self: end;
    color: var(--muted);
    font-size: 9px;
    letter-spacing: 0.14em;
    background: rgba(0, 0, 0, 0.55);
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--line);
    text-align: center;
    white-space: normal;
    pointer-events: none;
    opacity: 0.82;
    max-width: min(92%, 36rem);
}

.hud-hint kbd {
    margin: 0 1px;
}

.hud-hint.faded {
    opacity: 0;
    transition: opacity 1.2s ease;
    pointer-events: none;
}

.door-hint {
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid var(--accent);
    background: rgba(20, 12, 6, 0.85);
    color: var(--accent-2);
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    text-shadow: 0 2px 0 #000;
    box-shadow: 0 0 16px rgba(255, 138, 61, 0.35);
    pointer-events: none;
    white-space: nowrap;
    z-index: 5;
}

.door-hint.locked {
    border-color: var(--bad);
    color: var(--bad);
    background: rgba(40, 6, 12, 0.85);
    box-shadow: 0 0 16px rgba(255, 93, 108, 0.3);
}

.door-hint kbd {
    margin: 0 2px;
    padding: 1px 6px;
    border: 1px solid currentColor;
    border-bottom-width: 2px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.55);
    color: inherit;
    font-size: 10px;
}

/* ====== Spell cast overlay ====== */
.spell-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 8, 17, 0.82);
    padding: 24px;
    z-index: 12;
    pointer-events: auto;
}

.spell-overlay[hidden] {
    display: none;
}

.spell-panel {
    width: min(720px, 100%);
    max-height: min(90vh, 520px);
    overflow-y: auto;
    background: rgba(8, 12, 22, 0.96);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 20px 22px 18px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.55), 0 0 0 4px rgba(255, 138, 61, 0.08);
}

.spell-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.spell-title {
    font-size: 11px;
    letter-spacing: 0.22em;
    color: var(--accent-2);
    text-transform: uppercase;
}

.spell-timer {
    font-size: 18px;
    letter-spacing: 0.12em;
    color: var(--warn);
    font-variant-numeric: tabular-nums;
}

.spell-timer.spell-timer-urgent {
    color: var(--bad);
    animation: hp-pulse 0.6s ease-in-out infinite;
}

.spell-prompt-wrap {
    position: relative;
    margin: 0 0 16px;
    min-height: 48px;
}

.spell-input-hint {
    margin: 12px 0 0;
    text-align: center;
    font-size: 9px;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.spell-prompt {
    margin: 0;
    font-size: 22px;
    line-height: 1.45;
    text-align: center;
    letter-spacing: 0.04em;
    color: var(--text);
    min-height: 32px;
    word-break: break-word;
    white-space: pre-wrap;
    pointer-events: none;
    user-select: none;
}

.spell-prompt .ok {
    color: #e8f4ff;
    text-shadow: 0 0 8px rgba(108, 242, 166, 0.35);
}

.spell-prompt .err {
    color: var(--bad);
    text-decoration: underline;
    text-decoration-color: rgba(255, 93, 108, 0.85);
}

.spell-prompt .pending {
    color: rgba(110, 130, 160, 0.55);
}

.spell-caret {
    display: inline-block;
    width: 2px;
    height: 1.05em;
    margin-left: 1px;
    vertical-align: text-bottom;
    background: var(--accent-2);
    box-shadow: 0 0 6px rgba(255, 209, 102, 0.65);
    animation: spell-caret-blink 0.9s step-end infinite;
}

@keyframes spell-caret-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.spell-stats {
    margin: 0 0 10px;
    text-align: center;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.2em;
}

.spell-meters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 20px;
    margin: 0 0 8px;
}

.spell-meter {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    align-items: center;
    gap: 8px;
}

.spell-meter-label {
    font-size: 9px;
    letter-spacing: 0.18em;
    color: var(--muted);
}

.spell-meter-value {
    font-size: 10px;
    letter-spacing: 0.06em;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    min-width: 4.5em;
    text-align: right;
}

.spell-meter-track {
    height: 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.5);
    overflow: hidden;
    min-width: 80px;
}

.spell-meter-fill {
    height: 100%;
    width: 0%;
    transition: width 0.12s ease;
}

.spell-meter-wpm {
    background: linear-gradient(90deg, #4f8cff, #6ec1ff);
}

.spell-meter-acc {
    background: linear-gradient(90deg, #6cf2a6, #a8ffd0);
}

.pause-stats {
    margin: 12px 0 16px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.35);
    font-size: 10px;
    color: var(--muted);
    line-height: 1.8;
    letter-spacing: 0.08em;
}

.pause-stats strong {
    color: var(--text);
    float: right;
}

.spell-alert {
    margin: 0 0 10px;
    text-align: center;
    color: var(--bad);
    font-size: 14px;
    letter-spacing: 0.2em;
}

.spell-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    color: transparent;
    caret-color: transparent;
    font-family: var(--pixel);
    font-size: 22px;
    line-height: 1.45;
    letter-spacing: 0.04em;
    outline: none;
    text-align: center;
    -webkit-text-fill-color: transparent;
}

.spell-input:focus {
    box-shadow: none;
}

.spell-prompt-wrap:focus-within {
    outline: 1px solid rgba(255, 138, 61, 0.45);
    outline-offset: 4px;
    border-radius: 6px;
}

/* ====== Inventory ====== */
.inventory-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 8, 17, 0.7);
    backdrop-filter: blur(4px);
    padding: 24px;
    z-index: 13;
    pointer-events: auto;
}

.inventory-overlay[hidden] {
    display: none;
}

.inventory-panel {
    width: min(420px, 92%);
    background: linear-gradient(180deg, rgba(19, 26, 44, 0.95), rgba(11, 15, 26, 0.95));
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px 18px;
    box-shadow: var(--shadow);
}

.inventory-title {
    margin: 0 0 10px;
    color: var(--accent-2);
    letter-spacing: 0.18em;
    font-size: 13px;
    text-align: center;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
}

.inv-cell {
    aspect-ratio: 1 / 1;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    cursor: pointer;
    color: var(--muted);
    font-size: 9px;
    letter-spacing: 0.06em;
    padding: 4px;
    transition: border-color 0.12s ease, background 0.12s ease;
}

.inv-cell:hover {
    border-color: var(--accent);
}

.inv-cell.selected {
    border-color: var(--accent);
    background: rgba(255, 138, 61, 0.1);
    color: var(--text);
}

.inv-cell.has-item {
    color: var(--text);
}

.inv-cell .inv-glyph {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #0b0f1a;
    margin-bottom: 2px;
}

.inv-cell.health .inv-glyph {
    background: #6cf2a6;
    box-shadow: 0 0 12px #6cf2a6;
}

.inv-cell.strength .inv-glyph {
    background: #ffb46b;
    box-shadow: 0 0 12px #ffb46b;
}

.inv-cell.invincibility .inv-glyph {
    background: #b29bff;
    box-shadow: 0 0 12px #b29bff;
}

.inventory-actions {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 16px;
}

.inventory-tip {
    margin: 14px 0 0;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.55;
    letter-spacing: 0.04em;
}

.inventory-tip kbd {
    margin: 0 1px;
    padding: 1px 6px;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.5);
    color: var(--text);
    font-size: 10px;
}

.topbar-actions:empty {
    display: none;
}

/* ====== Leaderboard list ====== */
.leaderboard {
    margin: 4px 0 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.leaderboard .leaderboard-row {
    display: grid;
    grid-template-columns: 60px minmax(0, 1fr) 80px;
    align-items: center;
    padding: 10px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.leaderboard .leaderboard-row:first-child {
    border-top: none;
}

.leaderboard .leaderboard-row .rank {
    color: var(--accent-2);
    font-size: 12px;
    letter-spacing: 0.18em;
}

.leaderboard .leaderboard-row .name {
    color: var(--text);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard .leaderboard-row .value {
    color: var(--text);
    font-size: 14px;
    text-align: right;
}

.leaderboard li.empty {
    padding: 18px 14px;
    text-align: center;
    color: var(--muted);
    font-size: 11px;
}

/* ====== Sound / dash HUD ====== */
.hud-sound-btn {
    pointer-events: auto;
    cursor: pointer;
    font-family: var(--pixel);
    font-size: 9px;
    letter-spacing: 0.14em;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.55);
    color: var(--accent-2);
    margin-bottom: 4px;
}

.hud-sound-btn.muted {
    color: var(--muted);
    opacity: 0.7;
}

.hud-dash {
    font-size: 9px;
    letter-spacing: 0.12em;
    color: var(--info);
    padding: 2px 6px;
    border: 1px solid rgba(110, 193, 255, 0.35);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.45);
}

.hud-dash.ready {
    color: var(--good);
    border-color: rgba(108, 242, 166, 0.45);
}

.score-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.score-ghost {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: rgba(255, 209, 102, 0.45);
    font-variant-numeric: tabular-nums;
}

.score.score-bump {
    animation: score-bump 0.38s ease;
}

@keyframes score-bump {
    0% { transform: scale(1); color: var(--accent-2); }
    40% { transform: scale(1.14); color: #fff3b0; }
    100% { transform: scale(1); color: var(--accent-2); }
}

.hud-hint.hint-faded {
    opacity: 0;
    transition: opacity 1.2s ease;
    pointer-events: none;
}

.canvas-wrap.rampage-flash::after {
    animation: rampage-vignette 0.35s ease-out;
    box-shadow: inset 0 0 120px rgba(255, 209, 102, 0.65);
}

@keyframes rampage-vignette {
    0% { box-shadow: inset 0 0 160px rgba(255, 209, 102, 0.85); }
    100% { box-shadow: inset 0 0 60px rgba(255, 209, 102, 0.15); }
}

.canvas-wrap.door-flash::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    background: radial-gradient(circle at center, rgba(255, 209, 102, 0.35), transparent 70%);
    animation: door-flash 0.45s ease-out;
}

@keyframes door-flash {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ====== Pause run stats ====== */
.pause-stats {
    display: grid;
    gap: 6px;
    margin: 8px 0 4px;
}

.pause-stats .result-row {
    margin: 0;
}

/* ====== Touch controls ====== */
.touch-controls {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 9;
}

.touch-controls[hidden] {
    display: none !important;
}

.touch-joystick {
    position: absolute;
    left: max(18px, env(safe-area-inset-left, 0px));
    bottom: max(18px, env(safe-area-inset-bottom, 0px));
    width: 112px;
    height: 112px;
    border-radius: 50%;
    border: 1px solid rgba(110, 193, 255, 0.35);
    background: rgba(0, 0, 0, 0.45);
    pointer-events: auto;
    touch-action: none;
}

.touch-joystick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 44px;
    height: 44px;
    margin: -22px 0 0 -22px;
    border-radius: 50%;
    background: rgba(110, 193, 255, 0.35);
    border: 1px solid rgba(110, 193, 255, 0.65);
    pointer-events: none;
}

.touch-fire-btn {
    position: absolute;
    right: max(18px, env(safe-area-inset-right, 0px));
    bottom: max(28px, env(safe-area-inset-bottom, 0px));
    pointer-events: auto;
    touch-action: manipulation;
    font-family: var(--pixel);
    font-size: 11px;
    letter-spacing: 0.16em;
    padding: 16px 20px;
    border-radius: 50%;
    border: 1px solid var(--accent);
    background: rgba(255, 138, 61, 0.25);
    color: var(--accent-2);
    cursor: pointer;
    box-shadow: 0 0 16px rgba(255, 138, 61, 0.35);
}

.touch-fire-btn:active {
    transform: scale(0.96);
    background: rgba(255, 138, 61, 0.45);
}

@media (hover: hover) and (pointer: fine) {
    .touch-controls.is-touch-only {
        display: none !important;
    }
}

.hud-kill-feed .kill-feed-item {
    padding: 2px 0;
}

.hud-kill-feed .kill-elite {
    color: var(--warn);
}

.hud-kill-feed .kill-boss {
    color: var(--bad);
}

.hud-minimap.spell-ready-pulse {
    animation: minimap-spell-pulse 1.1s ease-in-out infinite;
    box-shadow: 0 0 14px rgba(255, 209, 102, 0.55);
}

@keyframes minimap-spell-pulse {
    0%, 100% { filter: brightness(1); border-color: var(--line); }
    50% { filter: brightness(1.35); border-color: var(--warn); }
}

.spell-grade {
    margin: 0 0 8px;
    font-size: 22px;
    letter-spacing: 0.2em;
    text-align: center;
    text-shadow: 0 0 18px rgba(255, 209, 102, 0.45);
}

.spell-grade.grade-s { color: #fff3b0; }
.spell-grade.grade-a { color: #6cf2a6; }
.spell-grade.grade-b { color: #6ec1ff; }
.spell-grade.grade-c { color: var(--muted); }

.home-title-animated {
    animation: home-title-glow 2.8s ease-in-out infinite;
    background: linear-gradient(90deg, var(--accent-2), #fff3b0, var(--accent-2));
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

@keyframes home-title-glow {
    0%, 100% { background-position: 0% center; filter: brightness(1); }
    50% { background-position: 100% center; filter: brightness(1.2); }
}

.meta-shop {
    margin: 18px 0 8px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.25);
}

.meta-shop-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
    gap: 12px;
}

.meta-shop-coins {
    color: var(--warn);
    font-size: 11px;
    letter-spacing: 0.12em;
}

.meta-robe-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.meta-robe-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.35);
    color: var(--text);
    font-family: var(--pixel);
    font-size: 10px;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.meta-robe-btn:hover {
    border-color: var(--accent);
}

.meta-robe-btn.active {
    border-color: var(--good);
    box-shadow: 0 0 10px rgba(108, 242, 166, 0.35);
}

.meta-robe-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.color-shop {
    margin: 16px 0;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.28);
}

.color-shop-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.color-swatch {
    position: relative;
    min-width: 88px;
    padding: 10px 12px 10px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.4);
    cursor: pointer;
    font-family: var(--pixel);
    font-size: 10px;
    color: var(--text);
    text-align: left;
}

.color-swatch::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    vertical-align: middle;
    border-radius: 50%;
    background: var(--swatch, #6cf2a6);
    box-shadow: 0 0 8px var(--swatch, #6cf2a6);
}

.color-swatch.active {
    border-color: var(--good);
    box-shadow: 0 0 12px rgba(108, 242, 166, 0.35);
}

.color-swatch.locked {
    opacity: 0.72;
}

.color-swatch-cost {
    display: block;
    margin-top: 4px;
    margin-left: 24px;
    color: var(--warn);
    font-size: 9px;
}

.coin-balance {
    color: var(--warn);
    font-size: 11px;
    letter-spacing: 0.1em;
    margin: 0 0 4px;
}

.title-animated,
.home-title-animated {
    font-size: 22px !important;
    margin-bottom: 4px !important;
}

