:root {
    color-scheme: dark;
    --ink: #111a1c;
    --panel: #1a2729;
    --panel-light: #233235;
    --line: #344649;
    --paper: #f4f0df;
    --muted: #94aaa4;
    --mint: #66e3c4;
    --gold: #ffcf5a;
    --board: #101b1e;
}

* {
    box-sizing: border-box;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--paper);
    background-color: var(--ink);
    background-image:
        repeating-linear-gradient(0deg, transparent 0 39px, rgba(161, 218, 198, 0.035) 39px 40px),
        repeating-linear-gradient(90deg, transparent 0 39px, rgba(161, 218, 198, 0.035) 39px 40px);
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

.page-shell {
    width: min(100% - 40px, 840px);
    min-height: 100vh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.site-header {
    min-height: 104px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

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

.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid var(--mint);
    color: var(--mint);
    font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
    font-size: 19px;
    letter-spacing: 1px;
    transform: rotate(-3deg);
}

.brand-kicker,
.section-heading,
.stat-label,
.action-caption,
.footer-note {
    font-family: "Lucida Console", Monaco, monospace;
    font-size: 10px;
    letter-spacing: 1px;
}

.brand-kicker {
    margin: 0 0 3px;
    color: var(--mint);
}

.site-header h1 {
    margin: 0;
    color: var(--paper);
    font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
    font-size: 30px;
    font-weight: 400;
    line-height: 1;
    text-transform: uppercase;
}

.mode-tag,
.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    font-family: "Lucida Console", Monaco, monospace;
    font-size: 10px;
    letter-spacing: 1px;
}

.mode-dot,
.live-indicator > span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--mint);
    box-shadow: 0 0 10px rgba(102, 227, 196, 0.7);
}

.game-shell {
    width: min(100%, 620px);
    margin: 34px auto 24px;
}

.section-heading {
    min-height: 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
}

.live-indicator {
    color: var(--mint);
    font-size: 9px;
}

.live-indicator > span {
    width: 6px;
    height: 6px;
}

.hud {
    display: grid;
    grid-template-columns: 1.25fr 1.25fr 0.7fr 0.8fr;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: rgba(26, 39, 41, 0.94);
}

.stat-block {
    min-width: 0;
    min-height: 72px;
    padding: 12px 14px 10px;
    display: grid;
    align-content: center;
    gap: 4px;
}

.stat-block + .stat-block {
    border-left: 1px solid var(--line);
}

.stat-label {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 9px;
}

.stat-block strong {
    color: var(--paper);
    font-family: "Lucida Console", Monaco, monospace;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.score-stat strong,
.high-score-stat strong {
    color: var(--gold);
}

.lives-stat strong {
    color: #ff8178;
}

.level-stat strong {
    color: var(--mint);
}

.unlocked-banner {
    grid-column: 1 / -1;
    min-height: 38px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    gap: 9px;
    border-top: 1px solid rgba(255, 207, 90, 0.35);
    color: var(--gold);
    background: rgba(255, 207, 90, 0.09);
    font-family: "Lucida Console", Monaco, monospace;
    font-size: 9px;
    letter-spacing: 1px;
}

.unlock-star {
    color: var(--gold);
    font-size: 14px;
}

.unlocked-banner strong {
    margin-left: auto;
    color: var(--paper);
    font-size: 16px;
    font-variant-numeric: tabular-nums;
}

.canvas-frame {
    position: relative;
    padding: 8px;
    overflow: hidden;
    border: 1px solid #3b5353;
    border-radius: 7px;
    background: #192628;
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(102, 227, 196, 0.04);
}

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 2;
    border-radius: 3px;
    background: var(--board);
    touch-action: none;
}

.powerup-toast[hidden] {
    display: none;
}

.powerup-toast {
    position: absolute;
    z-index: 1;
    top: 18px;
    left: 50%;
    width: max-content;
    max-width: calc(100% - 28px);
    min-height: 54px;
    padding: 8px 14px 8px 9px;
    display: flex;
    align-items: center;
    gap: 11px;
    border: 1px solid var(--powerup-color, var(--mint));
    border-radius: 5px;
    color: var(--paper);
    background: rgba(17, 26, 28, 0.94);
    box-shadow: 0 5px 22px rgba(0, 0, 0, 0.35), 0 0 18px color-mix(in srgb, var(--powerup-color, var(--mint)) 25%, transparent);
    opacity: 0;
    transform: translate(-50%, -12px) scale(0.96);
    transition: opacity 180ms ease, transform 180ms ease;
    pointer-events: none;
}

