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

body {
    font-family: "Trebuchet MS", "Arial", sans-serif;
    background:
        radial-gradient(circle at 50% 8%, rgba(255, 216, 73, 0.22), transparent 24%),
        radial-gradient(circle at 16% 82%, rgba(209, 0, 64, 0.38), transparent 30%),
        linear-gradient(180deg, #1A0611 0%, #360011 42%, #05020A 100%);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#gameContainer {
    width: 100vw;
    height: 100vh;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameArea {
    position: relative;
    width: min(980px, calc(100vw - 24px));
    aspect-ratio: 980 / 600;
    border: 5px solid rgba(255, 210, 64, 0.98);
    border-radius: 16px;
    box-shadow:
        0 0 0 3px rgba(120, 0, 25, 0.9),
        0 18px 50px rgba(0, 0, 0, 0.45),
        0 0 42px rgba(255, 201, 47, 0.52),
        inset 0 0 30px rgba(255, 0, 64, 0.18);
    background: radial-gradient(circle at center, #1E90FF 0%, #4169E1 100%);
    overflow: hidden;
}

#gameArea::before {
    content: "";
    position: absolute;
    inset: 7px;
    border: 2px solid rgba(255, 245, 173, 0.55);
    border-radius: 12px;
    box-shadow: inset 0 0 18px rgba(255, 213, 56, 0.35);
    pointer-events: none;
    z-index: 95;
}

#gameArea::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 16%),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.028) 0, rgba(255, 255, 255, 0.028) 1px, transparent 1px, transparent 4px);
    mix-blend-mode: screen;
    pointer-events: none;
    z-index: 96;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: default;
    background: transparent;
}

#ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

#scoreBoard {
    position: absolute;
    top: 10px;
    left: 10px;
    background: linear-gradient(160deg, rgba(24, 0, 10, 0.94), rgba(75, 0, 20, 0.82));
    color: #FFD700;
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 223, 92, 0.82);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.36), 0 0 18px rgba(255, 0, 72, 0.24), inset 0 0 18px rgba(255, 204, 47, 0.13);
    font-size: 18px;
    font-weight: bold;
    min-width: 200px;
    pointer-events: auto;
}

#scoreBoard div {
    margin-bottom: 5px;
}

#scoreBoard div:last-child {
    margin-bottom: 0;
}

#controls {
    position: absolute;
    bottom: 12px;
    right: 10px;
    display: flex;
    flex-direction: row;
    gap: 8px;
    pointer-events: auto;
}

#controls button {
    padding: 9px 14px;
    background: linear-gradient(180deg, #FFF3A5 0%, #FFD13B 42%, #C77700 100%);
    border: 1px solid #5B1200;
    border-radius: 8px;
    color: #000;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 0 #6B1B00, 0 0 14px rgba(255, 203, 61, 0.45);
}

#controls button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    background: linear-gradient(180deg, #FFFFFF 0%, #FFD946 48%, #D53C00 100%);
}

#controls button:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

#gameOver {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

#gameOverContent {
    background: linear-gradient(45deg, #4169E1, #1E90FF);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    color: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 3px solid #FFD700;
}

#gameOverContent h2 {
    font-size: 36px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#gameOverContent p {
    font-size: 24px;
    margin-bottom: 30px;
}

#restartBtn {
    padding: 15px 30px;
    background: linear-gradient(45deg, #FFD700, #FFA500);
    border: none;
    border-radius: 10px;
    color: #000;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

#restartBtn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

#loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 300;
}

#loadingContent {
    text-align: center;
    color: white;
}

#loadingContent h2 {
    font-size: 32px;
    margin-bottom: 30px;
    color: #FFD700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#progressBar {
    width: 300px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
    margin: 0 auto;
}

#progress {
    height: 100%;
    background: linear-gradient(90deg, #FFD700, #FFA500);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

.hidden {
    display: none !important;
}

/* 水波紋動畫效果 */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

.ripple-effect {
    position: absolute;
    border: 2px solid #FFD700;
    border-radius: 50%;
    animation: ripple 0.6s ease-out;
    pointer-events: none;
    z-index: 50;
}

/* 炮彈爆炸效果 */
@keyframes explosion {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(0) rotate(360deg);
        opacity: 0;
    }
}

.explosion-effect {
    position: absolute;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, #FFD700 0%, #FF4500 50%, transparent 100%);
    border-radius: 50%;
    animation: explosion 0.5s ease-out;
    pointer-events: none;
    z-index: 60;
}

/* 分數增加動畫 */
@keyframes scoreFloat {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-50px) scale(1.2);
        opacity: 0;
    }
}

.score-float {
    position: absolute;
    color: #FFD700;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    animation: scoreFloat 1s ease-out;
    pointer-events: none;
    z-index: 70;
}

