.game-container {
    background: #1a1a2e;
    max-width: 960px;
    margin: 0 auto;
    padding: 12px;
    border-radius: 12px;
    position: relative;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px 10px;
}

.game-logo {
    color: #e8a84c;
    font-size: 14px;
    font-weight: 700;
    font-family: monospace;
    margin: 0;
    letter-spacing: 0.5px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.coin-display {
    color: #ffd700;
    font-family: monospace;
    font-size: 13px;
    font-weight: 600;
    margin-right: 4px;
}

.ctrl-btn {
    background: #2a2a4e;
    color: #888;
    border: 1px solid #3a3a5e;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-family: monospace;
    line-height: 1;
}

.ctrl-btn:hover {
    background: #3a3a5e;
    color: #ccc;
}

.canvas-wrap {
    position: relative;
    text-align: center;
}

#gameCanvas {
    border-radius: 10px;
    border: 2px solid #3a3a5e;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: block;
    margin: 0 auto;
    width: 100%;
    height: auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.controls-hint {
    color: #555;
    font-family: monospace;
    font-size: 11px;
    margin-top: 6px;
}

.win-banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #4caf50;
    font-family: monospace;
    font-size: 28px;
    font-weight: 900;
    text-shadow: 0 0 20px rgba(76, 175, 80, 0.6);
    animation: winPulse 1s ease-in-out infinite;
    pointer-events: none;
}

@keyframes winPulse {
    0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 0.7; transform: translate(-50%, -50%) scale(1.05); }
}

/* Touch Controls */
.touch-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 10px 0 4px;
}

.action-btns {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dpad {
    display: flex;
    gap: 4px;
}

.touch-btn {
    background: #2a2a4e;
    color: #fff;
    border: 1px solid #3a3a5e;
    border-radius: 10px;
    width: 56px;
    height: 56px;
    font-size: 18px;
    font-family: monospace;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    transition: background 0.1s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.touch-btn:hover {
    background: #3a3a5e;
}

.touch-btn:active {
    background: #4a4a6e;
}

.jump-btn {
    background: #8b5e14;
    border-color: #aa7020;
    width: 80px;
    font-size: 13px;
    font-weight: 700;
}

.jump-btn:hover {
    background: #a06a10;
}

.jump-btn:active {
    background: #b07a20;
}

.interact-btn {
    background: #2e5e8b;
    border-color: #3a7aaa;
    width: 56px;
    font-size: 12px;
    font-weight: 700;
}

.interact-btn:hover {
    background: #3a7aaa;
}

.interact-btn:active {
    background: #4a8aba;
}

/* Settings Overlay */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
    background: rgba(0, 0, 0, 0.5);
}

.settings-panel {
    background: #1a1a2e;
    border: 1px solid #3a3a5e;
    border-radius: 12px;
    padding: 20px;
    width: 300px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.settings-title {
    color: #ccc;
    font-family: monospace;
    font-size: 12px;
    font-weight: 700;
}

.settings-header-btns {
    display: flex;
    gap: 10px;
}

.settings-reset {
    color: #555;
    background: none;
    border: none;
    font-family: monospace;
    font-size: 12px;
    cursor: pointer;
}

.settings-reset:hover {
    color: #999;
}

.settings-close {
    color: #666;
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
}

.settings-close:hover {
    color: #fff;
}

.setting-row {
    margin-bottom: 14px;
}

.setting-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.setting-label span:first-child {
    color: #666;
    font-family: monospace;
    font-size: 12px;
}

.setting-value {
    color: #e8a84c;
    font-family: monospace;
    font-size: 12px;
}

.setting-row input[type="range"] {
    width: 100%;
    height: 6px;
    background: #2a2a4e;
    border-radius: 4px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    accent-color: #e8a84c;
}

.setting-row input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #e8a84c;
    border-radius: 50%;
    cursor: pointer;
}

/* Keybinding Settings */
.keybinds-section {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #2a2a4e;
}

.keybinds-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.keybinds-title {
    color: #ccc;
    font-family: monospace;
    font-size: 11px;
    font-weight: 700;
}

.keybinds-reset {
    color: #555;
    background: none;
    border: none;
    font-family: monospace;
    font-size: 11px;
    cursor: pointer;
}

.keybinds-reset:hover {
    color: #999;
}

.keybinds-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.keybind-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
}