.powerup-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
}

.powerup-toast-icon {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--ink);
    background: var(--powerup-color, var(--mint));
    font-size: 20px;
    font-weight: 700;
}

.powerup-toast-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.powerup-toast-copy strong {
    color: var(--powerup-color, var(--mint));
    font: 700 11px "Lucida Console", Monaco, monospace;
    letter-spacing: 1px;
    white-space: nowrap;
}

.powerup-toast-copy > span {
    color: var(--paper);
    font: 9px "Lucida Console", Monaco, monospace;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.game-actions {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.action-caption {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    font-size: 9px;
}

.action-mark {
    color: var(--mint);
    font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
    font-size: 15px;
}

.button-group {
    display: flex;
    gap: 8px;
}

#pauseButton,
#startButton {
    min-height: 36px;
    padding: 0 16px;
    border: 1px solid var(--mint);
    border-radius: 4px;
    font: 700 12px "Lucida Console", Monaco, monospace;
    cursor: pointer;
    transition: background-color 120ms ease, transform 120ms ease;
}

#pauseButton {
    color: var(--mint);
    background: var(--panel);
}

#pauseButton:hover {
    background: var(--panel-light);
    transform: translateY(-1px);
}

#startButton {
    color: var(--ink);
    background: var(--mint);
}

#startButton:hover {
    background: #92f1d8;
    transform: translateY(-1px);
}

#pauseButton:focus-visible,
#startButton:focus-visible,
#gameCanvas:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
}

.site-footer {
    min-height: 56px;
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--line);
    color: var(--paper);
    font-size: 12px;
}

.footer-note {
    color: var(--muted);
    font-size: 9px;
}

.footer-note span {
    padding: 0 4px;
    color: var(--mint);
}

