/* BEARPROOF · "Terminal Arcade". Tokens match hq/index.html and docs/DECISIONS.md §2. */

@font-face {
    font-family: 'Jersey 10';
    src: url('./assets/fonts/jersey-10.woff2') format('woff2');
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('./assets/fonts/jetbrains-mono-400.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('./assets/fonts/jetbrains-mono-700.woff2') format('woff2');
    font-weight: 700;
    font-display: swap;
}

:root {
    --ink: #07090c;
    --panel: #0e1217;
    --panel-2: #131922;
    --grid: #1b222b;
    --line: #252e3a;
    --bull: #16e08a;
    --bull-deep: #0a8f55;
    --bear: #ff3b5c;
    --bear-deep: #b3173a;
    --gold: #ffc53d;
    --gold-deep: #b07a00;
    --info: #46c8ff;
    --text: #e8edf2;
    --muted: #7d8896;
    --display: 'Jersey 10', 'Courier New', monospace;
    --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    background: var(--ink);
    color: var(--text);
    font: 400 14px/1.45 var(--mono);
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

#app {
    position: fixed;
    inset: 0;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

#game {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
}

.touch-surface {
    position: absolute;
    inset: 0;
    touch-action: none;
    z-index: 1;
}

[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* --- Floating joystick -------------------------------------------------- */
.joy {
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    opacity: 0;
    z-index: 2;
    pointer-events: none;
    transition: opacity 90ms linear;
}
.joy::before,
.joy-knob {
    content: '';
    position: absolute;
    border: 2px solid rgba(232, 237, 242, 0.35);
}
.joy::before {
    width: 112px;
    height: 112px;
    left: -56px;
    top: -56px;
    border-radius: 50%;
    background: rgba(7, 9, 12, 0.25);
}
.joy-knob {
    width: 44px;
    height: 44px;
    left: -22px;
    top: -22px;
    border-radius: 50%;
    background: rgba(22, 224, 138, 0.55);
    border-color: var(--bull);
}

/* --- HUD ----------------------------------------------------------------- */
.hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    gap: 8px;
    padding: calc(8px + var(--safe-t)) calc(12px + var(--safe-r)) 0 calc(12px + var(--safe-l));
    pointer-events: none;
    text-shadow: 0 2px 0 var(--ink);
}
.hud-left {
    display: grid;
    gap: 5px;
    max-width: 180px;
}
.hud-lvl {
    font: 400 20px/1 var(--display);
    color: var(--muted);
}
.hud-lvl b {
    color: var(--text);
    font-weight: 400;
}
.bar {
    position: relative;
    height: 8px;
    background: var(--panel);
    border: 2px solid var(--ink);
    box-shadow: 0 0 0 1px var(--line);
}
.bar i {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    transition: width 120ms linear;
}
.bar-xp i {
    background: var(--gold);
}
.bar-hp {
    height: 10px;
}
.bar-hp i {
    background: var(--bull);
}
.bar-hp.low i {
    background: var(--bear);
}
.hud-mid {
    text-align: center;
}
.hud-time {
    font: 400 40px/0.9 var(--display);
    letter-spacing: 0.02em;
}
.hud-wave {
    font-size: 10px;
    letter-spacing: 0.14em;
    color: var(--muted);
    text-transform: uppercase;
    margin-top: 2px;
}
.hud-right {
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 10px;
}
.hud-score {
    text-align: right;
}
.hud-score small {
    display: block;
    font-size: 9px;
    letter-spacing: 0.14em;
    color: var(--muted);
}
.hud-score b {
    font: 400 28px/0.9 var(--display);
    color: var(--gold);
}
.icon-btn {
    pointer-events: auto;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    background: var(--panel);
    border: 2px solid var(--line);
    color: var(--text);
    cursor: pointer;
}
.icon-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    shape-rendering: crispEdges;
}

.loadout {
    position: absolute;
    z-index: 3;
    top: calc(64px + var(--safe-t));
    left: calc(12px + var(--safe-l));
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 50vw;
    pointer-events: none;
}
.slot {
    position: relative;
    width: 26px;
    height: 26px;
    background: rgba(14, 18, 23, 0.8);
    border: 1px solid var(--line);
    display: grid;
    place-items: center;
}
.slot canvas {
    width: 18px;
    height: 18px;
    image-rendering: pixelated;
}
.slot b {
    position: absolute;
    right: -1px;
    bottom: -3px;
    font: 400 12px/1 var(--display);
    color: var(--gold);
    text-shadow: 0 1px 0 var(--ink);
}
.slot.passive {
    border-style: dashed;
}

