/* 台灣夜市「香腸伯打彈珠」- 復古夜市風樣式表 (精準重構版) */

:root {
    --bg-dark: #1a0f0a;
    --wood-border: #4a2c11;
    --wood-light: #d8a05c;
    --neon-red: #ff3366;
    --neon-yellow: #ffcc00;
    --neon-cyan: #00f0ff;
    --taiwan-red: #d32f2f;
    --taiwan-gold: #ffb300;
    --card-bg: #2d1810;
    --text-light: #fff8e7;
    --font-stack: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
}

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

html, body {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 50% 10%, rgba(255, 100, 50, 0.15) 0%, transparent 60%),
        linear-gradient(to bottom, #180d09, #0f0705);
    color: var(--text-light);
    font-family: var(--font-stack);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 預設隱藏手機專屬頂列與抽屜標頭 (於 <= 900px 手機版啟用) */
.mobile-top-hud,
.mobile-drawer-backdrop,
.mobile-drawer-header {
    display: none;
}

/* 左右雙欄式主遊戲容器 (左側彈珠台零滾軸，右側儀表板) */
.app-split-container {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-width: 1920px;
    margin: 0 auto;
    padding: 8px 16px;
    gap: 16px;
    overflow: hidden;
    justify-content: center;
    align-items: center;
}

/* 左側：彈珠台專屬欄位 (絕對不產生滾軸，按螢幕高度與寬度等比例自適應) */
.pinball-column {
    flex: 0 0 auto;
    height: 100%;
    max-height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
    touch-action: none;
}

/* 彈珠機台外框 (照片同款實木直角外箱，由 JS 精準計算畫布尺寸確保零裁切) */
.pinball-chassis {
    position: relative;
    background: linear-gradient(145deg, #3d2314, #241209);
    border: 5px solid #8d4414;
    border-radius: 8px;
    padding: 6px;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.85),
        inset 0 0 15px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    touch-action: none;
}

#pinball-canvas {
    display: block;
    touch-action: none;
    -webkit-touch-callout: none;
}

/* 右側：儀表板欄位 (自適應高度，嚴格防裁切) */
.dashboard-column {
    flex: 1 1 auto;
    max-width: 520px;
    min-width: 320px;
    height: min(740px, calc(100vh - 16px));
    height: min(740px, calc(100dvh - 16px));
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    overflow-x: hidden;
    touch-action: pan-y;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 6px 8px 4px 4px;
    box-sizing: border-box;
}

/* 右側滾軸美化 (在小螢幕滾動時保持復古深色系) */
.dashboard-column::-webkit-scrollbar {
    width: 4px;
}
.dashboard-column::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.25);
}
.dashboard-column::-webkit-scrollbar-thumb {
    background: #8d4414;
    border-radius: 2px;
}
.dashboard-column::-webkit-scrollbar-thumb:hover {
    background: #ffb300;
}

/* 右側頂部霓虹招牌 */
.header-banner {
    width: 100%;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    gap: 4px;
}

/* 右側頂部復古型招牌 LOGO (嘉中管樂隊唬爛會) */
.retro-signboard-logo {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    background: radial-gradient(ellipse at 50% 30%, #9e1a1a 0%, #6d0a0a 65%, #3e0404 100%);
    border: 3px solid #d4af37;
    border-radius: 9px;
    padding: 4px 6px 5px 6px;
    box-shadow: 
        0 0 0 1.5px #260404,
        0 4px 14px rgba(0, 0, 0, 0.85),
        inset 0 0 16px rgba(0, 0, 0, 0.75),
        0 0 20px rgba(255, 179, 0, 0.35);
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, filter 0.25s ease;
    user-select: none;
}

.retro-signboard-logo:hover {
    transform: translateY(-1px);
    box-shadow: 
        0 0 0 1.5px #3a0808,
        0 6px 18px rgba(0, 0, 0, 0.9),
        inset 0 0 18px rgba(0, 0, 0, 0.6),
        0 0 26px rgba(255, 193, 7, 0.55);
    filter: brightness(1.05);
}

.retro-signboard-logo:active {
    transform: translateY(1px) scale(0.99);
}

/* 招牌四角復古金屬銅角釘 (Brass Rivets) */
.sign-rivet {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff9c4 0%, #ffd54f 40%, #ff8f00 75%, #3e2723 100%);
    box-shadow: 
        0 1px 2px rgba(0, 0, 0, 0.9),
        inset 0 0 1px rgba(255, 255, 255, 0.8);
    z-index: 3;
    pointer-events: none;
}

.rivet-tl { top: 4px; left: 4px; }
.rivet-tr { top: 4px; right: 4px; }
.rivet-bl { bottom: 4px; left: 4px; }
.rivet-br { bottom: 4px; right: 4px; }

/* 招牌內框線 (八角復古金線與飾邊) */
.signboard-inner-frame {
    position: relative;
    border: 1.2px solid rgba(255, 213, 79, 0.75);
    border-radius: 6px;
    padding: 3px 5px 3px 5px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, transparent 60%, rgba(0, 0, 0, 0.2) 100%);
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.signboard-inner-frame::before {
    content: '';
    position: absolute;
    inset: 1px;
    border: 1px dashed rgba(255, 224, 130, 0.35);
    border-radius: 4px;
    pointer-events: none;
}

/* 招牌頂部額眉 (省立嘉中與小金星) */
.sign-sub-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    line-height: 1.2;
    padding: 1px 0;
}

