/* Princess Learning Adventure - Styles */

/* CSS Variables for Princess Theme */
:root {
    --princess-pink: #ff69b4;
    --princess-pink-light: #ffb6c1;
    --princess-purple: #9b59b6;
    --princess-purple-light: #d4a5e8;
    --princess-gold: #ffd700;
    --princess-white: #fff5f8;
    --princess-cream: #fffaf0;
    --shadow-color: rgba(155, 89, 182, 0.3);
    --sparkle-color: #fff9c4;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', 'Comic Sans MS', 'Arial Rounded MT Bold', sans-serif;
    background: linear-gradient(135deg, var(--princess-pink-light) 0%, var(--princess-purple-light) 50%, var(--princess-pink-light) 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    touch-action: manipulation;
}

/* Sparkle Background Effect */
.sparkles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.sparkle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--sparkle-color);
    border-radius: 50%;
    animation: sparkle 2s ease-in-out infinite;
    box-shadow: 0 0 10px var(--princess-gold), 0 0 20px var(--princess-gold);
}

@keyframes sparkle {
    0%, 100% { opacity: 0; transform: scale(0); }
    50% { opacity: 1; transform: scale(1); }
}

/* Screen Management */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 500px;
    height: 100vh;
    max-height: 100vh;
    padding: 20px;
    position: relative;
    z-index: 1;
    overflow-y: auto;
}

.screen.active {
    display: flex;
}

/* Main Menu Styles */
.castle-header {
    text-align: center;
    padding: 20px 0;
}

.crown {
    font-size: 60px;
    animation: bounce 2s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px var(--shadow-color));
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.title {
    font-size: 28px;
    color: var(--princess-purple);
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.8);
    margin: 10px 0;
    line-height: 1.2;
}

.subtitle {
    font-size: 16px;
    color: var(--princess-pink);
    font-style: italic;
}

/* Menu Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    padding: 20px;
}

.menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 25px 30px;
    border: none;
    border-radius: 25px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px var(--shadow-color);
    position: relative;
    overflow: hidden;
    min-height: 80px;
}

.menu-btn:active {
    transform: scale(0.95);
}

.alphabet-btn {
    background: linear-gradient(135deg, var(--princess-pink) 0%, var(--princess-purple) 100%);
    color: white;
}

.numbers-btn {
    background: linear-gradient(135deg, var(--princess-purple) 0%, var(--princess-pink) 100%);
    color: white;
}

.quiz-btn {
    background: linear-gradient(135deg, #50c878 0%, #3cb371 100%);
    color: white;
}

.btn-icon {
    font-size: 36px;
}

.btn-text {
    flex: 1;
    text-align: left;
}

.btn-sparkle {
    font-size: 24px;
    animation: twinkle 1.5s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.5; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

.princess-character {
    font-size: 80px;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 10px 20px var(--shadow-color));
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-15px) rotate(5deg); }
}

/* Game Header */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 0;
    gap: 10px;
}

.back-btn {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--princess-gold) 0%, #ffc107 100%);
    font-size: 30px;
    cursor: pointer;
    box-shadow: 0 4px 10px var(--shadow-color);
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-btn:active {
    transform: scale(0.9);
}

.game-title {
    font-size: 22px;
    color: var(--princess-purple);
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
    flex: 1;
    text-align: center;
}

.progress-display {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--princess-pink) 0%, var(--princess-purple) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    box-shadow: 0 4px 10px var(--shadow-color);
}

/* Learning Area */
.learning-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 20px;
}

.main-display {
    background: var(--princess-white);
    border-radius: 30px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 10px 30px var(--shadow-color), inset 0 2px 10px rgba(255, 255, 255, 0.5);
    border: 4px solid var(--princess-gold);
    width: 100%;
    max-width: 320px;
    transition: transform 0.3s;
}

.main-display:active {
    transform: scale(0.98);
}