/* 響應式設計 */
@media (max-width: 768px), (max-height: 520px) {
    body {
        overflow: hidden;
    }

    #gameContainer {
        align-items: flex-start;
        justify-content: center;
        padding-top: max(4px, env(safe-area-inset-top));
    }

    #gameArea {
        width: min(100vw - 8px, calc((100vh - 112px) * 1.6333));
        max-width: 100vw;
        border-width: 3px;
        border-radius: 10px;
        box-shadow:
            0 0 0 2px rgba(120, 0, 25, 0.9),
            0 8px 24px rgba(0, 0, 0, 0.42),
            0 0 24px rgba(255, 201, 47, 0.38);
    }

    #gameArea::before {
        inset: 4px;
        border-width: 1px;
        border-radius: 7px;
    }

    #scoreBoard {
        top: 5px;
        left: 5px;
        font-size: 11px;
        line-height: 1.25;
        padding: 6px 7px;
        min-width: 108px;
        border-radius: 8px;
    }

    #scoreBoard div {
        margin-bottom: 2px;
    }

    #controls {
        position: fixed;
        left: max(6px, env(safe-area-inset-left));
        right: max(6px, env(safe-area-inset-right));
        bottom: max(6px, env(safe-area-inset-bottom));
        display: grid;
        grid-template-columns: 1.25fr 0.8fr 1fr;
        gap: 6px;
        z-index: 5000;
    }
    
    #controls button {
        width: 100%;
        padding: 8px 6px;
        font-size: 11px;
        border-radius: 8px;
        white-space: nowrap;
    }
    
    #gameOverContent {
        padding: 30px;
    }
    
    #gameOverContent h2 {
        font-size: 28px;
    }
    
    #gameOverContent p {
        font-size: 20px;
    }
    
    /* 賭注面板手機適配 */
    #betPanel {
        top: 5px;
        right: 5px;
        left: auto;
        width: 164px;
        min-width: 164px;
        max-width: 164px;
        font-size: 10px;
        padding: 7px;
        border-radius: 9px;
    }

    #betHeader {
        margin-bottom: 6px;
        padding-bottom: 5px;
    }
    
    #betHeader h3 {
        font-size: 11px;
    }

    #attackStatus {
        font-size: 9px;
        padding: 2px 5px;
    }

    #betControls {
        gap: 5px;
        margin-bottom: 6px;
    }
    
    .bet-btn {
        width: 28px;
        height: 28px;
        font-size: 15px;
        box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22), 0 2px 0 #5B1000;
    }

    #betAmount, #damageInfo {
        margin: 1px 0;
        font-size: 10px;
    }

    #currentBet, #damageValue {
        font-size: 12px;
    }
    
    #betPresets {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 3px;
    }
    
    .preset-btn {
        min-width: 0;
        width: 100%;
        padding: 4px 0;
        font-size: 9px;
        border-width: 1px;
        border-radius: 7px;
    }
    
    .skill-panel, .item-panel {
        position: fixed;
        right: max(5px, env(safe-area-inset-right));
        left: auto;
        width: 112px;
        min-width: 112px;
        max-width: 112px;
        margin: 0;
        padding: 6px;
        font-size: 9px;
        border-radius: 8px;
        z-index: 4500;
    }
    
    .skill-panel {
        top: auto;
        bottom: calc(48px + env(safe-area-inset-bottom));
    }
    
    .item-panel {
        top: auto;
        bottom: calc(168px + env(safe-area-inset-bottom));
    }

    .skill-panel h3,
    .item-panel h3 {
        font-size: 10px;
        margin-bottom: 4px;
    }

    .skill-btn,
    .item-btn {
        padding: 4px 5px;
        margin: 2px 0;
        font-size: 8px;
        border-radius: 5px;
    }
    
    .mission-panel, .achievement-panel {
        position: fixed;
        left: max(5px, env(safe-area-inset-left));
        width: 112px;
        min-width: 112px;
        max-width: 112px;
        margin: 0;
        bottom: calc(48px + env(safe-area-inset-bottom));
        max-height: 72px;
        padding: 5px;
        font-size: 8px;
        border-radius: 8px;
        z-index: 4500;
    }
    
    .achievement-panel {
        left: calc(max(5px, env(safe-area-inset-left)) + 118px);
    }

    .mission-panel h3,
    .achievement-panel h3 {
        font-size: 9px;
        margin-bottom: 3px;
    }

    .mission-item,
    .achievement-item {
        margin: 4px 0;
        padding: 4px;
    }

    .mission-name,
    .achievement-name {
        font-size: 9px;
    }

    .mission-description,
    .mission-progress,
    .achievement-description,
    .achievement-reward {
        font-size: 8px;
    }
    
    .jackpot-display {
        top: 6px;
        font-size: 12px;
        padding: 6px 10px;
        border-radius: 10px;
        max-width: 155px;
        white-space: nowrap;
    }

    .combo-display {
        top: auto;
        right: 8px;
        bottom: calc(224px + env(safe-area-inset-bottom));
        padding: 6px 10px;
        font-size: 12px;
    }

    .game-message {
        width: min(78vw, 280px);
        padding: 12px 16px;
        font-size: 16px;
    }
}

@media (max-width: 430px) and (orientation: portrait) {
    #gameContainer {
        padding-top: 34px;
    }

    #gameArea {
        width: calc(100vw - 6px);
    }

    .item-panel,
    .skill-panel {
        display: none;
    }

    .mission-panel,
    .achievement-panel {
        bottom: calc(50px + env(safe-area-inset-bottom));
    }
}