@media (max-width: 520px) {
    .page-shell {
        width: min(100% - 24px, 840px);
    }

    .site-header {
        min-height: 82px;
    }

    .brand-mark {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .site-header h1 {
        font-size: 25px;
    }

    .mode-tag {
        gap: 6px;
        font-size: 8px;
    }

    .game-shell {
        margin-top: 22px;
    }

    .hud {
        grid-template-columns: 1fr 1fr;
    }

    .stat-block {
        min-height: 64px;
        padding: 10px 12px;
    }

    .stat-block strong {
        font-size: 17px;
    }

    .unlocked-banner {
        min-height: 36px;
        padding: 0 11px;
        font-size: 8px;
    }

    .canvas-frame {
        padding: 5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

.level-complete[hidden] {
    display: none;
}

.level-complete {
    position: absolute;
    z-index: 2;
    inset: 8px;
    overflow: hidden;
    display: grid;
    place-items: center;
    padding: 20px;
    border-radius: 3px;
    background: rgba(11, 20, 22, 0.88);
    backdrop-filter: blur(5px);
    text-align: center;
}

.celebration-confetti {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.celebration-confetti i {
    position: absolute;
    top: -16px;
    width: 6px;
    height: 13px;
    border-radius: 1px;
    background: var(--mint);
    animation: confetti-fall 2.4s linear infinite;
}

.celebration-confetti i:nth-child(1) { left: 8%; animation-delay: -0.2s; }
.celebration-confetti i:nth-child(2) { left: 18%; background: var(--gold); animation-delay: -1.3s; }
.celebration-confetti i:nth-child(3) { left: 28%; background: #ff8178; animation-delay: -0.8s; }
.celebration-confetti i:nth-child(4) { left: 39%; background: #48dbfb; animation-delay: -1.8s; }
.celebration-confetti i:nth-child(5) { left: 51%; background: var(--gold); animation-delay: -0.5s; }
.celebration-confetti i:nth-child(6) { left: 62%; background: #ff8178; animation-delay: -1.5s; }
.celebration-confetti i:nth-child(7) { left: 72%; background: #48dbfb; animation-delay: -0.9s; }
.celebration-confetti i:nth-child(8) { left: 83%; background: var(--gold); animation-delay: -2.1s; }
.celebration-confetti i:nth-child(9) { left: 93%; background: #ff8178; animation-delay: -0.1s; }
.celebration-confetti i:nth-child(10) { left: 13%; background: #48dbfb; animation-delay: -1.9s; }
.celebration-confetti i:nth-child(11) { left: 46%; animation-delay: -1.1s; }
.celebration-confetti i:nth-child(12) { left: 77%; background: var(--gold); animation-delay: -1.6s; }

.completion-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.completion-kicker {
    color: var(--mint);
    font: 10px "Lucida Console", Monaco, monospace;
    letter-spacing: 2px;
}

.completion-medal {
    width: 64px;
    height: 64px;
    margin: 14px 0 10px;
    display: grid;
    place-items: center;
    border: 2px solid var(--gold);
    border-radius: 50%;
    color: var(--gold);
    background: rgba(255, 207, 90, 0.1);
    box-shadow: 0 0 28px rgba(255, 207, 90, 0.2), inset 0 0 18px rgba(255, 207, 90, 0.08);
    font-size: 34px;
    animation: medal-pop 500ms cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.completion-content h2 {
    margin: 0;
    color: var(--paper);
    font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
    font-size: 32px;
    font-weight: 400;
    line-height: 1.08;
}

.completion-content h2 span:last-child {
    color: var(--gold);
}

.completion-content p {
    margin: 12px 0 18px;
    color: var(--mint);
    font: 700 12px "Lucida Console", Monaco, monospace;
    letter-spacing: 1px;
}

#continueButton {
    min-height: 40px;
    padding: 0 18px;
    border: 1px solid var(--gold);
    border-radius: 4px;
    color: var(--ink);
    background: var(--gold);
    font: 700 11px "Lucida Console", Monaco, monospace;
    cursor: pointer;
    transition: background-color 120ms ease, transform 120ms ease;
}

#continueButton:hover {
    background: #ffe08a;
    transform: translateY(-1px);
}

#continueButton:focus-visible {
    outline: 2px solid var(--paper);
    outline-offset: 3px;
}

#pauseButton:disabled {
    color: #71857f;
    border-color: var(--line);
    background: var(--panel);
    cursor: default;
}

@keyframes confetti-fall {
    from { transform: translateY(-16px) rotate(0deg); }
    to { transform: translateY(430px) rotate(540deg); }
}

@keyframes medal-pop {
    from { opacity: 0; transform: scale(0.35) rotate(-35deg); }
    to { opacity: 1; transform: scale(1) rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
    .celebration-confetti i,
    .completion-medal {
        animation: none;
    }
}

@media (max-width: 520px) {
    .level-complete {
        padding: 8px;
    }

    .completion-medal {
        width: 48px;
        height: 48px;
        margin: 8px 0 6px;
        font-size: 27px;
    }

    .completion-content h2 {
        font-size: 26px;
    }

    .completion-content p {
        margin: 8px 0 12px;
    }

    #continueButton {
        min-height: 36px;
        padding: 0 14px;
    }
}

@media (max-width: 360px) {
    .level-complete {
        padding: 4px;
    }

    .completion-kicker {
        font-size: 9px;
    }

    .completion-medal {
        width: 40px;
        height: 40px;
        margin: 6px 0 4px;
        font-size: 23px;
    }

    .completion-content h2 {
        font-size: 22px;
    }

    .completion-content p {
        margin: 6px 0 8px;
        font-size: 11px;
    }

    #continueButton {
        min-height: 34px;
    }
}

@media (max-width: 360px) {
    .stat-block {
        padding-right: 8px;
        padding-left: 8px;
    }

    .stat-block strong {
        font-size: 15px;
    }

    .unlocked-banner {
        gap: 6px;
        font-size: 7px;
    }
}

@media (max-width: 520px) {
    .powerup-toast {
        top: 12px;
        min-height: 48px;
        padding: 6px 10px 6px 7px;
        gap: 8px;
    }

    .powerup-toast-icon {
        width: 30px;
        height: 30px;
        flex-basis: 30px;
        font-size: 18px;
    }

    .powerup-toast-copy strong {
        font-size: 10px;
    }

    .powerup-toast-copy > span {
        font-size: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .powerup-toast {
        transition: none;
    }
}