.big-character {
    font-size: 120px;
    font-weight: bold;
    color: var(--princess-purple);
    text-shadow: 3px 3px 6px var(--shadow-color);
    line-height: 1;
    animation: pop-in 0.5s ease-out;
}

@keyframes pop-in {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.character-word {
    font-size: 32px;
    color: var(--princess-pink);
    margin-top: 10px;
    font-weight: bold;
}

.character-emoji {
    font-size: 60px;
    margin-top: 10px;
    animation: wiggle 2s ease-in-out infinite;
}

@keyframes wiggle {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

/* Counting Dots for Numbers */
.counting-dots {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    max-width: 250px;
}

.counting-dot {
    width: 35px;
    height: 35px;
    background: linear-gradient(135deg, var(--princess-pink) 0%, var(--princess-purple) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    animation: dot-pop 0.3s ease-out backwards;
    box-shadow: 0 3px 8px var(--shadow-color);
}

/* Speak Button */
.speak-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 40px;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--princess-gold) 0%, #ffc107 100%);
    color: var(--princess-purple);
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 6px 15px var(--shadow-color);
    transition: all 0.2s;
    min-height: 65px;
}

.speak-btn:active {
    transform: scale(0.95);
    box-shadow: 0 3px 8px var(--shadow-color);
}

.speak-icon {
    font-size: 28px;
}

.speak-btn.speaking {
    animation: pulse 0.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Navigation Area */
.navigation-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    width: 100%;
    padding: 15px 0;
}

.nav-btn {
    width: 70px;
    height: 70px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--princess-pink) 0%, var(--princess-purple) 100%);
    color: white;
    font-size: 30px;
    cursor: pointer;
    box-shadow: 0 5px 15px var(--shadow-color);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:active {
    transform: scale(0.9);
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Letter/Number Grid */
.letter-grid, .number-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: 220px;
    max-height: 150px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 15px;
}

.grid-item {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: var(--princess-cream);
    color: var(--princess-purple);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 5px var(--shadow-color);
}

.grid-item:active, .grid-item.active {
    background: linear-gradient(135deg, var(--princess-pink) 0%, var(--princess-purple) 100%);
    color: white;
    transform: scale(1.1);
}

