* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #0d1b0f;
    color: #e8f5e9;
    font-family: 'Segoe UI', Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px;
    width: 100%;
    min-width: 0;
    max-width: 100vw;
}

h1 {
    letter-spacing: 2px;
    color: #4caf50;
}

/* MENU */
.game-selection {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    width: min(760px, 100%);
}

.game-select-btn {
    background: #163b1a;
    border: 2px solid #4caf50;
    color: #e8f5e9;
    padding: 16px 24px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 10px;
    cursor: pointer;
    min-width: 260px;
}

.game-select-btn.selected {
    background: #2e7d32;
    border-color: #a5d6a7;
}

#tower-defence-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.difficulty-buttons {
    display: flex;
    gap: 16px;
}

.difficulty-btn {
    background: #163b1a;
    border: 2px solid #4caf50;
    color: #e8f5e9;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.difficulty-btn span {
    font-size: 12px;
    font-weight: normal;
    color: #a5d6a7;
}

.difficulty-btn:hover {
    background: #1f5a26;
}

#continue-btn {
    background: #f1c40f;
    border: none;
    color: #201400;
    font-weight: bold;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
}

#map-archive-btn,
#map-select-back,
#victory-post-score-btn {
    min-height: 44px;
    padding: 10px 18px;
    border: 2px solid #f1c40f;
    background: #102712;
    color: #f1c40f;
    font-weight: bold;
    cursor: pointer;
}

#map-select-screen {
    justify-content: flex-start;
    overflow-y: auto;
    padding-top: 130px;
}

#map-select-title {
    margin: 8px 0 0;
    color: #f1c40f;
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(16px, 4vw, 26px);
    text-align: center;
}

#map-select-description {
    max-width: 560px;
    margin: 0;
    color: #a5d6a7;
    text-align: center;
    line-height: 1.6;
}

#map-select-difficulties {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.map-difficulty-btn {
    min-height: 42px;
    padding: 8px 12px;
    border: 2px solid #4caf50;
    background: #102712;
    color: #e8f5e9;
    font: bold 12px 'Press Start 2P', monospace;
    cursor: pointer;
}

.map-difficulty-btn.selected {
    border-color: #f1c40f;
    color: #f1c40f;
}

#map-select-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    width: min(760px, 100%);
}

.map-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    min-width: 0;
    padding: 8px;
    border: 2px solid #55a82d;
    border-radius: 0;
    background: #0c4319;
    color: #f3f1df;
    text-align: left;
    cursor: pointer;
    box-shadow: 3px 3px 0 #000, inset 2px 2px 0 rgba(255, 255, 255, 0.16);
}

.map-card:active,
.map-card:focus-visible {
    background: #176c26;
    border-color: #a4e74b;
    outline: none;
}

.map-card:disabled {
    border-color: #3a4938;
    color: #899184;
    cursor: default;
}

.map-card-cleared {
    border-color: #f1c40f;
}

.map-card-preview {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    border: 2px solid #347b27;
    border-radius: 0;
    background-color: #155018;
    background-image:
        radial-gradient(#438a28 1px, transparent 1px),
        radial-gradient(#0b3e13 1px, transparent 1px);
    background-size: 6px 6px;
    background-position: 0 0, 3px 3px;
    image-rendering: pixelated;
    pointer-events: none;
    touch-action: auto;
    cursor: inherit;
}

.map-card-title {
    color: #ffe34a;
    font: 10px 'Press Start 2P', monospace;
    text-shadow: 2px 2px 0 #000;
}

.map-card-status {
    color: #a5d6a7;
    font: 8px 'Press Start 2P', monospace;
    text-shadow: 1px 1px 0 #000;
}

.map-card-cleared .map-card-status {
    color: #ffe34a;
}

.map-card-play {
    align-self: stretch;
    padding: 6px 4px;
    border: 2px solid #e8a923;
    background: #78400d;
    color: #ffe34a;
    font: 8px 'Press Start 2P', monospace;
    text-align: center;
    text-shadow: 1px 1px 0 #000;
    box-shadow: 2px 2px 0 #000;
}

#victory-post-score-btn {
    width: min(360px, 100%);
}

#gameplay-description {
    max-width: 520px;
    text-align: center;
    color: #a5d6a7;
    font-size: 13px;
    line-height: 1.5;
}

