/* ===== 明亮主題 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    --pixel-font: 'Press Start 2P', 'Courier New', monospace;
    --bg-color: #f5f0eb;
    --console-color: #faf6f0;
    --screen-border: #d9d0c5;
    --btn-primary: #f0a070;
    --btn-secondary: #70b0d0;
    --text-dark: #3a2e2a;
    --text-light: #5a4e4a;
    --shadow-light: rgba(0,0,0,0.08);
    --shadow-heavy: rgba(0,0,0,0.15);
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #e8e0d8;
    font-family: var(--pixel-font);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 復古遊戲機外殼 — 明亮 */
.console {
    width: 100%;
    max-width: 440px;
    height: 100vh;
    max-height: 880px;
    background: var(--console-color);
    border-radius: 28px 28px 16px 16px;
    padding: 18px 16px 12px 16px;
    box-shadow: 0 12px 30px var(--shadow-heavy), inset 0 2px 4px rgba(255,255,255,0.6);
    border: 3px solid #c8bdb0;
    display: flex;
    flex-direction: column;
    position: relative;
}
.console::before {
    content: 'RECYCLE ★';
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--console-color);
    padding: 0 18px;
    font-size: 11px;
    letter-spacing: 4px;
    color: #8a7a6a;
    border-radius: 0 0 10px 10px;
    border: 2px solid #c8bdb0;
    border-top: none;
    font-family: var(--pixel-font);
}

/* 屏幕 */
.screen-wrapper {
    flex: 0 0 80%;
    background: var(--screen-border);
    border-radius: 20px;
    padding: 6px;
    margin-bottom: 8px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.08), 0 4px 12px var(--shadow-light);
    position: relative;
    overflow: hidden;
    min-height: 0;
}
#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 14px;
    background: #fcf9f5;
    image-rendering: auto;
    touch-action: none;
}

/* 控制區 */
.control-panel {
    flex: 0 0 20%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    min-height: 80px;
}
.btn-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    width: 100%;
}
.ctrl-btn {
    flex: 1;
    max-width: 130px;
    padding: 12px 0;
    font-size: 24px;
    font-family: var(--pixel-font);
    border: 4px solid #b8a898;
    border-radius: 14px;
    background: #f0e8e0;
    color: var(--text-dark);
    box-shadow: 0 4px 0 #b8a898, 0 6px 12px var(--shadow-light);
    transition: all 0.06s ease;
    touch-action: manipulation;
    cursor: pointer;
    letter-spacing: 1px;
    position: relative;
}
.ctrl-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0px 0 #b8a898, 0 4px 8px var(--shadow-light);
}
.ctrl-btn.left {
    background: #f5ddd0;
    border-color: #dbb8a8;
}
.ctrl-btn.left:active { background: #eccfc0; }
.ctrl-btn.right {
    background: #d0e8f0;
    border-color: #a8c8d8;
}
.ctrl-btn.right:active { background: #c0dce8; }
.ctrl-btn .sub {
    display: block;
    font-size: 9px;
    opacity: 0.7;
    margin-top: 2px;
    letter-spacing: 0;
}
.ctrl-btn:disabled {
    opacity: 0.4;
    transform: translateY(2px);
    box-shadow: 0 2px 0 #b8a898;
    pointer-events: none;
}

/* === BGM 音量按鈕 (小圓形) === */
.volume-btn {
    flex: 0 0 44px !important;
    max-width: 44px !important;
    min-width: 44px !important;
    padding: 6px 0 !important;
    font-size: 22px !important;
    background: #e8ddd0 !important;
    border-color: #c8bdb0 !important;
    border-radius: 50% !important;
    box-shadow: 0 4px 0 #b8a898 !important;
    margin-right: 0px;
    line-height: 1;
}
.volume-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0px 0 #b8a898 !important;
}
.volume-btn:disabled {
    opacity: 0.4;
    transform: translateY(2px);
    box-shadow: 0 2px 0 #b8a898;
    pointer-events: none;
}
.volume-btn #volumeIcon {
    display: block;
    line-height: 1;
}

.game-status {
    font-size: 11px;
    color: var(--text-light);
    background: #eee8e0;
    padding: 4px 16px;
    border-radius: 20px;
    border: 2px solid #d0c8c0;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90%;
    margin-top: 4px;
    display: none;
}

