:root {
    --cyan: #3df2ff;
    --magenta: #ff3df2;
    --gold: #ffd36b;
    --red: #ff2d55;
    --green: #5dff9e;
    --ink: #f4f1ff;
    --muted: rgba(230, 222, 255, 0.66);
    --panel: rgba(10, 5, 26, 0.9);
    --line: rgba(160, 140, 255, 0.22);
    --display: 'Orbitron', 'Arial Black', system-ui, sans-serif;
    --body: 'Rajdhani', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: #07020f;
    color: var(--ink);
    font-family: var(--body);
    font-size: 16px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

canvas#stage {
    position: fixed;
    inset: 0;
    display: block;
    touch-action: none;
}

.hidden {
    display: none !important;
}

button {
    font: inherit;
    color: inherit;
}

kbd {
    display: inline-block;
    min-width: 1.5em;
    padding: 0 0.35em;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-bottom-width: 2px;
    border-radius: 4px;
    font-family: var(--body);
    font-size: 0.8em;
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
    color: var(--muted);
}

.muted {
    color: var(--muted);
}

.center {
    text-align: center;
}

.gold {
    color: var(--gold);
}

.pos {
    color: var(--green);
}

.neg {
    color: #ff7a8f;
}

/* ------------------------------------------------------------ buttons */

.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45em;
    min-height: 44px;
    padding: 0 1.3em;
    border: 1px solid rgba(61, 242, 255, 0.45);
    border-radius: 10px;
    background: rgba(61, 242, 255, 0.06);
    font-family: var(--display);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:hover,
.btn:focus-visible,
.btn:focus {
    outline: none;
    border-color: var(--cyan);
    background: rgba(61, 242, 255, 0.16);
    box-shadow: 0 0 0 1px var(--cyan), 0 0 22px rgba(61, 242, 255, 0.35);
}

.btn:active {
    transform: translateY(1px);
}

.btn.primary {
    border-color: var(--cyan);
    background: linear-gradient(135deg, rgba(61, 242, 255, 0.35), rgba(255, 61, 242, 0.3));
    text-shadow: 0 0 8px rgba(61, 242, 255, 0.8);
}

.btn.danger {
    border-color: rgba(255, 45, 85, 0.55);
    background: rgba(255, 45, 85, 0.08);
}

.btn.danger:hover,
.btn.danger:focus {
    border-color: var(--red);
    background: rgba(255, 45, 85, 0.2);
    box-shadow: 0 0 0 1px var(--red), 0 0 22px rgba(255, 45, 85, 0.35);
}

.btn.small {
    min-height: 38px;
    padding: 0 0.9em;
    font-size: 0.7rem;
}

.btn.small b {
    color: var(--gold);
}

.btn[disabled] {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

.btn.on {
    border-color: var(--magenta);
    background: rgba(255, 61, 242, 0.22);
    box-shadow: 0 0 0 1px var(--magenta), 0 0 22px rgba(255, 61, 242, 0.35);
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(10, 5, 26, 0.6);
    cursor: pointer;
}

.icon-btn:hover,
.icon-btn:focus-visible {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 14px rgba(61, 242, 255, 0.4);
}

#btn-mute .off,
#btn-mute.muted .on {
    display: none;
}

#btn-mute.muted .off {
    display: block;
}

/* ------------------------------------------------------------ screens */