#language-flags {
    display: flex;
    gap: 8px;
}

.flag-btn {
    background: #163b1a;
    border: 2px solid #4caf50;
    border-radius: 4px;
    padding: 4px;
    cursor: pointer;
    line-height: 0;
}

.flag-btn img {
    display: block;
    border-radius: 2px;
}

.flag-btn.selected {
    border-color: #f1c40f;
    background: #1f5a26;
}

/* HUD */
#hud {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    width: min(800px, 100%);
    min-width: 0;
    background: #102712;
    border: 2px solid #4caf50;
    border-radius: 6px 6px 0 0;
    padding: 8px 16px;
    font-weight: bold;
    font-size: 14px;
    max-width: 100%;
}

#hud .hud-item {
    min-width: 0;
}

/* GAME AREA */
#game-area {
    position: relative;
    width: min(800px, 100%);
    max-width: 100%;
    min-width: 0;
    aspect-ratio: 4 / 3;
}

canvas {
    background: #1b2e1b;
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    border-left: 2px solid #4caf50;
    border-right: 2px solid #4caf50;
    cursor: crosshair;
}

.banner {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(16, 39, 18, 0.95);
    border: 2px solid #f1c40f;
    color: #f1c40f;
    font-weight: bold;
    font-size: 16px;
    padding: 10px 20px;
    border-radius: 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.banner.visible {
    opacity: 1;
}

.speed-controls {
    display: flex;
    gap: 4px;
}

.speed-btn {
    background: #163b1a;
    border: 1px solid #4caf50;
    color: #e8f5e9;
    font-weight: bold;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
}

.speed-btn.selected {
    background: #4caf50;
    color: #0d1b0f;
}

#restart-round-btn {
    background: #922b21;
    border: 1px solid #e74c3c;
    color: #f5e8e8;
    font-weight: bold;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
}

#sound-btn {
    background: #1f618d;
    border: 1px solid #5dade2;
    color: #eaf4fb;
    font-weight: bold;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
}

#sound-btn.muted {
    background: #424949;
    border-color: #7f8c8d;
    color: #d5d8dc;
}

/* TOWER BAR */
#tower-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(800px, 100%);
    min-width: 0;
    background: #102712;
    border: 2px solid #4caf50;
    border-radius: 0 0 6px 6px;
    padding: 10px 16px;
}

.tower-btn {
    background: #163b1a;
    border: 2px solid #4caf50;
    color: #e8f5e9;
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    min-width: 90px;
}

.tower-btn.selected {
    background: #2e7d32;
    border-color: #a5d6a7;
}

.tower-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tower-btn-cost {
    font-size: 11px;
    color: #a5d6a7;
}

#start-wave-btn {
    margin-left: auto;
    background: #ff9800;
    border: none;
    color: #201400;
    font-weight: bold;
    padding: 12px 20px;
    border-radius: 6px;
    cursor: pointer;
}

#start-wave-btn:disabled {
    background: #6d4c1f;
    color: #b8a98a;
    cursor: not-allowed;
}

#auto-wave-btn {
    background: #163b1a;
    border: 2px solid #4caf50;
    color: #e8f5e9;
    font-weight: bold;
    padding: 12px 16px;
    border-radius: 6px;
    cursor: pointer;
}

#auto-wave-btn.selected {
    background: #4caf50;
    color: #0d1b0f;
}

#save-game-btn {
    background: #2471a3;
    border: 2px solid #5dade2;
    color: #eaf4fb;
    font-weight: bold;
    padding: 12px 16px;
    border-radius: 6px;
    cursor: pointer;
}

/* TOWER INFO PANEL */
.panel {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(16, 39, 18, 0.95);
    border: 2px solid #4caf50;
    border-radius: 6px;
    padding: 12px 16px;
    min-width: 180px;
}

.panel h3 {
    margin: 0 0 6px 0;
    color: #4caf50;
}

.panel-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.panel-actions button {
    flex: 1;
    background: #163b1a;
    border: 1px solid #4caf50;
    color: #e8f5e9;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.panel-actions button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#panel-evolution-actions {
    flex-wrap: wrap;
}

#panel-evolve-frost-btn {
    background: #2471a3;
    border-color: #5dade2;
    color: #eaf4fb;
}

