* {
    box-sizing: border-box;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    margin: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
    overflow: hidden;
    padding: 10px 0;
    font-family: Arial, sans-serif;
    background: radial-gradient(circle at top, #5a1212, #1c0707 58%, #0a0303);
    color: #f8eeee;
}

.shell {
    width: min(94vw, 1100px);
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
    gap: clamp(5px, 1vh, 12px);
    margin-inline: auto;
}

.hud-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 14px;
    background: rgba(32, 10, 10, 0.82);
    border: 2px solid rgba(214, 40, 40, 0.8);
    border-radius: 12px;
    box-shadow: 0 0 14px rgba(220, 40, 40, 0.35);
}

.hud-panel h1 {
    margin: 0;
    font-size: clamp(1rem, 1.4vw, 1.5rem);
    color: #ffb3b3;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.stats {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    font-size: 1.05rem;
}

.health-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.health-bar {
    position: relative;
    display: inline-block;
    width: 180px;
    height: 22px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 4px;
    background: linear-gradient(#0b1a10, #050a07);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.8), inset 0 2px 5px rgba(0, 0, 0, 0.9), 0 0 8px rgba(57, 255, 106, 0.25);
}

.health-fill,
.health-lag {
    position: absolute;
    inset: 0 auto 0 0;
    width: 100%;
}

.health-fill {
    background: linear-gradient(#6bff95 0%, #2fd465 45%, #12823a 100%);
}

.health-lag {
    background: rgba(255, 255, 255, 0.8);
}

/* gloss highlight plus four angled dividers (five segments) */
.health-bar::before,
.health-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

.health-bar::before {
    background: linear-gradient(rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 50%);
}

.health-bar::after {
    background:
        linear-gradient(to right,
            transparent calc(20% - 1px), rgba(0, 0, 0, 0.85) calc(20% - 1px), rgba(0, 0, 0, 0.85) calc(20% + 1px), transparent calc(20% + 1px),
            transparent calc(40% - 1px), rgba(0, 0, 0, 0.85) calc(40% - 1px), rgba(0, 0, 0, 0.85) calc(40% + 1px), transparent calc(40% + 1px),
            transparent calc(60% - 1px), rgba(0, 0, 0, 0.85) calc(60% - 1px), rgba(0, 0, 0, 0.85) calc(60% + 1px), transparent calc(60% + 1px),
            transparent calc(80% - 1px), rgba(0, 0, 0, 0.85) calc(80% - 1px), rgba(0, 0, 0, 0.85) calc(80% + 1px), transparent calc(80% + 1px));
    transform: skewX(-25deg);
}

.hud-panel .stats,
.hud-panel .stats span strong,
.hud-panel .stats #score,
.hud-panel .stats #wave,
.hud-panel .stats .health-wrap {
    color: #fff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

body .hud-panel .stats > span:not(.health-wrap),
body .hud-panel .stats > span:not(.health-wrap) strong {
    color: #ff2b2b;
    text-shadow: 0 0 8px rgba(255, 43, 43, 0.7);
}

.stat-hud {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.stat-icon {
    width: 20px;
    height: 20px;
    fill: #ff2b2b;
    filter: drop-shadow(0 0 4px rgba(255, 43, 43, 0.8));
}

.stat-icon.score-icon {
    fill: none;
    filter: drop-shadow(0 0 4px rgba(255, 200, 40, 0.7));
}

.stat-icon.wave-icon {
    filter: drop-shadow(0 0 4px rgba(60, 150, 255, 0.8));
}

.health-label {
    display: inline-flex;
}

.health-icon {
    fill: none;
    filter: drop-shadow(0 0 4px rgba(60, 220, 90, 0.7));
}

.speed-hud {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    opacity: 0.35;
}

.speed-hud.active {
    opacity: 1;
}

.speed-icon {
    width: 16px;
    height: 22px;
    fill: #ffd23c;
    filter: drop-shadow(0 0 4px #ffd23c);
}

body .hud-panel .stats > span.speed-hud strong {
    color: #ffd23c;
    text-shadow: 0 0 6px rgba(255, 210, 60, 0.7);
}

body .hud-panel h1 {
    color: #fff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.hud-panel .stats .health-bar strong {
    position: relative;
    z-index: 3;
    display: block;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    line-height: 20px;
    color: #000;
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.6);
}

.weapon-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.weapon-slot {
    display: grid;
    grid-template-columns: 24px 28px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-width: 0;
    min-height: 48px;
    padding: 7px 10px;
    border: 1px solid rgba(214, 150, 150, 0.5);
    border-radius: 5px;
    background: rgba(32, 10, 10, 0.88);
    color: #f0d4d4;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.weapon-slot.selected {
    border-color: #ff6b6b;
    background: #7a1515;
    box-shadow: inset 0 0 0 1px rgba(255, 107, 107, 0.45);
}

.weapon-slot:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.weapon-slot kbd {
    display: grid;
    place-items: center;
    width: 22px;
    height: 24px;
    border: 1px solid rgba(240, 212, 212, 0.4);
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.22);
    color: #fff0ad;
    font: inherit;
    font-size: 0.8rem;
}

.weapon-icon {
    width: 28px;
    height: 14px;
    color: #d9dde6;
}

.weapon-slot.selected .weapon-icon {
    color: #fff;
    filter: drop-shadow(0 0 4px rgba(255, 60, 60, 0.9));
}

.weapon-slot span,
.weapon-slot strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.weapon-slot strong {
    color: #ffb3b3;
    font-size: 0.88rem;
}

#gameCanvas {
    display: block;
    width: min(100cqw, 150cqh);
    height: auto;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 3 / 2;
    object-fit: contain;
    border-radius: 8px;
    border: 3px solid rgba(214, 40, 40, 0.9);
    box-shadow: 0 0 30px rgba(220, 40, 40, 0.35);
    background: #2a0e0e;
    image-rendering: auto;
}

.game-stage {
    position: relative;
    display: grid;
    place-items: center;
    container-type: size;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    padding: 6px 10px;
    background: rgba(26, 8, 8, 0.78);
    border: 2px solid rgba(214, 40, 40, 0.6);
    border-radius: 12px;
}

.controls p {
    margin: 0;
    color: #f0d4d4;
    font-size: 0.95rem;
}

.about-game {
    width: min(1100px, 100%);
    box-sizing: border-box;
    text-align: center;
}

.about-game h2 {
    margin: 0 0 8px;
    color: #ff4d4d;
}

.about-game p {
    margin: 0 auto 10px;
    max-width: 800px;
    line-height: 1.5;
}

.map-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 8px;
}

.map-grid figure {
    margin: 0;
}

.map-grid img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    border: 2px solid rgba(214, 40, 40, 0.5);
}