/* 連鎖閃電效果 - 性能優化版 */
@keyframes lightning {
    0% { 
        opacity: 0; 
        transform: scale(0.8); 
    }
    25% { 
        opacity: 1; 
        transform: scale(1.1); 
    }
    50% { 
        opacity: 0.8; 
        transform: scale(1); 
    }
    100% { 
        opacity: 0; 
        transform: scale(0.9); 
    }
}

@keyframes chainPulse {
    0% { 
        filter: drop-shadow(0 0 10px #00FFFF) drop-shadow(0 0 20px #FFFFFF) brightness(1.5);
        transform: scale(1);
    }
    25% { 
        filter: drop-shadow(0 0 25px #00FFFF) drop-shadow(0 0 35px #FFFFFF) brightness(2.5);
        transform: scale(1.15);
    }
    50% { 
        filter: drop-shadow(0 0 30px #00FFFF) drop-shadow(0 0 40px #FFFFFF) brightness(3);
        transform: scale(1.2);
    }
    75% { 
        filter: drop-shadow(0 0 25px #00FFFF) drop-shadow(0 0 35px #FFFFFF) brightness(2.5);
        transform: scale(1.1);
    }
    100% { 
        filter: drop-shadow(0 0 10px #00FFFF) drop-shadow(0 0 20px #FFFFFF) brightness(1.5);
        transform: scale(1);
    }
}

.chain-lightning {
    animation: lightning 0.3s ease-in-out;
    pointer-events: none;
}

.chain-lightning svg {
    animation: chainPulse 0.3s ease-in-out;
}

/* 電火花效果 */
.electric-spark {
    animation: sparkFly 0.4s ease-out forwards;
}

@keyframes sparkFly {
    0% {
        opacity: 1;
        transform: scale(1);
        filter: drop-shadow(0 0 5px #FFFFFF) brightness(2);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.5);
        filter: drop-shadow(0 0 15px #00FFFF) brightness(3);
    }
    100% {
        opacity: 0;
        transform: scale(0.5);
        filter: drop-shadow(0 0 25px #00FFFF) brightness(1);
    }
}

/* 連鎖特效文字 */
.chain-effect {
    position: absolute;
    font-family: 'Arial Black', Arial, sans-serif;
    font-weight: bold;
    font-size: 16px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    pointer-events: none;
    z-index: 1000;
    animation: chainTextFloat 1s ease-out forwards;
}

@keyframes chainTextFloat {
    0% {
        opacity: 1;
        transform: scale(0.5) translateY(0);
    }
    50% {
        opacity: 1;
        transform: scale(1.2) translateY(-20px);
    }
    100% {
        opacity: 0;
        transform: scale(1) translateY(-40px);
    }
}

/* 多魚群特效 */
@keyframes fishSchoolSpawn {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.2);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.fish-school-spawn {
    animation: fishSchoolSpawn 0.8s ease-out;
}

/* 閃電炮口特效 */
@keyframes lightningFlash {
    0% {
        opacity: 0;
        transform: scale(0.5);
        filter: brightness(1) saturate(1);
    }
    25% {
        opacity: 1;
        transform: scale(1.5);
        filter: brightness(4) saturate(3);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.2);
        filter: brightness(3) saturate(2.5);
    }
    75% {
        opacity: 0.6;
        transform: scale(1);
        filter: brightness(2) saturate(2);
    }
    100% {
        opacity: 0;
        transform: scale(0.8);
        filter: brightness(1) saturate(1);
    }
}

.lightning-muzzle-flash {
    animation: lightningFlash 0.4s ease-out;
}

/* 電弧特效 */
@keyframes electricArc {
    0% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
        filter: brightness(2);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.2) rotate(180deg);
        filter: brightness(3);
    }
    100% {
        opacity: 0;
        transform: scale(0.5) rotate(360deg);
        filter: brightness(1);
    }
}

.electric-arc {
    animation: electricArc 0.2s ease-out;
}

/* 自動閃電攻擊指示器 */
.auto-lightning-indicator {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 3px solid #00FFFF;
    border-radius: 50%;
    pointer-events: none;
    z-index: 70;
    animation: lightningTarget 1s ease-in-out infinite;
}

@keyframes lightningTarget {
    0% {
        transform: scale(1);
        opacity: 1;
        border-color: #00FFFF;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.7;
        border-color: #FFFFFF;
    }
    100% {
        transform: scale(1);
        opacity: 1;
        border-color: #00FFFF;
    }
}

/* 連續電擊特效 */
.continuous-lightning {
    animation: continuousLightning 0.05s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes continuousLightning {
    0% {
        opacity: 0.9;
        filter: drop-shadow(0 0 12px #00FFFF) brightness(2.5);
    }
    100% {
        opacity: 1;
        filter: drop-shadow(0 0 18px #FFFFFF) brightness(3.5);
    }
}

/* 連續電擊目標指示器 */
.continuous-target-indicator {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid #00FFFF;
    border-radius: 50%;
    pointer-events: none;
    z-index: 75;
    animation: continuousTargetPulse 0.2s ease-in-out infinite;
}

@keyframes continuousTargetPulse {
    0% {
        transform: scale(1);
        opacity: 1;
        border-color: #00FFFF;
        box-shadow: 0 0 10px #00FFFF;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.8;
        border-color: #FFFFFF;
        box-shadow: 0 0 20px #FFFFFF;
    }
    100% {
        transform: scale(1);
        opacity: 1;
        border-color: #00FFFF;
        box-shadow: 0 0 10px #00FFFF;
    }
}

/* 電擊傷害數字 */
.lightning-damage {
    position: absolute;
    font-family: 'Arial Black', Arial, sans-serif;
    font-weight: bold;
    font-size: 14px;
    color: #00FFFF;
    text-shadow: 
        0 0 5px #FFFFFF,
        0 0 10px #00FFFF,
        2px 2px 4px rgba(0,0,0,0.8);
    pointer-events: none;
    z-index: 90;
    animation: lightningDamageFloat 0.8s ease-out forwards;
}

@keyframes lightningDamageFloat {
    0% {
        opacity: 1;
        transform: scale(0.8) translateY(0);
    }
    25% {
        opacity: 1;
        transform: scale(1.2) translateY(-10px);
    }
    100% {
        opacity: 0;
        transform: scale(1) translateY(-30px);
    }
}

/* 炮台連續電擊充能效果 */
.cannon-charging {
    animation: cannonCharging 1s ease-in-out infinite;
}

@keyframes cannonCharging {
    0% {
        filter: drop-shadow(0 0 10px #00FFFF) brightness(1.2);
    }
    50% {
        filter: drop-shadow(0 0 25px #FFFFFF) brightness(1.8);
    }
    100% {
        filter: drop-shadow(0 0 10px #00FFFF) brightness(1.2);
    }
}

/* 賭注面板樣式 - 移到遊戲畫布外面 */
#betPanel {
    position: absolute;
    top: 10px;
    right: 10px;
    background:
        linear-gradient(160deg, rgba(32, 0, 10, 0.96), rgba(93, 0, 25, 0.92)),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.04) 0, rgba(255,255,255,0.04) 1px, transparent 1px, transparent 8px);
    color: white;
    padding: 15px;
    border-radius: 14px;
    font-family: Arial, sans-serif;
    pointer-events: auto;
    border: 2px solid rgba(255, 219, 88, 0.96);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.44), 0 0 28px rgba(255, 28, 83, 0.38), inset 0 0 22px rgba(255, 215, 0, 0.14);
    width: 280px;
    min-width: 280px;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

#betHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.74);
    padding-bottom: 10px;
}

#betHeader h3 {
    margin: 0;
    color: #FFD700;
    font-size: 16px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.72);
}

#attackStatus {
    font-size: 12px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 5px;
    background: linear-gradient(180deg, #24FF7A, #008E37);
    color: #031407;
    border: 1px solid rgba(218, 255, 225, 0.55);
}

#betControls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    gap: 10px;
}

.bet-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #FFFFFF 0%, #FFE66D 30%, #F0A400 66%, #8A2500 100%);
    color: #250600;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.25), 0 4px 0 #5B1000, 0 0 15px rgba(255, 215, 0, 0.45);
}

.bet-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(255, 215, 0, 0.5);
}

.bet-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.5;
}

#betInfo {
    text-align: center;
    flex: 1;
}