.grid-item.completed {
    background: linear-gradient(135deg, var(--princess-gold) 0%, #ffc107 100%);
    color: var(--princess-purple);
}

/* Celebration */
.celebration {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: linear-gradient(135deg, var(--princess-gold) 0%, #ffc107 100%);
    color: var(--princess-purple);
    padding: 30px 50px;
    border-radius: 25px;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 10px 40px var(--shadow-color);
    z-index: 100;
    opacity: 0;
    transition: all 0.5s ease;
}

.celebration.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 380px) {
    .title {
        font-size: 24px;
    }

    .menu-btn {
        padding: 20px 25px;
        font-size: 20px;
    }

    .btn-icon {
        font-size: 30px;
    }

    .big-character {
        font-size: 90px;
    }

    .character-word {
        font-size: 26px;
    }

    .character-emoji {
        font-size: 50px;
    }

    .nav-btn {
        width: 60px;
        height: 60px;
        font-size: 26px;
    }
}

@media (min-height: 800px) {
    .main-display {
        padding: 40px;
    }

    .big-character {
        font-size: 140px;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .screen {
        padding: 10px;
    }

    .castle-header {
        padding: 5px 0;
    }

    .crown {
        font-size: 40px;
    }

    .title {
        font-size: 20px;
        margin: 5px 0;
    }

    .menu-buttons {
        flex-direction: row;
        padding: 10px;
    }

    .menu-btn {
        padding: 15px 20px;
        min-height: 60px;
    }

    .princess-character {
        font-size: 50px;
    }

    .main-display {
        padding: 15px;
    }

    .big-character {
        font-size: 60px;
    }

    .character-word {
        font-size: 20px;
    }

    .character-emoji {
        font-size: 35px;
    }

    .speak-btn {
        padding: 12px 25px;
        font-size: 18px;
        min-height: 50px;
    }
}

/* Touch feedback enhancement */
@media (hover: none) {
    .menu-btn:active,
    .back-btn:active,
    .speak-btn:active,
    .nav-btn:active,
    .grid-item:active {
        opacity: 0.8;
    }
}

/* Prevent text selection on buttons */
button {
    -webkit-user-select: none;
    user-select: none;
}

/* Safe area insets for notched phones */
@supports (padding: max(0px)) {
    .screen {
        padding-top: max(20px, env(safe-area-inset-top));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
}

/* ==========================================
   Quiz Mode Styles
   ========================================== */

.score-display {
    min-width: 80px;
    height: 50px;
    border-radius: 25px;
    background: linear-gradient(135deg, #50c878 0%, #3cb371 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    box-shadow: 0 4px 10px var(--shadow-color);
    padding: 0 15px;
}

.quiz-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 25px;
    padding: 20px 0;
}

.quiz-prompt {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.quiz-instruction {
    font-size: 24px;
    color: var(--princess-purple);
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.replay-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px 40px;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--princess-gold) 0%, #ffc107 100%);
    color: var(--princess-purple);
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 8px 20px var(--shadow-color);
    transition: all 0.2s;
    min-height: 70px;
}

.replay-btn:active {
    transform: scale(0.95);
}

.replay-btn.playing {
    animation: pulse 0.5s ease-in-out infinite;
}

/* Quiz Choices Grid */
.quiz-choices {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    width: 100%;
    max-width: 350px;
    padding: 10px;
}

.quiz-choice {
    padding: 25px 20px;
    border: 4px solid var(--princess-purple-light);
    border-radius: 20px;
    background: var(--princess-white);
    color: var(--princess-purple);
    font-size: 48px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 5px 15px var(--shadow-color);
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quiz-choice:active {
    transform: scale(0.95);
}

.quiz-choice.correct {
    background: linear-gradient(135deg, #50c878 0%, #3cb371 100%);
    border-color: #2e8b57;
    color: white;
    animation: correct-pulse 0.5s ease-out;
}

.quiz-choice.incorrect {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    border-color: #cc4444;
    color: white;
    animation: shake 0.5s ease-out;
}

.quiz-choice:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

@keyframes correct-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}

/* Quiz Feedback */
.quiz-feedback {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: bold;
    text-align: center;
    padding: 10px 20px;
    border-radius: 15px;
    transition: all 0.3s;
}

.quiz-feedback.correct {
    color: #2e8b57;
    background: rgba(80, 200, 120, 0.2);
}

.quiz-feedback.incorrect {
    color: #cc4444;
    background: rgba(255, 107, 107, 0.2);
}

/* Menu button adjustments for 4 buttons */
@media (max-height: 700px) {
    .menu-buttons {
        gap: 12px;
        padding: 10px;
    }

    .menu-btn {
        padding: 18px 25px;
        min-height: 65px;
        font-size: 20px;
    }

    .btn-icon {
        font-size: 28px;
    }

    .crown {
        font-size: 45px;
    }

    .title {
        font-size: 24px;
    }

    .princess-character {
        font-size: 60px;
    }
}

/* Quiz responsive adjustments */
@media (max-width: 380px) {
    .quiz-choice {
        font-size: 36px;
        padding: 20px 15px;
        min-height: 80px;
    }

    .quiz-instruction {
        font-size: 20px;
    }

    .replay-btn {
        padding: 15px 30px;
        font-size: 20px;
        min-height: 60px;
    }
}

@media (max-height: 600px) {
    .quiz-area {
        gap: 15px;
        padding: 10px 0;
    }

    .quiz-choice {
        padding: 15px;
        min-height: 70px;
        font-size: 32px;
    }

    .replay-btn {
        padding: 12px 25px;
        font-size: 18px;
        min-height: 50px;
    }
}
