:root {
    --bg: #030a18;
    --surface: rgba(18, 18, 30, 0.85);
    --card-bg: rgba(25, 25, 45, 0.6);
    --board-bg: #071327;
    --board-inner: #040b17;
    --accent: #00e5ff;
    --accent-glow: rgba(0, 229, 255, 0.3);
    --emerald: #00ff88;
    --pink: #ff2d55;
    --yellow: #ffcc00;
    --border: rgba(255, 255, 255, 0.08);
    --text-main: #e0e0e0;
    --text-dim: rgba(255, 255, 255, 0.5);
}

html,
body {
    width: 100%;
    overflow-x: hidden;
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg);
    background-image: 
        radial-gradient(circle at 0% 0%, rgba(0, 132, 255, 0.16) 0%, transparent 42%),
        radial-gradient(circle at 100% 100%, rgba(0, 229, 255, 0.12) 0%, transparent 45%),
        radial-gradient(circle at 50% 100%, rgba(19, 74, 164, 0.18) 0%, transparent 55%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
    padding-top: max(0px, env(safe-area-inset-top));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-main);
}

@keyframes shake {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-4px, 4px); }
    75% { transform: translate(4px, -4px); }
}

.shaking { animation: shake 0.1s infinite; }

#game-shell {
    display: flex;
    gap: 30px;
    padding: 16px;
    background: var(--surface);
    backdrop-filter: blur(50px);
    border-radius: 40px;
    border: 1px solid var(--border);
    box-shadow: 0 50px 150px rgba(0, 0, 0, 0.8);
    position: relative;
    max-width: 98vw;
    margin: 8px auto;
}


@keyframes titleFloat {
    0%, 100% { text-shadow: 0 0 30px var(--accent-glow), 0 0 60px rgba(0,229,255,0.15); transform: translateY(0); }
    50% { text-shadow: 0 0 50px rgba(0,229,255,0.55), 0 0 90px rgba(0,229,255,0.2); transform: translateY(-4px); }
}

@keyframes btnPulse {
    0%, 100% { box-shadow: 0 10px 25px var(--accent-glow); }
    50% { box-shadow: 0 10px 45px rgba(0,229,255,0.6), 0 0 0 6px rgba(0,229,255,0.08); }
}

@keyframes borderGlow {
    0%, 100% { border-color: rgba(138,225,255,0.2); }
    50% { border-color: rgba(0,229,255,0.42); box-shadow: inset 0 0 30px rgba(0,0,0,0.45), 0 14px 34px rgba(0,20,42,0.42), 0 0 30px rgba(0,229,255,0.12); }
}

.side-hud {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: clamp(196px, 22vw, 228px);
    position: relative;
    z-index: 20;
}

.hud-card {
    background: var(--card-bg);
    padding: 9px 12px;
    border-radius: 18px;
    border: 1px solid var(--border);
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-height: 64px;
}

.hud-card.preview {
    min-height: 122px;
}

.hud-card.rank {
    min-height: 84px;
}

.hud-card.missions {
    min-height: 88px;
    justify-content: flex-start;
}

.hud-card.clickable {
    cursor: pointer;
    justify-content: center;
    align-items: center;
    min-height: 60px;
    touch-action: manipulation;
}

.hud-card.clickable:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px var(--accent-glow);
}

.hud-card.clickable:active {
    transform: scale(0.96);
}

.hud-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 25%;
    height: 50%;
    width: 4px;
    background: var(--accent);
    border-radius: 0 4px 4px 0;
}