#panel-evolve-venom-btn {
    background: #218c48;
    border-color: #58d68d;
    color: #eafaf1;
}

/* GAME OVER / VICTORY */
#game-over-screen {
    gap: 12px;
    overflow: visible;
    text-align: center;
}

#game-over-screen h1,
#game-over-screen p {
    margin: 0;
}

.game-over-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.game-over-actions button {
    min-height: 44px;
    padding: 8px 14px;
    border: 2px solid #4caf50;
    border-radius: 8px;
    background: #163b1a;
    color: #e8f5e9;
    cursor: pointer;
}

#post-score-btn {
    border-color: #f1c40f;
    color: #f1c40f;
    font-weight: bold;
}

#post-score-help {
    max-width: 460px;
    font-size: 13px;
    color: #a5d6a7;
}

#game-over-screen h1 {
    color: #e74c3c;
}

#victory-screen h1 {
    color: #f1c40f;
}

@media (max-width: 700px) {
    body {
        align-items: flex-start;
        min-height: 100dvh;
        width: 100vw;
        max-width: 100vw;
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .screen {
        gap: 10px;
        padding: 10px;
        overflow: hidden;
    }

    #game-screen {
        align-items: stretch;
        width: 100vw;
        max-width: 100vw;
        padding-left: 4px;
        padding-right: 4px;
    }

    h1 {
        margin: 8px 0;
        font-size: 22px;
        text-align: center;
    }

    .game-selection {
        gap: 10px;
    }

    .game-select-btn {
        min-width: 0;
        width: 100%;
        padding: 12px 16px;
        font-size: 15px;
    }

    .difficulty-buttons {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .difficulty-btn {
        flex: 1 1 90px;
        min-width: 90px;
        padding: 12px 8px;
        font-size: 13px;
    }

    #hud {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px 12px;
        padding: 8px;
        font-size: 12px;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    #game-area,
    #tower-bar {
        width: calc(100vw - 8px);
        max-width: calc(100vw - 8px);
    }

    canvas {
        width: 100%;
        height: auto;
    }

    #restart-round-btn {
        padding: 5px 8px;
    }

    #tower-bar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        padding: 8px;
    }

    .tower-btn,
    #start-wave-btn,
    #auto-wave-btn,
    #save-game-btn {
        width: 100%;
        min-width: 0;
        margin: 0;
        padding: 9px 6px;
        font-size: 12px;
    }

    .panel {
        top: 6px;
        right: 6px;
        min-width: 155px;
        padding: 8px 10px;
        font-size: 12px;
    }

    .banner {
        top: 8px;
        max-width: calc(100% - 16px);
        padding: 7px 10px;
        font-size: 12px;
        text-align: center;
    }
}

/* iPhone Chrome can expose a wider legacy layout viewport; use device width
   as a fallback so the game still switches to the mobile layout. */
@media (max-device-width: 700px) {
    body,
    .screen,
    #game-screen,
    #hud,
    #game-area,
    #tower-bar {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    #game-screen {
        align-items: stretch;
        padding-left: 4px;
        padding-right: 4px;
    }

    #hud {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-content: initial;
        gap: 7px;
        overflow: hidden;
    }

    #hud .hud-item,
    #hud .speed-controls,
    #hud button {
        min-width: 0;
        max-width: 100%;
    }

    #hud .speed-controls {
        justify-content: center;
    }

    #game-area {
        aspect-ratio: 4 / 3;
    }

    #game-area canvas {
        width: 100%;
        max-width: 100%;
        height: auto;
    }

    #tower-bar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    #tower-bar button {
        min-width: 0;
        max-width: 100%;
        margin: 0;
    }
}


/* ===== CREEP COMMANDO APP (Android phones & tablets) ===== */
html,
body {
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

button {
    touch-action: manipulation;
    font-family: inherit;
}

canvas {
    touch-action: none;
}

body {
    padding-top: env(safe-area-inset-top);
}

.menu-title {
    margin: 4px 0;
    width: 100%;
    display: flex;
    justify-content: center;
}

.menu-title img {
    display: block;
    width: min(640px, 92vw);
    max-width: 100%;
    height: auto;
    image-rendering: pixelated;
}

#tower-defence-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: min(640px, 100%);
}

