* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    background: #16213e;
    font-family: 'Helvetica Neue', 'PingFang SC', sans-serif;
    user-select: none;
    -webkit-user-select: none;
    padding: 10px;
}

/* ========================================================================
   GameBoy 外壳
   ======================================================================== */

.gameboy {
    background: #cdc9b5;
    border-radius: 8px 8px 36px 8px;
    box-shadow:
        0 8px 32px rgba(0,0,0,0.45),
        inset 0 1px 0 rgba(255,255,255,0.18);
    max-width: 400px;
    width: 100%;
    padding: 0 14px 18px;
    position: relative;
}

/* ---- 顶部 ---- */
.shell-top {
    display: flex;
    align-items: center;
    padding: 10px 6px 6px;
}

.power-led {
    width: 7px;
    height: 7px;
    background: #d63031;
    border-radius: 50%;
    margin-right: 8px;
    box-shadow: 0 0 5px rgba(214,48,49,0.6);
    flex-shrink: 0;
}

.brand-text {
    font-size: 9px;
    font-weight: 700;
    color: #302b40;
    letter-spacing: 1.5px;
    font-family: 'Helvetica Neue', sans-serif;
    white-space: nowrap;
}

/* ---- 屏幕区域 ---- */
.screen-bezel {
    background: #232428;
    border-radius: 6px 6px 20px 6px;
    padding: 10px 10px 8px;
    margin: 0 auto 8px;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
}

.bezel-text {
    text-align: center;
    color: #5c5d66;
    font-size: 6px;
    font-weight: 700;
    letter-spacing: 2.5px;
    margin-bottom: 6px;
    font-family: 'Helvetica Neue', sans-serif;
}

.screen {
    background: #0f380f;
    border: 3px solid #193d19;
    border-radius: 2px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
}

#gameCanvas {
    display: block;
    width: 120px;
    height: 240px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    flex-shrink: 0;
}

.screen-side {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 8px 8px 4px;
    flex-shrink: 0;
}

.next-canvas {
    background: #163316;
    border-radius: 3px;
    width: 84px;
    height: 84px;
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-item {
    display: flex;
    flex-direction: column;
}

.info-label {
    color: #4a7a2e;
    font-size: 7px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.info-value {
    color: #8bac0f;
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-family: 'Courier New', monospace;
}

/* ========================================================================
   控制区
   ======================================================================== */

.controls-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
    margin: 10px 0 14px;
}

/* ---- 十字键 ---- */
.dpad {
    width: 102px;
    height: 102px;
    position: relative;
    flex-shrink: 0;
}

.dpad button {
    position: absolute;
    background: #2c2c32;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.dpad button:active {
    background: #3c3c44;
}

.dpad-up, .dpad-down {
    width: 28px;
    height: 40px;
    left: 37px;
}

.dpad-left, .dpad-right {
    width: 40px;
    height: 28px;
    top: 37px;
}

.dpad-up    { top: 0; }
.dpad-down  { bottom: 0; }
.dpad-left  { left: 0; }
.dpad-right { right: 0; }

.dpad-center {
    width: 28px;
    height: 28px;
    background: #1c1c20;
    border-radius: 50%;
    position: absolute;
    top: 37px;
    left: 37px;
    pointer-events: none;
}

/* ---- AB 按钮 ---- */
.action-buttons {
    display: flex;
    gap: 8px;
    transform: rotate(-15deg);
    padding-right: 10px;
    flex-shrink: 0;
}

.btn-a, .btn-b {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    color: #302b40;
    box-shadow: 0 3px 0 rgba(0,0,0,0.3);
    transition: transform 0.05s, box-shadow 0.05s;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Helvetica Neue', sans-serif;
}

.btn-a {
    background: #b3416c;
    box-shadow: 0 3px 0 #7a2a48;
}

.btn-b {
    background: #b3416c;
    box-shadow: 0 3px 0 #7a2a48;
}

.btn-a:active, .btn-b:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #7a2a48;
}

/* ========================================================================
   底部
   ======================================================================== */

.bottom-area {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 12px;
    margin-top: 2px;
}

.start-select {
    display: flex;
    gap: 14px;
    transform: rotate(-25deg);
}