.keybind-action {
    color: #666;
    font-family: monospace;
    font-size: 11px;
    min-width: 80px;
}

.keybind-keys {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.keybind-key {
    display: inline-block;
    background: #2a2a4e;
    color: #bbb;
    border: 1px solid #3a3a5e;
    border-radius: 4px;
    padding: 2px 7px;
    font-family: monospace;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    min-width: 24px;
    text-align: center;
    user-select: none;
    -webkit-user-select: none;
}

.keybind-key:hover {
    background: #3a3a5e;
    border-color: #e8a84c;
    color: #e8a84c;
}

.keybind-key.keybind-listening {
    background: #3a2a10;
    border-color: #e8a84c;
    color: #e8a84c;
    animation: keybindPulse 0.8s ease-in-out infinite;
}

@keyframes keybindPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.keybind-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: none;
    color: #444;
    border: 1px dashed #333;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    user-select: none;
    -webkit-user-select: none;
}

.keybind-add:hover {
    color: #e8a84c;
    border-color: #e8a84c;
}

.keybinds-hint {
    color: #444;
    font-family: monospace;
    font-size: 9px;
    margin-top: 8px;
    text-align: center;
    transition: color 0.2s;
}

.keybinds-hint-active {
    color: #e8a84c;
}

/* Large screens */
@media (min-width: 961px) {
    .game-container {
        padding: 20px;
    }

    .game-logo {
        font-size: 18px;
    }

    .coin-display {
        font-size: 16px;
    }

    .ctrl-btn {
        font-size: 16px;
        padding: 6px 10px;
    }

    .controls-hint {
        font-size: 13px;
        margin-top: 10px;
    }

    .touch-controls {
        display: none;
    }
}

/* Medium screens — touch still useful */
@media (min-width: 521px) and (max-width: 960px) {
    .game-container {
        padding: 16px;
    }

    .game-logo {
        font-size: 16px;
    }
}

/* Small screens */
@media (max-width: 520px) {
    .game-container {
        border-radius: 0;
        padding: 8px;
    }

    #gameCanvas {
        border-radius: 6px;
    }

    .touch-btn {
        width: 50px;
        height: 50px;
        font-size: 16px;
    }

    .jump-btn {
        width: 70px;
        font-size: 12px;
    }

    .interact-btn {
        width: 50px;
        font-size: 11px;
    }
}

/* Force-show touch on actual touch devices regardless of width */
@media (pointer: coarse) {
    .touch-controls {
        display: flex !important;
    }
}

/* ============================================================
   Menu Overlay
   ============================================================ */
.menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 20, 0.85);
    border-radius: 12px;
}

.menu-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 40px;
}

.menu-title {
    color: #e8a84c;
    font-family: monospace;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 1px;
    margin: 0;
    text-shadow: 0 0 12px rgba(232, 168, 76, 0.3);
}

#menuCatCanvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    width: 108px;
    height: 126px;
    margin: 4px 0;
}

.menu-btn {
    width: 200px;
    padding: 10px 0;
    background: #2a2a4e;
    color: #ccc;
    border: 1px solid #3a3a5e;
    border-radius: 6px;
    font-family: monospace;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    text-align: center;
}

.menu-btn:hover {
    background: #3a3a5e;
    color: #e8a84c;
    border-color: #e8a84c;
}

.menu-btn-secondary {
    background: #1a1a30;
    border-color: #2a2a4e;
    color: #999;
}

.menu-btn-secondary:hover {
    background: #2a2a4e;
    color: #e8a84c;
    border-color: #e8a84c;
}

.menu-btn-back {
    background: none;
    border: none;
    color: #888;
    font-family: monospace;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.15s;
}

.menu-btn-back:hover {
    color: #e8a84c;
}

/* ============================================================
   Level Select Overlay
   ============================================================ */
.level-select-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 20, 0.85);
    border-radius: 12px;
}

.level-select-panel {
    width: 360px;
    max-width: 90%;
}

.level-select-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.level-select-title {
    color: #e8a84c;
    font-family: monospace;
    font-size: 16px;
    font-weight: 700;
    margin: 0;
}

