/* ============ 基本樣式 ============ */
.tic-tac-toe-wrapper * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.tic-tac-toe-wrapper {
    font-family: 'Noto Sans TC', sans-serif;
    overflow-x: hidden;
    background-color: #F9F9F9;
    color: #333333;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* 允許遊戲區域選擇文字 */
.tic-tac-toe-wrapper .game-area,
.tic-tac-toe-wrapper .store-info-value-display,
.tic-tac-toe-wrapper .info-input,
.tic-tac-toe-wrapper .modal {
    -webkit-user-select: text;
    user-select: text;
}

/* ============ 標題金色光暈效果 ============ */
.tic-tac-toe-wrapper .game-title {
    font-size: 2.5rem;
    font-weight: bold;
    color: #e63946;
    text-align: center;
    margin: 20px 0;
    text-shadow: 
        0 0 10px rgba(255, 215, 0, 0.4),
        0 0 20px rgba(255, 215, 0, 0.3),
        0 0 30px rgba(255, 215, 0, 0.2),
        2px 2px 4px rgba(0,0,0,0.1);
    animation: titleGlow 2s ease-in-out infinite alternate;
    position: relative;
    z-index: 10;
}

@keyframes titleGlow {
    0% {
        text-shadow: 
            0 0 10px rgba(255, 215, 0, 0.4),
            0 0 20px rgba(255, 215, 0, 0.3),
            0 0 30px rgba(255, 215, 0, 0.2),
            2px 2px 4px rgba(0,0,0,0.1);
    }
    100% {
        text-shadow: 
            0 0 15px rgba(255, 215, 0, 0.6),
            0 0 25px rgba(255, 215, 0, 0.5),
            0 0 35px rgba(255, 215, 0, 0.4),
            2px 2px 4px rgba(0,0,0,0.1);
    }
}

@media (max-width: 768px) {
    .tic-tac-toe-wrapper .game-title {
        font-size: 1.8rem;
        margin: 15px 0;
    }
}

/* ============ 遊戲容器 ============ */
.tic-tac-toe-wrapper .game-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* ============ 遊戲區域 ============ */
.tic-tac-toe-wrapper .game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

/* ============ 玩家資訊區域 ============ */
.tic-tac-toe-wrapper .players-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 600px;
    margin-bottom: 20px;
}

.tic-tac-toe-wrapper .player-info {
    text-align: center;
    flex: 1;
    padding: 15px;
    border-radius: 15px;
    margin: 0 10px;
}

