/* ========================================
   財商小達人 v2.0 - 動畫與額外樣式
   ======================================== */

/* 教學系統樣式 */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
    pointer-events: none; /* 允許點擊下方的 highlight 區域，如果需要 */
}

.tutorial-overlay.transparent {
    background: rgba(0, 0, 0, 0);
}

.tutorial-popup {
    position: absolute; /* 改為絕對定位以便精確指向 */
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 2px solid #6366f1;
    border-radius: 24px;
    padding: 32px;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(99, 102, 241, 0.2);
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 2100;
    pointer-events: auto; /* 彈窗本身要可以點擊 */
}

@keyframes popIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.tutorial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.tutorial-title {
    font-size: 1.4rem;
    margin: 0;
}

.tutorial-skip {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.9rem;
}

.tutorial-skip:hover {
    color: #f8fafc;
}

.tutorial-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #e2e8f0;
    margin-bottom: 24px;
}

.tutorial-animation {
    margin-bottom: 20px;
}

.compound-demo {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 12px;
    height: 150px;
    padding: 16px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 12px;
}

.compound-bar {
    width: 60px;
    background: linear-gradient(to top, #10b981, #34d399);
    border-radius: 8px 8px 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 8px 4px;
    font-size: 0.7rem;
    text-align: center;
    height: var(--height);
    animation: growBar 0.5s ease forwards;
    animation-delay: calc(var(--height) / 100 * 0.5s);
}

@keyframes growBar {
    0% {
        height: 0;
    }

    100% {
        height: var(--height);
    }
}

.tutorial-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tutorial-dots {
    display: flex;
    gap: 8px;
}

.tutorial-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #334155;
    transition: all 0.3s;
}

.tutorial-dot.active {
    background: #6366f1;
    transform: scale(1.2);
}

.tutorial-highlight {
    position: fixed;
    border: 3px solid #6366f1;
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7), 0 0 20px rgba(99, 102, 241, 0.5);
    pointer-events: none;
    z-index: 1999;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7), 0 0 20px rgba(99, 102, 241, 0.5);
    }

    50% {
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7), 0 0 40px rgba(99, 102, 241, 0.8);
    }
}

/* 成就系統樣式 */
.achievement-notification {
    position: fixed;
    top: 100px;
    right: 20px;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 2px solid #fbbf24;
    border-radius: 16px;
    padding: 20px;
    z-index: 1500;
    animation: slideInRight 0.5s ease, fadeOut 0.5s ease 3s forwards;
    box-shadow: 0 0 30px rgba(251, 191, 36, 0.3);
    max-width: 300px;
}

.achievement-notification.negative {
    border-color: #ef4444;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.3);
}

@keyframes slideInRight {
    0% {
        transform: translateX(100%);
        opacity: 0;
    }

    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    100% {
        opacity: 0;
        transform: translateX(100%);
    }
}

.achievement-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.achievement-icon {
    font-size: 2rem;
}

.achievement-label {
    font-size: 0.8rem;
    color: #fbbf24;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.achievement-name {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.achievement-desc {
    font-size: 0.9rem;
    color: #94a3b8;
}

/* 成就面板 */
.achievements-panel {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.achievement-card {
    background: var(--bg-card-light);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.achievement-card.unlocked {
    border-color: #fbbf24;
    background: rgba(251, 191, 36, 0.1);
}

.achievement-card.unlocked.negative {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.achievement-card.locked {
    opacity: 0.5;
    filter: grayscale(1);
}

.achievement-card .icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.achievement-card .name {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.achievement-card .desc {
    font-size: 0.75rem;
    color: #64748b;
}

/* 使用者登入區域 */
.user-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #6366f1;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

#login-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: white;
    color: #333;
    border-radius: 8px;
    font-weight: 600;
}

#login-btn:hover {
    background: #f1f5f9;
}

#user-info {
    display: none;
    align-items: center;
    gap: 12px;
}

/* 可愛的浮動裝飾 */
.floating-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.floating-coin {
    position: absolute;
    font-size: 1.5rem;
    animation: floatAround 15s linear infinite;
    opacity: 0.3;
}

@keyframes floatAround {
    0% {
        transform: translateY(100vh) rotate(0deg);
    }

    100% {
        transform: translateY(-100px) rotate(360deg);
    }
}

.floating-star {
    position: absolute;
    font-size: 1rem;
    animation: twinkle 3s ease-in-out infinite;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.2;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.2);
    }
}

/* 設定面板 */
.settings-panel {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-label {
    font-weight: 600;
}

.toggle-switch {
    width: 50px;
    height: 26px;
    background: #334155;
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-switch.active {
    background: #10b981;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: left 0.3s;
}

.toggle-switch.active::after {
    left: 26px;
}

.language-select {
    padding: 8px 16px;
    background: var(--bg-card-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-main);
}

/* 更可愛的按鈕 */
.btn-cute {
    background: linear-gradient(135deg, #f472b6, #ec4899);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 28px;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.4);
    transition: all 0.3s;
}

.btn-cute:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.5);
}

/* 手機版響應式 - 加強版 */
@media (max-width: 768px) {
    .game-main {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        padding: 10px;
        gap: 10px;
    }

    .panel-left {
        order: 1;
        flex-direction: row;
        padding: 12px;
        gap: 12px;
    }

    .player-card {
        flex: 0 0 auto;
        border-bottom: none;
        border-right: 1px solid var(--border-color);
        padding-bottom: 0;
        padding-right: 16px;
    }

    .player-stats {
        flex: 1;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .stat-bar {
        flex: 1 1 45%;
        min-width: 120px;
    }

    .panel-center {
        order: 2;
        padding: 16px;
    }

    .panel-right {
        order: 3;
        flex-direction: row;
        padding: 12px;
        gap: 12px;
    }

    .finance-panel {
        flex: 1;
    }

    .compound-panel {
        flex: 1;
        min-height: 120px;
    }

    .action-buttons {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }

    .action-btn {
        padding: 12px 8px;
    }

    .action-icon {
        font-size: 1.5rem;
    }

    .action-name {
        font-size: 0.75rem;
    }

    .event-card {
        padding: 20px;
    }

    .event-icon {
        font-size: 2.5rem;
    }

    /* 底部固定行動列 */
    .mobile-action-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(10px);
        padding: 12px;
        border-top: 1px solid var(--border-color);
        display: none;
    }

    @media (max-width: 768px) {
        .mobile-action-bar {
            display: block;
        }

        #next-round-btn {
            display: none;
        }
    }
}

@media (max-width: 480px) {
    .game-header {
        flex-direction: column;
        gap: 8px;
        padding: 8px 12px;
    }

    .header-left,
    .header-right {
        display: none;
    }

    .action-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .tutorial-popup {
        padding: 20px;
    }

    .compound-demo {
        gap: 6px;
    }

    .compound-bar {
        width: 40px;
        font-size: 0.6rem;
    }
}

/* 滑動效果 */
.slide-enter {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    0% {
        transform: translateX(-20px);
        opacity: 0;
    }

    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 彈跳數字 */
.bounce-number {
    animation: bounceNum 0.5s ease;
}

@keyframes bounceNum {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
        color: #fbbf24;
    }
}

/* 閃爍效果 */
.shimmer {
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.2) 50%, transparent 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* 成就解鎖特效 */
.achievement-unlock-effect {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8rem;
    z-index: 2000;
    animation: achievementPop 1s ease forwards;
    pointer-events: none;
}

@keyframes achievementPop {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0;
    }
}