.level-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: #1a1a30;
    border: 1px solid #2a2a4e;
    border-left: 4px solid #3a3a5e;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.level-card:hover {
    background: #2a2a4e;
    border-color: #3a3a5e;
    transform: translateX(4px);
}

.level-card-num {
    color: #e8a84c;
    font-family: monospace;
    font-size: 18px;
    font-weight: 900;
    min-width: 28px;
    text-align: center;
}

.level-card-info {
    flex: 1;
}

.level-card-name {
    color: #ccc;
    font-family: monospace;
    font-size: 13px;
    font-weight: 700;
}

.level-card-theme {
    color: #666;
    font-family: monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 2px;
}

.level-card[data-theme="outdoor"] { border-left-color: #4a8a2e; }
.level-card[data-theme="dungeon"] { border-left-color: #336699; }
.level-card[data-theme="temple"] { border-left-color: #aa6622; }
.level-card[data-theme="ominous"] { border-left-color: #6644aa; }

/* ============================================================
   Editor Wrapper
   ============================================================ */
.editor-wrapper {
    background: #1a1a2e;
    padding: 12px;
    border-radius: 12px;
    max-width: 1400px;
    margin: 0 auto;
}

.editor-wrapper-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 4px 10px;
}

.editor-wrapper-title {
    color: #e8a84c;
    font-family: monospace;
    font-size: 14px;
    font-weight: 700;
}

/* ============================================================
   Dev Tools Sub-Menu Overlay
   ============================================================ */
.dev-tools-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 20, 0.85);
    border-radius: 12px;
}

.dev-tools-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 40px;
}

.dev-tools-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.dev-tools-title {
    color: #e8a84c;
    font-family: monospace;
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

/* ============================================================
   Sprite Viewer & Audio Viewer Wrappers
   ============================================================ */
.sprite-viewer-wrapper,
.audio-viewer-wrapper,
.level-manager-wrapper {
    background: #1a1a2e;
    padding: 12px;
    border-radius: 12px;
    max-width: 1400px;
    margin: 0 auto;
}

.dev-viewer-content {
    padding: 8px 4px;
}

/* ============================================================
   Level Manager
   ============================================================ */
.lm-section-title {
    color: #e8a84c;
    font-family: monospace;
    font-size: 13px;
    font-weight: 700;
    margin: 16px 0 8px;
}

.lm-playlist {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 40px;
}

.lm-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #1a1a30;
    border: 1px solid #2a2a4e;
    border-left: 4px solid #e8a84c;
    border-radius: 6px;
    cursor: grab;
    transition: background 0.15s, transform 0.15s;
}

.lm-row:hover {
    background: #22223a;
}

.lm-row-num {
    color: #e8a84c;
    font-family: monospace;
    font-size: 16px;
    font-weight: 900;
    min-width: 24px;
    text-align: center;
}

.lm-row-info {
    flex: 1;
    min-width: 0;
}

.lm-row-name {
    color: #ccc;
    font-family: monospace;
    font-size: 12px;
    font-weight: 700;
}

.lm-row-file {
    color: #555;
    font-family: monospace;
    font-size: 10px;
    margin-top: 1px;
}

.lm-row-btns {
    display: flex;
    gap: 4px;
    align-items: center;
}

.lm-btn {
    background: #2a2a4e;
    color: #888;
    border: 1px solid #3a3a5e;
    border-radius: 4px;
    padding: 3px 8px;
    font-family: monospace;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.lm-btn:hover {
    background: #3a3a5e;
    color: #ccc;
}

.lm-btn-danger {
    color: #aa4444;
}

.lm-btn-danger:hover {
    background: #4a2a2a;
    color: #ff6666;
}

.lm-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0;
}

.lm-save-btn {
    background: #e8a84c;
    color: #1a1a2e;
    border: none;
    border-radius: 6px;
    padding: 8px 20px;
    font-family: monospace;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

.lm-save-btn:hover {
    background: #f5c76b;
}

.lm-status {
    color: #888;
    font-family: monospace;
    font-size: 11px;
}

.lm-avail-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #1a1a30;
    border: 1px solid #2a2a4e;
    border-left: 4px solid #3a3a5e;
    border-radius: 6px;
    margin-bottom: 4px;
    transition: background 0.15s;
}

.lm-avail-row:hover {
    background: #22223a;
}