.sign-deco-symbol {
    color: #ffd54f;
    font-size: 0.58rem;
    filter: drop-shadow(0 0 2px #ff8f00);
}

.sign-origin-badge {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #fff9c4;
    text-shadow: 0 1px 2px #000, 0 0 5px rgba(255, 213, 79, 0.5);
}

/* 招牌核心主行 */
.sign-main-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 2px;
    gap: 4px;
}

/* 左側管樂小號金徽 */
.sign-crest-badge {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.6);
    transition: transform 0.25s ease;
}

.retro-signboard-logo:hover .sign-crest-badge {
    transform: rotate(-10deg) scale(1.08);
}

.sign-trumpet-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

/* 中間主標題與英文字 */
.sign-title-group {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    overflow: hidden;
}

.sign-main-title {
    font-size: clamp(1.15rem, 2.3vw, 1.40rem);
    font-weight: 900;
    letter-spacing: 2px;
    white-space: nowrap;
    margin: 0;
    line-height: 1.12;
    color: #fffef0;
    text-shadow: 
        0 1px 0 #ffe082,
        0 2px 0 #ffb300,
        0 3px 0 #e65100,
        0 4px 0 #c62828,
        0 5px 0 #670808,
        0 5px 2px rgba(0, 0, 0, 0.9),
        0 0 14px rgba(255, 215, 0, 0.65);
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.85));
}

.sign-en-sub {
    font-size: 0.48rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #ffe082;
    text-shadow: 0 1px 2px #000;
    white-space: nowrap;
    opacity: 0.95;
    margin-top: 1px;
}

/* 右側朱泥印章 (Authentic Vermilion Seal) */
.sign-seal-stamp {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border: 1.2px dashed #ff5252;
    outline: 1.2px solid #ff1744;
    outline-offset: 1px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(213, 0, 0, 0.35) 0%, rgba(183, 28, 28, 0.6) 100%);
    box-shadow: 
        0 1px 3px rgba(0, 0, 0, 0.7),
        inset 0 0 3px rgba(255, 23, 68, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(-7deg);
    transition: transform 0.2s ease;
}

.retro-signboard-logo:hover .sign-seal-stamp {
    transform: rotate(5deg) scale(1.08);
}

.seal-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 0.95;
}

.seal-char {
    font-size: 0.56rem;
    font-weight: 900;
    color: #ffcdd2;
    text-shadow: 0 0 2px #b71c1c;
    letter-spacing: 1px;
    font-family: "Noto Sans TC", "Microsoft JhengHei", serif;
}

/* 招牌下楣副底條 */
.sign-sub-bottom {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: linear-gradient(90deg, rgba(74, 20, 10, 0) 0%, rgba(93, 28, 14, 0.85) 20%, rgba(93, 28, 14, 0.85) 80%, rgba(74, 20, 10, 0) 100%);
    border-top: 1px solid rgba(255, 179, 0, 0.3);
    padding: 1px 8px;
    width: 100%;
    box-sizing: border-box;
    margin-top: 1px;
}

.sign-bullet {
    color: #ffb300;
    font-size: 0.50rem;
}