.bossbar {
    position: absolute;
    z-index: 3;
    left: 50%;
    transform: translateX(-50%);
    top: calc(76px + var(--safe-t));
    width: min(420px, 70vw);
    text-align: center;
    pointer-events: none;
}
.bossbar-name {
    font: 400 18px/1 var(--display);
    color: var(--bear);
    letter-spacing: 0.06em;
    margin-bottom: 4px;
    text-shadow: 0 2px 0 var(--ink);
}
.bar-boss {
    height: 10px;
}
.bar-boss i {
    background: var(--bear);
}

.toast {
    position: absolute;
    z-index: 4;
    left: 50%;
    top: 32%;
    transform: translate(-50%, -50%) scale(0.9);
    font: 400 44px/1 var(--display);
    letter-spacing: 0.04em;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    text-shadow:
        0 3px 0 var(--ink),
        3px 0 0 var(--ink),
        -3px 0 0 var(--ink),
        0 -3px 0 var(--ink);
    transition:
        opacity 160ms ease,
        transform 160ms ease;
}
.toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
.toast.gold {
    color: var(--gold);
}
.toast.bull {
    color: var(--bull);
}
.toast.bear {
    color: var(--bear);
}

.hint-move {
    position: absolute;
    z-index: 3;
    left: 50%;
    bottom: calc(18% + var(--safe-b));
    transform: translateX(-50%);
    font: 400 22px/1 var(--display);
    letter-spacing: 0.08em;
    color: var(--text);
    opacity: 0.85;
    white-space: nowrap;
    pointer-events: none;
    animation: hint-pulse 1.1s steps(2, jump-none) infinite;
    text-shadow: 0 2px 0 var(--ink);
}
.hint-move span {
    color: var(--muted);
}
@media (pointer: coarse) {
    .hint-move span {
        display: none;
    }
}
@keyframes hint-pulse {
    50% {
        opacity: 0.35;
    }
}

/* --- Boss intro card ------------------------------------------------------ */
.boss-card {
    position: absolute;
    z-index: 5;
    left: 0;
    right: 0;
    top: 38%;
    transform: translateY(-50%);
    background: var(--bear);
    color: var(--ink);
    text-align: center;
    padding: 0 16px 14px;
    box-shadow:
        0 6px 0 var(--bear-deep),
        0 0 0 4px var(--ink);
    pointer-events: none;
    animation: boss-in 260ms steps(4, end);
}
@keyframes boss-in {
    from {
        transform: translateY(-50%) scaleY(0);
    }
}
.boss-ticker {
    overflow: hidden;
    white-space: nowrap;
    background: var(--ink);
    color: var(--bear);
    font: 700 11px/22px var(--mono);
    letter-spacing: 0.12em;
    margin: 0 -16px 10px;
}
.boss-ticker span {
    display: inline-block;
    padding-left: 100%;
    animation: ticker 5s linear infinite;
}
@keyframes ticker {
    to {
        transform: translateX(-100%);
    }
}
.boss-warn {
    font: 700 12px/1 var(--mono);
    letter-spacing: 0.2em;
}
.boss-title {
    font: 400 clamp(48px, 14vw, 104px) / 0.9 var(--display);
    margin-top: 6px;
    text-transform: uppercase;
}
.boss-tag {
    font: 700 13px/1.3 var(--mono);
    margin-top: 4px;
}

