/* ============================================
   ZimLearn - Game Mode Styles
   ============================================ */

/* ============================================
   Level Map
   ============================================ */
.level-map {
    padding: 20px 0;
}

.level-map-header {
    text-align: center;
    margin-bottom: 24px;
}

.level-map-header h2 {
    font-size: 22px;
    font-weight: 800;
}

.level-map-header p {
    font-size: 13px;
    color: var(--text-light);
}

.level-path {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    padding: 0 20px;
}

/* Level connector line */
.level-path::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 4px;
    height: 100%;
    background: var(--border);
    border-radius: 2px;
    transform: translateX(-50%);
    z-index: 0;
}

.level-node {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 320px;
    padding: 8px 0;
}

.level-node:nth-child(odd) {
    flex-direction: row;
}

.level-node:nth-child(even) {
    flex-direction: row-reverse;
}

.level-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    position: relative;
    border: 3px solid transparent;
}

.level-circle.locked {
    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
}

.level-circle.available {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border-color: var(--primary-dark);
    box-shadow: 0 4px 16px rgba(108, 99, 255, 0.4);
    animation: pulse 2s infinite;
}

.level-circle.completed {
    background: linear-gradient(135deg, var(--success), #58D68D);
    color: white;
    border-color: #27AE60;
}

.level-circle:active:not(.locked) {
    transform: scale(0.9);
}

.level-info {
    flex: 1;
}

.level-info .level-label {
    font-size: 14px;
    font-weight: 700;
}

.level-info .level-stars {
    font-size: 16px;
    letter-spacing: 2px;
}

.level-info .level-score {
    font-size: 11px;
    color: var(--text-light);
}

/* ============================================
   Game Question Screen
   ============================================ */
.game-question-screen {
    animation: slideUp 0.4s ease;
}

.game-lives {
    display: flex;
    gap: 4px;
    font-size: 20px;
}

.game-lives .heart {
    transition: all 0.3s;
}

.game-lives .heart.lost {
    opacity: 0.2;
    transform: scale(0.8);
}

.game-streak {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(241, 196, 15, 0.15);
    color: #D4AC0D;
}

.game-streak.active {
    background: rgba(241, 196, 15, 0.25);
    animation: pulse 1s infinite;
}

/* ============================================
   Level Complete Overlay
   ============================================ */
.level-complete {
    text-align: center;
    padding: 32px 20px;
    animation: bounceIn 0.5s ease;
}

.level-complete .stars-display {
    font-size: 48px;
    margin-bottom: 16px;
    letter-spacing: 8px;
}

.level-complete h2 {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 8px;
}

.level-complete .score-text {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.level-complete .xp-earned {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    background: rgba(241, 196, 15, 0.15);
    border-radius: 20px;
    font-size: 18px;
    font-weight: 800;
    color: #D4AC0D;
    margin-bottom: 24px;
}

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

.level-complete .actions .btn {
    flex: 1;
}

/* ============================================
   Badge Earned Popup
   ============================================ */
.badge-earned {
    text-align: center;
    padding: 24px;
    animation: bounceIn 0.5s ease;
}

.badge-earned .badge-big {
    font-size: 64px;
    margin-bottom: 12px;
}

.badge-earned h3 {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 4px;
}

.badge-earned p {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 20px;
}

/* ============================================
   Confetti Animation
   ============================================ */
@keyframes confettiFall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ============================================
   Flashcard Styles
   ============================================ */
.flashcard-container {
    perspective: 1000px;
    margin: 20px 0;
}

.flashcard {
    width: 100%;
    min-height: 200px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
    cursor: pointer;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: 0 4px 20px var(--shadow-md);
    overflow-y: auto;
}

.flashcard-front {
    background: var(--surface);
}

.flashcard-front .question-image img {
    max-height: 200px;
    max-width: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.flashcard-back {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    transform: rotateY(180deg);
}

.flashcard-back .answer-image img {
    max-height: 160px;
    max-width: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.flashcard-front .question-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.flashcard-front .question-text {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 16px;
}

.flashcard-front .tap-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.flashcard-back .answer-label {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.7;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.flashcard-back .answer-text {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.flashcard-back .explanation-text {
    font-size: 14px;
    opacity: 0.85;
    line-height: 1.5;
}
.flashcard-back .ref-toggle {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}
.flashcard-back .ref-content {
    background: rgba(255, 255, 255, 0.15);
    border-left-color: rgba(255, 255, 255, 0.6);
    color: rgba(255, 255, 255, 0.9);
}

.flashcard-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.flashcard-actions .btn {
    flex: 1;
}

.flashcard-counter {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 12px;
}

/* Swipe indicators */
.flashcard-swipe-left {
    animation: swipeLeft 0.4s ease forwards;
}

.flashcard-swipe-right {
    animation: swipeRight 0.4s ease forwards;
}

@keyframes swipeLeft {
    to { transform: translateX(-120%) rotate(-15deg); opacity: 0; }
}

@keyframes swipeRight {
    to { transform: translateX(120%) rotate(15deg); opacity: 0; }
}

/* ============================================
   Subject Selector for Quest
   ============================================ */
.quest-subject-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.quest-subject-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 12px var(--shadow);
    border: 2px solid transparent;
}

.quest-subject-card:active {
    transform: scale(0.95);
}

.quest-subject-card .emoji {
    font-size: 36px;
    margin-bottom: 8px;
}

.quest-subject-card .name {
    font-size: 14px;
    font-weight: 700;
}

.quest-subject-card .progress-text {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
}

.quest-subject-card .mini-stars {
    margin-top: 6px;
    font-size: 12px;
}

/* ============================================
   XP Popup
   ============================================ */
.xp-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 12px 24px;
    background: rgba(241, 196, 15, 0.95);
    color: #333;
    border-radius: 20px;
    font-size: 20px;
    font-weight: 800;
    z-index: 9000;
    animation: xpFlyUp 1s ease forwards;
    pointer-events: none;
}

@keyframes xpFlyUp {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.5); }
    50% { opacity: 1; transform: translate(-50%, -80%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}

/* ============================================
   Game Mode Selection
   ============================================ */
.game-mode-header {
    text-align: center;
    padding: 16px;
    margin-bottom: 8px;
}

.game-mode-header h2 {
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-mode-header p {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 4px;
}

/* ============================================
   Tablet Portrait (768px+)
   ============================================ */
@media (min-width: 768px) {
    .level-node {
        max-width: 420px;
    }

    .level-circle {
        width: 64px;
        height: 64px;
        font-size: 22px;
    }

    .level-info .level-label {
        font-size: 16px;
    }

    .level-info .level-stars {
        font-size: 18px;
    }

    .level-map-header h2 {
        font-size: 26px;
    }

    .level-map-header p {
        font-size: 14px;
    }

    .game-mode-header h2 {
        font-size: 28px;
    }

    .game-mode-header p {
        font-size: 14px;
    }

    .level-complete h2 {
        font-size: 28px;
    }

    .level-complete .stars-display {
        font-size: 56px;
    }
}

/* ============================================
   Tablet Landscape (1024px+)
   ============================================ */
@media (min-width: 1024px) {
    .level-node {
        max-width: 480px;
    }

    .level-circle {
        width: 72px;
        height: 72px;
        font-size: 24px;
    }
}

/* ============================================
   Class Leaderboard
   ============================================ */
.lb-header {
    text-align: center;
    margin-bottom: 16px;
}

.lb-title {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, #FFD700, #FF8C00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Grade selector bar */
.lb-grade-bar {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 10px 0;
    background: linear-gradient(135deg, rgba(108,99,255,0.06), rgba(168,85,247,0.06));
    border-radius: 14px;
}

.lb-grade-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2.5px solid var(--border);
    background: var(--card);
    font-size: 18px;
    font-weight: 800;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
}

.lb-grade-btn.lb-grade-active {
    background: linear-gradient(135deg, #6C63FF, #A855F7);
    color: white;
    border-color: transparent;
    box-shadow: 0 3px 12px rgba(108, 99, 255, 0.4);
    transform: scale(1.1);
}

/* Scrollable tabs */
.lb-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0 12px;
    scrollbar-width: none;
}

.lb-tabs::-webkit-scrollbar {
    display: none;
}

.lb-tab {
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: var(--card);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.lb-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.3);
}

/* Podium */
.lb-podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
    margin: 8px 0 20px;
    padding: 16px 0 0;
}

.lb-podium-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 110px;
    position: relative;
}

.lb-crown {
    font-size: 24px;
    animation: crownBounce 2s ease-in-out infinite;
    margin-bottom: 4px;
}

@keyframes crownBounce {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-4px) rotate(-5deg); }
    75% { transform: translateY(-4px) rotate(5deg); }
}