.hud-card.pb::before { background: var(--yellow); }
.hud-card.hold::before { background: #ff9500; }
.hud-card.level::before { background: var(--emerald); }
.hud-card.combo::before { background: var(--pink); }
.hud-card.volume::before { background: #7000ff; }
.hud-card.pause::before { background: #fff; }
.hud-card.score::before { background: #ff9500; }
.hud-card.rank::before { background: #00d4ff; }
.hud-card.missions::before { background: #00ff88; }

.hud-label {
    font-size: 9px;
    font-weight: 800;
    color: var(--text-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 4px;
    display: block;
    text-align: center;
    width: 100%;
}

.hud-value {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 18px;
    font-weight: 800;
    display: block;
    color: #fff;
    text-align: center;
    width: 100%;
}

/* Volume bars */
.vol-bars-wrap {
    display: flex;
    align-items: flex-end;
    gap: 5px;
    height: 24px;
    justify-content: center;
    margin: 4px 0 3px;
}
.vbar {
    width: 9px;
    border-radius: 3px;
    background: rgba(255,255,255,0.1);
    transition: background 0.2s, box-shadow 0.2s;
}
#vb1 { height: 10px; }
#vb2 { height: 19px; }
#vb3 { height: 28px; }
.vbar.active { background: #7000ff; box-shadow: 0 0 8px rgba(112,0,255,0.55); }

/* Pause icon */
.pause-icon-display {
    font-size: 28px;
    line-height: 1;
    margin: 3px 0 2px;
    display: block;
    text-align: center;
}

/* CSS-drawn pause / play bars */
.pause-bars {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    height: 24px;
    margin: 3px 0 2px;
}
.pause-bars span {
    display: block;
    width: 7px;
    height: 22px;
    background: #fff;
    border-radius: 3px;
    transition: all 0.2s;
}
.pause-bars.playing span:first-child {
    width: 0;
    height: 0;
    background: transparent;
    border-style: solid;
    border-width: 11px 0 11px 18px;
    border-color: transparent transparent transparent #fff;
    border-radius: 0;
}
.pause-bars.playing span:last-child { display: none; }

/* Shared small label under icons */
.icon-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-dim);
    text-transform: uppercase;
    text-align: center;
    display: block;
}

.xp-track {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
    margin: 6px 0;
}

#xp-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #00e5ff, #00ff88);
    transition: width 0.25s ease;
}

.missions-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 9px;
    line-height: 1.25;
    color: var(--text-dim);
    width: 100%;
}

.mission-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 4px;
}

.mission-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.mission-row.done .mission-name {
    color: #b4ffd5;
}

.mission-progress {
    font-family: 'Orbitron', sans-serif;
    color: var(--accent);
    white-space: nowrap;
}

.streak-popup {
    position: absolute;
    top: 14%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(24px, 4vw, 42px);
    font-weight: 900;
    letter-spacing: 2px;
    color: #00e5ff;
    text-shadow: 0 0 20px rgba(0, 229, 255, 0.5);
    opacity: 0;
    pointer-events: none;
    z-index: 120;
}

.streak-popup.show {
    animation: streakPop 0.8s ease;
}

@keyframes streakPop {
    0% { opacity: 0; transform: translate(-50%, -40%) scale(0.8); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
    100% { opacity: 0; transform: translate(-50%, -64%) scale(0.94); }
}


    #start-screen .neon-title {
        animation: titleFloat 3s ease-in-out infinite;
    }

/* Controls hint in start screen */
.start-controls-hint {
    margin-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.07);
    padding-top: 14px;
    width: 100%;
    max-width: 280px;
}
.ctrl-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-bottom: 7px;
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}
.ctrl-row kbd {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 5px;
    padding: 2px 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 9px;
    color: var(--accent);
    line-height: 1.6;
}
kbd.ml { margin-left: 8px; }
.ctrl-touch {
    margin-top: 4px;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 8px;
    font-size: 9px;
}

.ctrl-touch-only {
    display: none;
    margin-top: 4px;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 8px;
    font-size: 9px;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    justify-content: center;
}
@media (hover: none) and (pointer: coarse) {
    .ctrl-touch-only { display: flex; }
    .ctrl-kb-hint { display: none; }
}

.hud-card.pb,
.hud-card.level,
.hud-card.score,
.hud-card.combo,
.hud-card.rank,
.hud-card.volume,
.hud-card.pause {
    align-items: center;
    text-align: center;
}
.canvas-box {
    height: 84px;
    background: linear-gradient(160deg, rgba(8, 22, 46, 0.72), rgba(5, 14, 31, 0.72));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 4px;
    border: 1px solid var(--border);
}

@media (max-height: 900px) and (min-width: 801px) {
    #game-shell {
        gap: 20px;
        padding: 16px;
    }

    .side-hud {
        width: 188px;
        gap: 7px;
    }

    .hud-card {
        min-height: 58px;
        padding: 8px 11px;
        border-radius: 16px;
    }

    .hud-card.preview { min-height: 106px; }
    .hud-card.rank { min-height: 78px; }
    .hud-card.missions { min-height: 80px; }

    .hud-label {
        font-size: 8px;
        margin-bottom: 2px;
    }

    .hud-value {
        font-size: 17px;
    }

    .canvas-box {
        height: 72px;
        margin-top: 3px;
    }

    .missions-list {
        font-size: 8px;
    }
}