#betAmount, #damageInfo {
    margin: 5px 0;
    font-size: 14px;
    color: #FFE8B0;
}

#currentBet, #damageValue {
    color: #FFD700;
    font-weight: bold;
    font-size: 18px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}

#betAmount {
    display: grid;
    grid-template-columns: auto minmax(72px, 1fr);
    align-items: center;
    gap: 8px;
}

#betAmount label {
    color: #FFE8B0;
    font-weight: bold;
}

#currentBet {
    width: 100%;
    min-width: 0;
    height: 34px;
    padding: 4px 8px;
    border: 2px solid rgba(255, 215, 0, 0.95);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(30, 0, 8, 0.96), rgba(91, 0, 25, 0.9));
    color: #FFD700;
    font-family: inherit;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    outline: none;
    box-shadow: inset 0 0 10px rgba(255, 215, 0, 0.16), 0 0 12px rgba(255, 60, 0, 0.25);
}

#currentBet:focus {
    border-color: #FFFFFF;
    box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.2), 0 0 18px rgba(255, 215, 0, 0.7);
}

#currentBet::-webkit-inner-spin-button,
#currentBet::-webkit-outer-spin-button {
    opacity: 1;
}

#betPresets {
    display: flex;
    gap: 5px;
    justify-content: center;
    flex-wrap: wrap;
}

.preset-btn {
    min-width: 38px;
    padding: 7px 8px;
    border: 2px solid #FFD700;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.22), rgba(255, 215, 0, 0.18) 38%, rgba(73, 0, 18, 0.72) 100%);
    color: #FFD700;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preset-btn:hover {
    background: rgba(255, 215, 0, 0.3);
    transform: scale(1.05);
}

.preset-btn.active {
    background: radial-gradient(circle at 35% 28%, #FFFFFF, #FFD700 40%, #C92700 100%);
    color: #1C0500;
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.8), inset 0 0 0 2px rgba(91, 0, 0, 0.4);
}