#choose-difficulty-label {
    margin: 8px 0 4px;
    color: #a5d6a7;
    font-weight: bold;
    letter-spacing: 1px;
}

.menu-account-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 4px;
}

.account-btn {
    background: #163b1a;
    border: 2px solid #f1c40f;
    color: #f1c40f;
    font-weight: bold;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.pro-badge {
    background: #12601f;
    border: 2px solid #f1c40f;
    color: #ffe34a;
    font-weight: bold;
    padding: 6px 12px;
    border-radius: 14px;
    font-size: 13px;
    letter-spacing: 1px;
    text-shadow: 1px 1px 0 #000;
}

#studio-logo {
    width: 96px;
    height: auto;
    margin-top: 14px;
    opacity: 0.9;
}

.speed-btn.locked {
    opacity: 0.6;
    border-style: dashed;
    border-color: #f1c40f;
}

.panel-actions button.locked {
    border-style: dashed;
    border-color: #f1c40f;
    opacity: 0.8;
}

.app-toast {
    position: fixed;
    left: 50%;
    bottom: calc(18px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    max-width: min(92vw, 560px);
    background: rgba(16, 39, 18, 0.97);
    border: 2px solid #f1c40f;
    color: #f1c40f;
    font-weight: bold;
    font-size: 14px;
    text-align: center;
    padding: 10px 16px;
    border-radius: 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 50;
}

.app-toast.visible {
    opacity: 1;
}

#play-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-width: 0;
}

#game-screen > #hud,
#play-row > #game-area,
#play-row > #tower-bar {
    margin: 0;
}

#game-screen {
    gap: 0;
}

/* Tablets in portrait: use the extra width for the board. */
@media (min-width: 701px) and (orientation: portrait) {
    #hud,
    #game-area,
    #tower-bar {
        width: min(960px, 100%);
    }

    #tower-bar {
        flex-wrap: wrap;
        justify-content: center;
    }

    #start-wave-btn {
        margin-left: 0;
    }

    #hud {
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        column-gap: 18px;
        row-gap: 10px;
        font-size: 16px;
    }

    #hud .hud-item {
        white-space: nowrap;
    }

    #hud button.hud-item,
    #hud .speed-btn {
        padding: 8px 14px;
        font-size: 15px;
    }

    #tower-bar button {
        min-height: 64px;
        min-width: 120px;
        font-size: 16px;
    }
}

/* Landscape phones and tablets: HUD on top, board on the left and the tower
   bar as a sidebar so the whole game fits on screen without scrolling. */
@media (orientation: landscape) and (max-height: 900px) {
    body {
        align-items: flex-start;
        padding: 0;
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    #menu-screen {
        padding: 8px 16px 16px;
        gap: 6px;
    }

    .menu-title img {
        width: min(520px, 70vw);
    }

    #game-screen {
        height: 100vh;
        height: 100dvh;
        width: 100%;
        max-width: 100%;
        padding: 4px 6px;
        gap: 4px;
        align-items: stretch;
        overflow: hidden;
    }

    #hud,
    #game-screen #hud {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        width: 100%;
        max-width: 100%;
        gap: 4px 12px;
        padding: 3px 8px;
        font-size: 12px;
        border-radius: 6px;
        flex: 0 0 auto;
    }

    #hud .speed-controls {
        justify-content: center;
    }

    .speed-btn {
        padding: 3px 9px;
    }

    #restart-round-btn,
    #sound-btn {
        padding: 3px 8px;
        font-size: 11px;
    }

    #play-row {
        flex: 1 1 auto;
        min-height: 0;
        flex-direction: row;
        align-items: stretch;
        justify-content: center;
        gap: 6px;
        container-type: size;
    }

    #game-area,
    #game-screen #game-area {
        flex: 0 0 auto;
        align-self: center;
        width: min(calc(100vw - 230px), calc((100dvh - 60px) * 4 / 3));
        width: min(calc(100cqw - 206px), calc(100cqh * 4 / 3));
        max-width: none;
        aspect-ratio: 4 / 3;
        height: auto;
    }

    #game-area canvas {
        width: 100%;
        height: 100%;
        border: 2px solid #4caf50;
        border-radius: 6px;
    }

    #tower-bar,
    #game-screen #tower-bar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-rows: min-content;
        align-content: center;
        width: 200px;
        max-width: 200px;
        flex: 0 0 200px;
        gap: 6px;
        padding: 6px;
        border-radius: 6px;
        overflow-y: auto;
    }

    .tower-btn,
    #tower-bar button {
        width: 100%;
        min-width: 0;
        margin: 0;
        padding: 8px 4px;
        font-size: 12px;
    }

    #start-wave-btn {
        grid-column: 1 / -1;
        padding: 12px 6px;
    }

    .panel {
        top: 6px;
        right: 6px;
        min-width: 160px;
        max-width: 60%;
        padding: 8px 10px;
        font-size: 12px;
    }

    .banner {
        top: 8px;
        max-width: calc(100% - 16px);
        padding: 6px 10px;
        font-size: 12px;
        text-align: center;
    }
}