#board-container {
    position: relative;
    background: radial-gradient(circle at 20% 10%, rgba(0, 212, 255, 0.08), transparent 45%), var(--board-bg);
    padding: 10px;
    border-radius: 24px;
    border: 1px solid rgba(138, 225, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.45), 0 14px 34px rgba(0, 20, 42, 0.42);
    max-width: 100%;
    overflow: hidden;
    overscroll-behavior: contain;
}

#gameCanvas {
    border-radius: 16px;
    background: linear-gradient(180deg, #081124 0%, var(--board-inner) 100%);
    touch-action: none;
}

.overlay {
    position: absolute;
    inset: 0;
    background: rgba(4, 4, 8, 0.96);
    backdrop-filter: blur(25px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 28px;
    padding: 40px;
    text-align: center;
}

.neon-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 56px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 30px var(--accent-glow);
    margin-bottom: 40px;
    line-height: 0.9;
}

.start-caption {
    color: rgba(224, 245, 255, 0.72);
    font-size: 11px;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-top: -14px;
    margin-bottom: 20px;
}

.start-name-input {
    width: 100%;
    max-width: 280px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    padding: 13px 16px;
    color: #fff;
    font-family: 'Plus Jakarta Sans', sans-serif;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    outline: none;
}

.start-name-input:focus {
    border-color: var(--accent);
}

.start-error {
    color: var(--pink);
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.btn-main {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 16px 45px;
    border-radius: 60px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 25px var(--accent-glow);
}

.btn-main:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 15px 35px var(--accent-glow);
}

.btn-wide {
    width: 100%;
    max-width: 280px;
}

#start-game-btn {
     animation: btnPulse 2.2s ease-in-out infinite;
}
#start-game-btn:hover { animation: none; }
.board-idle { animation: borderGlow 3s ease-in-out infinite; }

.btn-full {
    width: 100%;
}

.btn-gap-top {
    margin-top: 10px;
}

#pause-screen .btn-gap-top {
    margin-top: 20px;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    box-shadow: none;
}

.title-sm {
    font-size: 32px;
}

.overlay-title-danger {
    color: var(--pink);
    font-family: 'Orbitron', sans-serif;
    margin-bottom: 10px;
}

.final-score {
    font-family: 'Orbitron', sans-serif;
    font-size: 36px;
    font-weight: 900;
    margin-bottom: 16px;
}

.name-submit-box {
    width: 100%;
    max-width: 280px;
    margin-bottom: 16px;
}

.record-status {
    color: var(--accent);
    font-size: 11px;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.name-submit-input {
    margin-bottom: 8px;
}

.lb-title {
    text-align: center;
    margin-bottom: 10px;
}

.leaderboard {
    margin: 25px 0;
    width: 100%;
    max-width: 280px;
    font-size: 13px;
    text-align: left;
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.ad-break {
    z-index: 110;
}

.ad-break-reason {
    margin-top: 4px;
    margin-bottom: 14px;
    color: rgba(224, 245, 255, 0.78);
    font-size: 11px;
    letter-spacing: 0.8px;
}

.ad-slot-box {
    width: 320px;
    max-width: 100%;
    padding: 10px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.03);
}

.ad-break-slot {
    width: 300px;
    max-width: 100%;
    height: 250px;
    min-height: 250px;
    max-height: 250px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.12), rgba(255, 45, 85, 0.12));
    border: 1px dashed rgba(255, 255, 255, 0.24);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 12px;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.75);
    font-size: 12px;
    line-height: 1.35;
}

.ad-break-slot .adsbygoogle {
    width: 100% !important;
    height: 100% !important;
}

.ad-break-fallback {
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    letter-spacing: 0.8px;
    text-align: center;
    color: rgba(224, 245, 255, 0.82);
    line-height: 1.35;
    max-width: 240px;
}

#ad-break-continue[disabled] {
    opacity: 0.75;
    cursor: not-allowed;
    transform: none;
}

.lb-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.lb-row:last-child { border-bottom: none; }