.screen {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(12px + var(--safe-top)) 12px calc(12px + var(--safe-bottom));
    background: rgba(5, 1, 14, 0.62);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.screen.behind {
    visibility: hidden;
}

#scr-title {
    background: radial-gradient(ellipse at center, rgba(7, 2, 15, 0.25), rgba(7, 2, 15, 0.85));
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.modal-screen {
    background: rgba(5, 1, 14, 0.5);
    animation: fade 0.18s ease-out;
}

@keyframes fade {
    from {
        opacity: 0;
    }
}

.panel {
    display: flex;
    flex-direction: column;
    width: min(680px, 100%);
    max-height: 100%;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: 0 0 0 1px rgba(255, 61, 242, 0.08), 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.panel.wide {
    width: min(1040px, 100%);
}

.panel.narrow {
    width: min(460px, 100%);
}

.panel header {
    padding: 20px 24px 10px;
}

.panel header h2,
.modal-title {
    margin: 0;
    font-family: var(--display);
    font-size: clamp(1.1rem, 3.2vw, 1.6rem);
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: linear-gradient(90deg, var(--cyan), var(--magenta));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.panel header p {
    margin: 6px 0 0;
}

.panel footer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    padding: 14px 24px 20px;
    border-top: 1px solid var(--line);
}

.scroll {
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(61, 242, 255, 0.4) transparent;
}

/* ------------------------------------------------------------ title */

.title-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}

.logo {
    display: flex;
    flex-direction: column;
    margin: 0;
    font-family: var(--display);
    font-weight: 900;
    line-height: 0.92;
    letter-spacing: 0.08em;
}

.logo .l1 {
    font-size: clamp(3rem, 13vw, 7rem);
    color: #fff;
    text-shadow: 0 0 6px #fff, 0 0 24px var(--cyan), 0 0 60px var(--cyan);
    animation: flicker 6s infinite;
}

.logo .l2 {
    font-size: clamp(2.4rem, 10.4vw, 5.6rem);
    color: transparent;
    -webkit-text-stroke: 2px var(--magenta);
    text-shadow: 0 0 24px rgba(255, 61, 242, 0.7);
}

@keyframes flicker {

    0%,
    18%,
    22%,
    62%,
    64%,
    100% {
        opacity: 1;
    }

    20%,
    63% {
        opacity: 0.55;
    }
}

.tagline {
    margin: 0;
    font-size: 1.15rem;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(300px, 80vw);
    margin-top: 10px;
}

.menu .btn {
    min-height: 50px;
    font-size: 0.95rem;
}

.foot {
    max-width: 440px;
    margin: 12px 0 0;
    font-size: 0.95rem;
    color: var(--muted);
}

/* ------------------------------------------------------------ cards */

.card {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s, background 0.15s;
}

.card:hover,
.card:focus {
    outline: none;
    border-color: var(--c, var(--cyan));
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.02));
    box-shadow: 0 0 0 1px var(--c, var(--cyan)), 0 0 26px color-mix(in srgb, var(--c, var(--cyan)) 40%, transparent);
    transform: translateY(-1px);
}

.card.selected {
    border-color: var(--gold);
}

.card-name {
    font-family: var(--display);
    font-weight: 800;
    font-size: 0.9rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.card-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--muted);
}

.card-desc {
    margin: 6px 0;
    color: var(--muted);
}

/* ship select */

.ship-layout {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    gap: 16px;
    padding: 8px 24px 16px;
    min-height: 0;
    overflow-y: auto;
}

.ship-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 10px;
    align-content: start;
}

.ship-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    text-align: center;
}

.ship-detail {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.25);
    align-self: start;
}

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

.detail-head h3 {
    margin: 0;
    font-family: var(--display);
    font-size: 1.1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.detail-head p {
    margin: 4px 0 0;
    color: var(--muted);
}

.detail-weapon {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 12px 0;
    padding: 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
}

.detail-weapon small {
    display: block;
    color: var(--muted);
}

.stat-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.stat-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

.stat-list li span {
    color: var(--muted);
}

.stat-list li.perk b {
    color: var(--gold);
    font-weight: 600;
    text-align: right;
}

.stat-list.compact li {
    padding: 3px 0;
}

/* stage select */

.stage-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    padding: 8px 24px 18px;
    overflow-y: auto;
}

.stage-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 210px;
    padding: 18px;
    overflow: hidden;
}

.stage-card::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.35;
    pointer-events: none;
}

.stage-card.st-grid {
    --c: var(--cyan);
}