/* Very small landscape phones: the sidebar gets narrower. */
@media (orientation: landscape) and (max-height: 380px) {
    #tower-bar,
    #game-screen #tower-bar {
        width: 170px;
        max-width: 170px;
        flex-basis: 170px;
    }

    #game-area,
    #game-screen #game-area {
        width: min(calc(100vw - 200px), calc((100dvh - 56px) * 4 / 3));
        width: min(calc(100cqw - 176px), calc(100cqh * 4 / 3));
    }

    .tower-btn,
    #tower-bar button {
        padding: 6px 3px;
        font-size: 11px;
    }
}
#studio-logo {
    width: min(240px, 60vw);
    margin-top: 18px;
}

@media (orientation: portrait) {
    #menu-screen {
        min-height: 100vh;
        min-height: 100dvh;
        justify-content: center;
        box-sizing: border-box;
    }

    #menu-screen .difficulty-btn {
        min-height: 72px;
    }

    #game-screen {
        min-height: 100vh;
        min-height: 100dvh;
        justify-content: center;
    }
}

#app-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    min-height: 100vh;
    min-height: 100dvh;
}

#app-content {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

#app-content > .screen {
    flex: 1;
    min-height: 0;
    max-width: 100%;
}

#app-content > #menu-screen,
#app-content > #game-over-screen,
#app-content > #victory-screen {
    padding-top: 54px;
}

#account-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 20;
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    padding: 4px;
    border-radius: 50%;
}

#account-btn svg {
    width: 32px;
    height: 32px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
}

#account-btn img {
    display: block;
    width: 36px;
    height: 36px;
    image-rendering: pixelated;
    justify-self: center;
    align-self: center;
}

#game-screen #hud {
    min-height: 48px;
    padding-right: 54px;
}

#play-row > #game-area,
#play-row > #tower-bar {
    max-width: 100%;
}

.tower-btn-image {
    width: 36px;
    height: 36px;
    object-fit: contain;
    image-rendering: pixelated;
    flex-shrink: 0;
    pointer-events: none;
}

#studio-watermark {
    padding: 2px 8px;
    color: #a5d6a7;
    opacity: 0.55;
    font-size: 10px;
    letter-spacing: 1px;
    text-align: right;
    pointer-events: none;
}

#boss-guide {
    width: 100%;
    max-width: 520px;
    padding: 10px 14px;
    border: 1px solid #82734a;
    border-radius: 8px;
    color: #d7dfcd;
    font-size: 12px;
    line-height: 1.5;
}

#boss-guide summary {
    cursor: pointer;
    color: #f1c40f;
    font-weight: bold;
}

#boss-guide dt {
    color: #f1c40f;
    font-weight: bold;
    margin-top: 10px;
}

#boss-guide dd {
    margin: 2px 0 0;
}

#boss-status {
    flex: 0 0 80px;
    height: 80px;
    width: 100%;
    min-width: 0;
    padding: 4px 8px;
    background: #080b08;
    color: #ffc470;
    font-family: Arial, sans-serif;
    font-size: 13px;
    line-height: 18px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    overflow: auto;
    text-align: center;
}

#app-promotion {
    flex: 0 0 auto;
    padding: 6px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
}