/* 金幣相關動畫 */
@keyframes coinFloat {
    0% { 
        opacity: 1; 
        transform: translateY(0); 
    }
    100% { 
        opacity: 0; 
        transform: translateY(-30px); 
    }
}

.coin-reward {
    position: absolute;
    color: #FFD700;
    font-weight: bold;
    font-size: 14px;
    pointer-events: none;
    z-index: 100;
    animation: coinFloat 1s ease-out forwards;
}

@keyframes warningFlash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.insufficient-coins {
    animation: warningFlash 0.5s ease-in-out 2;
}

/* 新增：特殊技能面板 */
.skill-panel {
    position: fixed;
    top: 215px;
    right: 10px;
    background: linear-gradient(160deg, rgba(39, 0, 11, 0.95), rgba(12, 5, 16, 0.92));
    border: 1px solid rgba(255, 215, 0, 0.88);
    border-radius: 12px;
    padding: 10px;
    min-width: 150px;
    max-width: 150px;
    z-index: 2000;
    color: white;
    font-family: Arial, sans-serif;
    pointer-events: auto;
}

.skill-panel h3 {
    margin: 0 0 8px 0;
    text-align: center;
    color: #FFD700;
    font-size: 14px;
}

.skill-btn {
    display: block;
    width: 100%;
    margin: 3px 0;
    padding: 6px 8px;
    background: linear-gradient(180deg, #4DFF8A, #109436);
    border: 1px solid rgba(234, 255, 222, 0.45);
    border-radius: 5px;
    color: white;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.skill-btn:hover {
    background: linear-gradient(45deg, #45a049, #4CAF50);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.skill-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.skill-btn.cooling {
    background: linear-gradient(45deg, #FF6B6B, #FF5252);
}

/* 新增：道具面板 */
.item-panel {
    position: fixed;
    top: 365px;
    right: 10px;
    background: linear-gradient(160deg, rgba(34, 0, 44, 0.95), rgba(18, 0, 18, 0.92));
    border: 1px solid rgba(255, 96, 247, 0.88);
    border-radius: 12px;
    padding: 10px;
    min-width: 150px;
    max-width: 150px;
    z-index: 2000;
    color: white;
    font-family: Arial, sans-serif;
    pointer-events: auto;
}

.item-panel h3 {
    margin: 0 0 8px 0;
    text-align: center;
    color: #9370DB;
    font-size: 14px;
}

.item-btn {
    display: block;
    width: 100%;
    margin: 3px 0;
    padding: 6px 8px;
    background: linear-gradient(180deg, #C877FF, #6A20C8);
    border: 1px solid rgba(244, 220, 255, 0.42);
    border-radius: 5px;
    color: white;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.item-btn:hover {
    background: linear-gradient(45deg, #8A2BE2, #9370DB);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.item-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.item-btn.active {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    animation: pulse 1s infinite;
}

/* 新增：任務面板 */
.mission-panel {
    position: fixed;
    bottom: 10px;
    left: 10px;
    background: linear-gradient(160deg, rgba(12, 0, 18, 0.9), rgba(0, 20, 42, 0.86));
    border: 2px solid #00F0FF;
    border-radius: 10px;
    padding: 8px;
    min-width: 150px;
    max-width: 150px;
    max-height: 100px;
    overflow-y: auto;
    z-index: 1000;
    color: white;
    font-family: Arial, sans-serif;
}

.mission-panel h3 {
    margin: 0 0 6px 0;
    text-align: center;
    color: #00CED1;
    font-size: 12px;
}

.mission-item {
    margin: 8px 0;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    border-left: 3px solid #00CED1;
}

.mission-item.completed {
    border-left-color: #4CAF50;
    background: rgba(76, 175, 80, 0.2);
}

.mission-name {
    font-weight: bold;
    color: #FFD700;
    font-size: 12px;
}

.mission-description {
    font-size: 10px;
    color: #CCC;
    margin: 2px 0;
}

.mission-progress {
    font-size: 10px;
    color: #00CED1;
}

/* 新增：成就面板 */
.achievement-panel {
    position: fixed;
    bottom: 10px;
    left: 180px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #FFD700;
    border-radius: 10px;
    padding: 8px;
    min-width: 150px;
    max-width: 150px;
    max-height: 100px;
    overflow-y: auto;
    z-index: 1000;
    color: white;
    font-family: Arial, sans-serif;
}

.achievement-panel h3 {
    margin: 0 0 6px 0;
    text-align: center;
    color: #FFD700;
    font-size: 12px;
}

.achievement-item {
    margin: 8px 0;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    border-left: 3px solid #666;
}

.achievement-item.unlocked {
    border-left-color: #FFD700;
    background: rgba(255, 215, 0, 0.2);
    animation: achievement-glow 2s ease-in-out;
}

.achievement-name {
    font-weight: bold;
    color: #FFD700;
    font-size: 12px;
}

.achievement-description {
    font-size: 10px;
    color: #CCC;
    margin: 2px 0;
}

.achievement-reward {
    font-size: 10px;
    color: #4CAF50;
}

/* 新增：特效動畫 */
@keyframes laser-pulse {
    0% { opacity: 0; transform: scaleY(0.5); }
    50% { opacity: 1; transform: scaleY(1.2); }
    100% { opacity: 0; transform: scaleY(0.5); }
}

@keyframes net-expand {
    0% { 
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 0.6;
    }
}

@keyframes ice-shimmer {
    0% { opacity: 0.3; }
    50% { opacity: 0.6; }
    100% { opacity: 0.3; }
}

.ice-effect {
    animation: ice-shimmer 2s ease-in-out infinite;
}

@keyframes achievement-glow {
    0% { box-shadow: 0 0 5px #FFD700; }
    50% { box-shadow: 0 0 20px #FFD700, 0 0 30px #FFD700; }
    100% { box-shadow: 0 0 5px #FFD700; }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* 新增：彩金顯示 */
.jackpot-display {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(180deg, #FFF7B2 0%, #FFD700 38%, #FF3B00 100%);
    border: 3px solid #8F0000;
    border-radius: 15px;
    padding: 10px 20px;
    color: #8B0000;
    font-weight: bold;
    font-size: 18px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: jackpot-shine 2s ease-in-out infinite;
}

@keyframes jackpot-shine {
    0%, 100% { box-shadow: 0 0 10px #FFD700; }
    50% { box-shadow: 0 0 25px #FFD700, 0 0 35px #FFA500; }
}

/* 新增：連擊顯示 */
.combo-display {
    position: fixed;
    top: 535px;
    right: 10px;
    background: linear-gradient(180deg, #FF263F, #790010);
    border: 2px solid #FFD700;
    border-radius: 10px;
    padding: 8px 15px;
    color: white;
    font-weight: bold;
    font-size: 16px;
    z-index: 1000;
    transform: scale(0);
    transition: transform 0.3s ease;
}

.combo-display.active {
    transform: scale(1);
    animation: combo-pulse 0.5s ease-in-out;
}

@keyframes combo-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* 新增：消息提示 */
.game-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #FFD700;
    border-radius: 10px;
    padding: 20px 30px;
    color: #FFD700;
    font-size: 20px;
    font-weight: bold;
    text-align: center;
    z-index: 2000;
    animation: message-appear 0.5s ease-out;
}

@keyframes message-appear {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
} 

/* Final mobile override: keep the playfield readable and prevent UI overlap. */
@media (max-width: 768px), (max-height: 520px) {
    #gameContainer {
        align-items: flex-start;
        justify-content: center;
        padding-top: max(4px, env(safe-area-inset-top));
    }

    #gameArea {
        width: min(100vw - 8px, calc((100vh - 112px) * 1.6333));
        max-width: 100vw;
        border-width: 3px;
        border-radius: 10px;
    }

    #gameCanvas {
        width: 100%;
        height: 100%;
    }

    #scoreBoard {
        top: 5px;
        left: 5px;
        min-width: 108px;
        padding: 6px 7px;
        font-size: 11px;
        line-height: 1.25;
        border-radius: 8px;
    }

    #betPanel {
        top: 5px;
        right: 5px;
        left: auto;
        width: 164px;
        min-width: 164px;
        max-width: 164px;
        padding: 7px;
        font-size: 10px;
        border-radius: 9px;
    }

    #betHeader {
        margin-bottom: 6px;
        padding-bottom: 5px;
    }

    #betHeader h3 {
        font-size: 11px;
    }

    #attackStatus {
        font-size: 9px;
        padding: 2px 5px;
    }

    #betControls {
        gap: 5px;
        margin-bottom: 6px;
    }

    .bet-btn {
        width: 28px;
        height: 28px;
        font-size: 15px;
    }

    #betAmount,
    #damageInfo {
        margin: 1px 0;
        font-size: 10px;
    }

    #currentBet,
    #damageValue {
        font-size: 12px;
    }

    #betPresets {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 3px;
    }

    .preset-btn {
        min-width: 0;
        width: 100%;
        padding: 4px 0;
        font-size: 9px;
        border-width: 1px;
        border-radius: 7px;
    }

    #controls {
        position: fixed;
        left: max(6px, env(safe-area-inset-left));
        right: max(6px, env(safe-area-inset-right));
        bottom: max(6px, env(safe-area-inset-bottom));
        display: grid;
        grid-template-columns: 1.25fr 0.8fr 1fr;
        gap: 6px;
        z-index: 5000;
    }

    #controls button {
        width: 100%;
        padding: 8px 6px;
        font-size: 11px;
        white-space: nowrap;
    }

    .skill-panel,
    .item-panel {
        right: max(5px, env(safe-area-inset-right));
        left: auto;
        width: 112px;
        min-width: 112px;
        max-width: 112px;
        padding: 6px;
        font-size: 9px;
        border-radius: 8px;
        z-index: 4500;
    }

    .skill-panel {
        top: auto;
        bottom: calc(48px + env(safe-area-inset-bottom));
    }

    .item-panel {
        top: auto;
        bottom: calc(168px + env(safe-area-inset-bottom));
    }

    .skill-panel h3,
    .item-panel h3 {
        font-size: 10px;
        margin-bottom: 4px;
    }

    .skill-btn,
    .item-btn {
        padding: 4px 5px;
        margin: 2px 0;
        font-size: 8px;
    }

    .mission-panel,
    .achievement-panel {
        bottom: calc(48px + env(safe-area-inset-bottom));
        width: 112px;
        min-width: 112px;
        max-width: 112px;
        max-height: 72px;
        padding: 5px;
        font-size: 8px;
        z-index: 4500;
    }

    .mission-panel {
        left: max(5px, env(safe-area-inset-left));
    }

    .achievement-panel {
        left: calc(max(5px, env(safe-area-inset-left)) + 118px);
    }

    .mission-panel h3,
    .achievement-panel h3 {
        font-size: 9px;
        margin-bottom: 3px;
    }

    .mission-item,
    .achievement-item {
        margin: 4px 0;
        padding: 4px;
    }

    .jackpot-display {
        top: 6px;
        max-width: 155px;
        padding: 6px 10px;
        font-size: 12px;
        white-space: nowrap;
    }

    .combo-display {
        top: auto;
        right: 8px;
        bottom: calc(224px + env(safe-area-inset-bottom));
        padding: 6px 10px;
        font-size: 12px;
    }
}