/* --- Screens (menus) -------------------------------------------------------- */
.screen {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: calc(20px + var(--safe-t)) calc(16px + var(--safe-r)) calc(20px + var(--safe-b))
        calc(16px + var(--safe-l));
    background: rgba(7, 9, 12, 0.82);
    overflow-y: auto;
    text-align: center;
}
.screen-title {
    background:
        linear-gradient(rgba(7, 9, 12, 0.55), rgba(7, 9, 12, 0.92)),
        linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 40px 40px,
        linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 40px 40px,
        var(--ink);
}
.screen-h {
    font: 400 52px/1 var(--display);
    margin: 0;
    letter-spacing: 0.03em;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    text-decoration: none;
    font-size: 11px;
    letter-spacing: 0.1em;
}
.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--bull);
    box-shadow: 0 0 8px var(--bull);
    animation: blink 1.6s steps(2, jump-none) infinite;
}
@keyframes blink {
    50% {
        opacity: 0.25;
    }
}
.title-bull {
    width: 180px;
    height: 140px;
    image-rendering: pixelated;
    margin-top: 6px;
}
.logo {
    font: 400 clamp(60px, 19vw, 150px) / 0.8 var(--display);
    margin: 0;
    color: var(--bull);
    letter-spacing: 0.02em;
    text-shadow: 0 6px 0 var(--bull-deep);
}
.tagline {
    margin: 0 0 8px;
    color: #c9d2dc;
    font-size: 14px;
}
.title-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 8px;
}
.today-top {
    min-height: 1.4em;
    margin: 0;
    font-size: 12px;
    color: var(--gold);
}
.title-foot {
    max-width: 34ch;
    margin: 6px 0 0;
    font-size: 11px;
    color: var(--muted);
}
.title-foot a {
    color: var(--bull);
}

.btn {
    font: 400 26px/1 var(--display);
    letter-spacing: 0.05em;
    color: var(--text);
    background: var(--panel-2);
    border: 2px solid var(--line);
    min-height: 48px;
    min-width: 220px;
    padding: 10px 20px 12px;
    cursor: pointer;
    box-shadow: 4px 4px 0 var(--ink);
    transition: transform 60ms ease;
}
.btn:active {
    transform: translate(3px, 3px);
    box-shadow: 1px 1px 0 var(--ink);
}
.btn:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
}
.btn-primary {
    background: var(--bull);
    border-color: var(--bull);
    color: var(--ink);
    box-shadow: 5px 5px 0 var(--bull-deep);
}
.btn-primary:active {
    box-shadow: 1px 1px 0 var(--bull-deep);
}
.btn-big {
    display: grid;
    gap: 6px;
    min-width: min(360px, 92vw);
    padding: 14px 20px 14px;
    font-size: 34px;
}
.btn-big small {
    font: 400 11px/1.2 var(--mono);
    letter-spacing: 0.04em;
    opacity: 0.8;
}
.btn-ghost {
    background: transparent;
    box-shadow: none;
}
.btn-text {
    background: none;
    border: 0;
    box-shadow: none;
    min-width: 0;
    font: 700 11px/1 var(--mono);
    letter-spacing: 0.12em;
    color: var(--muted);
    padding: 12px 8px;
}
.btn-text:hover {
    color: var(--text);
}

/* Level-up */
.screen-level {
    background: rgba(7, 9, 12, 0.72);
    gap: 10px;
}
.level-head {
    display: flex;
    align-items: baseline;
    gap: 14px;
}
.ath {
    font: 400 56px/1 var(--display);
    color: var(--gold);
    text-shadow: 0 4px 0 var(--gold-deep);
}
.lv {
    font: 400 24px/1 var(--display);
    color: var(--muted);
}
.lv b {
    color: var(--text);
    font-weight: 400;
}
.cards {
    display: grid;
    gap: 10px;
    width: min(520px, 100%);
}
@media (min-width: 900px) and (min-height: 560px) {
    .cards {
        grid-template-columns: repeat(3, 1fr);
        width: min(900px, 100%);
    }
    .card {
        flex-direction: column;
        text-align: center;
        align-items: center;
        min-height: 240px;
    }
}
.card {
    position: relative;
    display: flex;
    gap: 14px;
    align-items: center;
    text-align: left;
    padding: 14px 16px;
    min-height: 88px;
    background: var(--panel);
    border: 2px solid var(--line);
    color: var(--text);
    cursor: pointer;
    box-shadow: 5px 5px 0 var(--ink);
    font: inherit;
}
.card:hover,
.card:focus-visible {
    border-color: var(--bull);
    outline: none;
}
.card.evo {
    border-color: var(--gold);
    background: linear-gradient(180deg, rgba(255, 197, 61, 0.12), var(--panel));
}
.card.heal {
    border-style: dashed;
}
.card-icon {
    flex: none;
    width: 48px;
    height: 48px;
    image-rendering: pixelated;
}
.card-top {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}
.card-name {
    font: 400 28px/1 var(--display);
    letter-spacing: 0.02em;
}
.card-tag {
    font: 700 10px/1 var(--mono);
    letter-spacing: 0.1em;
    padding: 3px 5px;
    border: 1px solid currentColor;
    color: var(--muted);
}
.card-tag.new {
    color: var(--bull);
}
.card-tag.evo {
    color: var(--gold);
}
.card-desc {
    margin: 6px 0 0;
    font-size: 12px;
    color: #c9d2dc;
}
.card-evo {
    margin: 6px 0 0;
    font-size: 11px;
    color: var(--gold);
}
.card kbd {
    position: absolute;
    right: 8px;
    top: 6px;
    font: 400 16px/1 var(--display);
    color: var(--muted);
}
@media (pointer: coarse) {
    .card kbd {
        display: none;
    }
    .level-hint {
        display: none;
    }
}
.level-hint {
    margin: 0;
    font-size: 11px;
    color: var(--muted);
}
.cards.locked .card {
    opacity: 0.6;
}