.stage-card.st-grid::before {
    background: linear-gradient(transparent 95%, rgba(255, 61, 242, 0.5) 95%) 0 0 / 22px 22px, linear-gradient(90deg, transparent 95%, rgba(255, 61, 242, 0.5) 95%) 0 0 / 22px 22px;
    mask-image: linear-gradient(to top, #000, transparent 75%);
    -webkit-mask-image: linear-gradient(to top, #000, transparent 75%);
}

.stage-card.st-wastes {
    --c: #7ae8ff;
}

.stage-card.st-wastes::before {
    background: radial-gradient(circle at 80% 85%, rgba(122, 232, 255, 0.55), transparent 35%), radial-gradient(circle at 25% 95%, rgba(196, 255, 61, 0.4), transparent 30%);
}

.stage-card.st-void {
    --c: #b06bff;
}

.stage-card.st-void::before {
    background: radial-gradient(circle at 70% 80%, rgba(176, 107, 255, 0.6), transparent 40%), radial-gradient(circle at 20% 70%, rgba(255, 45, 85, 0.35), transparent 30%);
}

.stage-card > * {
    position: relative;
}

.stage-tag {
    align-self: flex-start;
    padding: 2px 8px;
    border: 1px solid var(--c);
    border-radius: 999px;
    font-family: var(--display);
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--c);
}

.stage-card .card-name {
    font-size: 1.15rem;
}

.stage-meta {
    display: flex;
    gap: 10px;
    margin-top: auto;
    font-size: 0.85rem;
    color: var(--muted);
}

.stage-best {
    font-size: 0.85rem;
    color: var(--gold);
}

.toggle-btn {
    margin-right: auto;
    order: -1;
}

#btn-stage-back {
    order: 0;
}

.toggle-btn small {
    font-family: var(--body);
    font-size: 0.8rem;
    letter-spacing: 0;
    text-transform: none;
    color: var(--muted);
}

.tb-dot {
    width: 12px;
    height: 12px;
    border: 1px solid currentColor;
    border-radius: 50%;
}

.toggle-btn.on .tb-dot {
    background: var(--magenta);
    box-shadow: 0 0 10px var(--magenta);
}

/* ------------------------------------------------------------ modals */

.modal {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(700px, 100%);
    max-height: 100%;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: 0 0 60px rgba(61, 242, 255, 0.12), 0 30px 80px rgba(0, 0, 0, 0.6);
    overflow-y: auto;
}

.modal.pop {
    animation: pop 0.22s cubic-bezier(0.2, 1.4, 0.5, 1);
}

@keyframes pop {
    from {
        transform: scale(0.94);
        opacity: 0;
    }
}

.modal-title {
    text-align: center;
}

.choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.choice {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 10px 14px 10px 10px;
    border-left: 4px solid var(--c);
}

.choice-icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
}

.choice-top {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.choice-top b {
    font-family: var(--display);
    font-size: 0.92rem;
    letter-spacing: 0.04em;
    color: var(--c);
}

.badge {
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    font-family: var(--display);
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.1em;
}

.is-new .badge {
    background: var(--gold);
    color: #241500;
}

.choice p {
    margin: 4px 0 0;
    font-size: 1rem;
    line-height: 1.25;
}

.choice .hint {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.85rem;
}

.choice-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.banish-hint {
    display: none;
    margin: 0;
    text-align: center;
    color: var(--magenta);
}

.banishing .banish-hint {
    display: block;
}

.banishing .choice[data-banishable='0'] {
    opacity: 0.35;
    pointer-events: none;
}

.banishing .choice[data-banishable='1'] {
    border-color: var(--magenta);
    animation: banishGlow 0.8s infinite alternate;
}

@keyframes banishGlow {
    from {
        box-shadow: 0 0 0 1px rgba(255, 61, 242, 0.4);
    }

    to {
        box-shadow: 0 0 0 1px var(--magenta), 0 0 24px rgba(255, 61, 242, 0.5);
    }
}

/* chest */

.modal.chest {
    align-items: stretch;
    overflow: hidden auto;
}

.chest-glow {
    position: absolute;
    inset: -40% -20% auto;
    height: 120%;
    background: conic-gradient(from 0deg, transparent, rgba(255, 211, 107, 0.18), transparent 30%, rgba(61, 242, 255, 0.15), transparent 60%, rgba(255, 61, 242, 0.15), transparent);
    animation: spin 6s linear infinite;
    pointer-events: none;
}

@keyframes spin {
    to {
        transform: rotate(1turn);
    }
}

#chest-items {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chest-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.35);
    animation: reveal 0.45s cubic-bezier(0.2, 1.3, 0.5, 1) both;
}

.chest-item.evolve {
    border-color: var(--gold);
    box-shadow: 0 0 24px rgba(255, 211, 107, 0.35);
}

.chest-item.evolve b {
    color: var(--gold);
}

.chest-item p {
    margin: 2px 0 0;
    color: var(--muted);
}

@keyframes reveal {
    from {
        opacity: 0;
        transform: scale(0.6) rotate(-4deg);
    }
}