#promotion-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 86px;
    padding: 10px 12px;
    border: 1px solid #9a86ef;
    border-radius: 12px;
    background: linear-gradient(135deg, #30225b, #142a40);
    color: #fff;
    text-decoration: none;
    box-shadow: inset 0 0 24px #6548d930;
    touch-action: manipulation;
}

#promotion-link:focus-visible {
    outline: 3px solid #f1c40f;
    outline-offset: 2px;
}

.pro-promotion #promotion-link {
    border-color: #f1c40f;
    background: linear-gradient(135deg, #294a26, #142a40);
}

.pro-promotion #promotion-name {
    color: #ffe880;
}

#promotion-art {
    width: 72px;
    height: 72px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 3px 4px #0008);
}

#promotion-label {
    color: #d7cdf8;
    font-size: 10px;
    letter-spacing: 1px;
}

#promotion-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

#promotion-name {
    font-size: 18px;
    letter-spacing: 1px;
    overflow-wrap: anywhere;
}

#promotion-description {
    font-size: 12px;
    color: #e2dcf6;
}

#promotion-cta {
    color: #f1c40f;
    font-size: 11px;
    font-weight: bold;
}

@media (orientation: portrait) {
    #promotion-link {
        min-height: 86px;
        padding: 6px 12px;
    }

    #promotion-name {
        font-size: 16px;
    }

    #promotion-description {
        font-size: 11px;
    }

    #promotion-cta {
        font-size: 10px;
    }
}

@media (orientation: portrait) and (max-width: 420px) {
    #promotion-label {
        display: none;
    }
}

@media (orientation: portrait) and (max-width: 700px) {
    .tower-btn {
        display: grid;
        grid-template-columns: 36px minmax(0, 1fr);
        column-gap: 6px;
    }

    .tower-btn-image {
        grid-row: 1 / 3;
    }
}

@media (orientation: landscape) {
    #app-shell {
        flex-direction: row;
        height: 100vh;
        height: 100dvh;
        min-height: 0;
    }

    #app-content {
        height: 100%;
        overflow-y: auto;
    }

    #app-content > #game-screen {
        height: auto;
        min-height: 0;
    }

    #app-promotion {
        order: -1;
        display: flex;
        align-items: center;
        width: clamp(100px, 14vw, 180px);
        padding: 6px;
        padding-left: max(6px, env(safe-area-inset-left));
    }

    #promotion-link {
        flex-direction: column;
        width: 100%;
        padding: 14px 6px;
        gap: 10px;
        text-align: center;
    }

    #promotion-art {
        width: min(80px, 100%);
        height: auto;
    }

    #promotion-name {
        font-size: 15px;
    }
}

@media (orientation: landscape) and (max-height: 380px) {
    .tower-btn-image {
        width: 28px;
        height: 28px;
    }

    #tower-bar,
    #game-screen #tower-bar {
        align-content: start;
    }
}

/* Retro pixel-art palette and hard-edged game panels. */
@font-face {
    font-family: "Press Start 2P";
    src: url("../assets/fonts/press-start-2p.ttf") format("truetype");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

:root {
    color-scheme: dark;
}

body {
    background: #050705;
    color: #ffe34a;
    font-family: "Press Start 2P", monospace;
    font-size: 9px;
    font-weight: 400;
}

button,
.panel,
#hud,
#tower-bar,
.banner,
#boss-guide,
#promotion-link {
    border-radius: 0;
    box-shadow: 3px 3px 0 #000, inset 2px 2px 0 rgba(255, 255, 255, 0.16);
}

button {
    font-family: inherit;
    font-weight: 400;
    text-shadow: 1px 1px 0 #000;
}

h1,
#choose-difficulty-label,
#hud,
.tower-btn-name,
.tower-btn-cost {
    text-shadow: 2px 2px 0 #000;
}

h1,
#choose-difficulty-label {
    color: #ffe34a;
}

.game-select-btn,
.difficulty-btn,
#continue-btn,
.flag-btn,
.speed-btn,
.account-btn {
    border-radius: 0;
}

.game-select-btn,
.difficulty-btn,
.flag-btn,
.account-btn,
.panel-actions button,
.game-over-actions button {
    border-radius: 0;
    box-shadow: 3px 3px 0 #000, inset 2px 2px 0 rgba(255, 255, 255, 0.16);
}