@media (max-width: 430px) and (orientation: portrait) {
    #gameContainer {
        padding-top: 34px;
    }

    #gameArea {
        width: calc(100vw - 6px);
    }

    .item-panel,
    .skill-panel {
        display: none;
    }
}

/* Keep the betting console outside the playfield. */
@media (min-width: 769px) {
    #gameContainer {
        justify-content: flex-start;
        padding-left: 18px;
        padding-right: 324px;
    }

    #gameArea {
        width: min(980px, calc(100vw - 366px), calc((100vh - 32px) * 1.6333));
    }

    #betPanel {
        position: fixed;
        top: 18px;
        right: 18px;
        left: auto;
        width: 280px;
        min-width: 280px;
        max-width: 280px;
    }

    .skill-panel {
        top: 318px;
        right: 18px;
    }

    .item-panel {
        top: 468px;
        right: 18px;
    }

    .combo-display {
        right: 18px;
    }
}

@media (max-width: 768px), (max-height: 520px) {
    #gameContainer {
        padding-bottom: calc(178px + env(safe-area-inset-bottom));
    }

    #gameArea {
        width: min(100vw - 8px, calc((100vh - 238px) * 1.6333));
    }

    #betPanel {
        position: fixed;
        left: max(6px, env(safe-area-inset-left));
        right: max(6px, env(safe-area-inset-right));
        top: auto;
        bottom: calc(48px + env(safe-area-inset-bottom));
        width: auto;
        min-width: 0;
        max-width: none;
        padding: 7px 8px;
        z-index: 4900;
    }

    #betPanel #betHeader {
        margin-bottom: 5px;
    }

    #betPanel #betControls {
        margin-bottom: 5px;
    }

    #betPanel #betPresets {
        grid-template-columns: repeat(11, minmax(22px, 1fr));
    }

    #betPanel .preset-btn {
        padding: 4px 0;
        font-size: 8px;
    }

    .mission-panel,
    .achievement-panel {
        bottom: calc(158px + env(safe-area-inset-bottom));
    }

    .skill-panel {
        bottom: calc(158px + env(safe-area-inset-bottom));
    }

    .item-panel {
        bottom: calc(278px + env(safe-area-inset-bottom));
    }
}

