/* ============================================
   Museum Memory Game - CSS Styles
   配色主題：博物館 70 週年
   - 主色：深青墨綠 #2D5A5A
   - 輔色：橘紅漸層 #D7524A → #E87654
   - 背景：米黃 #E8D5C4
   ============================================ */

/* ===== 浮動按鈕 ===== */
.museum-game-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #2D5A5A 0%, #D7524A 100%);
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(45, 90, 90, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 998;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.museum-game-fab:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 30px rgba(215, 82, 74, 0.6);
    background: linear-gradient(135deg, #D7524A 0%, #E87654 100%);
}

.museum-game-fab i {
    font-size: 28px;
    color: white;
}

.game-tooltip {
    position: absolute;
    right: 70px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
}

.museum-game-fab:hover .game-tooltip {
    opacity: 1;
    visibility: visible;
    right: 75px;
}

/* ===== 模態視窗 ===== */
.museum-game-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    display: none; /* 預設隱藏 */
    align-items: center;
    justify-content: center;
}

.museum-game-modal.active {
    display: flex !important; /* 強制顯示 */
}

.museum-game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
}

.museum-game-container {
    position: relative;
    background: #E8D5C4; /* 米黃色背景 */
    border-radius: 20px;
    padding: 40px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-50px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.museum-game-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.7);
    border: 2px solid #a00;
    border-radius: 50%;
    color: #a00;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index:999;
}

.museum-game-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* ===== 難度選擇畫面 ===== */
.game-difficulty-screen {
    text-align: center;
    min-width: 500px;
}