#hud {
    background: #080b08;
    border: 2px solid #347b27;
    color: #ffe34a;
    letter-spacing: 0.03em;
}

#hud .hud-item {
    text-shadow: 2px 2px 0 #000;
}

#game-area canvas {
    background-color: #155018;
    background-image:
        radial-gradient(#438a28 1px, transparent 1px),
        radial-gradient(#0b3e13 1px, transparent 1px);
    background-size: 12px 12px;
    background-position: 0 0, 6px 6px;
    border-color: #347b27;
    image-rendering: pixelated;
}

#tower-bar {
    background: #070b08;
    border: 2px solid #347b27;
}

.tower-btn {
    background: #0c4319;
    border: 2px solid #55a82d;
    color: #ffe34a;
    border-radius: 0;
    box-shadow: 3px 3px 0 #000, inset 2px 2px 0 rgba(255, 255, 255, 0.16);
}

.tower-btn.selected {
    background: #176c26;
    border-color: #a4e74b;
}

.tower-btn-cost {
    color: #f3f1df;
}

.tower-btn-name {
    font-size: 9px;
}

.tower-btn-image {
    width: 52px;
    height: 52px;
}

.tower-btn-cost {
    font-size: 7px;
}

#gameplay-description,
#boss-guide,
#promotion-description {
    font-family: Arial, sans-serif;
}

#gameplay-description {
    font-size: 13px;
    line-height: 1.7;
}

#boss-guide {
    font-size: 11px;
}

#hud {
    font-size: 8px;
}

#start-wave-btn {
    background: #78400d;
    border: 2px solid #e8a923;
    color: #ffe34a;
    box-shadow: 3px 3px 0 #000, inset 2px 2px 0 rgba(255, 255, 255, 0.16);
}

#start-wave-btn:disabled {
    background: #392b18;
    border-color: #765a2c;
    color: #b7a979;
}

#auto-wave-btn {
    background: #12601f;
    border: 2px solid #68c832;
    color: #fff;
    box-shadow: 3px 3px 0 #000, inset 2px 2px 0 rgba(255, 255, 255, 0.16);
}

#auto-wave-btn.selected {
    background: #278c2d;
    color: #fff;
}

#save-game-btn,
#sound-btn {
    background: #06488f;
    border: 2px solid #3b91ef;
    color: #fff;
    box-shadow: 3px 3px 0 #000, inset 2px 2px 0 rgba(255, 255, 255, 0.16);
}

#restart-round-btn {
    background: #8d1717;
    border: 2px solid #e54536;
    color: #fff;
    box-shadow: 3px 3px 0 #000, inset 2px 2px 0 rgba(255, 255, 255, 0.16);
}

#sound-btn.muted {
    background: #343838;
    border-color: #828888;
}

.panel,
.banner,
.app-toast {
    background: #080b08;
    border: 2px solid #e5c72f;
    color: #ffe34a;
    box-shadow: 4px 4px 0 #000;
}

.panel h3 {
    color: #ffe34a;
}

.panel-actions button {
    background: #0c4319;
    border: 2px solid #55a82d;
    color: #fff;
}

#panel-evolve-frost-btn {
    background: #06488f;
    border-color: #3b91ef;
}

#panel-evolve-venom-btn {
    background: #12601f;
    border-color: #68c832;
}

#boss-guide {
    background: #080b08;
    border-color: #347b27;
    color: #e6e5d5;
}

#boss-guide summary,
#boss-guide dt,
#promotion-cta {
    color: #ffe34a;
}

#promotion-link {
    background: #241542;
    border-color: #9664cf;
    box-shadow: 4px 4px 0 #000;
}

#promotion-name {
    color: #ffe34a;
}

#studio-watermark {
    color: #83b85b;
    font-family: inherit;
}

button:hover:not(:disabled) {
    filter: brightness(1.15);
}

@media (max-width: 700px) and (orientation: portrait) {
    #tower-bar {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
        padding: 7px;
    }

    #tower-bar .tower-btn {
        display: flex;
        min-width: 0;
        min-height: 105px;
        padding: 5px 2px;
        gap: 2px;
    }

    #tower-bar .tower-btn-image {
        width: 52px;
        height: 52px;
    }

    #tower-bar .tower-btn-name {
        font-size: 10px;
    }

    #tower-bar .tower-btn-cost {
        font-size: 9px;
    }

    #start-wave-btn {
        grid-column: 1 / 3;
    }

    #auto-wave-btn {
        grid-column: 3;
    }

    #save-game-btn {
        grid-column: 4;
    }
}