/* 覆蓋層 (明亮) */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(250, 245, 240, 0.94);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px 20px;
    border-radius: 18px;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.overlay-title {
    font-size: 20px;
    color: #3a2e2a;
    text-shadow: 0 2px 0 rgba(255,255,255,0.5);
    margin-bottom: 6px;
    letter-spacing: 1px;
    text-align: center;
    line-height: 1.4;
}
.overlay-sub {
    font-size: 13px;
    color: #5a4e4a;
    margin-bottom: 16px;
}
.pixel-input {
    background: #fffcf8;
    border: 4px solid #b8a898;
    padding: 12px 16px;
    font-size: 20px;
    font-family: var(--pixel-font);
    color: #3a2e2a;
    text-align: center;
    width: 180px;
    border-radius: 10px;
    outline: none;
    letter-spacing: 2px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.04);
}
.pixel-input:focus {
    border-color: #f0a070;
    box-shadow: 0 0 20px rgba(240,160,112,0.2), inset 0 0 10px rgba(0,0,0,0.04);
}
.pixel-btn {
    background: #e8ddd0;
    border: 4px solid #b8a898;
    padding: 12px 28px;
    font-size: 15px;
    font-family: var(--pixel-font);
    color: var(--text-dark);
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 0 #b8a898;
    transition: all 0.08s ease;
    touch-action: manipulation;
    letter-spacing: 1px;
}
.pixel-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0px 0 #b8a898;
}
.pixel-btn.primary {
    background: #f0c8a8;
    border-color: #dbb08a;
}
.feedback-detail {
    color: var(--text-dark);
    font-size: 13px;
    text-align: center;
    max-width: 280px;
    line-height: 1.6;
    font-family: var(--pixel-font);
    background: rgba(255,255,255,0.6);
    padding: 12px 16px;
    border-radius: 12px;
    margin-top: 4px;
}
.feedback-score {
    color: #5a7a6a;
    font-size: 14px;
    margin-top: 10px;
    font-family: var(--pixel-font);
}

/* 排行榜 */
.rank-list {
    width: 100%;
    max-width: 320px;
    max-height: 260px;
    overflow-y: auto;
    background: rgba(255,252,248,0.7);
    border: 3px solid #d0c8c0;
    border-radius: 12px;
    padding: 8px 6px;
    margin: 6px 0 8px 0;
}
.rank-list::-webkit-scrollbar { width: 6px; }
.rank-list::-webkit-scrollbar-thumb { background: #c8bdb0; border-radius: 4px; }
.rank-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--text-dark);
    border-bottom: 1px solid #e0d8d0;
    letter-spacing: 0.5px;
}
.rank-item:last-child { border-bottom: none; }
.rank-item .pos { color: #7a3613; min-width: 28px; }
.rank-item .id { color: #001830; min-width: 60px; }
.rank-item .sc { color: #40cf64; min-width: 50px; text-align: right; }
.rank-item .tm { color: #646464; min-width: 60px; text-align: right; }
.rank-empty {
    color: #8a7a6a;
    font-size: 12px;
    text-align: center;
    padding: 20px 0;
}

.footer-hint {
    font-size: 17px;
    color: #ae8e6e;
    margin-top: 8px;
    letter-spacing: 1px;
    font-family: var(--pixel-font);
}

/* 響應式 */
@media (max-width: 440px) {
    .console { padding: 12px 10px 8px 10px; max-height: 780px; }
    .ctrl-btn { font-size: 20px; padding: 10px 0; max-width: 140px; }
    /* === 音量按鈕在小屏幕略縮 === */
    .volume-btn {
        flex: 0 0 38px !important;
        max-width: 38px !important;
        min-width: 38px !important;
        font-size: 18px !important;
    }
    .overlay-title { font-size: 17px; }
    .pixel-input { width: 150px; font-size: 17px; padding: 10px 12px; }
    .rank-item { font-size: 10px; padding: 4px 6px; }
    .screen-wrapper { padding: 4px; border-radius: 14px; }
    .game-status { font-size: 10px; display:none;}
    
}
@media (max-height: 700px) {
    .console { max-height: 100vh; border-radius: 12px; padding: 6px; }
    .screen-wrapper { flex: 0 0 78%; padding: 4px; }
    .control-panel { flex: 0 0 22%; min-height: 60px; gap: 2px; }
    .ctrl-btn { padding: 6px 0; font-size: 16px; max-width: 120px; max-height: 100px; }
    .ctrl-btn .sub { font-size: 7px; }
    .volume-btn {
        flex: 0 0 32px !important;
        max-width: 32px !important;
        min-width: 32px !important;
        font-size: 15px !important;
        padding: 4px 0 !important;
    }
}
@media (min-width: 600px) {
    .console { max-width: 500px; max-height: 940px; border-radius: 36px; padding: 22px 20px 14px 20px; }
    .ctrl-btn { max-width: 170px; padding: 16px 0; font-size: 28px; max-height: 90px;}
    .volume-btn {
        flex: 0 0 52px !important;
        max-width: 52px !important;
        min-width: 52px !important;
        font-size: 26px !important;
    }
}