.start-select button {
    width: 46px;
    height: 11px;
    background: #6b6b70;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 5px;
    font-weight: 700;
    color: #302b40;
    letter-spacing: 1px;
    box-shadow: 0 2px 0 rgba(0,0,0,0.25);
    transition: transform 0.05s, box-shadow 0.05s;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Helvetica Neue', sans-serif;
    padding: 0;
    line-height: 11px;
    text-align: center;
}

.start-select button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 rgba(0,0,0,0.25);
}

/* ---- 扬声器格栅 ---- */
.speaker-grille {
    display: flex;
    gap: 3px;
}

.speaker-grille span {
    width: 4px;
    height: 22px;
    background: #a8b490;
    border-radius: 2px;
}

/* ========================================================================
   覆盖层
   ======================================================================== */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.25s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    background: #cdc9b5;
    border-radius: 12px;
    padding: 30px 28px;
    text-align: center;
    min-width: 250px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.45);
}

.overlay-content h2 {
    font-size: 1.4rem;
    color: #302b40;
    margin-bottom: 12px;
    letter-spacing: 2px;
    font-family: 'Courier New', monospace;
}

.overlay-stats {
    margin-bottom: 16px;
}

.overlay-stats.hidden {
    display: none;
}

.overlay-stats p {
    font-size: 0.9rem;
    color: #4a4458;
    margin: 2px 0;
    font-weight: 600;
}

.overlay-stats p span {
    color: #232428;
    font-size: 1rem;
}

.overlay-btn {
    background: #232428;
    color: #8bac0f;
    border: none;
    padding: 14px 44px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    letter-spacing: 1.5px;
}

.overlay-btn:active {
    background: #38383e;
}

/* ========================================================================
   移动端
   ======================================================================== */

@media (max-width: 480px) {
    body {
        padding: 0;
        align-items: flex-start;
        background: #cdc9b5;
    }

    .gameboy {
        border-radius: 0;
        max-width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        padding: 0 12px 16px;
        box-shadow: none;
        display: flex;
        flex-direction: column;
    }

    .shell-top {
        padding: 12px 6px 8px;
        flex-shrink: 0;
    }

    .screen-bezel {
        flex-shrink: 0;
        margin-bottom: 12px;
    }

    .controls-area {
        flex: 1;
        padding: 0 10px;
        margin: 0;
        align-items: center;
    }

    .dpad {
        width: 110px;
        height: 110px;
    }

    .dpad-up, .dpad-down {
        width: 30px;
        height: 44px;
        left: 40px;
    }

    .dpad-left, .dpad-right {
        width: 44px;
        height: 30px;
        top: 40px;
    }

    .dpad-up    { top: 0; }
    .dpad-down  { bottom: 0; }
    .dpad-left  { left: 0; }
    .dpad-right { right: 0; }

    .dpad-center {
        width: 30px;
        height: 30px;
        top: 40px;
        left: 40px;
    }

    .btn-a, .btn-b {
        width: 50px;
        height: 50px;
        font-size: 15px;
    }

    .start-select button {
        width: 52px;
        height: 13px;
        font-size: 6px;
        line-height: 13px;
    }

    .speaker-grille span {
        width: 5px;
        height: 26px;
    }

    .bottom-area {
        flex-shrink: 0;
        padding-bottom: 4px;
    }

    .overlay-content {
        min-width: 280px;
        padding: 34px 24px;
    }
}

/* ---- 横屏 ---- */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        align-items: center;
        padding: 4px;
        background: #16213e;
    }

    .gameboy {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
        gap: 8px;
        padding: 10px 14px 12px;
        border-radius: 8px;
        max-width: 100%;
        min-height: auto;
    }

    .shell-top {
        width: 100%;
        padding: 0 0 4px;
        flex-shrink: 0;
    }

    .screen-bezel {
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .controls-area {
        flex: 0;
        margin: 0;
        flex-shrink: 0;
    }

    .bottom-area {
        width: 100%;
        padding: 2px 10px 0;
        flex-shrink: 0;
    }

    #gameCanvas {
        height: 170px;
        width: 85px;
    }

    .next-canvas {
        width: 60px;
        height: 60px;
    }
}