.lb-name {
    color: rgba(255, 255, 255, 0.82);
    font-weight: 700;
}
.lb-score {
    font-family: 'Orbitron';
    font-weight: 700;
    color: var(--accent);
}

.mobile-controls {
    display: none;
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    gap: 25px;
    width: 100%;
    padding: 0 40px;
    justify-content: space-between;
}

.mobile-controls-row {
    display: flex;
    gap: 10px;
}

.btn-ctrl {
    width: 75px;
    height: 75px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 28px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

@media (max-width: 800px) {
    body {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        width: 100%;
        min-height: 100dvh;
        padding-top: calc(env(safe-area-inset-top) + 2px);
        padding-bottom: calc(env(safe-area-inset-bottom) + 2px);
        overflow: hidden;
    }

    #game-shell {
        display: flex;
        flex-direction: column;
        gap: 5px;
        padding: 5px;
        border-radius: 18px;
        align-items: center;
        height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 4px);
        max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 4px);
        width: min(calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 8px), 480px);
        max-width: 480px;
        border: 1px solid var(--border);
        background: var(--surface);
        box-shadow: 0 24px 46px rgba(0, 0, 0, 0.35);
        margin: 0;
        overflow: hidden;
    }

    .side-hud {
        display: grid;
        flex: 0 0 auto;
        width: 100%;
        max-width: none;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        grid-auto-rows: auto;
        gap: 5px;
        margin-top: 0;
        padding: 0;
    }

    .side-hud .rank,
    .side-hud .missions {
        display: none !important;
    }

    .side-hud .pb,
    .side-hud .level,
    .side-hud .score,
    .side-hud .combo {
        min-height: 48px;
        padding: 6px 4px;
    }

    .side-hud .preview {
        display: flex;
        grid-column: 1 / 3;
        grid-row: 2;
        min-height: 70px;
        padding: 6px 5px;
    }

    .side-hud .preview .canvas-box {
        height: 48px;
        margin-top: 2px;
        border-radius: 10px;
    }

    .side-hud .preview #nextCanvas {
        width: 56px;
        height: 56px;
    }

    .side-hud .hud-card {
        min-height: 48px;
        padding: 6px 5px;
        border-radius: 12px;
    }

    .side-hud .hud-label {
        font-size: 7px;
        letter-spacing: 1px;
        margin-bottom: 1px;
    }

    .side-hud .hud-value {
        font-size: 12px;
        font-weight: 800;
    }

    .side-hud .pause .icon-label,
    .side-hud .pause .pause-icon-display {
        display: inline-flex;
    }

    .side-hud .pause {
        grid-column: 4 / 5;
        grid-row: 2;
        width: 100%;
        justify-self: stretch;
        min-height: 70px;
        justify-content: center;
        gap: 3px;
        pointer-events: auto;
    }

    .side-hud .volume {
        grid-column: 3 / 4;
        grid-row: 2;
        min-height: 70px;
        padding: 6px 5px;
        pointer-events: auto;
    }

    .side-hud .volume .vol-bars-wrap {
        height: 14px;
        gap: 3px;
        margin: 2px 0;
    }

    .side-hud .volume .vbar {
        width: 6px;
        border-radius: 2px;
    }

    .side-hud .volume #vb1 { height: 6px; }
    .side-hud .volume #vb2 { height: 10px; }
    .side-hud .volume #vb3 { height: 14px; }

    .side-hud .volume .icon-label,
    .side-hud .volume .hud-label {
        font-size: 7px;
        letter-spacing: 1px;
    }

    .side-hud .pause .hud-label {
        margin-bottom: 0;
        font-size: 7px;
        letter-spacing: 1.3px;
    }

    .side-hud .pause .icon-label {
        font-size: 9px;
        letter-spacing: 1.6px;
    }

    .side-hud .pause .pause-bars {
        margin: 1px 0;
        height: 18px;
        gap: 4px;
    }

    .side-hud .pause .pause-bars span {
        height: 16px;
        width: 6px;
    }

    #board-container {
        flex: 1 1 100%;
        min-height: 0;
        width: 100%;
        max-width: none;
        padding: 2px;
        border-radius: 14px;
        margin: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    #gameCanvas {
        display: block;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        object-fit: contain;
    }
    
    .mobile-controls { 
        display: none !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        position: relative;
        bottom: 0;
        margin-top: 12px;
        margin-bottom: calc(8px + env(safe-area-inset-bottom));
        transform: none;
        left: 0;
        padding: 0;
        width: min(96vw, 320px);
        max-width: 320px;
        gap: 10px;
        z-index: 2;
    }

    .mobile-controls-row { display: none; }

    #start-screen .start-controls-hint {
        display: block;
        margin-top: 12px;
        max-width: 230px;
    }

    #start-screen .ctrl-kb-hint {
        display: none;
    }

    #start-screen .ctrl-touch-only {
        display: flex;
        border-top: none;
        padding-top: 0;
        margin-top: 0;
        font-size: 10px;
        line-height: 1.4;
    }

    .overlay {
        padding: 24px 18px;
        border-radius: 20px;
    }

    #game-over {
        justify-content: flex-start;
        padding-top: 12px;
        padding-bottom: 14px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #game-over .overlay-title-danger {
        margin-bottom: 6px;
    }

    #game-over .final-score {
        font-size: 30px;
        margin-bottom: 10px;
    }

    #game-over .leaderboard {
        margin: 10px 0;
        max-height: min(54dvh, 360px);
        overflow-y: auto;
    }

    #game-over .lb-row {
        padding: 8px 4px;
    }

    #game-over .btn-main {
        flex-shrink: 0;
        margin-top: 8px;
        margin-bottom: 2px;
    }

    .start-name-input,
    .btn-wide {
        max-width: 240px;
    }
    
    .neon-title { font-size: 32px; }
}

