/* ===== 遊戲開始畫面 ===== */
.start-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #FBCEB1 0%, #FF8C42 100%);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.5s ease;
    overflow-y: auto;
    padding: 1rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.start-screen-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: clamp(1.5rem, 3vw, 3rem) clamp(1rem, 2vw, 2rem);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: slideUp 0.6s ease;
    margin: auto;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.game-title {
    color: #FF8C42;
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    animation: titlePulse 2s ease infinite;
}

/* 作者署名 */
.author-credit {
    color: #666666;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

@keyframes titlePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.start-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.btn-start {
    background: linear-gradient(135deg, #FF8C42, #E67A35);
    color: var(--white);
    font-size: 1.2rem;
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(255, 140, 66, 0.3);
}

.btn-start:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 140, 66, 0.4);
    background: linear-gradient(135deg, #E67A35, #D06A25);
}

.btn-continue {
    background: linear-gradient(135deg, #FFB366, #FF9933);
    color: var(--white);
    font-size: 1.2rem;
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(255, 179, 102, 0.3);
}

.btn-continue:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 179, 102, 0.4);
    background: linear-gradient(135deg, #FF9933, #FF8000);
}

.btn-continue:disabled {
    background: #cccccc;
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

.btn-continue:disabled:hover {
    transform: none;
}

/* 捐贈區塊 - 開始畫面 */
.donation-section {
    background: #fff8f0;
    border: 2px solid #FFB366;
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 1.5rem 0;
}

.donation-message {
    color: #666666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.donation-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.btn-donation {
    background: linear-gradient(135deg, #FFB366, #FF9933);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(255, 153, 51, 0.2);
}

.btn-donation:hover {
    background: linear-gradient(135deg, #FF9933, #FF8000);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(255, 153, 51, 0.3);
}

.btn-donation:active {
    transform: translateY(0);
}

/* 加密貨幣地址 - 開始畫面 */
.crypto-addresses {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #FFD4B8;
}

.crypto-addresses p {
    color: #666666;
    font-size: 0.85rem;
    margin: 0.5rem 0;
    line-height: 1.5;
    word-break: break-all;
    font-family: monospace;
}

.warning-notice {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-top: 1rem;
}

.warning-notice p {
    color: #666666;
    font-size: 0.85rem;
    margin: 0.5rem 0;
    line-height: 1.5;
}

.warning-notice .warning-emphasis {
    color: #999999;
    font-weight: bold;
    font-size: 0.9rem;
    margin-top: 0.75rem;
}

/* AI製作說明 - 起始畫面 */
.ai-credit {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
}

.ai-credit p {
    color: #888888;
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
    margin: 0;
}

/* 響應式設計 - 開始畫面 */
@media (max-width: 768px) {
    .game-title {
        font-size: 2rem;
    }
    
    .start-screen-content {
        padding: 2rem 1.5rem;
    }
    
    .btn-start,
    .btn-continue {
        font-size: 1.1rem;
        padding: 0.875rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 1.75rem;
    }
    
    .start-screen-content {
        padding: 1.5rem 1rem;
    }
    
    .warning-notice p {
        font-size: 0.8rem;
    }
}

/* ===== 全局樣式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 顏色變量 */
    --primary-color: #FF8C42;  /* 橙色 */
    --primary-dark: #E67A35;    /* 深橙色 */
    --accent-color: #FBCEB1;    /* 杏色 */
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #FFB366;   /* 淺橙色 */
    --bg-color: #FFF5EE;        /* 淺杏色背景 */
    --text-color: #2C2C2C;      /* 深黑色文字 */
    --text-light: #666666;      /* 淺黑色文字 */
    --white: #ffffff;
    --border-color: #FFD4B8;    /* 淺杏色邊框 */
    
    /* 間距 */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* 圓角 */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --radius-full: 50%;
    
    /* 陰影 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', '微軟正黑體', sans-serif;
    background: linear-gradient(135deg, #FBCEB1 0%, #FF8C42 100%);
    min-height: 100vh;
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* ===== 頂部導航欄 ===== */
.header {
    background: var(--white);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) 0;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

/* AI製作說明 - 遊戲進行畫面 */
.ai-credit-inline {
    color: var(--text-light);
    font-size: 0.75rem;
    font-style: italic;
    flex: 1;
    text-align: center;
    min-width: 200px;
}

.ai-credit-inline p {
    font-style: normal;
    font-weight: bold;
    margin: 0.25rem 0;
}

.logo {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: bold;
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.balance {
    background: var(--accent-color);
    color: var(--text-color);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    font-weight: bold;
}

.balance-amount {
    font-size: 1.25rem;
}

.stats-quick {
    display: flex;
    gap: var(--spacing-md);
    color: var(--text-light);
    font-size: 0.9rem;
}

/* ===== 主要內容區 ===== */
.main-content {
    padding: clamp(1rem, 2vw, 2rem) 0;
    min-height: calc(100vh - 80px);
    display: flex;
    align-items: flex-start;
}

.main-content .container {
    display: grid;
    grid-template-columns: 1fr minmax(280px, 320px);
    gap: clamp(1rem, 2vw, 2rem);
    width: 100%;
}

/* ===== 遊戲區域 ===== */
.game-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: clamp(1rem, 2vw, 2rem);
    box-shadow: var(--shadow-xl);
    min-height: fit-content;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

/* 選號面板 */
.number-selection-panel h2,
.draw-result-panel h2 {
    color: var(--primary-color);
    margin-bottom: var(--spacing-lg);
    text-align: center;
}

.number-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
    max-width: 400px;
    margin: 0 auto var(--spacing-xl) auto;
    gap: clamp(0.25rem, 1vw, 0.5rem);
}

.number-btn {
    aspect-ratio: 1;
    border: 2px solid var(--border-color);
    background: var(--white);
    border-radius: var(--radius-full);
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.number-btn:hover {
    transform: scale(1.1);
    border-color: var(--primary-color);
    background: var(--bg-color);
}

.number-btn.selected {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
    animation: selectPulse 0.5s ease;
}

.number-btn.matched {
    background: var(--success-color);
    border-color: var(--success-color);
    /* 移除無限動畫，改為靜態效果 */
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

@keyframes selectPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes matchPulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* 已選號碼顯示 */
.selected-numbers {
    margin-bottom: var(--spacing-lg);
}

.selected-numbers h3 {
    color: var(--text-color);
    margin-bottom: var(--spacing-md);
    text-align: center;
}

.selected-numbers-display {
    display: flex;
    justify-content: center;
    gap: var(--spacing-sm);
}

.selected-number-slot {
    width: 50px;
    height: 50px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    background: var(--bg-color);
    transition: all 0.3s ease;
}

.selected-number-slot.filled {
    background: var(--primary-color);
    border-style: solid;
    border-color: var(--primary-color);
    color: var(--white);
}

/* 控制按鈕 */
.control-buttons {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
}

.btn {
    padding: var(--spacing-md) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--accent-color);
    color: var(--text-color);
}

.btn-secondary:hover:not(:disabled) {
    background: #F5B89A;
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--danger-color);
    color: var(--white);
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-2px);
}

.btn-success {
    background: var(--success-color);
    color: var(--white);
}

.btn-success:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-2px);
}

.btn-icon {
    font-size: 1.2rem;
}

/* 開獎顯示區 */
.draw-result-panel {
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.winning-numbers {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.winning-numbers h3 {
    color: var(--text-color);
    margin-bottom: var(--spacing-md);
}

.winning-numbers-display {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
    min-height: 200px;
    align-items: center;
    position: relative;
}

/* ===== 新攪珠機設計 ===== */
.lottery-machine {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 600px;
    margin: 0 auto 2rem;
    padding: 2rem 0;
    /* 整體背景框架 */
    background: linear-gradient(180deg,
        #f8f8f8 0%,
        #e8e8e8 50%,
        #d8d8d8 100%
    );
    border-radius: 20px;
    box-shadow: 
        0 20px 50px rgba(0, 0, 0, 0.3),
        inset 0 2px 5px rgba(255, 255, 255, 0.5),
        inset 0 -2px 5px rgba(0, 0, 0, 0.1);
    border: 3px solid #999;
}

/* 球體容器 */
.sphere-container {
    position: absolute;
    width: 250px;
    height: 250px;
    left: 50%;
    top: 30px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, 
        rgba(255, 255, 255, 0.95),
        rgba(255, 220, 200, 0.9),
        rgba(255, 180, 150, 0.85)
    );
    border: 4px solid var(--primary-color);
    box-shadow: 
        inset 0 0 40px rgba(255, 140, 66, 0.15),
        inset -5px -5px 20px rgba(255, 140, 66, 0.1),
        0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    z-index: 10;
}

/* 球體反光效果 */
.sphere-container::before {
    content: '';
    position: absolute;
    top: 8%;
    left: 12%;
    width: 35%;
    height: 25%;
    background: radial-gradient(
        ellipse at center,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(255, 255, 255, 0.4) 40%,
        rgba(255, 255, 255, 0) 70%
    );
    border-radius: 50%;
    transform: rotate(-20deg);
    z-index: 100;
}

/* 三支攪拌棒容器 (Mercedes-Benz style) */
.stirring-rods {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 20;
}

/* 攪拌棒旋轉動畫 - 持續旋轉 */
.stirring-rods.rotating {
    animation: stirringRotation 1s linear infinite;
}

@keyframes stirringRotation {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* 單支攪拌棒 */
.rod {
    position: absolute;
    width: 4px;
    height: 50%;
    background: linear-gradient(to bottom,
        #666666 0%,
        #888888 50%,
        #666666 100%
    );
    top: 50%;
    left: 50%;
    transform-origin: center top;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

/* 三支攪拌棒的角度 (120度間隔) */
.rod-1 {
    transform: translateX(-50%) rotate(0deg);
}

.rod-2 {
    transform: translateX(-50%) rotate(120deg);
}

.rod-3 {
    transform: translateX(-50%) rotate(240deg);
}

/* 中心樞紐 */
.center-hub {
    position: absolute;
    width: 30px;
    height: 30px;
    background: radial-gradient(circle,
        #999999 0%,
        #666666 100%
    );
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 
        0 0 10px rgba(0, 0, 0, 0.4),
        inset 0 0 5px rgba(255, 255, 255, 0.3);
    z-index: 25;
}

/* 球體容器 (放置小球) */
.balls-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 15;
}

/* 單個小球 */
.lottery-ball {
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 
        0 2px 5px rgba(0, 0, 0, 0.3),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

/* 球體沿邊緣順時針翻動動畫 */
@keyframes ballCircularMotion {
    0% {
        transform: rotate(0deg) translateX(var(--orbit-radius)) rotate(0deg);
    }
    100% {
        transform: rotate(360deg) translateX(var(--orbit-radius)) rotate(-360deg);
    }
}

/* 球體攪動時的翻滾效果 */
@keyframes ballTumble {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* 球體沿邊緣翻動效果 */
@keyframes ballTumbleAlongEdge {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    25% {
        transform: translateY(-10px) scale(1.05);
    }
    50% {
        transform: translateY(0) scale(1);
    }
    75% {
        transform: translateY(10px) scale(0.95);
    }
}

/* 球體浮空效果 - 更自然的浮動 */
@keyframes ballFloat {
    0% {
        transform: translateY(0) translateX(0) rotate(0deg) scale(1);
    }
    10% {
        transform: translateY(-5px) translateX(2px) rotate(36deg) scale(1.02);
    }
    25% {
        transform: translateY(-15px) translateX(5px) rotate(90deg) scale(1.05);
    }
    40% {
        transform: translateY(-22px) translateX(3px) rotate(144deg) scale(1.03);
    }
    50% {
        transform: translateY(-25px) translateX(0) rotate(180deg) scale(1);
    }
    60% {
        transform: translateY(-22px) translateX(-3px) rotate(216deg) scale(0.98);
    }
    75% {
        transform: translateY(-10px) translateX(-5px) rotate(270deg) scale(0.97);
    }
    90% {
        transform: translateY(-3px) translateX(-2px) rotate(324deg) scale(0.99);
    }
    100% {
        transform: translateY(0) translateX(0) rotate(360deg) scale(1);
    }
}

/* 向下延伸的管道 */
.tube-downward {
    position: absolute;
    width: 60px;
    height: 160px;
    left: 50%;
    top: 280px;
    transform: translateX(-50%);
    background: linear-gradient(180deg,
        #e8e8e8 0%,
        #f0f0f0 20%,
        #ffffff 50%,
        #f0f0f0 80%,
        #d0d0d0 100%
    );
    border-left: 3px solid #888;
    border-right: 3px solid #888;
    box-shadow: 
        inset 0 0 10px rgba(0, 0, 0, 0.1);
    z-index: 5;
}

/* 管道內部 */
.tube-inner {
    position: absolute;
    width: calc(100% - 10px);
    height: calc(100% - 10px);
    top: 5px;
    left: 5px;
    background: linear-gradient(180deg,
        rgba(0, 0, 0, 0.05) 0%,
        rgba(0, 0, 0, 0.1) 50%,
        rgba(0, 0, 0, 0.05) 100%
    );
    border-radius: 2px;
}

/* 橫放長方形容器 */
.collection-tray {
    position: absolute;
    width: 420px;
    height: 100px;
    left: 50%;
    top: 440px;  /* 調整為緊貼管道底部 */
    transform: translateX(-50%);
    background: linear-gradient(180deg,
        #f5f5f5 0%,
        #e0e0e0 100%
    );
    border: 3px solid #666;
    border-radius: 15px;
    box-shadow: 
        inset 0 3px 8px rgba(0, 0, 0, 0.15),
        inset 0 -2px 5px rgba(255, 255, 255, 0.3);
    z-index: 3;
}

/* 容器槽位 */
.tray-slots {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    height: 100%;
    padding: 0 15px;
}

/* 單個槽位 */
.tray-slot {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle,
        rgba(0, 0, 0, 0.08) 0%,
        rgba(0, 0, 0, 0.15) 100%
    );
    border: 2px solid #888;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.2),
        0 1px 2px rgba(255, 255, 255, 0.5);
}

/* 槽位中的球 */
.tray-slot .lottery-ball {
    position: relative;
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
}

/* 球體從管道滑下動畫 - 淡入後自由落體 */
@keyframes ballFallDown {
    0% {
        transform: translate(-50%, 0) scale(1) rotate(0deg);
        opacity: 0;
    }
    /* 淡入階段 */
    10% {
        transform: translate(-50%, 5px) scale(1) rotate(30deg);
        opacity: 1;
    }
    /* 自由落體加速階段 */
    20% {
        transform: translate(-50%, 20px) scale(1) rotate(90deg);
        opacity: 1;
    }
    30% {
        transform: translate(-50%, 45px) scale(1) rotate(180deg);
        opacity: 1;
    }
    40% {
        transform: translate(-50%, 80px) scale(1) rotate(270deg);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, 125px) scale(1) rotate(360deg);
        opacity: 1;
    }
    60% {
        transform: translate(-50%, 180px) scale(1) rotate(450deg);
        opacity: 1;
    }
    70% {
        transform: translate(-50%, 245px) scale(1) rotate(540deg);
        opacity: 1;
    }
    /* 接近容器時開始淡出 */
    80% {
        transform: translate(-50%, 320px) scale(1) rotate(630deg);
        opacity: 0.8;
    }
    90% {
        transform: translate(-50%, 380px) scale(1) rotate(720deg);
        opacity: 0.4;
    }
    /* 接觸容器時完全淡出 */
    100% {
        transform: translate(-50%, 420px) scale(1) rotate(810deg);
        opacity: 0;
    }
}

/* 調整後的球體自由落體動畫 - 在管道上方邊緣淡入，容器上方邊緣淡出 */
@keyframes ballFallDownAdjusted {
    0% {
        transform: translate(-50%, 0) scale(1) rotate(0deg);
        opacity: 0;
    }
    /* 在管道上方邊緣淡入 */
    5% {
        transform: translate(-50%, 2px) scale(1) rotate(15deg);
        opacity: 0.5;
    }
    10% {
        transform: translate(-50%, 5px) scale(1) rotate(30deg);
        opacity: 1;
    }
    /* 通過管道的自由落體 */
    20% {
        transform: translate(-50%, 20px) scale(1) rotate(90deg);
        opacity: 1;
    }
    30% {
        transform: translate(-50%, 45px) scale(1) rotate(180deg);
        opacity: 1;
    }
    40% {
        transform: translate(-50%, 80px) scale(1) rotate(270deg);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, 125px) scale(1) rotate(360deg);
        opacity: 1;
    }
    60% {
        transform: translate(-50%, 180px) scale(1) rotate(450deg);
        opacity: 1;
    }
    /* 接近長方形容器上方邊緣時開始淡出 */
    70% {
        transform: translate(-50%, 240px) scale(1) rotate(540deg);
        opacity: 1;
    }
    75% {
        transform: translate(-50%, 270px) scale(1) rotate(585deg);
        opacity: 0.9;
    }
    80% {
        transform: translate(-50%, 300px) scale(1) rotate(630deg);
        opacity: 0.7;
    }
    85% {
        transform: translate(-50%, 330px) scale(1) rotate(675deg);
        opacity: 0.5;
    }
    90% {
        transform: translate(-50%, 360px) scale(1) rotate(720deg);
        opacity: 0.3;
    }
    95% {
        transform: translate(-50%, 390px) scale(1) rotate(765deg);
        opacity: 0.1;
    }
    /* 在長方形容器上方邊緣完全淡出 */
    100% {
        transform: translate(-50%, 420px) scale(1) rotate(810deg);
        opacity: 0;
    }
}

/* 優化的流暢落球動畫 - 更自然的加速度 */
@keyframes ballFallDownSmooth {
    0% {
        transform: translate(-50%, 0) scale(1) rotate(0deg);
        opacity: 1;
    }
    /* 加速下落階段 */
    10% {
        transform: translate(-50%, 8px) scale(1) rotate(45deg);
        opacity: 1;
    }
    20% {
        transform: translate(-50%, 24px) scale(1) rotate(90deg);
        opacity: 1;
    }
    30% {
        transform: translate(-50%, 48px) scale(1) rotate(135deg);
        opacity: 1;
    }
    40% {
        transform: translate(-50%, 80px) scale(1) rotate(180deg);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, 120px) scale(1) rotate(225deg);
        opacity: 1;
    }
    60% {
        transform: translate(-50%, 168px) scale(1) rotate(270deg);
        opacity: 1;
    }
    70% {
        transform: translate(-50%, 224px) scale(1) rotate(315deg);
        opacity: 1;
    }
    80% {
        transform: translate(-50%, 288px) scale(1) rotate(360deg);
        opacity: 1;
    }
    /* 接近容器上方邊緣時開始淡出 */
    85% {
        transform: translate(-50%, 320px) scale(1) rotate(405deg);
        opacity: 0.9;
    }
    90% {
        transform: translate(-50%, 352px) scale(1) rotate(450deg);
        opacity: 0.6;
    }
    95% {
        transform: translate(-50%, 384px) scale(1) rotate(495deg);
        opacity: 0.3;
    }
    /* 觸碰容器上方邊緣時完全消失 */
    100% {
        transform: translate(-50%, 410px) scale(1) rotate(540deg);
        opacity: 0;
    }
}

/* 球體在收集盤中出現的動畫 */
@keyframes ballDropInTray {
    0% {
        transform: translateY(-20px) scale(0.3) rotate(0deg);
        opacity: 0;
    }
    20% {
        transform: translateY(-10px) scale(0.6) rotate(72deg);
        opacity: 0.5;
    }
    40% {
        transform: translateY(5px) scale(1.1) rotate(144deg);
        opacity: 1;
    }
    60% {
        transform: translateY(2px) scale(1.05) rotate(216deg);
    }
    80% {
        transform: translateY(-1px) scale(0.98) rotate(288deg);
    }
    90% {
        transform: translateY(0.5px) scale(1.01) rotate(324deg);
    }
    100% {
        transform: translateY(0) scale(1) rotate(360deg);
        opacity: 1;
    }
}

/* 球體滾動動畫 - 用於舊版兼容 */
@keyframes ballRoll {
    0% {
        transform: translateY(0) rotate(0deg);
    }
    100% {
        transform: translateY(var(--roll-distance)) rotate(720deg);
    }
}

/* 攪珠機整體連接效果 */
.lottery-machine::before {
    content: '';
    position: absolute;
    width: 100px;
    height: 30px;
    left: 50%;
    top: 275px;
    transform: translateX(-50%);
    background: radial-gradient(ellipse,
        rgba(0, 0, 0, 0.1) 0%,
        transparent 70%
    );
    z-index: 4;
}

.lottery-machine::after {
    content: '';
    position: absolute;
    width: 150px;
    height: 30px;
    left: 50%;
    bottom: 135px;
    transform: translateX(-50%);
    background: radial-gradient(ellipse,
        rgba(0, 0, 0, 0.1) 0%,
        transparent 70%
    );
    z-index: 4;
}

/* 球體掉落到槽位動畫 - 更自然的重力彈跳效果 */
@keyframes ballDrop {
    0% {
        transform: translateY(-35px) scale(0.6) rotate(0deg);
        opacity: 0;
    }
    15% {
        transform: translateY(-20px) scale(0.75) rotate(90deg);
        opacity: 0.7;
    }
    30% {
        transform: translateY(10px) scale(1.2) rotate(180deg);
        opacity: 1;
    }
    40% {
        transform: translateY(5px) scale(1.1) rotate(225deg);
    }
    50% {
        transform: translateY(-5px) scale(0.9) rotate(270deg);
    }
    60% {
        transform: translateY(4px) scale(1.08) rotate(315deg);
    }
    70% {
        transform: translateY(2px) scale(1.04) rotate(360deg);
    }
    80% {
        transform: translateY(-2px) scale(0.96) rotate(385deg);
    }
    90% {
        transform: translateY(1px) scale(1.02) rotate(405deg);
    }
    95% {
        transform: translateY(-0.5px) scale(0.99) rotate(415deg);
    }
    100% {
        transform: translateY(0) scale(1) rotate(420deg);
        opacity: 1;
    }
}

/* 倒數計時顯示 */
.draw-countdown {
    position: absolute;
    bottom: 560px;  /* 改為從底部定位，放在攪珠機內部上方 */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 140, 66, 0.95);  /* 半透明背景 */
    color: var(--white);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    font-weight: bold;
    box-shadow: var(--shadow-md);
    white-space: nowrap;
    z-index: 30;  /* 確保在攪珠機元素之上 */
    font-size: 0.9rem;  /* 稍微縮小字體 */
}