.lb-podium-rank {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 12px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.lb-podium-name {
    font-size: 12px;
    font-weight: 700;
    margin-top: 6px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

.lb-podium-score {
    font-size: 14px;
    font-weight: 800;
    color: var(--primary);
    margin: 2px 0 6px;
}

.lb-podium-bar {
    width: 100%;
    border-radius: 8px 8px 0 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 8px;
    position: relative;
}

.lb-podium-medal {
    font-size: 20px;
}

/* List rows */
.lb-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lb-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: all 0.3s;
}

.lb-rank {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    background: var(--bg);
    color: var(--text-light);
    flex-shrink: 0;
}

.lb-info {
    flex: 1;
    min-width: 0;
}

.lb-name {
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-score {
    font-size: 12px;
    color: var(--text-light);
}

/* Highlight own row */
.lb-me {
    border: 2px solid var(--primary);
    background: rgba(108, 99, 255, 0.05);
}

/* Movement effects */
.lb-rise {
    box-shadow: 0 0 12px rgba(46, 204, 113, 0.25);
}

.lb-fall {
    box-shadow: 0 0 12px rgba(231, 76, 60, 0.2);
}

/* Delta badges */
.lb-delta {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    flex-shrink: 0;
}

.lb-delta-up {
    color: #27AE60;
    background: rgba(46, 204, 113, 0.12);
}

.lb-delta-down {
    color: #E74C3C;
    background: rgba(231, 76, 60, 0.1);
}

/* Tablet+ */
@media (min-width: 768px) {
    .lb-title {
        font-size: 26px;
    }

    .lb-podium {
        gap: 16px;
    }

    .lb-podium-item {
        max-width: 140px;
    }

    .lb-tab {
        padding: 8px 18px;
        font-size: 13px;
    }

    .lb-row {
        padding: 12px 16px;
    }
}