#chest-credits {
    position: relative;
    text-align: center;
    color: var(--gold);
    font-family: var(--display);
    font-size: 0.8rem;
}

.modal.chest .btn {
    position: relative;
    align-self: center;
    min-width: 200px;
}

.relic .choice-icon img {
    filter: drop-shadow(0 0 6px var(--c));
}

/* ------------------------------------------------------------ HUD */

#hud {
    position: fixed;
    inset: 0;
    z-index: 5;
    pointer-events: none;
}

.xp {
    position: absolute;
    top: var(--safe-top);
    left: 0;
    right: 0;
    height: 14px;
    background: rgba(5, 1, 14, 0.75);
    border-bottom: 1px solid rgba(61, 242, 255, 0.3);
}

#xp-fill {
    height: 100%;
    background: linear-gradient(90deg, #1f8fff, var(--cyan), #c0fbff);
    box-shadow: 0 0 12px var(--cyan);
    transform-origin: left;
    transform: scaleX(0);
    transition: transform 0.12s linear;
}

#hud-level {
    position: absolute;
    right: 8px;
    top: -1px;
    font-family: var(--display);
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-shadow: 0 0 4px #000, 0 0 2px #000;
}

.hud-top {
    position: absolute;
    top: calc(18px + var(--safe-top));
    left: 8px;
    right: 8px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    gap: 8px;
}

.hud-slots {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.slots {
    display: flex;
    gap: 3px;
}

.slot {
    position: relative;
    width: 34px;
    height: 38px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.slot img {
    display: block;
    width: 30px;
    height: 30px;
}

.slot.empty {
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    height: 30px;
    width: 30px;
    margin: 0 2px 8px;
}

.pips {
    display: flex;
    gap: 1px;
    margin-top: 2px;
}

.pips i {
    width: 3px;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
}

.pips i.on {
    background: var(--cyan);
    box-shadow: 0 0 3px var(--cyan);
}

.slot.evolved img {
    filter: drop-shadow(0 0 5px var(--gold));
}

.relic-row {
    display: flex;
    gap: 4px;
}

.hud-mid {
    text-align: center;
}

#hud-timer {
    font-family: var(--body);
    font-size: clamp(1.7rem, 5.4vw, 2.6rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    letter-spacing: 0.06em;
    text-shadow: 0 0 10px rgba(61, 242, 255, 0.8), 0 2px 0 #000;
}

#hud-timer.urgent {
    color: #ff8fa3;
    text-shadow: 0 0 12px var(--red), 0 2px 0 #000;
    animation: pulse 1s infinite;
}

#hud-timer.overtime {
    color: var(--gold);
    text-shadow: 0 0 12px var(--gold), 0 2px 0 #000;
}

@keyframes pulse {
    50% {
        opacity: 0.6;
    }
}

#hud-sub {
    white-space: nowrap;
    font-family: var(--display);
    font-size: 0.6rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

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

.counter {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--body);
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 0 #000;
}

.counter svg {
    color: var(--muted);
}

.counter.gold {
    color: var(--gold);
}

.counter.gold svg {
    color: var(--gold);
}

.hud-btns {
    display: flex;
    gap: 6px;
    margin-top: 2px;
    pointer-events: auto;
}

#bossbar {
    position: absolute;
    left: 50%;
    top: calc(84px + var(--safe-top));
    width: min(560px, 84vw);
    transform: translateX(-50%);
    text-align: center;
    --boss: var(--red);
}

.bb-name {
    font-family: var(--display);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--boss);
    text-shadow: 0 0 10px var(--boss), 0 1px 0 #000;
}

.bb-track {
    height: 8px;
    margin-top: 3px;
    border: 1px solid var(--boss);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.bb-fill {
    height: 100%;
    background: var(--boss);
    box-shadow: 0 0 10px var(--boss);
    transform-origin: left;
    transition: transform 0.15s;
}

#banner {
    position: fixed;
    left: 50%;
    top: 26%;
    z-index: 8;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 92vw;
    transform: translateX(-50%);
    pointer-events: none;
}

.banner-item {
    text-align: center;
    animation: bannerIn 0.35s cubic-bezier(0.2, 1.4, 0.5, 1);
    transition: opacity 0.5s, transform 0.5s;
}

.banner-item.out {
    opacity: 0;
    transform: translateY(-12px);
}