.bottom-brand {
    font-size: 0.68rem;
    font-weight: 700;
    color: #ffe0b2;
    text-shadow: 0 1px 2px #000;
    letter-spacing: 0.8px;
    white-space: nowrap;
}

/* 數據狀態與功能列 (精簡單行) */
.top-stats-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(45, 24, 16, 0.85);
    border: 1px solid rgba(255, 179, 0, 0.3);
    border-radius: 6px;
    box-sizing: border-box;
}

.stats-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 0.82rem;
    font-weight: bold;
    color: #d7ccc8;
}

.stat-val {
    color: var(--neon-yellow);
    font-size: 0.98rem;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-icon {
    background: #3e2723;
    border: 1px solid #8d6e63;
    color: #fff;
    padding: 2px 7px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.76rem;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: #5d4037;
    border-color: var(--neon-yellow);
}

/* 玩法模式切換頁籤 */
.mode-tabs {
    display: flex;
    justify-content: center;
    gap: 4px;
    width: 100%;
}

.tab-btn {
    flex: 1;
    padding: 4px 6px;
    font-size: 0.82rem;
    font-weight: bold;
    color: #d7ccc8;
    background: #2b1810;
    border: 1px solid #5d4037;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: var(--taiwan-red);
    border-color: var(--neon-yellow);
    color: #fff;
    box-shadow: 0 0 8px rgba(255, 51, 102, 0.5);
}

.mode-desc-strip {
    width: 100%;
    padding: 2px 6px;
    background: rgba(20, 10, 5, 0.65);
    border-radius: 4px;
    font-size: 0.76rem;
    color: #ffe0b2;
    text-align: center;
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* 右側面板本體 */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.pinball-inner-box {
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    background: #000;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.9);
}

#pinball-canvas {
    display: block;
    width: 440px;
    height: 740px;
}

/* 盤面即時懸浮 HUD (已完全隱藏，不遮擋彈珠台畫布) */
.table-hud {
    display: none !important;
}

/* 常駐每局 5 顆鋼珠即時累計記分儀表板 (精簡緊湊) */
.live-score-dashboard {
    width: 100%;
    margin-top: 2px;
    background: linear-gradient(180deg, #1f1109, #130a05);
    border: 1.5px solid #8d4414;
    border-radius: 6px;
    padding: 4px 8px;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-sizing: border-box;
}

.live-score-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.live-score-title {
    font-size: 0.82rem;
    font-weight: bold;
    color: #ffe082;
}

.live-balls-badge {
    font-size: 0.76rem;
    color: #d7ccc8;
    background: rgba(0, 0, 0, 0.6);
    padding: 1px 6px;
    border-radius: 10px;
    border: 1px solid #5d4037;
}

.live-balls-badge b {
    color: var(--neon-yellow);
    font-size: 0.88rem;
}

/* 5 顆鋼珠各自落球分數槽 */
.live-ball-slots {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.ball-slot {
    background: #0d0603;
    border: 1.5px solid #4e2608;
    border-radius: 5px;
    padding: 2px 2px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.25s ease;
}

.ball-slot.scored {
    border-color: #ffd54f;
    background: #2a1508;
    box-shadow: 0 0 6px rgba(255, 213, 79, 0.4);
    transform: translateY(-1px);
}

.slot-idx {
    font-size: 0.68rem;
    color: #8d6e63;
    font-weight: bold;
}

.slot-val {
    font-size: 0.88rem;
    font-weight: 900;
    color: #bcaaa4;
    margin-top: 1px;
}

.ball-slot.scored .slot-val {
    color: #ffeb3b;
    text-shadow: 0 0 4px rgba(255, 235, 59, 0.6);
}

/* 當前累計總分列 */
.live-total-row {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    padding: 2px 6px;
    gap: 4px;
    border: 1px dashed rgba(255, 204, 0, 0.35);
}

.live-total-label {
    font-size: 0.80rem;
    font-weight: bold;
    color: #ffcc80;
}

.live-total-formula {
    font-size: 0.78rem;
    color: #cfd8dc;
    font-family: monospace;
}

.live-total-eq {
    color: #8d6e63;
    font-weight: bold;
}

.live-total-val {
    font-size: 1.15rem;
    font-weight: 900;
    color: var(--neon-yellow);
    text-shadow: 0 0 6px rgba(255, 214, 0, 0.6);
}

.live-total-unit {
    font-size: 0.80rem;
    font-weight: bold;
    color: #ffe082;
}

/* 底部操作控制區 */
.plunger-control-container {
    width: 100%;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: rgba(20, 10, 5, 0.7);
    padding: 8px 12px;
    border-radius: 10px;
}

.plunger-guide {
    font-size: 0.84rem;
    color: #bcaaa4;
    line-height: 1.35;
}

.plunger-assembly {
    display: flex;
    align-items: center;
    gap: 8px;
}

.plunger-power-meter {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: #120703;
    border: 1.5px solid #5d4037;
    border-radius: 6px;
    padding: 4px 6px;
    min-width: 44px;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.8);
}

.power-meter-label {
    font-size: 0.68rem;
    font-weight: bold;
    color: #bcaaa4;
}

.power-meter-bar {
    width: 12px;
    height: 46px;
    background: #000;
    border: 1px solid #3e2723;
    border-radius: 3px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column-reverse;
}

.power-bar-fill {
    width: 100%;
    height: 0%;
    background: linear-gradient(to top, #43a047 0%, #fbc02d 55%, #e53935 100%);
    box-shadow: 0 0 6px rgba(255, 193, 7, 0.8);
    transition: height 0.04s ease;
}

.power-bar-text {
    font-size: 0.72rem;
    font-weight: 900;
    color: #ffd54f;
    font-family: monospace;
}

.plunger-touch-track {
    width: 58px;
    height: 78px;
    background: linear-gradient(to bottom, #2b180d, #140a05);
    border: 2px solid #a1887f;
    border-radius: 29px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 5px;
    cursor: grab;
    touch-action: none;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.8);
}

.plunger-touch-track:active {
    cursor: grabbing;
}

.plunger-touch-track::after {
    content: "▼ 蓄力";
    position: absolute;
    bottom: 5px;
    font-size: 0.65rem;
    color: rgba(255, 224, 130, 0.6);
    pointer-events: none;
}

.plunger-knob {
    width: 38px;
    height: 38px;
    background: radial-gradient(circle at 35% 35%, #ff5252, #b71c1c);
    border: 2px solid #ffcdd2;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    transition: transform 0.05s ease-out;
    z-index: 2;
}

.stack-selector-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(180deg, #2b1810, #170a04);
    border: 1.5px solid #ffb74d;
    border-radius: 20px;
    padding: 4px 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.6);
}

.btn-stack-step {
    background: linear-gradient(180deg, #5d4037, #3e2723);
    border: 1px solid #ffe082;
    color: #fff;
    font-size: 0.82rem;
    font-weight: bold;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}

.btn-stack-step:active {
    transform: scale(0.88);
}

.stack-label {
    font-size: 0.88rem;
    font-weight: bold;
    color: #fff3e0;
    white-space: nowrap;
}

.btn-launch-pill {
    background: linear-gradient(to bottom, #f44336, #b71c1c);
    border: 2px solid #ffcdd2;
    color: #fff;
    font-size: 0.95rem;
    font-weight: bold;
    padding: 8px 14px;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(244, 67, 54, 0.4);
}

.btn-launch-pill:active {
    transform: scale(0.96);
}

.btn-stopper-pill {
    background: linear-gradient(to bottom, #ff9800, #e65100);
    border: 2px solid #ffe082;
    color: #fff;
    font-size: 0.92rem;
    font-weight: bold;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(255, 152, 0, 0.4);
}

.btn-stopper-pill:active {
    transform: scale(0.96);
}

/* 香腸伯與蒜味技能整合列 */
.uncle-fever-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.uncle-speech-pill {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(30, 15, 10, 0.85);
    border: 1px solid #6d4c41;
    border-radius: 6px;
    padding: 3px 8px;
    min-height: 28px;
    box-sizing: border-box;
}

.uncle-avatar-mini {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.uncle-speech-mini {
    font-size: 0.78rem;
    color: #fff3e0;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-fever-compact {
    flex-shrink: 0;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: bold;
    border: 1.5px solid #8d6e63;
    background: #3e2723;
    color: #bcaaa4;
    cursor: not-allowed;
    transition: all 0.2s ease;
}

.btn-fever-compact.ready {
    background: linear-gradient(135deg, #ff9800, #e65100);
    border-color: var(--neon-yellow);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 152, 0, 0.6);
    animation: pulseGlow 1.5s infinite;
}

@keyframes pulseGlow {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

/* 炭烤架 (精簡橫幅) */
.grill-station-card {
    background: var(--card-bg);
    border: 1.5px solid #8d6e63;
    border-radius: 8px;
    padding: 4px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    box-sizing: border-box;
}

.grill-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.grill-title {
    font-size: 0.82rem;
    font-weight: bold;
    color: #ffe082;
    white-space: nowrap;
}

.grill-count-highlight {
    color: var(--neon-yellow);
    font-size: 0.98rem;
    font-weight: 900;
    text-shadow: 0 0 6px rgba(255, 235, 59, 0.6);
}

.grill-hint {
    font-size: 0.72rem;
    color: #ffab91;
    white-space: nowrap;
}

.grill-canvas-wrapper {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    border: 1.5px solid #3e2723;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.8);
    cursor: pointer;
    width: 100%;
    display: flex;
    justify-content: center;
}

#grill-canvas {
    display: block;
    width: 100%;
    max-width: 360px;
    height: 75px;
}

/* 過五關指示燈條 (緊湊排版) */
.stage-pills-row {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    width: 100%;
}

.stage-pill {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 2px 3px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #5d4037;
    font-size: 0.72rem;
    color: #bcaaa4;
    transition: all 0.25s ease;
}

.stage-pill .stage-target {
    font-weight: bold;
    font-size: 0.80rem;
    color: #ffe082;
}

.stage-pill.current {
    border-color: var(--neon-yellow);
    background: rgba(255, 204, 0, 0.15);
    color: #fff;
    box-shadow: 0 0 6px rgba(255, 204, 0, 0.4);
}

.stage-pill.passed {
    border-color: #76ff03;
    background: rgba(118, 255, 3, 0.2);
    color: #ccff90;
}

.stage-pill.trap-hit {
    border-color: #ff1744;
    background: rgba(255, 23, 68, 0.35);
    color: #ff8a80;
    animation: trapFlash 0.6s infinite alternate;
}

@keyframes trapFlash {
    0% { transform: scale(1); }
    100% { transform: scale(1.06); box-shadow: 0 0 10px #ff1744; }
}

/* 精簡規則條 */
.rules-compact-strip {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(20, 10, 6, 0.75);
    border: 1px dashed rgba(141, 110, 99, 0.6);
    border-radius: 6px;
    padding: 3px 6px;
    box-sizing: border-box;
}

.rules-pill {
    font-size: 0.72rem;
    color: #d7ccc8;
    line-height: 1.25;
}

.rules-pill b {
    color: #ffe082;
}

/* 彈窗 (Modal) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}

.modal-content {
    background: linear-gradient(to bottom, #3e2723, #21110a);
    border: 3px solid var(--neon-yellow);
    border-radius: 16px;
    padding: 22px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.9);
    animation: modalPop 0.3s ease-out;
}

@keyframes modalPop {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-title {
    font-size: 1.55rem;
    color: var(--neon-yellow);
    margin-bottom: 12px;
}

.modal-desc {
    font-size: 1.02rem;
    color: #f5f5f5;
    line-height: 1.5;
    margin-bottom: 18px;
}

.rewards-display {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.reward-pill {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 1.08rem;
    font-weight: bold;
}

.reward-pill.sausage-won {
    background: rgba(211, 47, 47, 0.3);
    border: 1px solid #ef5350;
    color: #ffcdd2;
}

.reward-pill.garlic-won {
    background: rgba(255, 179, 0, 0.25);
    border: 1px solid #ffb300;
    color: #fff9c4;
}

.btn-primary {
    background: linear-gradient(to bottom, #f44336, #c62828);
    border: 2px solid #ffcdd2;
    color: #fff;
    font-size: 1.12rem;
    font-weight: bold;
    padding: 9px 26px;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.5);
}

.btn-primary:active {
    transform: scale(0.97);
}

/* 機台設定表單樣式 */
.settings-form {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 14px 0 20px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #5d4037;
}

.setting-label {
    font-size: 0.95rem;
    color: #ffcc80;
    font-weight: bold;
}

.setting-select {
    background: #1e110a;
    border: 1px solid #8d6e63;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
}

.culture-modal-body {
    text-align: left;
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 8px;
    font-size: 0.92rem;
    line-height: 1.6;
    color: #efebe9;
}

.culture-modal-body h3 {
    color: var(--neon-yellow);
    margin: 12px 0 6px;
    font-size: 1.15rem;
}

.culture-modal-body p {
    margin-bottom: 8px;
}

.culture-modal-body a {
    color: var(--neon-cyan);
    text-decoration: underline;
}

/* 右側面板常駐局末結算卡片 (完全不遮擋彈珠台) */
.round-result-card {
    background: linear-gradient(145deg, #3e1b0c, #260f05);
    border: 2px solid #ff9800;
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: 0 4px 18px rgba(255, 152, 0, 0.25);
    animation: sideResultPop 0.35s ease-out;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@keyframes sideResultPop {
    0% { transform: translateY(-8px) scale(0.96); opacity: 0.2; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

.result-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-card-title {
    font-size: 1.05rem;
    font-weight: 900;
    color: var(--neon-yellow);
    text-shadow: 0 0 6px rgba(255, 235, 59, 0.5);
}

.result-card-tag {
    background: #d32f2f;
    color: #fff;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 10px;
}

.result-card-desc {
    font-size: 0.88rem;
    color: #ffe0b2;
    line-height: 1.4;
}

.result-card-rewards {
    width: 100%;
}

.btn-side-restart {
    width: 100%;
    padding: 9px 12px;
    font-size: 0.95rem;
    font-weight: bold;
    color: #ffffff;
    background: linear-gradient(135deg, #e53935, #c62828);
    border: 2px solid #ffcdd2;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(229, 57, 53, 0.4);
    transition: all 0.2s ease;
    margin-top: 4px;
}

.btn-side-restart:hover {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(229, 57, 53, 0.6);
}

/* ==========================================================================
   手機與平板直立版全螢幕固定防捲動響應式佈局 (<= 900px)
   確保彈珠台 100% 完整呈現絕不切半，且拖拉彈簧發射器時畫面完全固定不晃動
   ========================================================================== */
@media (max-width: 900px) {
    .app-split-container {
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        width: 100%;
        height: 100%;
        height: 100dvh;
        padding: max(4px, env(safe-area-inset-top)) 6px max(6px, env(safe-area-inset-bottom)) 6px;
        gap: 4px;
        overflow: hidden;
    }

    /* 1. 手機頂部常駐雙行精簡狀態列 */
    .mobile-top-hud {
        display: flex;
        flex-direction: column;
        width: 100%;
        max-width: 460px;
        gap: 3px;
        flex-shrink: 0;
        z-index: 10;
    }

    .m-hud-row-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 4px;
        background: linear-gradient(180deg, #4a1210, #2b0806);
        border: 1.5px solid #d4af37;
        border-radius: 8px;
        padding: 3px 6px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
    }

    .m-brand-plaque {
        display: flex;
        align-items: center;
        gap: 3px;
        flex: 0 1 auto;
        min-width: 0;
        overflow: hidden;
        font-size: 0.76rem;
        font-weight: 900;
        color: #fffef0;
        text-shadow: 0 1px 0 #e65100, 0 2px 3px #000;
        white-space: nowrap;
        cursor: pointer;
    }

    .m-brand-text {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .m-quick-stats {
        display: flex;
        align-items: center;
        gap: 4px;
        font-size: 0.74rem;
        color: #ffe082;
        white-space: nowrap;
    }

    .m-stat-pill {
        background: rgba(0, 0, 0, 0.45);
        border: 1px solid rgba(255, 213, 79, 0.4);
        border-radius: 10px;
        padding: 1px 5px;
    }

    .m-stat-pill b {
        color: #ffeb3b;
        font-weight: 900;
    }

    .m-quick-actions {
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .m-hud-icon-btn {
        background: #3e2723;
        border: 1px solid #8d6e63;
        color: #fff;
        border-radius: 6px;
        padding: 2px 6px;
        font-size: 0.80rem;
        cursor: pointer;
        touch-action: manipulation;
    }

    .m-hud-drawer-btn {
        background: linear-gradient(180deg, #ff8f00, #e65100);
        border: 1.5px solid #ffe082;
        color: #fff;
        border-radius: 6px;
        padding: 3px 7px;
        font-size: 0.74rem;
        font-weight: 900;
        white-space: nowrap;
        cursor: pointer;
        box-shadow: 0 2px 6px rgba(230, 81, 0, 0.5);
        touch-action: manipulation;
    }

    .m-hud-row-score {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 4px;
        background: rgba(24, 12, 6, 0.92);
        border: 1px solid #6d4c41;
        border-radius: 7px;
        padding: 2px 6px;
    }

    .m-mode-pill {
        background: #3e2014;
        border: 1px solid #ffb300;
        color: #ffe082;
        border-radius: 5px;
        padding: 2px 6px;
        font-size: 0.72rem;
        font-weight: 900;
        white-space: nowrap;
        cursor: pointer;
        touch-action: manipulation;
    }

    .m-ball-mini-slots {
        display: flex;
        align-items: center;
        gap: 3px;
        flex: 1 1 auto;
        justify-content: center;
    }

    .m-mini-slot {
        min-width: 24px;
        padding: 1px 3px;
        text-align: center;
        font-size: 0.68rem;
        font-weight: 900;
        color: #9e9e9e;
        background: #0d0603;
        border: 1px solid #4e2608;
        border-radius: 4px;
    }

    .m-mini-slot.scored {
        color: #ffeb3b;
        background: #2b1508;
        border-color: #ffd54f;
    }

    .m-score-summary {
        display: flex;
        align-items: center;
        gap: 4px;
        font-size: 0.73rem;
        color: #ffcc80;
        white-space: nowrap;
    }

    .m-score-summary b {
        color: #ffeb3b;
        font-size: 0.86rem;
        font-weight: 900;
    }

    .m-balls-left-tag {
        background: rgba(0, 0, 0, 0.55);
        border: 1px solid #5d4037;
        border-radius: 8px;
        padding: 0 5px;
        font-size: 0.68rem;
        color: #d7ccc8;
    }

    /* 2. 彈珠台主機區域：100% 置中呈現、不超出螢幕、不產生捲軸 */
    .pinball-column {
        flex: 1 1 auto;
        width: 100%;
        height: auto;
        max-height: none;
        min-height: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        overflow: visible;
    }

    .pinball-chassis {
        border-width: 3px;
        padding: 4px;
        border-radius: 8px;
        max-width: 100%;
    }

    /* 手機隱藏鍵盤文字說明，讓退珠、彈簧拉桿與彈射鈕寬敞好按 */
    .plunger-guide {
        display: none;
    }

    .plunger-control-container {
        margin-top: 4px;
        padding: 4px 8px;
        gap: 6px;
        touch-action: none;
    }

    .plunger-touch-track {
        width: 48px;
        height: 62px;
        padding-top: 4px;
    }

    .plunger-knob {
        width: 32px;
        height: 32px;
        font-size: 1.0rem;
    }

    .plunger-power-meter {
        padding: 3px 5px;
        min-width: 38px;
    }

    .power-meter-bar {
        width: 10px;
        height: 34px;
    }

    .btn-stopper-pill,
    .btn-launch-pill {
        padding: 8px 11px;
        font-size: 0.85rem;
        white-space: nowrap;
        touch-action: none;
    }

    /* 3. 右側看板於手機改為上拉式抽屜面板 (Drawer Modal)，平時完全不佔機台寬度 */
    .mobile-drawer-backdrop.visible {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.72);
        backdrop-filter: blur(2px);
        z-index: 940;
    }

    .dashboard-column {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        height: 85dvh;
        max-height: 85dvh;
        background: linear-gradient(180deg, #2b150c, #140905);
        border-top: 3px solid #d4af37;
        border-radius: 18px 18px 0 0;
        padding: 10px 12px max(18px, env(safe-area-inset-bottom)) 12px;
        box-shadow: 0 -10px 35px rgba(0, 0, 0, 0.92);
        z-index: 950;
        transform: translateY(105%);
        transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    }

    .dashboard-column.drawer-open {
        transform: translateY(0);
    }

    .mobile-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-bottom: 8px;
        margin-bottom: 4px;
        border-bottom: 1px solid rgba(255, 213, 79, 0.3);
        flex-shrink: 0;
    }

    .mobile-drawer-title {
        font-size: 0.95rem;
        font-weight: 900;
        color: #ffe082;
    }

    .btn-close-drawer {
        background: linear-gradient(180deg, #d32f2f, #9a0007);
        border: 1.5px solid #ffcdd2;
        color: #fff;
        font-size: 0.82rem;
        font-weight: bold;
        padding: 4px 12px;
        border-radius: 14px;
        cursor: pointer;
    }

    .modal-content {
        width: 92%;
        padding: 18px 16px;
        touch-action: pan-y;
    }
}

/* ==========================================================================
   錄影功能樣式 (Recording Indicator, Buttons & MP4 Download Card)
   ========================================================================== */

.hidden {
    display: none !important;
}

/* 1. 浮動錄影中指示器 (Overlay on Pinball Chassis) */
.pinball-inner-box {
    position: relative;
}

.record-indicator {
    position: absolute;
    top: 14px;
    left: 14px;
    background: rgba(0, 0, 0, 0.78);
    border: 1.5px solid #ff1744;
    border-radius: 20px;
    padding: 5px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.88rem;
    font-weight: 900;
    color: #ff5252;
    box-shadow: 0 4px 14px rgba(255, 23, 68, 0.4);
    z-index: 20;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.rec-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    background-color: #ff1744;
    border-radius: 50%;
}

.rec-dot.pulsing {
    animation: recPulse 1s infinite alternate;
}

@keyframes recPulse {
    0% { transform: scale(0.85); opacity: 0.4; box-shadow: 0 0 0 rgba(255, 23, 68, 0); }
    100% { transform: scale(1.25); opacity: 1; box-shadow: 0 0 10px rgba(255, 23, 68, 0.9); }
}

/* 2. 錄影按鈕樣式 (開關狀態指示) */
.btn-record {
    transition: all 0.2s ease;
}

.btn-record.active-glow {
    background: linear-gradient(180deg, #1b5e20, #2e7d32) !important;
    border-color: #76ff03 !important;
    color: #e8f5e9 !important;
    box-shadow: 0 0 8px rgba(118, 255, 3, 0.6) !important;
}

.btn-record.recording-btn {
    background: linear-gradient(180deg, #c62828, #b71c1c) !important;
    color: #ffffff !important;
    border-color: #ff8a80 !important;
    box-shadow: 0 0 12px rgba(255, 23, 68, 0.7) !important;
    animation: recBtnGlow 1.5s infinite alternate;
}

@keyframes recBtnGlow {
    0% { box-shadow: 0 0 6px rgba(255, 23, 68, 0.4); }
    100% { box-shadow: 0 0 16px rgba(255, 23, 68, 0.9); }
}

/* 3. 錄影提示 Toast */
.rec-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(30px);
    background: rgba(20, 20, 20, 0.94);
    border: 2px solid #ffd54f;
    border-radius: 25px;
    padding: 10px 22px;
    font-size: 0.95rem;
    font-weight: bold;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.rec-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 4. MP4 下載通知卡片 */
.rec-download-card {
    position: fixed;
    top: 24px;
    right: 24px;
    background: linear-gradient(145deg, #1e252b, #101417);
    border: 2px solid #00e676;
    border-radius: 14px;
    padding: 14px 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.85), 0 0 15px rgba(0, 230, 118, 0.3);
    z-index: 9999;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.35s ease;
    max-width: 360px;
}

.rec-download-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.rec-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.rec-card-title {
    font-size: 1.0rem;
    font-weight: 900;
    color: #69f0ae;
}

.btn-rec-close {
    background: transparent;
    border: none;
    color: #90a4ae;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 2px 6px;
}

.btn-rec-close:hover {
    color: #fff;
}

.rec-card-file {
    font-size: 0.82rem;
    color: #b0bec5;
    word-break: break-all;
    margin-bottom: 12px;
}

.rec-card-actions {
    display: flex;
    gap: 8px;
}

.btn-rec-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #00c853, #009624);
    color: #fff;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: bold;
    padding: 7px 14px;
    border-radius: 8px;
    box-shadow: 0 3px 8px rgba(0, 200, 83, 0.4);
    transition: all 0.2s;
}

.btn-rec-download:hover {
    background: linear-gradient(135deg, #00e676, #00c853);
    transform: translateY(-1px);
    box-shadow: 0 5px 12px rgba(0, 200, 83, 0.6);
}