.map-grid figcaption {
    margin-top: 6px;
    font-size: 0.9rem;
}

.map-grid figcaption strong {
    display: block;
    color: #ffd54a;
}

.about-game-page,
.mailing-box,
.featured-giveaway {
    text-align: center;
    margin: 40px 0;
    padding: 24px 20px 28px;
    background: rgba(26, 8, 8, 0.78);
    border: 2px solid rgba(214, 40, 40, 0.6);
    border-radius: 14px;
    box-shadow: 0 0 22px rgba(255, 42, 42, 0.25), inset 0 0 16px rgba(255, 42, 42, 0.1);
}

.about-game-page::before,
.mailing-box::before,
.featured-giveaway::before {
    content: "THE GAME";
    display: block;
    width: fit-content;
    margin: -38px auto 14px;
    padding: 4px 16px;
    background: #1a0808;
    border: 1px solid rgba(214, 40, 40, 0.8);
    border-radius: 20px;
    color: #ffd54a;
    font-size: 0.8rem;
    letter-spacing: 0.25em;
}

.mailing-box::before {
    content: "STAY UPDATED";
}

.featured-giveaway::before {
    content: "GIVEAWAY";
}

body .featured-giveaway .featured-card {
    background: none;
    border: 0;
    box-shadow: none;
    padding: 0;
}

.mailing-box form {
    justify-content: center;
}

.mailing-box .page-note,
.mailing-box .privacy-note {
    margin-left: auto;
    margin-right: auto;
    max-width: 800px;
}

.about-game-page p {
    margin: 0 auto 10px;
    max-width: 800px;
    line-height: 1.5;
}

.about-game-page .map-grid {
    margin: 12px 0 16px;
}

.about-game-page .button-link {
    display: inline-block;
}

.social-links {
    position: relative;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 22px;
    padding: 4px 10px 6px;
    border-bottom: 1px solid rgba(214, 150, 150, 0.25);
}

.nav-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
}

.nav-divider {
    align-self: stretch;
    width: 2px;
    min-height: 24px;
    background: rgba(255, 107, 107, 0.6);
    border-radius: 1px;
}