.tic-tac-toe-wrapper .player-x {
    background: linear-gradient(145deg, #6ecbf5, #059ee3);
    color: white;
}

.tic-tac-toe-wrapper .player-o {
    background: linear-gradient(145deg, #ff9a3d, #ff6b35);
    color: white;
}

.tic-tac-toe-wrapper .player-label {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.tic-tac-toe-wrapper .player-symbol {
    font-size: 2.5rem;
    font-weight: bold;
}

.tic-tac-toe-wrapper .current-player {
    border: 4px solid #FFD700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

/* ============ 井字棋棋盤 ============ */
.tic-tac-toe-wrapper .tic-tac-toe-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 500px;
    margin: 0 auto 20px;
    aspect-ratio: 1 / 1;
}

.tic-tac-toe-wrapper .cell {
    background: white;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
}

.tic-tac-toe-wrapper .cell:hover:not(.occupied) {
    transform: translateY(-5px);
    box-shadow: 0 12px 25px rgba(0,0,0,0.2);
    background: #f8f9fa;
}

.tic-tac-toe-wrapper .cell.occupied {
    cursor: not-allowed;
}

.tic-tac-toe-wrapper .cell.x {
    color: #3498db;
}

.tic-tac-toe-wrapper .cell.o {
    color: #ff9f43;
}

/* ============ 重要修正：勝利連線格子金色光暈脈動效果 ============ */
/* 修正選擇器，確保足夠的優先級 */
.tic-tac-toe-wrapper .tic-tac-toe-board .cell.winning-cell {
    position: relative !important;
    z-index: 100 !important;
    background: linear-gradient(145deg, #fffacd, #fff176) !important;
    border: 3px solid #FFD700 !important;
    animation: goldGlowPulse 1.5s ease-in-out infinite alternate !important;
    box-shadow: 
        0 0 20px rgba(255, 215, 0, 0.8),
        0 0 40px rgba(255, 215, 0, 0.6),
        0 0 60px rgba(255, 215, 0, 0.4),
        inset 0 0 20px rgba(255, 215, 0, 0.3) !important;
    transform-origin: center !important;
}

/* 保留額外的類名以確保覆蓋 */
.tic-tac-toe-wrapper .tic-tac-toe-board .cell.winning-cell-gold {
    /* 使用相同的樣式確保一致性 */
    position: relative !important;
    z-index: 100 !important;
    background: linear-gradient(145deg, #fffacd, #fff176) !important;
    border: 3px solid #FFD700 !important;
    animation: goldGlowPulse 1.5s ease-in-out infinite alternate !important;
    box-shadow: 
        0 0 20px rgba(255, 215, 0, 0.8),
        0 0 40px rgba(255, 215, 0, 0.6),
        0 0 60px rgba(215, 175, 0, 0.4),
        inset 0 0 20px rgba(255, 215, 0, 0.3) !important;
    transform-origin: center !important;
}

@keyframes goldGlowPulse {
    0% {
        box-shadow: 
            0 0 15px rgba(255, 215, 0, 0.7),
            0 0 30px rgba(255, 215, 0, 0.5),
            0 0 45px rgba(255, 215, 0, 0.3),
            inset 0 0 15px rgba(255, 215, 0, 0.2) !important;
        transform: scale(1) !important;
    }
    100% {
        box-shadow: 
            0 0 25px rgba(255, 215, 0, 1),
            0 0 50px rgba(255, 215, 0, 0.8),
            0 0 75px rgba(255, 215, 0, 0.6),
            inset 0 0 25px rgba(255, 215, 0, 0.4) !important;
        transform: scale(1.05) !important;
    }
}

/* ============ 遊戲統計 ============ */
/* 桌機端統計區域 - 明顯放大 */
.tic-tac-toe-wrapper .game-stats {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin: 25px 0;
    flex-wrap: wrap;
}

.tic-tac-toe-wrapper .stat-item {
    text-align: center;
    background: linear-gradient(145deg, #ffffff, #f5f5f5);
    padding: 25px 20px;
    border-radius: 18px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
    min-width: 160px;
    transition: all 0.3s ease;
    border: 2px solid #FF7A00;
}

.tic-tac-toe-wrapper .stat-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(255, 122, 0, 0.2);
    border-color: #FF5722;
}

.tic-tac-toe-wrapper .stat-value {
    font-size: 3rem; /* 桌機放大 */
    font-weight: bold;
    color: #FF7A00;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 8px;
    line-height: 1;
}

.tic-tac-toe-wrapper .stat-label {
    font-size: 1.2rem; /* 桌機放大 */
    color: #555;
    font-weight: 600;
    line-height: 1.3;
    margin-top: 5px;
}

/* 平板調整 */
@media (min-width: 769px) and (max-width: 900px) {
    .tic-tac-toe-wrapper .game-stats {
        gap: 20px;
    }
    
    .tic-tac-toe-wrapper .stat-item {
        min-width: 140px;
        padding: 20px 15px;
    }
    
    .tic-tac-toe-wrapper .stat-value {
        font-size: 2.5rem;
    }
    
    .tic-tac-toe-wrapper .stat-label {
        font-size: 1.1rem;
    }
}

/* ============ 手機端統計區域 - 和桌機一樣的外型，只是尺寸縮小 ============ */
@media (max-width: 768px) {
    .tic-tac-toe-wrapper .game-stats {
        display: flex !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        gap: 12px !important;
        margin: 20px 0 !important;
        padding: 0 15px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* 手機端統計圖框 - 和桌機一樣的比例（較高的長方形） */
    .tic-tac-toe-wrapper .stat-item {
        text-align: center;
        background: linear-gradient(145deg, #ffffff, #f5f5f5);
        padding: 15px 10px !important;
        border-radius: 15px !important;
        box-shadow: 0 6px 18px rgba(0,0,0,0.1) !important;
        min-width: 0 !important;
        width: calc(25% - 9px) !important;
        transition: all 0.3s ease;
        border: 2px solid #FF7A00 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        flex-shrink: 0 !important;
        height: auto !important;
        aspect-ratio: unset !important;
    }
    
    /* 手機端數值 - 和桌機一樣，只是尺寸縮小 */
    .tic-tac-toe-wrapper .stat-value {
        font-size: 2.2rem !important;
        font-weight: bold;
        color: #FF7A00;
        text-shadow: 1px 1px 3px rgba(0,0,0,0.1);
        margin-bottom: 6px !important;
        line-height: 1;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        height: auto !important;
    }
    
    /* 手機端文字 - 和桌機一樣，只是尺寸縮小 */
    .tic-tac-toe-wrapper .stat-label {
        font-size: 0.95rem !important;
        color: #555;
        font-weight: 600;
        line-height: 1.3;
        margin-top: 0 !important;
        text-align: center !important;
        word-break: keep-all !important;
        white-space: normal !important;
        padding: 0 5px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        height: auto !important;
    }
    
    /* 保持懸停效果，和桌機一樣 */
    .tic-tac-toe-wrapper .stat-item:hover {
        transform: translateY(-3px) !important;
        box-shadow: 0 8px 22px rgba(255, 122, 0, 0.15) !important;
        border-color: #FF5722 !important;
    }
}

/* 超小手機調整 - 保持桌機外型 */
@media (max-width: 375px) {
    .tic-tac-toe-wrapper .game-stats {
        gap: 10px !important;
        padding: 0 12px !important;
    }
    
    .tic-tac-toe-wrapper .stat-item {
        padding: 12px 8px !important;
        border-radius: 13px !important;
        width: calc(25% - 8px) !important;
    }
    
    .tic-tac-toe-wrapper .stat-value {
        font-size: 1.9rem !important;
        margin-bottom: 5px !important;
    }
    
    .tic-tac-toe-wrapper .stat-label {
        font-size: 0.85rem !important;
        padding: 0 3px !important;
    }
}

/* 中等手機調整 - 保持桌機外型 */
@media (min-width: 376px) and (max-width: 480px) {
    .tic-tac-toe-wrapper .game-stats {
        gap: 11px !important;
        padding: 0 14px !important;
    }
    
    .tic-tac-toe-wrapper .stat-item {
        padding: 14px 9px !important;
        width: calc(25% - 9px) !important;
    }
    
    .tic-tac-toe-wrapper .stat-value {
        font-size: 2rem !important;
        margin-bottom: 5px !important;
    }
    
    .tic-tac-toe-wrapper .stat-label {
        font-size: 0.9rem !important;
        padding: 0 4px !important;
    }
}

/* 較大手機調整 - 保持桌機外型 */
@media (min-width: 481px) and (max-width: 768px) {
    .tic-tac-toe-wrapper .game-stats {
        gap: 15px !important;
        padding: 0 18px !important;
    }
    
    .tic-tac-toe-wrapper .stat-item {
        padding: 16px 12px !important;
        border-radius: 16px !important;
        width: calc(25% - 12px) !important;
    }
    
    .tic-tac-toe-wrapper .stat-value {
        font-size: 2.3rem !important;
        margin-bottom: 7px !important;
    }
    
    .tic-tac-toe-wrapper .stat-label {
        font-size: 1rem !important;
        padding: 0 6px !important;
    }
}
        
/* ============ 遊戲控制按鈕容器 ============ */
.tic-tac-toe-wrapper .game-controls-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
}

/* ============ 主要遊戲按鈕 ============ */
.tic-tac-toe-wrapper .main-game-btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background: linear-gradient(145deg, #e63946, #d62828);
    color: white;
    box-shadow: 0 6px 15px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    min-width: 250px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.tic-tac-toe-wrapper .main-game-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(230, 57, 70, 0.6);
}

.tic-tac-toe-wrapper .main-game-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

/* ============ 一鍵生成海報按鈕 ============ */
#generatePosterBtn {
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background: linear-gradient(145deg, #FFD700, #FFA500) !important;
    color: #FFFFFF !important;
    box-shadow: 0 6px 15px rgba(255, 215, 0, 0.4);
    transition: all 0.3s ease;
    min-width: 250px;
    margin: 20px auto;
    display: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    position: relative;
    overflow: hidden;
    z-index: 1;
    animation: posterBtnGlow 1.5s ease-in-out infinite alternate;
}

#generatePosterBtn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 215, 0, 0.6);
    animation: posterBtnGlowFast 0.8s ease-in-out infinite alternate;
}

/* 海報按鈕光暈效果 */
@keyframes posterBtnGlow {
    0% {
        box-shadow: 
            0 0 15px rgba(255, 215, 0, 0.6),
            0 0 30px rgba(255, 215, 0, 0.4),
            0 0 45px rgba(255, 215, 0, 0.2) !important;
        transform: scale(1) !important;
    }
    100% {
        box-shadow: 
            0 0 25px rgba(255, 215, 0, 0.9),
            0 0 50px rgba(255, 215, 0, 0.7),
            0 0 75px rgba(255, 215, 0, 0.5) !important;
        transform: scale(1.02) !important;
    }
}

@keyframes posterBtnGlowFast {
    0% {
        box-shadow: 
            0 0 20px rgba(255, 215, 0, 0.8),
            0 0 40px rgba(255, 215, 0, 0.6),
            0 0 60px rgba(255, 215, 0, 0.4) !important;
        transform: scale(1) translateY(-3px) !important;
    }
    100% {
        box-shadow: 
            0 0 30px rgba(255, 215, 0, 1),
            0 0 60px rgba(255, 215, 0, 0.8),
            0 0 90px rgba(255, 215, 0, 0.6) !important;
        transform: scale(1.03) translateY(-3px) !important;
    }
}

/* 海報按鈕外層光環 */
#generatePosterBtn::before {
    content: '';
    position: absolute;
    top: -15px;
    left: -15px;
    right: -15px;
    bottom: -15px;
    background: radial-gradient(circle, rgba(255,215,0,0.3) 0%, rgba(255,215,0,0) 70%);
    border-radius: 25px;
    z-index: -1;
    animation: posterBtnRing 2s ease-in-out infinite;
}

@keyframes posterBtnRing {
    0%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* 手機版調整 */
@media (max-width: 768px) {
    #generatePosterBtn {
        padding: 12px 30px;
        font-size: 1.1rem;
        min-width: 200px;
        margin: 15px auto;
    }
}

/* ============ 遊戲控制按鈕組 ============ */
.tic-tac-toe-wrapper .game-controls {
    display: flex;
    gap: 15px;
}

.tic-tac-toe-wrapper .game-btn {
    padding: 12px 28px;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    color: white;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.tic-tac-toe-wrapper #resetBtn {
    background: linear-gradient(145deg, #457b9d, #1d3557);
}

.tic-tac-toe-wrapper #clearBtn {
    background: linear-gradient(145deg, #2a9d8f, #21867a);
}

/* ============ 修改：遊戲規則按鈕改為橙色 ============ */
.tic-tac-toe-wrapper #rulesBtn {
    background: linear-gradient(145deg, #FF9800, #F57C00);
}

.tic-tac-toe-wrapper #storeInfoBtn {
    background: linear-gradient(145deg, #457b9d, #1d3557);
}

.tic-tac-toe-wrapper #prizeSettingBtn {
    background: linear-gradient(145deg, #ff9800, #f57c00);
}

.tic-tac-toe-wrapper .game-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.tic-tac-toe-wrapper #rulesBtn:hover:not(:disabled) {
    background: linear-gradient(145deg, #F57C00, #FF9800);
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.5);
}

.tic-tac-toe-wrapper #storeInfoBtn:hover:not(:disabled) {
    background: linear-gradient(145deg, #1d3557, #457b9d);
    box-shadow: 0 6px 20px rgba(69, 123, 157, 0.5);
}

.tic-tac-toe-wrapper #prizeSettingBtn:hover:not(:disabled) {
    background: linear-gradient(145deg, #f57c00, #ff9800);
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.5);
}

.tic-tac-toe-wrapper .game-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

/* ============ 店家資訊展示區域 ============ */
.tic-tac-toe-wrapper .store-info-display {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    margin: 30px auto;
    max-width: 800px;
    width: 100%;
    border: 3px solid #FF7A00;
}

.tic-tac-toe-wrapper .store-info-row {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    gap: 15px;
    width: 100%;
}

.tic-tac-toe-wrapper .store-info-label-display {
    font-weight: bold;
    color: #FF7A00;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 120px;
    flex-shrink: 0;
}

.tic-tac-toe-wrapper .store-info-value-display {
    flex: 1;
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #e0e0e0;
    font-size: 16px;
    line-height: 1.6;
    word-break: break-word;
    transition: all 0.3s;
    min-height: 50px;
    display: flex;
    align-items: center;
}

.tic-tac-toe-wrapper .store-info-value-display:hover {
    border-color: #FF7A00;
    box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.15);
    background: white;
}

@media (max-width: 768px) {
    .tic-tac-toe-wrapper .store-info-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .tic-tac-toe-wrapper .store-info-label-display {
        min-width: auto;
        width: 100%;
    }
    
    .tic-tac-toe-wrapper .store-info-value-display {
        width: 100%;
        font-size: 14px;
        padding: 10px;
        min-height: 45px;
    }
}

/* ============ 店家資訊和獎項設定按鈕容器 ============ */
.tic-tac-toe-wrapper .store-prize-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 20px auto;
    max-width: 500px;
    width: 90%;
}

.tic-tac-toe-wrapper .store-prize-buttons .game-btn {
    flex: 1;
    max-width: 200px;
    min-width: 150px;
}

@media (max-width: 768px) {
    .tic-tac-toe-wrapper .store-prize-buttons {
        flex-direction: row;
        justify-content: center;
        max-width: 320px;
        gap: 12px;
    }
    
    .tic-tac-toe-wrapper .store-prize-buttons .game-btn {
        padding: 10px 15px;
        font-size: 14px;
        max-width: 140px;
    }
}

/* ============ 彈窗樣式 ============ */
.tic-tac-toe-wrapper .modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 15px;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 勝利彈窗樣式 */
.tic-tac-toe-wrapper .win-modal-content {
    background: linear-gradient(145deg, #fff9c4, #ffeb3b);
    padding: 30px 20px;
    border-radius: 30px;
    max-width: 450px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 50px rgba(255, 235, 59, 0.7);
    animation: winPopup 0.5s ease-out;
    border: 8px solid #ffd600;
    margin: 20px auto;
    box-sizing: border-box;
}

@keyframes winPopup {
    0% { transform: scale(0.5); opacity: 0; }
    70% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.tic-tac-toe-wrapper .win-emoji {
    font-size: 70px;
    margin-bottom: 15px;
    animation: bounce 1s infinite alternate;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-6px) scale(1.05); }
}

.tic-tac-toe-wrapper .win-title {
    font-size: 28px;
    color: #e63946;
    margin-bottom: 12px;
    font-weight: bold;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.3);
}