/* Game over */
.over-title {
    font: 400 clamp(64px, 18vw, 120px) / 0.85 var(--display);
    color: var(--bear);
    text-shadow: 0 6px 0 var(--bear-deep);
}
.over-title.win {
    color: var(--bull);
    text-shadow: 0 6px 0 var(--bull-deep);
}
.over-sub {
    color: #c9d2dc;
    max-width: 34ch;
}
.over-score small,
.over-stats small {
    display: block;
    font-size: 10px;
    letter-spacing: 0.14em;
    color: var(--muted);
}
.over-score b {
    font: 400 72px/0.9 var(--display);
    color: var(--gold);
}
.over-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(86px, 1fr));
    border: 1px solid var(--line);
    background: var(--panel);
}
.over-stats > div {
    padding: 8px 12px;
    border-right: 1px solid var(--line);
}
.over-stats > div:last-child {
    border-right: 0;
}
.over-stats b {
    font: 400 30px/1 var(--display);
}
.over-rank {
    min-height: 1.5em;
    font-size: 13px;
    color: var(--gold);
}
.over-btns {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}
.over-btns .btn {
    min-width: 150px;
}
.over-build {
    font-size: 11px;
    color: var(--muted);
    margin: 0;
}
.name-form {
    display: grid;
    gap: 6px;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--muted);
}
.name-row {
    display: flex;
    gap: 8px;
}
.name-row input {
    font: 400 24px/1 var(--display);
    background: var(--ink);
    color: var(--text);
    border: 2px solid var(--line);
    padding: 8px 10px;
    width: 180px;
    user-select: text;
    -webkit-user-select: text;
}
.name-row .btn {
    min-width: 0;
}

/* Board */
.board-list {
    list-style: none;
    margin: 0;
    padding: 0;
    width: min(460px, 100%);
    max-height: 56vh;
    overflow-y: auto;
    border: 1px solid var(--line);
    background: var(--panel);
    text-align: left;
}
.board-list li {
    display: grid;
    grid-template-columns: 38px 1fr auto auto;
    gap: 10px;
    align-items: baseline;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
}
.board-list li.me {
    background: rgba(22, 224, 138, 0.1);
}
.board-list .r {
    font: 400 22px/1 var(--display);
    color: var(--muted);
}
.board-list li:nth-child(1) .r {
    color: var(--gold);
}
.board-list .n {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.board-list .s {
    font: 400 22px/1 var(--display);
    color: var(--gold);
}
.board-list .v {
    font-size: 10px;
    color: var(--muted);
}
.board-list .empty {
    display: block;
    text-align: center;
    color: var(--muted);
    padding: 22px 12px;
}
.board-sub,
.pause-sub {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
}

/* Settings */
.settings-list {
    display: grid;
    width: min(420px, 100%);
    border: 1px solid var(--line);
    background: var(--panel);
}
.settings-list label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    cursor: pointer;
}
.settings-list input[type='checkbox'] {
    width: 22px;
    height: 22px;
    accent-color: var(--bull);
}

.attract-badge {
    position: absolute;
    z-index: 7;
    left: 10px;
    bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    background: rgba(7, 9, 12, 0.8);
    border: 1px solid var(--line);
    font: 700 10px/1 var(--mono);
    letter-spacing: 0.12em;
}

body.attract .hud-right .icon-btn,
body.attract .touch-surface,
body.attract .hint-move {
    display: none;
}

@media (max-width: 420px) {
    .hud-time {
        font-size: 34px;
    }
    .hud-score b {
        font-size: 24px;
    }
    .toast {
        font-size: 34px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dot,
    .hint-move,
    .boss-card,
    .boss-ticker span {
        animation: none;
    }
    .toast,
    .bar i {
        transition: none;
    }
}