.lm-avail-active {
    border-left-color: #4caf50;
    opacity: 0.6;
}

.lm-btn-add {
    background: #1a3a1a;
    color: #4caf50;
    border: 1px solid #2a5a2a;
    border-radius: 4px;
    padding: 3px 10px;
    font-family: monospace;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.lm-btn-add:hover {
    background: #2a5a2a;
    color: #6fcf6f;
}

.lm-dragging {
    opacity: 0.4;
}

.lm-dragover {
    border-top: 2px solid #e8a84c;
}

.lm-empty {
    color: #555;
    font-family: monospace;
    font-size: 12px;
    padding: 16px;
    text-align: center;
}

.lm-hint {
    color: #444;
    font-family: monospace;
    font-size: 10px;
    margin-top: 4px;
}

/* ============================================================
   D-pad up/down buttons (hidden by default, shown in GB mode)
   ============================================================ */
.dpad-up,
.dpad-down {
    display: none;
}

/* ============================================================
   Pause Overlay
   ============================================================ */
.pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 80;
    border-radius: 12px;
    cursor: pointer;
}

.pause-content {
    text-align: center;
}

.pause-text {
    color: #fff;
    font-family: monospace;
    font-size: 32px;
    font-weight: 900;
    letter-spacing: 4px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.pause-hint {
    color: rgba(255, 255, 255, 0.6);
    font-family: monospace;
    font-size: 12px;
    margin-top: 8px;
}

/* ============================================================
   Game Boy decorative elements (hidden by default)
   ============================================================ */
.gb-brand-bar,
.gb-meta-row,
.gb-speaker {
    display: none;
}

/* ============================================================
   Game Boy Mode — fullscreen on touch devices
   ============================================================ */
.gameboy-mode {
    background: #8b8b73 !important;
    padding: 0 !important;
}

/* Propagate height through Bootstrap wrapper */
.gameboy-mode .container-fluid {
    height: 100%;
    padding: 0;
}

.gameboy-mode .game-container {
    background: #8b8b73;
    max-width: 100%;
    border-radius: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    height: 100dvh; /* dynamic vh for mobile browser chrome */
    overflow: hidden;
}

/* Hide header and controls hint in GB mode */
.gameboy-mode .game-header {
    display: none;
}

.gameboy-mode .controls-hint {
    display: none;
}

/* Fullscreen button hidden in GB mode (use SELECT instead) */
.gameboy-mode .fullscreen-btn {
    display: none !important;
}

/* ---- Brand bar ---- */
.gameboy-mode .gb-brand-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
    order: -1; /* brand bar is after canvas in DOM, reorder to top */
}

.gb-power-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    box-shadow: 0 0 6px rgba(76, 175, 80, 0.6);
}

.gb-brand-text {
    color: #3a3a5e;
    font-family: monospace;
    font-size: 13px;
    font-weight: 700;
    font-style: italic;
    letter-spacing: 1px;
}