@keyframes bannerIn {
    from {
        opacity: 0;
        transform: scale(1.4);
        letter-spacing: 0.5em;
    }
}

.b-title {
    font-family: var(--display);
    font-weight: 900;
    font-size: clamp(0.9rem, 3vw, 1.2rem);
    letter-spacing: 0.16em;
    text-shadow: 0 0 12px currentColor, 0 2px 0 #000;
}

.b-sub {
    margin-top: 2px;
    font-size: 1rem;
    color: var(--muted);
    text-shadow: 0 1px 2px #000;
}

.banner-item.warn {
    color: #ffb000;
}

.banner-item.info {
    color: var(--cyan);
}

.banner-item.boss {
    color: var(--red);
}

.banner-item.boss .b-title,
.banner-item.big .b-title {
    font-size: clamp(1.2rem, 4.8vw, 2.1rem);
}

.banner-item.big {
    color: var(--gold);
}

#stick {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 6;
    width: 0;
    height: 0;
    pointer-events: none;
}

#stick::before {
    content: '';
    position: absolute;
    left: -56px;
    top: -56px;
    width: 112px;
    height: 112px;
    border: 2px solid rgba(61, 242, 255, 0.35);
    border-radius: 50%;
    background: radial-gradient(rgba(61, 242, 255, 0.08), rgba(61, 242, 255, 0.02));
}

#stick-knob {
    position: absolute;
    left: -22px;
    top: -22px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #fff, var(--cyan) 45%, rgba(61, 242, 255, 0.3));
    box-shadow: 0 0 18px var(--cyan);
}

#fps {
    position: fixed;
    left: 8px;
    bottom: calc(6px + var(--safe-bottom));
    z-index: 30;
    font: 12px ui-monospace, monospace;
    color: var(--green);
    text-shadow: 0 1px 0 #000;
    pointer-events: none;
}

/* ------------------------------------------------------------ summaries */

#pause-body,
#over-body {
    padding: 4px 24px 16px;
    min-height: 0;
}

.summary {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
}

.summary h4,
.sum-scores h4 {
    margin: 10px 0 6px;
    font-family: var(--display);
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--cyan);
}

.dmg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.dmg-table th {
    text-align: left;
    font-weight: 600;
    color: var(--muted);
    font-size: 0.8rem;
}

.dmg-table td,
.dmg-table th {
    padding: 4px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    vertical-align: middle;
}

.dmg-table td:nth-child(n + 3),
.dmg-table th:nth-child(n + 3) {
    text-align: right;
    white-space: nowrap;
}

.dmg-table img {
    display: block;
}

.bar {
    height: 3px;
    margin-top: 3px;
    background: rgba(255, 255, 255, 0.08);
}

.bar i {
    display: block;
    height: 100%;
}

.sum-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sum-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.9rem;
}

.sum-chip.relic {
    border-color: rgba(255, 156, 246, 0.4);
}

.score-line {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}

.score-line span {
    font-family: var(--display);
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

.score-line b {
    font-family: var(--body);
    font-weight: 700;
    font-size: clamp(1.6rem, 5vw, 2.4rem);
    color: var(--gold);
    text-shadow: 0 0 16px rgba(255, 211, 107, 0.6);
}

.score-line em {
    font-style: normal;
    font-family: var(--display);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    color: var(--magenta);
}

#scr-over.won h2 {
    background: linear-gradient(90deg, var(--gold), var(--green));
    -webkit-background-clip: text;
    background-clip: text;
}

.sum-scores {
    margin-top: 6px;
}

.scores {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: rank;
}

.scores li {
    display: grid;
    grid-template-columns: 2em 1.2fr 1fr 0.8fr 1fr;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 6px;
    counter-increment: rank;
}

.scores li::before {
    content: counter(rank) '.';
    color: var(--muted);
}

.scores li span:first-child {
    color: var(--gold);
    font-weight: 700;
}

.scores li.me {
    background: rgba(255, 61, 242, 0.15);
    outline: 1px solid rgba(255, 61, 242, 0.4);
}

/* ------------------------------------------------------------ settings, help, codex */

.settings {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px 24px 16px;
}

.set-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    font-size: 1.05rem;
}

.set-row output {
    width: 3.2em;
    text-align: right;
    color: var(--muted);
}