.countdown-number {
    display: inline-block;
    margin-left: var(--spacing-sm);
    font-size: 1.2rem;
    color: #FFE5D9;
    animation: countdownPulse 1s ease infinite;
}

@keyframes countdownPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.winning-number-ball {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--white);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    box-shadow: var(--shadow-lg);
}

/* 球滾出動畫 */
.winning-number-ball.rolling-out {
    position: absolute;
    animation: rollThroughTube 2s ease-in-out forwards;
    z-index: 100;
}

@keyframes rollThroughTube {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
    20% {
        transform: translate(40px, 0) rotate(90deg) scale(0.9);
    }
    35% {
        transform: translate(80px, 0) rotate(180deg) scale(0.8);
    }
    50% {
        transform: translate(100px, 20px) rotate(270deg) scale(0.9);
    }
    65% {
        transform: translate(90px, 60px) rotate(360deg) scale(1);
    }
    80% {
        transform: translate(50px, 100px) rotate(450deg) scale(1.1);
    }
    100% {
        transform: translate(0, 150px) rotate(540deg) scale(1);
        opacity: 0;
    }
}

/* 最終位置的球體動畫 */
.winning-number-ball.final-position {
    opacity: 0;
    transform: translateY(-30px) scale(0) rotate(0deg);
    animation: ballDrop 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes ballDrop {
    to {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(360deg);
    }
}

.winning-number-ball.matched {
    background: linear-gradient(135deg, var(--success-color), #059669);
    animation: ballDrop 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
    /* 移除 matchPulse 無限動畫 */
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.6);
}

.special-number {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    font-weight: bold;
}

.special-number-ball {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--accent-color), var(--warning-color));
    color: var(--text-color);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    box-shadow: var(--shadow-lg);
}