@media (max-width: 360px) and (orientation: portrait) {
    #tower-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #start-wave-btn {
        grid-column: 1 / -1;
    }

    #auto-wave-btn,
    #save-game-btn {
        grid-column: auto;
    }
}

@media (orientation: landscape) and (max-height: 380px) {
    #tower-bar .tower-btn-image {
        width: 32px;
        height: 32px;
    }
}
/* User menu popup and boosters. */
.user-menu {
    position: absolute;
    top: 64px;
    right: 6px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 190px;
    padding: 8px;
    background: #080b08;
    border: 3px solid #55a82d;
    box-shadow: 4px 4px 0 #000, inset 2px 2px 0 rgba(255, 255, 255, 0.12);
}

.user-menu.hidden {
    display: none;
}

.user-menu::before {
    content: "";
    position: absolute;
    top: -11px;
    right: 18px;
    width: 14px;
    height: 8px;
    background: #55a82d;
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 6px 10px;
    background: #0c4319;
    border: 2px solid #347b27;
    color: #ffe34a;
    font-family: "Press Start 2P", monospace;
    font-size: 9px;
    text-align: left;
    cursor: pointer;
    box-shadow: 3px 3px 0 #000, inset 2px 2px 0 rgba(255, 255, 255, 0.16);
}

.user-menu-item:hover,
.user-menu-item:focus-visible {
    background: #176c26;
    border-color: #a4e74b;
    outline: none;
}

.user-menu-item img {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    image-rendering: pixelated;
}

#hud .booster-bar {
    display: flex;
    align-items: center;
    gap: 5px;
}

.booster-coins {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 4px;
    color: #ffe34a;
}

.booster-coins img {
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
}

.booster-btn {
    position: relative;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 2px;
    background: #0c4319;
    border: 2px solid #55a82d;
    cursor: pointer;
}

.booster-btn img {
    width: 24px;
    height: 24px;
    image-rendering: pixelated;
}

.booster-count {
    position: absolute;
    right: -5px;
    bottom: -5px;
    min-width: 14px;
    padding: 2px 2px 1px;
    background: #000;
    border: 1px solid #55a82d;
    color: #f3f1df;
    font-size: 6px;
    line-height: 1;
    text-align: center;
}

.booster-count.price {
    color: #ffe34a;
    border-color: #e8a923;
}

.booster-btn.active {
    background: #78400d;
    border-color: #ffe34a;
    animation: booster-glow 0.8s steps(2) infinite;
}

.booster-btn.unaffordable {
    opacity: 0.45;
    filter: grayscale(0.85);
}

@keyframes booster-glow {
    0% { box-shadow: 3px 3px 0 #000, 0 0 0 2px #ffe34a; }
    100% { box-shadow: 3px 3px 0 #000, 0 0 0 2px #e8402a; }
}

#game-screen.one-hit-armed #game-area canvas {
    cursor: crosshair;
    outline: 3px dashed #e8402a;
    outline-offset: -3px;
}

.victory-coins {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #b7a979;
}

.victory-coins.earned {
    color: #ffe34a;
}

.victory-coins img {
    width: 20px;
    height: 20px;
    image-rendering: pixelated;
}

#tower-info-panel {
    top: 50%;
    right: auto;
    left: 50%;
    width: min(360px, calc(100% - 16px));
    max-height: calc(100% - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translate(-50%, -50%);
    z-index: 5;
}

#tower-info-panel .panel-actions {
    flex-wrap: wrap;
}

#tower-info-panel .panel-actions button {
    min-height: 44px;
}

#game-over-screen .game-over-actions button,
#victory-screen > button {
    min-height: 58px;
    padding: 14px 20px;
    font-size: 12px;
}

#game-over-screen .game-over-actions button {
    flex: 1 1 180px;
}

#victory-screen > button {
    width: min(100%, 360px);
}

@media (max-width: 700px), (max-device-width: 700px) {
    #game-over-screen,
    #victory-screen {
        overflow-y: auto;
    }
}