input[type='range'] {
    width: min(200px, 40vw);
    accent-color: var(--cyan);
}

input[type='range']:focus {
    outline: 2px solid var(--cyan);
    outline-offset: 4px;
    border-radius: 4px;
}

.toggle {
    position: relative;
    width: 52px;
    height: 28px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    grid-column: 3;
}

.toggle .knob {
    position: absolute;
    left: 3px;
    top: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 0.15s, background 0.15s;
}

.toggle.on {
    border-color: var(--cyan);
    background: rgba(61, 242, 255, 0.2);
}

.toggle.on .knob {
    transform: translateX(24px);
    background: var(--cyan);
    box-shadow: 0 0 10px var(--cyan);
}

.toggle:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--cyan);
}

.help {
    padding: 0 24px 12px;
    font-size: 1.05rem;
    line-height: 1.4;
}

.help ul {
    padding-left: 1.2em;
}

.help li {
    margin-bottom: 6px;
}

.keys {
    width: 100%;
    border-collapse: collapse;
}

.keys td {
    padding: 5px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.keys td:first-child {
    color: var(--muted);
    width: 40%;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.tab {
    padding: 6px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    font-family: var(--display);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
}

.tab.selected {
    border-color: var(--cyan);
    background: rgba(61, 242, 255, 0.15);
}

.tab:focus,
.tab:hover {
    outline: none;
    box-shadow: 0 0 0 1px var(--cyan), 0 0 14px rgba(61, 242, 255, 0.3);
}

.codex {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 10px;
    padding: 4px 24px 16px;
    min-height: 0;
}

.codex-entry {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
}

.codex-entry b {
    font-family: var(--display);
    font-size: 0.82rem;
    letter-spacing: 0.04em;
}

.codex-entry p {
    margin: 3px 0;
    color: var(--muted);
    line-height: 1.25;
}

.codex-entry small {
    display: block;
    color: var(--muted);
    font-style: italic;
}

.recipe {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin: 4px 0 2px;
    font-size: 0.9rem;
}

.recipe span {
    color: var(--muted);
}

.noscript {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 760px) {
    .ship-layout {
        grid-template-columns: 1fr;
        padding: 6px 14px 12px;
    }

    .ship-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .ship-card {
        padding: 8px 4px;
    }

    .ship-card .card-sub {
        display: none;
    }

    .ship-card .card-name {
        font-size: 0.7rem;
    }

    .stage-grid {
        grid-template-columns: 1fr;
        padding: 6px 14px 12px;
    }

    .stage-card {
        min-height: 0;
    }

    .panel header {
        padding: 16px 16px 8px;
    }

    .panel footer {
        padding: 12px 14px 14px;
    }

    .summary {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    #pause-body,
    #over-body {
        padding: 2px 14px 12px;
    }

    .modal {
        padding: 14px;
    }

    .choice {
        grid-template-columns: 48px 1fr;
        gap: 10px;
        padding: 8px 10px 8px 8px;
    }

    .choice kbd {
        display: none;
    }

    .choice-icon,
    .choice-icon img {
        width: 48px;
        height: 48px;
    }

    .choice p {
        font-size: 0.95rem;
    }

    .codex {
        grid-template-columns: 1fr;
        padding: 4px 14px 12px;
    }

    .slot {
        width: 26px;
        height: 30px;
    }

    .slot img {
        width: 24px;
        height: 24px;
    }

    .slot.empty {
        width: 22px;
        height: 22px;
        margin: 0 2px 8px;
    }

    .pips {
        display: none;
    }

    #bossbar {
        top: calc(96px + var(--safe-top));
    }

    .scores li {
        grid-template-columns: 2em 1fr 1fr 0.8fr;
    }

    .scores li span:last-child {
        display: none;
    }
}

@media (max-height: 520px) {
    .logo .l1 {
        font-size: 3rem;
    }

    .logo .l2 {
        font-size: 2.4rem;
    }

    .menu .btn {
        min-height: 40px;
    }

    .title-wrap {
        gap: 6px;
    }

    .stage-card {
        min-height: 0;
    }
}

@media (hover: none) {
    .btn kbd,
    .choice kbd {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {

    .logo .l1,
    #hud-timer.urgent,
    .chest-glow,
    .banishing .choice[data-banishable='1'] {
        animation: none;
    }
}