@media (max-width: 430px) and (orientation: portrait) {
    #gameContainer {
        padding-top: 18px;
    }

    #gameArea {
        width: min(100vw - 6px, calc((100vh - 246px) * 1.6333));
    }

    #betPanel #betPresets {
        grid-template-columns: repeat(6, 1fr);
    }

    .mission-panel,
    .achievement-panel {
        display: none;
    }
}

/* Product layout: the betting console is a real control surface, not a canvas overlay. */
#gameContainer {
    padding: 14px;
}

#gameCabinet {
    width: min(1320px, calc(100vw - 28px));
    height: min(760px, calc(100vh - 28px));
    display: grid;
    grid-template-columns: minmax(0, 980px) minmax(260px, 300px);
    gap: 18px;
    align-items: center;
    justify-content: center;
}

#gameArea {
    width: 100%;
    max-width: 980px;
    max-height: calc(100vh - 28px);
    justify-self: end;
}

#sideConsole {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    min-width: 0;
    pointer-events: auto;
    z-index: 6000;
}

#sideConsole #betPanel,
#sideConsole #controls {
    position: static;
    inset: auto;
    width: 100%;
    min-width: 0;
    max-width: none;
}

#sideConsole #controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

#sideConsole #controls button {
    width: 100%;
    padding: 11px 12px;
}

@media (min-width: 769px) {
    #gameContainer {
        justify-content: center;
        padding: 14px;
    }

    #gameArea {
        width: min(100%, calc((100vh - 28px) * 1.6333));
    }

    #sideConsole .skill-panel,
    #sideConsole .item-panel {
        position: static;
    }
}