.social-links a {
    padding: 8px 15px;
    border: 1px solid #ff6b6b;
    border-radius: 4px;
    background: #a31616;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.15s;
}

.social-links a:hover {
    background: #c21d1d;
    text-decoration: none;
}

.social-links a:focus-visible {
    outline: 3px solid #f2d56b;
    outline-offset: 3px;
}

@media (max-width: 600px) {
    .shell {
        width: 96vw;
    }

    .hud-panel {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
        padding: 8px 10px;
    }

    .stats {
        gap: 6px 12px;
        font-size: 0.9rem;
    }

    .weapon-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .weapon-slot {
        gap: 6px;
        padding-inline: 7px;
        font-size: 0.9rem;
    }

    .controls {
        gap: 5px 14px;
        padding: 5px 8px;
    }

    .controls p,
    .social-links a {
        font-size: 0.8rem;
    }
}

.mobile-controls {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 16px 20px 24px;
    pointer-events: none;
    touch-action: none;
}

.mobile-controls[hidden] {
    display: none;
}

.stick {
    position: relative;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.35);
    pointer-events: auto;
    touch-action: none;
}

.stick .knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 56px;
    height: 56px;
    margin: -28px 0 0 -28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.45);
}

.jump-button {
    width: 76px;
    height: 76px;
    margin-bottom: 20px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: rgba(163, 22, 22, 0.75);
    color: #fff;
    font-weight: 700;
    pointer-events: auto;
    touch-action: none;
}

.is-mobile .controls {
    display: none;
}

.is-mobile:not(.fs-mode) {
    height: auto;
    min-height: 100dvh;
    overflow-y: auto;
    padding-bottom: 190px;
}

.is-mobile:not(.fs-mode) .shell {
    height: auto;
    grid-template-rows: none;
    grid-auto-rows: auto;
}

.is-mobile:not(.fs-mode) .game-stage {
    aspect-ratio: 3 / 2;
    width: 100%;
}

.fullscreen-button {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 3;
    padding: 6px 12px;
    border: 1px solid rgba(255, 60, 60, 0.8);
    border-radius: 4px;
    background: rgba(20, 0, 0, 0.75);
    color: #fff;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
}

.fullscreen-button[hidden] {
    display: none;
}

.fs-mode .social-links,
.fs-mode .social-links,
.fs-mode .giveaway-banner,
.fs-mode .controls {
    display: none;
}

.fs-mode {
    padding: 0;
    overflow: hidden;
}

.fs-mode .shell {
    position: fixed;
    inset: 0;
    z-index: 1;
    width: 100vw;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px;
    background: #000;
}

.fs-mode .hud-panel {
    flex: none;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2px 12px;
    padding: 3px 8px;
}

.fs-mode .hud-panel h1 {
    font-size: 0.85rem;
    letter-spacing: 0.15em;
}

.fs-mode .stats {
    gap: 2px 10px;
    font-size: 0.72rem;
}

.fs-mode .weapon-bar {
    flex: none;
    gap: 4px;
}

.fs-mode .weapon-slot {
    grid-template-columns: 28px auto;
    justify-content: center;
    min-height: 28px;
    padding: 2px 6px;
    gap: 4px;
}

.fs-mode .weapon-slot kbd,
.fs-mode .weapon-slot span {
    display: none;
}

.fs-mode .game-stage {
    flex: 1;
    min-height: 0;
    background: #000;
}

.fs-mode .site-footer {
    display: none;
}

.fs-mode .shell {
    display: block;
    padding: 0;
}

.fs-mode .game-stage {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: 0;
}