/* ---- Screen bezel ---- */
.gameboy-mode .canvas-wrap {
    background: #2a2a3e;
    border-radius: 12px 12px 24px 12px;
    padding: 10px;
    margin: 0 12px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
    width: calc(100% - 24px);
    box-sizing: border-box;
    /* flex: fill remaining space, but shrink if controls need room */
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.gameboy-mode #gameCanvas {
    border: none;
    border-radius: 4px;
    box-shadow: none;
    /* fill bezel, object-fit scales the 480x320 bitmap to fit both axes */
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ---- Touch controls in GB mode ---- */
.gameboy-mode .touch-controls {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}

/* ---- D-pad: CSS grid cross shape ---- */
.gameboy-mode .dpad {
    display: grid;
    grid-template-columns: 48px 48px 48px;
    grid-template-rows: 48px 48px 48px;
    gap: 0;
    flex-shrink: 0;
}

.gameboy-mode .dpad-up {
    display: flex;
    align-items: center;
    justify-content: center;
    grid-column: 2;
    grid-row: 1;
}

.gameboy-mode .dpad-left {
    grid-column: 1;
    grid-row: 2;
}

.gameboy-mode .dpad-right {
    grid-column: 3;
    grid-row: 2;
}

.gameboy-mode .dpad-down {
    display: flex;
    align-items: center;
    justify-content: center;
    grid-column: 2;
    grid-row: 3;
}

.gameboy-mode .dpad .touch-btn {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    background: #3a3a4e;
    border: 1px solid #4a4a5e;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.gameboy-mode .dpad .touch-btn:active {
    background: #5a5a6e;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ---- A/B buttons (jump + interact) ---- */
.gameboy-mode .action-btns {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.gameboy-mode .jump-btn,
.gameboy-mode .interact-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #8b2252;
    border: 2px solid #a03060;
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    flex-shrink: 0;
    box-shadow: 0 3px 0 #5a1535, 0 4px 8px rgba(0, 0, 0, 0.3);
}

.gameboy-mode .jump-btn:active,
.gameboy-mode .interact-btn:active {
    box-shadow: 0 1px 0 #5a1535;
    transform: translateY(2px);
}

/* ---- Meta row (SELECT / START) ---- */
.gameboy-mode .gb-meta-row {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 4px 0 2px;
    flex-shrink: 0;
}

.gb-meta-btn {
    background: #6a6a5e;
    color: #3a3a30;
    border: none;
    border-radius: 10px;
    padding: 5px 16px;
    font-family: monospace;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    transform: rotate(-25deg);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.gb-meta-btn:active {
    background: #7a7a6e;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* ---- Speaker grille ---- */
.gameboy-mode .gb-speaker {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-self: flex-end;
    padding: 4px 20px 8px;
    transform: rotate(-25deg);
    opacity: 0.4;
    flex-shrink: 0;
}

.gb-speaker-line {
    width: 28px;
    height: 2px;
    background: #5a5a4e;
    border-radius: 1px;
}

/* ---- Pause overlay in GB mode ---- */
.gameboy-mode .pause-overlay {
    border-radius: 0;
}

/* ---- Settings overlay z-index fix for GB mode ---- */
.gameboy-mode .settings-overlay {
    z-index: 100;
}

/* ---- Menu/level-select overlays in GB mode ---- */
.gameboy-mode .menu-overlay,
.gameboy-mode .level-select-overlay,
.gameboy-mode .dev-tools-overlay {
    border-radius: 0;
}

/* ---- Safe area insets for notched phones ---- */
@supports (padding-top: env(safe-area-inset-top)) {
    .gameboy-mode .game-container {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* ---- Landscape: compact column, controls still below ---- */
@media (orientation: landscape) {
    .gameboy-mode .gb-brand-bar {
        padding: 2px 12px;
    }

    .gameboy-mode .canvas-wrap {
        padding: 4px;
        margin: 0 8px;
        width: calc(100% - 16px);
        border-radius: 8px 8px 16px 8px;
    }

    .gameboy-mode .touch-controls {
        padding: 4px 20px;
    }

    .gameboy-mode .dpad {
        grid-template-columns: 34px 34px 34px;
        grid-template-rows: 34px 34px 34px;
    }

    .gameboy-mode .dpad .touch-btn {
        width: 34px;
        height: 34px;
        font-size: 10px;
    }

    .gameboy-mode .action-btns {
        gap: 10px;
    }

    .gameboy-mode .jump-btn,
    .gameboy-mode .interact-btn {
        width: 44px;
        height: 44px;
        font-size: 9px;
    }

    .gameboy-mode .gb-meta-row {
        padding: 1px 0;
    }

    .gameboy-mode .gb-speaker {
        display: none;
    }
}

/* ---- Small portrait phones (under 600px tall) ---- */
@media (orientation: portrait) and (max-height: 600px) {
    .gameboy-mode .gb-brand-bar {
        padding: 3px 12px;
    }

    .gameboy-mode .canvas-wrap {
        padding: 6px;
        margin: 0 8px;
        width: calc(100% - 16px);
    }

    .gameboy-mode .touch-controls {
        padding: 8px 16px;
    }

    .gameboy-mode .dpad {
        grid-template-columns: 42px 42px 42px;
        grid-template-rows: 42px 42px 42px;
    }

    .gameboy-mode .dpad .touch-btn {
        width: 42px;
        height: 42px;
        font-size: 13px;
    }

    .gameboy-mode .jump-btn,
    .gameboy-mode .interact-btn {
        width: 52px;
        height: 52px;
        font-size: 10px;
    }

    .gameboy-mode .gb-speaker {
        display: none;
    }
}
