:root {
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #03050b;
    color: #f7f8ff;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background:
        radial-gradient(circle at 15% 0%, rgba(50, 82, 255, .20), transparent 34%),
        radial-gradient(circle at 88% 12%, rgba(255, 210, 0, .09), transparent 31%),
        #03050b;
}

body {
    min-width: 0;
    min-height: 0;
}

button,
a {
    font: inherit;
}

.game-shell {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: grid;
    place-items: center;
    padding: clamp(7px, 1.8vmin, 16px);
}

.game-card {
    width: min(100%, 940px);
    height: min(100%, 602px);
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: clamp(7px, 1.35vmin, 12px);
}

.game-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-width: 0;
}

.game-kicker {
    display: block;
    color: #70edff;
    font-size: clamp(7px, 1.3vmin, 10px);
    font-weight: 900;
    letter-spacing: .18em;
}

.game-head h1 {
    margin: 1px 0 0;
    color: #ffdd25;
    font-size: clamp(1.3rem, 4.2vmin, 2.35rem);
    line-height: .95;
    letter-spacing: -.055em;
    text-shadow: 0 0 22px rgba(255, 221, 37, .24);
}

.audio-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 11px;
    color: #f8f9ff;
    background: rgba(15, 21, 35, .92);
    box-shadow: 0 10px 30px rgba(0,0,0,.24);
    cursor: pointer;
    font-size: .78rem;
    font-weight: 800;
    transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.audio-toggle:hover {
    transform: translateY(-1px);
    border-color: rgba(112, 237, 255, .42);
}

.audio-toggle[aria-pressed="true"] {
    color: #ffbac5;
    border-color: rgba(255, 79, 112, .35);
    background: rgba(62, 18, 30, .88);
}

.game-layout {
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 245px);
    gap: clamp(9px, 1.8vmin, 16px);
    align-items: stretch;
}

.board-wrap {
    position: relative;
    min-width: 0;
    min-height: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(92, 124, 255, .28);
    border-radius: clamp(12px, 2vmin, 18px);
    background: #02040a;
    box-shadow:
        0 24px 70px rgba(0,0,0,.44),
        inset 0 0 0 1px rgba(255,255,255,.025),
        inset 0 0 38px rgba(35, 62, 190, .10);
}

#gameCanvas {
    display: block;
    width: auto;
    height: 100%;
    max-width: 100%;
    aspect-ratio: 25 / 21;
    outline: none;
    touch-action: none;
    image-rendering: auto;
}

.status-overlay {
    position: absolute;
    z-index: 10;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 7px;
    padding: 24px;
    text-align: center;
    background: rgba(2, 4, 10, .72);
    backdrop-filter: blur(7px);
}

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

.status-overlay strong {
    color: #ffdd25;
    font-size: clamp(1.8rem, 6.8vmin, 3.8rem);
    line-height: .95;
    letter-spacing: -.06em;
    text-shadow: 0 0 24px rgba(255, 221, 37, .22);
}

.status-overlay span {
    max-width: 320px;
    color: #a8b1c5;
    font-size: clamp(.72rem, 1.8vmin, .92rem);
    line-height: 1.45;
}

.hud {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: clamp(6px, 1.25vmin, 10px);
    justify-content: center;
}

.hud-card {
    min-width: 0;
    padding: clamp(8px, 1.5vmin, 13px);
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 13px;
    background: rgba(14, 20, 33, .82);
    box-shadow: 0 10px 28px rgba(0,0,0,.22);
}

.hud-card > span {
    display: block;
    color: #8f9bb1;
    font-size: clamp(7px, 1.25vmin, 10px);
    font-weight: 850;
}

.hud-card strong {
    display: block;
    margin-top: 3px;
    font-size: clamp(1rem, 3vmin, 1.55rem);
    line-height: 1;
}

.hud-score strong {
    color: #ffdd25;
    font-size: clamp(1.35rem, 4.2vmin, 2.15rem);
}

.hud-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(6px, 1.2vmin, 9px);
}

.meter {
    height: 5px;
    margin-top: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
}

.meter i {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #5fe3ff, #ffdd25);
    transform-origin: left center;
    transition: transform .18s ease;
}

.controls-card dl,
.controls-card div,
.controls-card dt,
.controls-card dd {
    margin: 0;
}

.controls-card dl {
    display: grid;
    gap: clamp(3px, .7vmin, 6px);
    margin-top: 8px;
}

.controls-card div {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: #8f9bb1;
    font-size: clamp(7px, 1.2vmin, 9px);
}

.controls-card dt {
    color: #f5f7ff;
    font-weight: 850;
}

.tip-card p {
    margin: 6px 0 0;
    color: #a7b1c4;
    font-size: clamp(7px, 1.2vmin, 9px);
    line-height: 1.45;
}

.game-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #667188;
    font-size: clamp(7px, 1.2vmin, 9px);
}

.game-footer a {
    color: #8c9fca;
    text-decoration: none;
}

.game-footer a:hover {
    color: #d9e4ff;
    text-decoration: underline;
}

@media (max-width: 720px) {
    .game-card {
        height: 100%;
    }

    .game-layout {
        grid-template-columns: minmax(0, 1fr) minmax(118px, 28vw);
        gap: 7px;
    }

    .tip-card {
        display: none;
    }

    .hud-card {
        padding: 7px;
        border-radius: 10px;
    }

    .controls-card div {
        display: grid;
        gap: 1px;
    }

    .game-footer > span {
        display: none;
    }

    .game-footer {
        justify-content: flex-end;
    }
}

@media (max-width: 460px) {
    .game-shell {
        padding: 5px;
    }

    .game-head {
        gap: 8px;
    }

    .audio-toggle {
        min-height: 32px;
        padding: 6px 8px;
    }

    .game-layout {
        position: relative;
        display: block;
    }

    .board-wrap {
        width: 100%;
        height: 100%;
    }

    #gameCanvas {
        width: 100%;
        height: auto;
        max-height: 100%;
    }

    .hud {
        position: absolute;
        z-index: 5;
        top: 7px;
        left: 7px;
        right: 7px;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        pointer-events: none;
    }

    .hud > .hud-card,
    .hud > .hud-grid {
        background: rgba(3, 7, 17, .82);
        backdrop-filter: blur(5px);
    }

    .hud-grid {
        display: contents;
    }

    .controls-card,
    .pellets-card,
    .tip-card {
        display: none;
    }
}