@media (max-height: 700px) and (max-width: 800px) {
    #game-shell {
        gap: 4px;
        padding: 4px;
        border-radius: 16px;
    }

    .side-hud {
        gap: 4px;
    }

    .side-hud .pb,
    .side-hud .level,
    .side-hud .score,
    .side-hud .combo {
        min-height: 44px;
        padding: 4px 3px;
    }

    .side-hud .hud-label {
        font-size: 6px;
        margin-bottom: 0;
    }

    .side-hud .hud-value {
        font-size: 11px;
    }

    .side-hud .preview {
        min-height: 62px;
        padding: 4px;
    }

    .side-hud .preview .canvas-box {
        height: 40px;
    }

    .side-hud .preview #nextCanvas {
        width: 48px;
        height: 48px;
    }

    .side-hud .volume,
    .side-hud .pause {
        min-height: 62px;
        padding: 4px;
    }

    #board-container {
        padding: 4px;
    }
}

@media (max-height: 560px) {
    body {
        align-items: flex-start;
    }

    #game-shell {
        margin-top: 0;
        border-radius: 16px;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    body {
        justify-content: center;
        padding-top: calc(env(safe-area-inset-top) + 10px);
        padding-bottom: calc(env(safe-area-inset-bottom) + 10px);
    }

    #game-shell {
        height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 20px);
        max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 20px);
    }
}

@media (max-width: 500px) {
    .btn-ctrl { width: 60px; height: 60px; font-size: 20px; border-radius: 16px; }
}

@media (max-height: 800px) and (min-width: 1100px) {
    .side-hud {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 320px;
        gap: 10px;
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }
    .hud-card { padding: 8px 12px; }
    .hud-value { font-size: 16px; }
    .canvas-box { height: 70px; }
}

@media (min-width: 801px) and (max-width: 1366px) {
    #game-shell {
        gap: 18px;
        padding: 12px;
        border-radius: 24px;
    }

    .side-hud {
        width: clamp(162px, 18vw, 186px);
        gap: 7px;
    }

    .hud-card {
        min-height: 56px;
        padding: 7px 10px;
        border-radius: 14px;
    }

    .hud-card.preview {
        min-height: 104px;
    }

    .hud-card.rank,
    .hud-card.missions {
        min-height: 74px;
    }

    .hud-label {
        font-size: 8px;
        margin-bottom: 2px;
        letter-spacing: 1.2px;
    }

    .hud-value {
        font-size: 15px;
    }

    .icon-label {
        font-size: 7px;
        letter-spacing: 1px;
    }

    .canvas-box {
        height: 66px;
        border-radius: 12px;
        margin-top: 2px;
    }

    .missions-list {
        font-size: 8px;
        gap: 4px;
    }

    .mission-row {
        padding-bottom: 3px;
    }
}