/* 特別號容器 */
.special-number-container {
    position: relative;
    display: inline-block;
}

.special-label {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-color);
    font-weight: bold;
    white-space: nowrap;
}

/* 小型旋轉容器（特別號用） */
.rotating-container-small {
    position: relative;
    width: 100px;
    height: 100px;
    transform-style: preserve-3d;
}

.rotating-container-small.spinning {
    animation: spinContainer 3s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
}

.sphere-container-small {
    position: absolute;
    width: 90px;
    height: 90px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, 
        rgba(255, 255, 255, 0.95),
        rgba(251, 206, 177, 0.9),
        rgba(255, 179, 102, 0.85)
    );
    border: 2px solid var(--warning-color);
    box-shadow: 
        inset 0 0 20px rgba(255, 179, 102, 0.15),
        inset -3px -3px 10px rgba(255, 179, 102, 0.1),
        0 8px 20px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.sphere-container-small::before {
    content: '';
    position: absolute;
    top: 8%;
    left: 12%;
    width: 35%;
    height: 25%;
    background: radial-gradient(
        ellipse at center,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(255, 255, 255, 0.4) 40%,
        rgba(255, 255, 255, 0) 70%
    );
    border-radius: 50%;
    transform: rotate(-20deg);
}

.sphere-inner-small {
    position: absolute;
    width: 100%;
    height: 100%;
    animation: gentleRotate 15s linear infinite;
}