@media (max-width: 768px), (max-height: 520px) {
    #gameContainer {
        height: 100vh;
        padding: max(4px, env(safe-area-inset-top)) 6px max(6px, env(safe-area-inset-bottom));
        align-items: stretch;
    }

    #gameCabinet {
        width: 100%;
        height: 100%;
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) auto;
        gap: 6px;
        align-items: stretch;
    }

    #gameArea {
        align-self: center;
        justify-self: center;
        width: min(100%, calc((100vh - 150px) * 1.6333));
        max-height: calc(100vh - 150px);
        border-width: 3px;
        border-radius: 10px;
    }

    #sideConsole {
        align-self: end;
        width: 100%;
        gap: 6px;
    }

    #sideConsole #betPanel {
        position: static;
        width: 100%;
        min-width: 0;
        max-width: none;
        padding: 6px 7px;
        border-radius: 9px;
    }

    #sideConsole #controls {
        position: static;
        width: 100%;
        display: grid;
        grid-template-columns: 1.25fr 0.8fr 1fr;
        gap: 6px;
    }

    #sideConsole #controls button {
        padding: 8px 6px;
        font-size: 11px;
        white-space: nowrap;
    }

    #sideConsole #betHeader {
        margin-bottom: 4px;
        padding-bottom: 4px;
    }

    #sideConsole #betControls {
        margin-bottom: 5px;
    }

    #sideConsole #betPresets {
        display: grid;
        grid-template-columns: repeat(11, minmax(20px, 1fr));
        gap: 3px;
    }

    #sideConsole .preset-btn {
        min-width: 0;
        padding: 4px 0;
        font-size: 8px;
        border-radius: 7px;
    }

    #scoreBoard {
        top: 5px;
        left: 5px;
        min-width: 108px;
        padding: 6px 7px;
        font-size: 11px;
        line-height: 1.25;
    }

    .jackpot-display {
        top: 6px;
        max-width: 155px;
        padding: 6px 10px;
        font-size: 12px;
    }

    .mission-panel,
    .achievement-panel,
    .skill-panel,
    .item-panel {
        display: none;
    }
}

@media (max-width: 430px) and (orientation: portrait) {
    #gameArea {
        width: 100%;
        max-height: calc(100vh - 190px);
    }

    #sideConsole #betPresets {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* Centered cabinet pass: controls sit below the playfield so the game itself never drifts left. */
#gameCabinet {
    width: min(980px, calc(100vw - 28px));
    height: min(760px, calc(100vh - 28px));
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    justify-items: center;
    align-items: stretch;
    gap: 10px;
}

#gameArea {
    justify-self: center;
    align-self: center;
    width: min(100%, calc((100vh - 205px) * 1.6333));
    max-width: 980px;
    max-height: calc(100vh - 205px);
}

#sideConsole {
    align-self: end;
    width: 100%;
    max-width: 980px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 230px;
    align-items: stretch;
    gap: 10px;
}

#sideConsole #betPanel {
    padding: 9px 11px;
    border-radius: 11px;
}

#sideConsole #betHeader {
    margin-bottom: 6px;
    padding-bottom: 6px;
}

#sideConsole #betControls {
    margin-bottom: 7px;
}

#sideConsole #betPresets {
    display: grid;
    grid-template-columns: repeat(11, minmax(30px, 1fr));
    gap: 5px;
}

#sideConsole .preset-btn {
    min-width: 0;
    padding: 5px 2px;
    font-size: 10px;
    border-radius: 7px;
}

#sideConsole #controls {
    height: 100%;
    align-content: stretch;
}

#sideConsole #controls button {
    min-height: 0;
}

@media (max-width: 900px), (max-height: 760px) {
    .mission-panel,
    .achievement-panel,
    .skill-panel,
    .item-panel {
        display: none !important;
    }
}

@media (max-width: 768px), (max-height: 520px) {
    #gameCabinet {
        width: 100%;
        height: 100%;
        gap: 6px;
    }

    #gameArea {
        width: min(100%, calc((100vh - 150px) * 1.6333));
        max-height: calc(100vh - 150px);
    }

    #sideConsole {
        display: flex;
        max-width: none;
    }
}

/* Skills and items are real console controls, not floating overlays. */
#actionDock {
    grid-column: 1;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 5px;
    min-width: 0;
}

#sideConsole #controls {
    grid-column: 2;
    grid-row: 1 / span 2;
}

#actionDock .skill-panel,
#actionDock .item-panel {
    position: static !important;
    display: contents !important;
    visibility: visible !important;
    opacity: 1 !important;
}

#actionDock .skill-panel h3,
#actionDock .item-panel h3 {
    display: none;
}

#actionDock .skill-btn,
#actionDock .item-btn {
    width: 100%;
    min-width: 0;
    min-height: 30px;
    margin: 0;
    padding: 5px 4px;
    font-size: 9px;
    white-space: nowrap;
    border-radius: 7px;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 768px), (max-height: 520px) {
    #actionDock {
        width: 100%;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 4px;
    }

    #sideConsole #controls {
        grid-column: auto;
        grid-row: auto;
    }

    #actionDock .skill-btn,
    #actionDock .item-btn {
        min-height: 24px;
        padding: 4px 3px;
        font-size: 8px;
    }
}