.tic-tac-toe-wrapper .win-details {
    font-size: 18px;
    color: #2c3e50;
    margin-bottom: 12px;
    line-height: 1.4;
}

.tic-tac-toe-wrapper .win-gold {
    font-size: 32px;
    color: #e63946;
    font-weight: bold;
    margin: 12px 0;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.3);
}

.tic-tac-toe-wrapper .win-btn {
    background: linear-gradient(to right, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    font-size: 18px;
    transition: all 0.3s;
    box-shadow: 0 8px 20px rgba(52, 152, 219, 0.5);
    margin-top: 12px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.tic-tac-toe-wrapper .win-btn:hover {
    background: linear-gradient(to right, #3498db, #1abc9c);
    transform: scale(1.05);
    box-shadow: 0 12px 25px rgba(52, 152, 219, 0.6);
}

/* 失敗彈窗樣式 */
.tic-tac-toe-wrapper .lose-modal-content {
    background: linear-gradient(145deg, #e0e0e0, #b0b0b0);
    padding: 30px 20px;
    border-radius: 30px;
    max-width: 450px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
    animation: losePopup 0.5s ease-out;
    border: 8px solid #777;
    margin: 20px auto;
    box-sizing: border-box;
}

@keyframes losePopup {
    0% { transform: scale(0.5); opacity: 0; }
    70% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.tic-tac-toe-wrapper .lose-emoji {
    font-size: 70px;
    margin-bottom: 15px;
    animation: shake 1s infinite alternate;
}

@keyframes shake {
    from { transform: rotate(-10deg); }
    to { transform: rotate(10deg); }
}

.tic-tac-toe-wrapper .lose-title {
    font-size: 28px;
    color: #333;
    margin-bottom: 12px;
    font-weight: bold;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.2);
}

.tic-tac-toe-wrapper .lose-details {
    font-size: 18px;
    color: #555;
    margin-bottom: 12px;
    line-height: 1.4;
}

.tic-tac-toe-wrapper .lose-gold {
    font-size: 32px;
    color: #333;
    font-weight: bold;
    margin: 12px 0;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.2);
}

/* 平手彈窗樣式 */
.tic-tac-toe-wrapper .draw-modal-content {
    background: linear-gradient(145deg, #e0e0e0, #f0f0f0);
    padding: 30px 20px;
    border-radius: 30px;
    max-width: 450px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 50px rgba(108, 117, 125, 0.3);
    animation: drawPopup 0.5s ease-out;
    border: 8px solid #6c757d;
    margin: 20px auto;
    box-sizing: border-box;
}

@keyframes drawPopup {
    0% { transform: scale(0.5); opacity: 0; }
    70% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.tic-tac-toe-wrapper .draw-emoji {
    font-size: 70px;
    margin-bottom: 15px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

.tic-tac-toe-wrapper .draw-title {
    font-size: 28px;
    color: #333;
    margin-bottom: 12px;
    font-weight: bold;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.1);
}

.tic-tac-toe-wrapper .draw-details {
    font-size: 18px;
    color: #555;
    margin-bottom: 12px;
    line-height: 1.4;
}

/* 成功訊息彈窗樣式 */
.tic-tac-toe-wrapper .success-modal-content {
    background: linear-gradient(145deg, #d4edda, #c3e6cb);
    padding: 25px;
    border-radius: 20px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 15px 40px rgba(42, 157, 143, 0.3);
    animation: popup 0.4s ease-out;
    border: 4px solid #2a9d8f;
}

.tic-tac-toe-wrapper .success-title {
    font-size: 24px;
    color: #2a9d8f;
    margin-bottom: 15px;
    font-weight: bold;
}

.tic-tac-toe-wrapper .success-message {
    font-size: 16px;
    color: #2c3e50;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* 確認彈窗樣式 */
.tic-tac-toe-wrapper .confirm-modal-content {
    background: white;
    padding: 25px 15px;
    border-radius: 25px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
    animation: popup 0.4s ease-out;
    border: 4px solid #FF7A00;
    margin: 20px auto;
    box-sizing: border-box;
}

.tic-tac-toe-wrapper .confirm-title {
    font-size: 24px;
    color: #e63946;
    margin-bottom: 12px;
    font-weight: bold;
}

.tic-tac-toe-wrapper .confirm-message {
    font-size: 18px;
    color: #333;
    margin-bottom: 20px;
    line-height: 1.5;
}

.tic-tac-toe-wrapper .confirm-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 15px;
}

.tic-tac-toe-wrapper .confirm-yes, .tic-tac-toe-wrapper .confirm-no {
    padding: 10px 25px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    min-width: 90px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.tic-tac-toe-wrapper .confirm-yes {
    background: linear-gradient(145deg, #e63946, #d62828);
    color: white;
}

.tic-tac-toe-wrapper .confirm-yes:hover {
    background: linear-gradient(145deg, #d62828, #e63946);
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(230, 57, 70, 0.4);
}

.tic-tac-toe-wrapper .confirm-no {
    background: linear-gradient(145deg, #457b9d, #1d3557);
    color: white;
}

.tic-tac-toe-wrapper .confirm-no:hover {
    background: linear-gradient(145deg, #1d3557, #457b9d);
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(69, 123, 157, 0.4);
}

/* 店家資訊和獎項設定彈窗樣式 */
.tic-tac-toe-wrapper .info-modal-content {
    background: white;
    padding: 25px;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
    animation: popup 0.4s ease-out;
}

.tic-tac-toe-wrapper .info-title {
    font-size: 28px;
    font-weight: 900;
    color: #457b9d;
    text-align: center;
    margin-bottom: 25px;
}

.tic-tac-toe-wrapper .prize-title {
    color: #ff9800;
}

.tic-tac-toe-wrapper .info-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.tic-tac-toe-wrapper .info-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tic-tac-toe-wrapper .info-label {
    font-size: 16px;
    font-weight: bold;
    color: #FF7A00;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tic-tac-toe-wrapper .info-input {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    outline: none;
    transition: all 0.3s;
    background: #f8f9fa;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.tic-tac-toe-wrapper .info-input:focus {
    border-color: #FF7A00;
    box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.2);
    background: white;
}

.tic-tac-toe-wrapper .info-char-count {
    font-size: 14px;
    color: #666;
    text-align: right;
}

.tic-tac-toe-wrapper .info-buttons {
    display: flex;
    gap: 15px;
}

.tic-tac-toe-wrapper .info-save, .tic-tac-toe-wrapper .info-cancel {
    flex: 1;
    padding: 15px;
    border: none;
    border-radius: 15px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.tic-tac-toe-wrapper .info-save {
    background: linear-gradient(145deg, #457b9d, #1d3557);
    color: white;
}

.tic-tac-toe-wrapper .info-save:hover {
    background: linear-gradient(145deg, #1d3557, #457b9d);
    transform: translateY(-3px);
}

.tic-tac-toe-wrapper .info-cancel {
    background: linear-gradient(145deg, #95a5a6, #7f8c8d);
    color: white;
}

.tic-tac-toe-wrapper .info-cancel:hover {
    background: linear-gradient(145deg, #7f8c8d, #95a5a6);
    transform: translateY(-3px);
}

.tic-tac-toe-wrapper .prize-save {
    background: linear-gradient(145deg, #ff9800, #f57c00) !important;
}

.tic-tac-toe-wrapper .prize-save:hover {
    background: linear-gradient(145deg, #f57c00, #ff9800) !important;
}

/* ============ 修正：遊戲規則彈窗樣式 - 完全對稱間距（參考您的範例） ============ */
.tic-tac-toe-wrapper .rules-modal-content {
    background: white;
    padding: 25px;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
    animation: popup 0.4s ease-out;
    border: 3px solid #FF9800;
}

.tic-tac-toe-wrapper .rules-modal-title {
    font-size: 28px;
    font-weight: 900;
    color: #FF5722;
    text-align: center;
    margin-bottom: 25px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    padding-bottom: 15px;
    border-bottom: 3px solid #FF9800;
    width: 100%;
    box-sizing: border-box;
}

.tic-tac-toe-wrapper .rules-modal-list {
    list-style: none;
    padding: 0;
    margin: 0 0 25px 0;
    width: 100%;
    box-sizing: border-box;
}

/* 關鍵修正：完全對稱間距，像您的範例一樣 */
.tic-tac-toe-wrapper .rules-modal-list li {
    padding: 10px 0; /* 和您的範例一樣，只有上下間距 */
    border-bottom: 1px solid #eee; /* 像您的範例一樣用淺色分隔線 */
    display: flex;
    align-items: center; /* 垂直居中對齊 */
    width: 100%;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.tic-tac-toe-wrapper .rules-modal-list li:last-child {
    border-bottom: none;
}

.tic-tac-toe-wrapper .rules-modal-list li:hover {
    background-color: rgba(255, 248, 225, 0.3);
}

/* 關鍵修正：圖標樣式完全對齊 */
.tic-tac-toe-wrapper .rules-modal-list li i.fa {
    color: #FF7A00; /* 使用橙色，像您的範例一樣 */
    margin-right: 10px;
    width: 25px; /* 固定寬度，像您的範例一樣 */
    min-width: 25px; /* 確保不壓縮 */
    max-width: 25px; /* 確保不擴展 */
    text-align: center;
    flex-shrink: 0; /* 防止圖標被壓縮 */
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 關鍵修正：文字部分完全對齊 */
.tic-tac-toe-wrapper .rules-modal-list li span {
    flex: 1;
    font-size: 16px;
    color: #5D4037;
    font-weight: 500;
    line-height: 1.6;
    padding: 0; /* 移除所有內邊距 */
    margin: 0; /* 移除所有外邊距 */
    width: auto; /* 自動寬度 */
    box-sizing: border-box;
    text-align: left;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* 遊戲規則彈窗關閉按鈕 */
.tic-tac-toe-wrapper .rules-modal-content .info-buttons {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    width: 100%;
}

.tic-tac-toe-wrapper .rules-modal-content .info-save {
    background: linear-gradient(145deg, #FF9800, #F57C00);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 15px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    flex: 1;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    text-align: center;
}

.tic-tac-toe-wrapper .rules-modal-content .info-save:hover {
    background: linear-gradient(145deg, #F57C00, #FF9800);
    transform: translateY(-3px);
}

@media (max-width: 768px) {
    .tic-tac-toe-wrapper .rules-modal-content {
        padding: 20px;
        max-height: 85vh;
        border-width: 3px;
    }
    
    .tic-tac-toe-wrapper .rules-modal-title {
        font-size: 24px;
        margin-bottom: 20px;
        padding-bottom: 12px;
    }
    
    .tic-tac-toe-wrapper .rules-modal-list li {
        padding: 10px 0; /* 保持對稱 */
    }
    
    .tic-tac-toe-wrapper .rules-modal-list li i.fa {
        width: 25px; /* 手機端也保持固定寬度 */
        min-width: 25px;
        max-width: 25px;
        margin-right: 10px; /* 保持一致的右邊距 */
        font-size: 16px;
    }
    
    .tic-tac-toe-wrapper .rules-modal-list li span {
        font-size: 15px;
    }
    
    .tic-tac-toe-wrapper .rules-modal-content .info-save {
        padding: 12px;
        font-size: 16px;
    }
}

@keyframes popup {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ============ 返回頂部按鈕（只在手機顯示） ============ */
#backToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(145deg, #FF7A00, #FF5722);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 5px 15px rgba(255, 122, 0, 0.5);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    display: none;
}

@media (max-width: 768px) {
    #backToTop {
        display: flex;
    }
}

#backToTop.show {
    opacity: 1;
    visibility: visible;
}

#backToTop:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(255, 122, 0, 0.7);
}

@media (max-width: 768px) {
    #backToTop {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
        bottom: 20px;
        right: 20px;
    }
}

/* ============ 遊戲結果訊息 - 完全修正版 ============ */
#gameResult {
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    margin: 15px 0;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    display: none !important;
    width: 100%;
    max-width: 500px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

#gameResult.show {
    display: flex !important;
    opacity: 1;
    transform: translateY(0);
}

/* ============ 贏：白色背景 + 紅色字體 + 金色光暈 ============ */
#gameResult.win-result {
    background: linear-gradient(145deg, #FFFFFF, #F8F8F8) !important; /* 白色漸層 */
    color: #FF0000 !important; /* 鮮紅色字體 */
    border: 3px solid #FFD700 !important; /* 金色邊框 */
    text-shadow: 
        2px 2px 4px rgba(255, 215, 0, 0.3),
        0 0 8px rgba(255, 215, 0, 0.2) !important;
    animation: winResultGlow 1.2s ease-in-out infinite alternate !important;
    position: relative;
}

/* 贏：金色光暈特效 */
#gameResult.win-result::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: radial-gradient(circle, rgba(255,215,0,0.4) 0%, rgba(255,215,0,0) 70%);
    border-radius: 20px;
    z-index: -1;
    animation: winGlowRing 2s ease-in-out infinite !important;
}

/* 贏的脈動效果 */
@keyframes winResultGlow {
    0% {
        box-shadow: 
            0 0 10px rgba(255, 215, 0, 0.5),
            0 0 20px rgba(255, 215, 0, 0.3),
            0 0 30px rgba(255, 215, 0, 0.2),
            inset 0 0 5px rgba(255, 255, 255, 0.8) !important;
        transform: scale(1) translateY(0) !important;
        background: linear-gradient(145deg, #FFFFFF, #F8F8F8) !important;
    }
    50% {
        background: linear-gradient(145deg, #FFF8DC, #FFFAF0) !important; /* 稍微偏暖白色 */
    }
    100% {
        box-shadow: 
            0 0 20px rgba(255, 215, 0, 0.8),
            0 0 40px rgba(255, 215, 0, 0.6),
            0 0 60px rgba(255, 215, 0, 0.4),
            inset 0 0 10px rgba(255, 255, 255, 0.9) !important;
        transform: scale(1.03) translateY(-2px) !important;
        background: linear-gradient(145deg, #FFFFFF, #F8F8F8) !important;
    }
}

@keyframes winGlowRing {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

/* ============ 輸：白色背景 + 深藍色字體 + 銀色光暈 ============ */
#gameResult.lose-result {
    background: linear-gradient(145deg, #FFFFFF, #F8F8F8) !important; /* 白色漸層 */
    color: #1E3A8A !important; /* 深藍色字體（增加對比度） */
    border: 3px solid #C0C0C0 !important; /* 銀色邊框 */
    text-shadow: 
        2px 2px 4px rgba(192, 192, 192, 0.3),
        0 0 8px rgba(192, 192, 192, 0.2) !important;
    animation: loseResultGlow 1.2s ease-in-out infinite alternate !important;
    position: relative;
}

/* 輸：銀色光暈特效 */
#gameResult.lose-result::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: radial-gradient(circle, rgba(192,192,192,0.4) 0%, rgba(192,192,192,0) 70%);
    border-radius: 20px;
    z-index: -1;
    animation: loseGlowRing 2s ease-in-out infinite !important;
}

/* 輸的脈動效果 */
@keyframes loseResultGlow {
    0% {
        box-shadow: 
            0 0 10px rgba(192, 192, 192, 0.5),
            0 0 20px rgba(192, 192, 192, 0.3),
            0 0 30px rgba(192, 192, 192, 0.2),
            inset 0 0 5px rgba(255, 255, 255, 0.8) !important;
        transform: scale(1) translateY(0) !important;
        background: linear-gradient(145deg, #FFFFFF, #F8F8F8) !important;
    }
    50% {
        background: linear-gradient(145deg, #F5F5F5, #EAEAEA) !important; /* 稍微偏冷白色 */
    }
    100% {
        box-shadow: 
            0 0 20px rgba(192, 192, 192, 0.8),
            0 0 40px rgba(192, 192, 192, 0.6),
            0 0 60px rgba(192, 192, 192, 0.4),
            inset 0 0 10px rgba(255, 255, 255, 0.9) !important;
        transform: scale(1.03) translateY(-2px) !important;
        background: linear-gradient(145deg, #FFFFFF, #F8F8F8) !important;
    }
}

@keyframes loseGlowRing {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

/* ============ 平手：白色背景 + 綠色字體 + 橙色光暈 ============ */
#gameResult.draw-result {
    background: linear-gradient(145deg, #FFFFFF, #F8F8F8) !important; /* 白色漸層 */
    color: #228B22 !important; /* 森林綠色字體 */
    border: 3px solid #FF8C00 !important; /* 橙色邊框 */
    text-shadow: 
        2px 2px 4px rgba(255, 140, 0, 0.3),
        0 0 8px rgba(255, 140, 0, 0.2) !important;
    animation: drawResultGlow 2s ease-in-out infinite alternate !important;
    position: relative;
}

/* 平手：橙色光暈特效 */
#gameResult.draw-result::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: radial-gradient(circle, rgba(255,140,0,0.4) 0%, rgba(255,140,0,0) 70%);
    border-radius: 20px;
    z-index: -1;
    animation: drawGlowRing 3s ease-in-out infinite !important;
}

/* 平手的脈動效果 */
@keyframes drawResultGlow {
    0% {
        box-shadow: 
            0 0 10px rgba(255, 140, 0, 0.5),
            0 0 20px rgba(255, 140, 0, 0.3),
            0 0 30px rgba(255, 140, 0, 0.2),
            inset 0 0 5px rgba(255, 255, 255, 0.8) !important;
        transform: scale(1) !important;
        background: linear-gradient(145deg, #FFFFFF, #F8F8F8) !important;
    }
    50% {
        background: linear-gradient(145deg, #FFF5E6, #FFEEDD) !important; /* 稍微偏暖白色 */
    }
    100% {
        box-shadow: 
            0 0 20px rgba(255, 140, 0, 0.8),
            0 0 40px rgba(255, 140, 0, 0.6),
            0 0 60px rgba(255, 140, 0, 0.4),
            inset 0 0 10px rgba(255, 255, 255, 0.9) !important;
        transform: scale(1.02) !important;
        background: linear-gradient(145deg, #FFFFFF, #F8F8F8) !important;
    }
}

@keyframes drawGlowRing {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

/* ============ 正常狀態（遊戲進行中）：白色背景 + 藍色字體 + 藍色光暈 ============ */
#gameResult:not(.win-result):not(.lose-result):not(.draw-result) {
    background: linear-gradient(145deg, #FFFFFF, #F8F8F8) !important; /* 白色漸層 */
    color: #1E90FF !important; /* 道奇藍字體 */
    border: 2px solid #4169E1 !important; /* 皇家藍邊框 */
    text-shadow: 
        1px 1px 2px rgba(65, 105, 225, 0.3),
        0 0 5px rgba(65, 105, 225, 0.2) !important;
    animation: normalGlow 3s ease-in-out infinite alternate !important;
}

/* 進行中的脈動效果 */
@keyframes normalGlow {
    0% {
        box-shadow: 
            0 0 5px rgba(65, 105, 225, 0.5),
            0 0 10px rgba(65, 105, 225, 0.3) !important;
        transform: scale(1) !important;
    }
    100% {
        box-shadow: 
            0 0 15px rgba(65, 105, 225, 0.8),
            0 0 30px rgba(65, 105, 225, 0.6) !important;
        transform: scale(1.01) !important;
    }
}

/* ============ 確保字體在手機上也能清楚顯示 ============ */
@media (max-width: 768px) {
    #gameResult {
        font-size: 1.3rem;
        padding: 12px;
        min-height: 55px;
        margin: 12px auto;
        max-width: 90%;
    }
    
    #gameResult.win-result,
    #gameResult.lose-result,
    #gameResult.draw-result,
    #gameResult:not(.win-result):not(.lose-result):not(.draw-result) {
        font-size: 1.3rem;
        font-weight: 800; /* 更粗的字體 */
        letter-spacing: 0.5px; /* 稍微增加字距 */
    }
}

/* ============ 確保文字對比度足夠，易於閱讀 ============ */
#gameResult.win-result {
    /* 紅色文字在白色背景上需要足夠對比度 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-weight: 900; /* 更粗的字體確保可讀性 */
}

#gameResult.lose-result {
    /* 深藍色文字在白色背景上需要足夠對比度 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-weight: 900; /* 更粗的字體確保可讀性 */
}

#gameResult.draw-result {
    /* 綠色文字在白色背景上需要足夠對比度 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-weight: 900; /* 更粗的字體確保可讀性 */
}

#gameResult:not(.win-result):not(.lose-result):not(.draw-result) {
    /* 藍色文字在白色背景上需要足夠對比度 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-weight: 700; /* 正常粗度 */
}

/* ============ 手機端統計區域 - 正方形 ============ */
@media (max-width: 768px) {
    .tic-tac-toe-wrapper .game-stats {
        display: flex !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        gap: 10px !important;
        margin: 20px 0 !important;
        padding: 0 15px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* 手機端統計圖框 - 正方形 */
    .tic-tac-toe-wrapper .stat-item {
        text-align: center;
        background: linear-gradient(145deg, #ffffff, #f5f5f5);
        border-radius: 15px !important;
        box-shadow: 0 6px 18px rgba(0,0,0,0.1) !important;
        min-width: 0 !important;
        width: calc(25% - 8px) !important; /* 調整寬度計算 */
        transition: all 0.3s ease;
        border: 2px solid #FF7A00 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        flex-shrink: 0 !important;
        height: auto !important;
        aspect-ratio: 1 / 1 !important; /* 強制正方形比例 */
        padding: 10px !important; /* 調整內邊距 */
    }
    
    /* 手機端數值 - 正方形調整 */
    .tic-tac-toe-wrapper .stat-value {
        font-size: 2rem !important; /* 調整字體大小 */
        font-weight: bold;
        color: #FF7A00;
        text-shadow: 1px 1px 3px rgba(0,0,0,0.1);
        margin-bottom: 5px !important;
        line-height: 1;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        height: auto !important;
    }
    
    /* 手機端文字 - 正方形調整 */
    .tic-tac-toe-wrapper .stat-label {
        font-size: 0.85rem !important; /* 調整字體大小 */
        color: #555;
        font-weight: 600;
        line-height: 1.3;
        margin-top: 0 !important;
        text-align: center !important;
        word-break: keep-all !important;
        white-space: normal !important;
        padding: 0 3px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        height: auto !important;
    }
    
    /* 保持懸停效果 */
    .tic-tac-toe-wrapper .stat-item:hover {
        transform: translateY(-3px) !important;
        box-shadow: 0 8px 22px rgba(255, 122, 0, 0.15) !important;
        border-color: #FF5722 !important;
    }
}

/* 超小手機調整 - 正方形 */
@media (max-width: 375px) {
    .tic-tac-toe-wrapper .game-stats {
        gap: 8px !important;
        padding: 0 12px !important;
    }
    
    .tic-tac-toe-wrapper .stat-item {
        width: calc(25% - 6px) !important; /* 調整寬度計算 */
        border-radius: 12px !important;
        padding: 8px !important;
    }
    
    .tic-tac-toe-wrapper .stat-value {
        font-size: 1.7rem !important;
        margin-bottom: 4px !important;
    }
    
    .tic-tac-toe-wrapper .stat-label {
        font-size: 0.75rem !important;
        padding: 0 2px !important;
    }
}

/* 中等手機調整 - 正方形 */
@media (min-width: 376px) and (max-width: 480px) {
    .tic-tac-toe-wrapper .game-stats {
        gap: 9px !important;
        padding: 0 14px !important;
    }
    
    .tic-tac-toe-wrapper .stat-item {
        width: calc(25% - 7px) !important; /* 調整寬度計算 */
        padding: 9px !important;
    }
    
    .tic-tac-toe-wrapper .stat-value {
        font-size: 1.8rem !important;
        margin-bottom: 4px !important;
    }
    
    .tic-tac-toe-wrapper .stat-label {
        font-size: 0.8rem !important;
        padding: 0 2px !important;
    }
}

/* 較大手機調整 - 正方形 */
@media (min-width: 481px) and (max-width: 768px) {
    .tic-tac-toe-wrapper .game-stats {
        gap: 10px !important;
        padding: 0 16px !important;
    }
    
    .tic-tac-toe-wrapper .stat-item {
        width: calc(25% - 8px) !important; /* 調整寬度計算 */
        border-radius: 15px !important;
        padding: 12px !important;
    }
    
    .tic-tac-toe-wrapper .stat-value {
        font-size: 2.2rem !important;
        margin-bottom: 6px !important;
    }
    
    .tic-tac-toe-wrapper .stat-label {
        font-size: 0.9rem !important;
        padding: 0 4px !important;
    }
}

/* ============ 海報樣式優化 - 修正版本 ============ */

/* 海報容器優化 */
#posterContainer {
    /* 移除動畫效果，保持靜態 */
}

/* 海報內容優化 - 移除所有動畫效果 */
#posterContent {
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border: 4px solid #FFD700;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 0 30px rgba(255, 215, 0, 0.4);
    /* 移除動畫: animation: posterPopIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); */
    overflow: hidden;
    position: relative;
}

/* 海報裝飾元素 */
#posterContent::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(255,215,0,0.2) 0%, rgba(255,215,0,0) 70%);
    border-radius: 50%;
    z-index: 0;
}

#posterContent::after {
    content: '';
    position: absolute;
    bottom: -50px;
    left: -50px;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(255,122,0,0.2) 0%, rgba(255,122,0,0) 70%);
    border-radius: 50%;
    z-index: 0;
}

/* 海報主要標題優化 - 移除所有動畫 */
.poster-main-title {
    color: #e63946;
    font-size: 32px;
    margin-bottom: 20px;
    font-weight: 900;
    text-align: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    text-shadow: 
        0 0 15px rgba(255, 215, 0, 0.6),
        0 0 30px rgba(255, 215, 0, 0.4),
        0 0 45px rgba(255, 215, 0, 0.2),
        3px 3px 6px rgba(0,0,0,0.15);
    /* 移除動畫: animation: posterTitleGlow 2s ease-in-out infinite alternate; */
    padding: 15px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(255, 249, 196, 0.7));
    border-radius: 20px;
    border: 3px solid #FFD700;
    box-shadow: 
        0 10px 30px rgba(255, 215, 0, 0.3),
        inset 0 0 20px rgba(255, 255, 255, 0.8);
    z-index: 1;
    position: relative;
    overflow: hidden;
}

.poster-main-title::before {
    content: "🏆";
    font-size: 40px;
    /* 移除動畫: animation: trophyGlow 1.5s ease-in-out infinite alternate; */
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.8));
}

.poster-main-title::after {
    content: "✨";
    font-size: 28px;
    /* 移除動畫: animation: sparkle 2s ease-in-out infinite; */
    position: absolute;
    top: 10px;
    left: 20px;
}

/* 增加更多裝飾元素 */
.poster-main-title span.decoration {
    position: absolute;
    font-size: 20px;
    /* 移除動畫: animation: float 3s ease-in-out infinite; */
}

.poster-main-title span.decoration:nth-child(1) {
    top: 5px;
    right: 25px;
}

.poster-main-title span.decoration:nth-child(2) {
    bottom: 5px;
    left: 25px;
}

/* 遊戲結果文字優化 - 移除動畫 */
.poster-victory-text {
    font-size: 28px;
    font-weight: bold;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    border: 4px solid #FFD700;
    background: linear-gradient(145deg, #fff9c4, #ffecb3);
    text-align: center;
    color: #e63946;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.2),
        0 0 20px rgba(255, 215, 0, 0.5),
        inset 0 0 20px rgba(255, 255, 255, 0.8);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    /* 移除動畫: animation: victoryTextPulse 1.5s ease-in-out infinite alternate; */
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.poster-victory-text::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: radial-gradient(circle, rgba(255,215,0,0.3) 0%, rgba(255,215,0,0) 70%);
    border-radius: 25px;
    z-index: -1;
    /* 移除動畫: animation: victoryGlow 2s ease-in-out infinite; */
}

/* 棋盤容器優化 */
.poster-game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin: 25px 0;
    background: linear-gradient(145deg, #f8f9fa, #ffffff);
    padding: 25px;
    border-radius: 20px;
    border: 4px solid #FFD700;
    box-shadow: 
        0 15px 35px rgba(255, 215, 0, 0.2),
        inset 0 0 30px rgba(255, 255, 255, 0.9);
    position: relative;
    overflow: hidden;
}

.poster-game-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, 
        #e63946 0%, 
        #FFD700 25%, 
        #FF7A00 50%, 
        #FFD700 75%, 
        #e63946 100%);
    z-index: 1;
}

/* 棋盤優化 - 移除動畫效果 */
.poster-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 12px;
    background: white;
    padding: 20px;
    border-radius: 15px;
    border: 4px solid #FFD700;
    box-shadow: 
        0 10px 25px rgba(0, 0, 0, 0.15),
        0 0 15px rgba(255, 215, 0, 0.3),
        inset 0 0 15px rgba(255, 255, 255, 0.8);
    width: 400px;
    height: 400px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.poster-cell {
    background: linear-gradient(145deg, #ffffff, #f5f5f5);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    font-weight: bold;
    border: 3px solid #e0e0e0;
    position: relative;
    overflow: hidden;
}

.poster-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(145deg, rgba(255,255,255,0.9), rgba(255,255,255,0.7));
    z-index: -1;
}

.poster-cell.winning-cell {
    background: linear-gradient(145deg, #fff9c4, #ffecb3);
    border: 4px solid #FFD700;
    box-shadow: 
        0 0 20px rgba(255, 215, 0, 0.8),
        0 0 40px rgba(255, 215, 0, 0.6),
        inset 0 0 20px rgba(255, 255, 255, 0.9);
    /* 移除動畫: animation: winningCellGlow 1.5s ease-in-out infinite alternate; */
    transform-origin: center;
}

/* 獎項內容優化 */
.poster-prize-content {
    font-size: 20px;
    color: #2c3e50;
    margin-top: 20px;
    text-align: center;
    font-weight: 600;
    line-height: 1.5;
    padding: 25px;
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border-radius: 15px;
    border: 3px solid #FFD700;
    box-shadow: 
        0 0 15px rgba(255, 215, 0, 0.4),
        0 0 30px rgba(255, 215, 0, 0.2),
        inset 0 0 10px rgba(255, 255, 255, 0.9);
    position: relative;
    overflow: hidden;
}

.poster-prize-content::before {
    content: '🎁';
    position: absolute;
    top: -15px;
    left: -15px;
    font-size: 50px;
    opacity: 0.2;
    transform: rotate(-15deg);
}

.poster-prize-content::after {
    content: '✨';
    position: absolute;
    bottom: -15px;
    right: -15px;
    font-size: 40px;
    opacity: 0.2;
    transform: rotate(15deg);
}

/* 店家資訊區塊優化 */
.poster-store-section {
    text-align: center;
    padding: 25px;
    background: linear-gradient(145deg, #f8f9fa, #ffffff);
    border-radius: 20px;
    border: 4px solid #FFD700;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.12),
        inset 0 0 20px rgba(255, 255, 255, 0.9);
    margin-bottom: 25px;
    position: relative;
    overflow: hidden;
}

.poster-store-title {
    color: #457b9d;
    font-size: 24px;
    margin-bottom: 20px;
    font-weight: 800;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    padding-bottom: 15px;
    border-bottom: 3px solid #FFD700;
}

.poster-store-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    text-align: left;
}

.poster-store-item {
    background: linear-gradient(145deg, #ffffff, #f5f5f5);
    padding: 18px;
    border-radius: 12px;
    border: 2px solid #e0e0e0;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.poster-store-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: linear-gradient(to bottom, #FF7A00, #FFD700);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.poster-store-item:hover {
    border-color: #FFD700;
    box-shadow: 
        0 5px 15px rgba(255, 215, 0, 0.2),
        inset 0 0 10px rgba(255, 255, 255, 0.9);
    transform: translateY(-3px);
}

.poster-store-item:hover::before {
    opacity: 1;
}

.poster-store-icon {
    font-size: 1.5rem;
    margin-right: 15px;
    min-width: 30px;
    color: #FF9800;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.poster-store-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.poster-store-label {
    font-weight: 700;
    color: #FF7A00;
    margin-bottom: 5px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.poster-store-value {
    color: #333;
    font-size: 16px;
    line-height: 1.4;
    word-break: break-word;
}

/* ============ 海報按鈕修正（重點修改部分） ============ */
.poster-buttons-container {
    display: flex;
    justify-content: center;      /* 水平置中 */
    align-items: center;          /* 垂直置中 */
    gap: 20px;
    margin-top: 25px;
    padding-top: 25px;
    border-top: 3px solid #e0e0e0;
    width: 100%;
    position: relative;
    z-index: 10;
    background: white;
}

/* 海報按鈕統一大小和樣式 */
.poster-button {
    padding: 15px 35px !important;
    border: none !important;
    border-radius: 15px !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    min-width: 180px !important;        /* 設定最小寬度 */
    max-width: 200px !important;       /* 設定最大寬度 */
    text-align: center !important;
    position: relative !important;
    overflow: hidden !important;
    box-shadow: 
        0 8px 20px rgba(0, 0, 0, 0.15),
        0 4px 10px rgba(0, 0, 0, 0.1) !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    height: auto !important;
    box-sizing: border-box !important;
    flex: 0 0 auto !important;         /* 不拉伸，固定大小 */
    width: auto !important;
}

/* 確保兩個按鈕寬度相同 */
.poster-button.download,
.poster-button.close {
    width: 180px !important;
    min-width: 180px !important;
    max-width: 180px !important;
}

/* 按鈕光暈效果 */
.poster-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s ease;
}

.poster-button:hover::before {
    left: 100%;
}

/* 關閉按鈕樣式 */
.poster-button.close {
    background: linear-gradient(145deg, #457b9d, #1d3557) !important;
    color: white !important;
}

.poster-button.close:hover {
    background: linear-gradient(145deg, #1d3557, #457b9d) !important;
    transform: translateY(-5px) !important;
    box-shadow: 
        0 12px 30px rgba(69, 123, 157, 0.4),
        0 6px 15px rgba(69, 123, 157, 0.3) !important;
}

/* 下載按鈕樣式 */
.poster-button.download {
    background: linear-gradient(145deg, #2a9d8f, #21867a) !important;
    color: white !important;
}

.poster-button.download:hover {
    background: linear-gradient(145deg, #21867a, #2a9d8f) !important;
    transform: translateY(-5px) !important;
    box-shadow: 
        0 12px 30px rgba(42, 157, 143, 0.4),
        0 6px 15px rgba(42, 157, 143, 0.3) !important;
}

.poster-button.download::after {
    content: ' ⬇';
}

/* 響應式設計優化 */
@media (max-width: 768px) {
    #posterContent {
        padding: 20px;
        max-height: 85vh;
    }
    
    .poster-main-title {
        font-size: 26px;
        padding: 12px;
        gap: 10px;
    }
    
    .poster-main-title::before {
        font-size: 32px;
    }
    
    .poster-victory-text {
        font-size: 22px;
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .poster-game-container {
        padding: 20px;
        gap: 15px;
        margin: 20px 0;
    }
    
    .poster-board {
        width: 320px;
        height: 320px;
        gap: 10px;
        padding: 15px;
    }
    
    .poster-cell {
        font-size: 4rem;
    }
    
    .poster-prize-content {
        font-size: 18px;
        padding: 20px;
        margin-top: 15px;
    }
    
    .poster-store-section {
        padding: 20px;
    }
    
    .poster-store-title {
        font-size: 20px;
    }
    
    .poster-store-item {
        padding: 15px;
    }
    
    .poster-store-icon {
        font-size: 1.3rem;
        margin-right: 12px;
    }
    
    .poster-store-label {
        font-size: 13px;
    }
    
    .poster-store-value {
        font-size: 14px;
    }
    
    .poster-buttons-container {
        gap: 15px;
        margin-top: 20px;
        padding-top: 20px;
    }
    
    .poster-button {
        padding: 12px 25px !important;
        min-width: 150px !important;
        max-width: 150px !important;
        font-size: 16px !important;
    }
    
    .poster-button.download,
    .poster-button.close {
        width: 150px !important;
        min-width: 150px !important;
        max-width: 150px !important;
    }
}

@media (max-width: 480px) {
    #posterContent {
        padding: 15px;
    }
    
    .poster-main-title {
        font-size: 22px;
        flex-direction: column;
        gap: 8px;
    }
    
    .poster-victory-text {
        font-size: 20px;
    }
    
    .poster-board {
        width: 280px;
        height: 280px;
    }
    
    .poster-cell {
        font-size: 3.5rem;
    }
    
    .poster-buttons-container {
        gap: 12px;
        flex-direction: row; /* 保持橫向排列 */
        justify-content: center;
    }
    
    .poster-button {
        padding: 10px 20px !important;
        min-width: 140px !important;
        max-width: 140px !important;
        font-size: 14px !important;
    }
    
    .poster-button.download,
    .poster-button.close {
        width: 140px !important;
        min-width: 140px !important;
        max-width: 140px !important;
    }
}