/* 特別號掉落動畫 */
.special-ball-drop {
    animation: specialBallDrop 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes specialBallDrop {
    from {
        transform: translateY(-50px) scale(0) rotate(0deg);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1) rotate(360deg);
        opacity: 1;
    }
}

/* 中獎結果 */
.prize-result {
    text-align: center;
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    border-radius: var(--radius-md);
    background: var(--bg-color);
}

.prize-result.win {
    background: linear-gradient(135deg, #FFE5D9, #FFD4B8);
    border: 2px solid var(--primary-color);
}

.prize-result.jackpot {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--white);
    animation: jackpotGlow 2s ease infinite;
}

@keyframes jackpotGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 140, 66, 0.5); }
    50% { box-shadow: 0 0 40px rgba(255, 140, 66, 0.8); }
}

.prize-amount {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.prize-message {
    font-size: 1.2rem;
    margin-top: var(--spacing-sm);
}

/* ===== 側邊欄 ===== */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: clamp(0.75rem, 1.5vw, 1.5rem);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* 自定義滾動條 for 側邊欄 */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

/* 面板通用樣式 */
.history-panel,
.stats-panel,
.prize-info-panel,
.donation-panel,
.save-load-panel {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    min-width: 0;
    flex-shrink: 1;
}

.panel-header {
    background: var(--primary-color);
    color: var(--white);
    padding: var(--spacing-md);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3,
.history-panel h3,
.stats-panel h3,
.prize-info-panel h3,
.donation-panel h3,
.save-load-panel h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    padding: 0;
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.panel-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.panel-content {
    padding: var(--spacing-md);
    max-height: 300px;
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

.panel-content.collapsed {
    max-height: 0;
    padding: 0;
}

/* 遊戲歷史 */
.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.history-item {
    padding: var(--spacing-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.history-item.win {
    background: #f0fdf4;
    border-color: var(--success-color);
}

.history-date {
    color: var(--text-light);
    font-size: 0.8rem;
}

.history-numbers {
    display: flex;
    gap: var(--spacing-xs);
    margin: var(--spacing-xs) 0;
}

.history-number {
    width: 24px;
    height: 24px;
    background: var(--bg-color);
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
}

.history-prize {
    color: var(--success-color);
    font-weight: bold;
}

.no-history {
    text-align: center;
    color: var(--text-light);
    padding: var(--spacing-lg);
}

/* 統計信息 */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.stat-item {
    text-align: center;
    padding: var(--spacing-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.stat-label {
    display: block;
    color: var(--text-light);
    font-size: 0.85rem;
    margin-bottom: var(--spacing-xs);
}

.stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* 獎金說明表格 */
.prize-table {
    width: 100%;
    border-collapse: collapse;
}

.prize-table th,
.prize-table td {
    padding: var(--spacing-sm);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.prize-table th {
    background: var(--bg-color);
    font-weight: bold;
    color: var(--text-color);
}

.prize-table tr.jackpot td {
    background: linear-gradient(90deg, #FFE5D9, #FFD4B8);
    font-weight: bold;
    color: var(--text-color);
}

/* ===== 中獎動畫覆蓋層 ===== */
.win-animation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.win-message {
    font-size: 3rem;
    font-weight: bold;
    color: var(--primary-color);
    text-align: center;
    animation: winMessagePop 1s ease;
}

@keyframes winMessagePop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    animation: confettiFall 3s linear;
}

@keyframes confettiFall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* ===== 響應式設計 ===== */
@media (max-width: 1200px) {
    .main-content .container {
        grid-template-columns: 1fr minmax(260px, 300px);
    }
}

@media (max-width: 1024px) {
    .main-content .container {
        grid-template-columns: 1fr;
        max-width: 100%;
    }
    
    .sidebar {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: var(--spacing-md);
        max-height: none;
        overflow-y: visible;
    }
    
    .history-panel {
        grid-column: span 2;
    }
    
    .game-section {
        max-height: none;
        overflow-y: visible;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: var(--spacing-sm);
        padding: var(--spacing-sm) 0;
    }
    
    .ai-credit-inline {
        order: 3;
        width: 100%;
    }
    
    .user-info {
        flex-direction: row;
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }
    
    .balance {
        font-size: 0.9rem;
    }
    
    .stats-quick {
        justify-content: center;
        font-size: 0.8rem;
    }
    
    .number-grid {
        grid-template-columns: repeat(auto-fit, minmax(35px, 1fr));
        max-width: 350px;
    }
    
    .control-buttons {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .btn {
        width: 100%;
        justify-content: center;
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: 0.9rem;
    }
    
    .sidebar {
        grid-template-columns: 1fr;
    }
    
    .winning-numbers-display {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }
    
    .winning-number-ball,
    .special-number-ball {
        width: clamp(40px, 8vw, 60px);
        height: clamp(40px, 8vw, 60px);
        font-size: clamp(1rem, 2vw, 1.5rem);
    }
    
    .selected-numbers-display {
        gap: var(--spacing-xs);
    }
    
    .selected-number-slot {
        width: clamp(35px, 7vw, 50px);
        height: clamp(35px, 7vw, 50px);
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 1.1rem;
    }
    
    .number-grid {
        grid-template-columns: repeat(auto-fit, minmax(30px, 1fr));
        max-width: 280px;
    }
    
    .number-btn {
        font-size: 0.9rem;
    }
    
    .selected-numbers-display {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .selected-number-slot {
        width: 35px;
        height: 35px;
        font-size: 0.8rem;
    }
    
    .game-title {
        font-size: 1.5rem;
    }
    
    .donation-buttons {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.3rem;
    }
    
    .btn-donation {
        font-size: 0.75rem;
        padding: 0.4rem 0.2rem;
    }
    
    .panel-content {
        max-height: 250px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* 超小屏幕優化 */
@media (max-width: 360px) {
    .container {
        padding: 0 var(--spacing-xs);
    }
    
    .game-section {
        padding: var(--spacing-md);
    }
    
    .number-grid {
        max-width: 240px;
    }
    
    .donation-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 高度響應式設計 */
@media (max-height: 700px) {
    .header {
        position: relative;
    }
    
    .main-content {
        min-height: auto;
        padding: var(--spacing-md) 0;
    }
    
    .game-section,
    .sidebar {
        max-height: none;
    }
    
    .panel-content {
        max-height: 200px;
    }
}

@media (max-height: 500px) {
    .start-screen-content {
        max-height: 95vh;
        padding: 1rem;
    }
    
    .game-title {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
    
    .donation-section {
        margin: 0.5rem 0;
        padding: 0.5rem;
    }
}

/* ===== 加載動畫 ===== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== 工具提示 ===== */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-color);
    color: var(--white);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.tooltip:hover::after {
    opacity: 1;
}

/* ===== 擲骰子模態框 ===== */
.dice-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dice-modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: clamp(1rem, 3vw, 2rem);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: var(--shadow-xl);
}

.dice-modal-content h2 {
    color: var(--primary-color);
    margin-bottom: var(--spacing-lg);
}

.dice-container {
    margin: var(--spacing-xl) 0;
}

.dice {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.dice:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-xl);
}

.dice.rolling {
    animation: diceRoll 1s ease;
}

@keyframes diceRoll {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(720deg); }
}

.dice-face {
    font-size: 3rem;
    font-weight: bold;
    color: var(--white);
}

.dice-result {
    margin: var(--spacing-lg) 0;
}

.dice-result p {
    font-size: 1.2rem;
    margin: var(--spacing-sm) 0;
}

.dice-result span {
    color: var(--primary-color);
    font-weight: bold;
}

.dice-rules {
    background: var(--bg-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-top: var(--spacing-lg);
    text-align: left;
}

.dice-rules h4 {
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
}

.dice-rules ul {
    list-style: none;
    padding: 0;
}

.dice-rules li {
    padding: var(--spacing-xs) 0;
    color: var(--text-color);
}

/* ===== 遊戲結束覆蓋層 ===== */
.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-over-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: clamp(1rem, 3vw, 2rem);
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: var(--shadow-xl);
}

.game-over-content h2 {
    color: var(--danger-color);
    margin-bottom: var(--spacing-lg);
}

.game-over-stats {
    background: var(--bg-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin: var(--spacing-lg) 0;
}

.game-over-stats p {
    margin: var(--spacing-sm) 0;
    color: var(--text-color);
}

.game-over-stats span {
    font-weight: bold;
    color: var(--primary-color);
}

.warning-message {
    background: var(--bg-color);
    border: 2px solid var(--warning-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin: var(--spacing-lg) 0;
    text-align: center;
}

.warning-message p {
    margin: var(--spacing-xs) 0;
    color: var(--text-color);
    font-size: 0.9rem;
}

.warning-message .warning-text {
    color: var(--danger-color);
    font-weight: bold;
    font-size: 1rem;
    margin-top: var(--spacing-sm);
}

/* ===== 滾動條樣式 ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-color);
}

/* ===== 捐贈面板 - 側邊欄 ===== */

.donation-message-sidebar {
    color: #666666;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.donation-buttons-sidebar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
}

.btn-donation-small {
    background: linear-gradient(135deg, #FFB366, #FF9933);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.3rem;
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(255, 153, 51, 0.2);
}

.btn-donation-small:hover {
    background: linear-gradient(135deg, #FF9933, #FF8000);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(255, 153, 51, 0.3);
}

.btn-donation-small:active {
    transform: translateY(0);
}

/* 加密貨幣地址 - 側邊欄 */
.crypto-addresses-sidebar {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #FFD4B8;
}

.crypto-addresses-sidebar p {
    color: #666666;
    font-size: 0.75rem;
    margin: 0.4rem 0;
    line-height: 1.4;
    word-break: break-all;
    font-family: monospace;
}

/* ===== 存檔/讀檔面板 ===== */
.save-load-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.btn-info {
    background: #3b82f6;
    color: var(--white);
}

.btn-info:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-warning {
    background: var(--warning-color);
    color: var(--text-color);
}

.btn-warning:hover:not(:disabled) {
    background: #FF9933;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ===== 模態框通用樣式 ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: clamp(1rem, 3vw, 2rem);
    max-width: min(600px, 95vw);
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-xl);
    margin: auto;
}

.close-modal {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    font-size: 2rem;
    color: var(--text-light);
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-modal:hover {
    color: var(--danger-color);
}

/* ===== 儲存模態框 ===== */
.save-modal h2 {
    color: var(--primary-color);
    margin-bottom: var(--spacing-lg);
}

.save-info,
.encrypted-data,
.qr-code-section,
.password-section {
    margin-bottom: var(--spacing-lg);
}

.save-info h3,
.encrypted-data h3,
.qr-code-section h3,
.password-section h3 {
    color: var(--text-color);
    margin-bottom: var(--spacing-md);
    font-size: 1.1rem;
}

.save-info pre {
    background: var(--bg-color);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-family: monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.encrypted-data textarea {
    width: 100%;
    padding: var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: monospace;
    resize: vertical;
    background: var(--bg-color);
}

#saveQRCode {
    display: block;
    margin: 0 auto;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    background: var(--white);
}

.password-section .warning-text {
    color: var(--danger-color);
    font-size: 0.9rem;
    margin-top: var(--spacing-sm);
}

/* ===== 讀取模態框 ===== */
.load-modal h2 {
    color: var(--primary-color);
    margin-bottom: var(--spacing-lg);
}

.load-input,
.qr-upload,
.password-input {
    margin-bottom: var(--spacing-lg);
}

.load-input h3,
.qr-upload h3,
.password-input h3 {
    color: var(--text-color);
    margin-bottom: var(--spacing-md);
    font-size: 1.1rem;
}

.load-input textarea {
    width: 100%;
    padding: var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: monospace;
    resize: vertical;
}

.qr-upload input[type="file"] {
    width: 100%;
    padding: var(--spacing-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-color);
}

.password-input input {
    width: 100%;
    padding: var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: monospace;
    font-size: 1rem;
}

.load-buttons {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    margin-bottom: var(--spacing-md);
}

.load-result {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    text-align: center;
    display: none;
}

.load-result.success {
    background: #f0fdf4;
    border: 1px solid var(--success-color);
    color: var(--success-color);
    display: block;
}

.load-result.error {
    background: #fef2f2;
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
    display: block;
}

/* ===== 複製按鈕動畫 ===== */
#copyEncryptedBtn {
    margin-top: var(--spacing-sm);
    position: relative;
}

#copyEncryptedBtn.copied::after {
    content: "✓ 已複製";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--success-color);
    color: var(--white);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    animation: copySuccess 1s ease;
}

@keyframes copySuccess {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}