.game-title {    
    font-size: 26px;
    font-weight: 700;
    margin: 0 0 10px 0;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.game-title i {
    color: #a00;
}

.game-subtitle {
    font-size: 16px;
    margin: 0 0 30px 0;
}

/* ===== 遊戲操作須知 ===== */
.game-instructions {
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid #2D5A5A;
    border-radius: 12px;
    padding: 20px 25px;
    margin: 0 auto 30px;
    max-width: 600px;
    text-align: left;
}

.instructions-title {
    color: #a00;
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 15px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.instructions-title i {
    font-size: 20px;
}

.instructions-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.instructions-list li {
    color: #1a1a1a;
    font-size: 14px;
    line-height: 1.8;
    margin: 8px 0;
    padding-left: 28px;
    position: relative;
}

.instructions-list li i {
    position: absolute;
    left: 0;
    top: 3px;
    color: #a00;
    font-size: 16px;
}

.difficulty-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.difficulty-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(10px);
}

.difficulty-btn:hover {
    background: rgba(255, 255, 255, 0.1);  /* ✅ hover 時更白 */
    border-color: #a00;  /* ✅ 橘紅色邊框 */
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(215, 82, 74, 0.4);
}

.difficulty-btn i {
    font-size: 48px;
}

.difficulty-btn span {
    font-size: 24px;
    font-weight: 700;
}

.difficulty-btn small {
    font-size: 14px;
    opacity: 0.8;
}

.difficulty-btn.easy:hover i {
    color: #4caf50;
}

.difficulty-btn.medium:hover i {
    color: #ff9800;
}

.difficulty-btn.hard:hover i {
    color: #f44336;
}

/* ===== 遊戲畫面 ===== */
.game-play-screen {
    min-width: 700px;
}

.game-info-panel {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
}

.game-stats {
    display: flex;
    gap: 30px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #1a1a1a;  /* ✅ 深黑色 */
    font-size: 18px;
    font-weight: 600;
}

.stat-item i {
    font-size: 24px;
    color: #a00;
}

.stars i {
    font-size: 20px;
    color: #a00;
    margin: 0 2px;
}

.stars i.fa-thumbs-down {
    color: rgba(255, 255, 255, 0.3);
}

.game-actions {
    display: flex;
    gap: 10px;
}

.btn-restart,
.btn-back {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.7);  /* ✅ 較不透明的背景 */
    border: 2px solid #a00;  /* ✅ 加上邊框 */
    border-radius: 8px;
    color: #a00;  /* ✅ 深青色文字 */
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-restart:hover,
.btn-back:hover {
    background: #D7524A;  /* ✅ 橘紅色背景 */
    color: white;  /* ✅ 白色文字 */
    border-color: #D7524A;
    transform: scale(1.1);
}

/* ===== 遊戲卡片區 ===== */
.game-board {
    display: grid;
    gap: 15px;
    justify-content: center;
}

/* 簡單：6對 = 12張 (4x3) */
.game-board.easy {
    grid-template-columns: repeat(4, 120px);
}

/* 中等：9對 = 18張 (6x3) */
.game-board.medium {
    grid-template-columns: repeat(6, 110px);
}

/* 困難：12對 = 24張 (6x4) */
.game-board.hard {
    grid-template-columns: repeat(6, 110px);
}

.game-card {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    backdrop-filter: blur(10px);
}

.game-card.flipped {
    transform: rotateY(180deg);
}

.game-card.flipped .card-face.card-back{
    backface-visibility: visible !important;
}

.game-card.matched {
    opacity: 0.6;
    cursor: default;
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.card-front {
    background: rgba(255, 255, 255, 0.9);
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.card-front i {
    font-size: 48px;
    color: #a00;
}

.card-back {
    background: #F5EBE0;
    transform: rotateY(180deg);
    border: 3px solid rgba(255, 255, 255, 0.5);
}

.card-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 動畫效果 */
.game-card.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: rotateY(0deg) translateX(0); }
    25% { transform: rotateY(0deg) translateX(-10px); }
    75% { transform: rotateY(0deg) translateX(10px); }
}

/* 當卡片已翻轉且需要搖動時 */
.game-card.flipped.shake {
    animation: shakeFlipped 0.5s;
}

@keyframes shakeFlipped {
    0%, 100% { transform: rotateY(180deg) translateX(0); }
    25% { transform: rotateY(180deg) translateX(-10px); }
    75% { transform: rotateY(180deg) translateX(10px); }
}

.game-card.bounce {
    animation: bounce 0.6s;
}

@keyframes bounce {
    0%, 100% { transform: rotateY(180deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.1); }
}

/* ===== 響應式設計 ===== */
@media (max-width: 768px) {
    .museum-game-fab {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
    }
    
    .museum-game-fab i {
        font-size: 24px;
    }
    
    .museum-game-container {
        padding: 20px;
        max-width: 95%;
        max-height: 75vh;
        width:95vw;
    }
    
    .game-difficulty-screen {
        min-width: auto;
    }
    
    .game-instructions {
        padding: 15px 20px;
        margin: 0 0 20px;
    }
    
    .instructions-title {
        font-size: 16px;
    }
    
    .instructions-list li {
        font-size: 13px;
        padding-left: 24px;
    }
    
    .difficulty-buttons {
        flex-direction: column;
    }
    
    .game-play-screen {
        min-width: auto;
    }
    
    .game-info-panel {
        flex-direction: column;
        gap: 15px;
    }
    
    .game-stats {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .game-board.easy {
        grid-template-columns: repeat(3, 90px);
    }
    
    .game-board.medium {
        grid-template-columns: repeat(3, 90px);
    }
    
    .game-board.hard {
        grid-template-columns: repeat(4, 80px);
    }
    
    .card-front i {
        font-size: 32px;
    }
}

/* ===== SweetAlert 客製化 ===== */
.swal2-popup {
    background: linear-gradient(135deg, #2D5A5A 0%, #D7524A 100%);
    color: white;
}

.swal2-title {
    color: white;
}

.swal2-html-container {
    color: rgba(255, 255, 255, 0.9);
}

.swal2-confirm {
    background: rgba(255, 255, 255, 0.9) !important;
    color: #2D5A5A !important;
}

/* ===== 載入動畫 ===== */
.game-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #2D5A5A;  /* ✅ 深青色 */
    font-size: 18px;
    font-weight: 600;
}

.game-loading i {
    margin-right: 10px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}