.fs-mode .hud-panel,
.fs-mode .weapon-bar {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 4;
    background: rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

.fs-mode .hud-panel button,
.fs-mode .weapon-slot {
    pointer-events: auto;
}

.fs-mode .hud-panel {
    top: 0;
    border: 0;
    box-shadow: none;
}

.fs-mode .weapon-bar {
    top: 30px;
    right: auto;
    left: 4px;
    width: max-content;
    display: flex;
    gap: 3px;
    background: none;
    transform: scale(0.75);
    transform-origin: top left;
}

.fs-mode .weapon-slot {
    min-height: 22px;
    padding: 1px 4px;
    grid-template-columns: 22px auto;
}

.fs-mode .weapon-slot strong {
    display: none;
}

.is-mobile.fs-mode .health-wrap {
    position: static;
    max-width: none;
    margin: 0;
    display: inline-flex;
}

.is-mobile.fs-mode .health-wrap .health-bar {
    width: 110px;
    height: 14px;
}

.fs-mode #leaderboardButton,
.fs-mode #aboutButton,
.fs-mode .hud-panel .hud-leaderboard:not(#pauseButton) {
    display: none;
}

.fs-mode .hud-panel h1 {
    display: none;
}

.fs-mode .hud-panel {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
}

.fs-mode .weapon-bar {
    top: 34px;
}

.fs-mode #gameCanvas {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    aspect-ratio: auto;
    object-fit: fill;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

@media (orientation: landscape) {
    .fs-mode .hud-panel h1 {
        display: none;
    }
}

.game-overlay {
    position: fixed;
    inset: 0;
    z-index: 5;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(12, 3, 3, 0.84);
}

.game-overlay:has(#startPanel:not([hidden])) .leaderboard {
    display: none;
}

.play-now-wrap {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
}

.play-now-wrap[hidden] {
    display: none;
}

.play-now-box {
    padding: 14px;
    background: #240c0c;
    border: 1px solid rgba(214, 40, 40, 0.8);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
    pointer-events: auto;
}

.play-now-box {
    text-align: center;
}

.play-now-title {
    margin: 0 0 6px;
    font-size: 1.5rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 40, 40, 0.8);
}

.play-now-score {
    margin: 0 0 12px;
    color: #ffd23c;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.play-now-score strong {
    color: #fff;
}

#playNow {
    min-width: 180px;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid #ff6b6b;
    border-radius: 4px;
    background: #a31616;
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

#playNow:hover {
    background: #c21d1d;
}

#playNow:focus-visible {
    outline: 3px solid #f2d56b;
    outline-offset: 2px;
}

#startForm[hidden] {
    display: none;
}

.game-overlay[hidden] {
    display: none;
}

.menu-panel {
    width: min(100%, 440px);
    max-height: min(90vh, 720px);
    overflow-y: auto;
    padding: 26px;
    background: #240c0c;
    border: 1px solid rgba(214, 40, 40, 0.8);
    border-radius: 8px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

.menu-panel h2,
.menu-panel h3 {
    margin: 0 0 18px;
    color: #ffb3b3;
}

#startForm {
    display: grid;
    gap: 10px;
}

#startForm label {
    color: #f0d4d4;
    font-size: 0.95rem;
}

#playerName {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #8a5a5a;
    border-radius: 4px;
    background: #120505;
    color: #f8eeee;
    font: inherit;
}

.menu-panel button {
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid #ff6b6b;
    border-radius: 4px;
    background: #a31616;
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.menu-panel button:hover {
    background: #c21d1d;
}

.menu-panel button:focus-visible,
#playerName:focus-visible {
    outline: 3px solid #f2d56b;
    outline-offset: 2px;
}

.leaderboard {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid rgba(214, 40, 40, 0.35);
}

.leaderboard h3 {
    margin-bottom: 10px;
}

#leaderboardStatus {
    margin: 0 0 10px;
    color: #d4a8a8;
    font-size: 0.85rem;
}

#leaderboardList {
    display: grid;
    gap: 7px;
    margin: 0;
    padding-left: 24px;
    color: #f3dcdc;
}

#leaderboardList li {
    padding-left: 3px;
    overflow-wrap: anywhere;
}

.champion-card {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 0 14px;
    padding: 12px 16px;
    border: 1px solid #ffc928;
    background: linear-gradient(90deg, rgba(255, 201, 40, 0.22), rgba(255, 201, 40, 0.05));
    box-shadow: 0 0 16px rgba(255, 201, 40, 0.3), inset 0 0 12px rgba(255, 201, 40, 0.12);
    clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}

.crown-icon {
    flex: none;
    width: 44px;
    height: 34px;
    filter: drop-shadow(0 0 6px rgba(255, 200, 40, 0.8));
}

.champion-info {
    display: grid;
    min-width: 0;
}

.champion-name {
    color: #ffd23c;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    overflow-wrap: anywhere;
}

.champion-meta {
    color: #fff;
    font-weight: 600;
    letter-spacing: 0.05em;
}

#emptyLeaderboard {
    margin: 0;
    color: #d4a8a8;
}

#finalScore {
    margin: 0 0 18px;
    color: #fff0ad;
    font-size: 1.1rem;
}

.menu-actions {
    display: grid;
    gap: 10px;
}

@media (max-width: 600px) {
    .menu-panel {
        padding: 20px;
    }
}
