/* ============================================
   Nauka Liter i Cyfr - Style CSS
   Motyw: Przyjazny dla Dzieci (Kid Friendly)
   ============================================ */

/* === CSS Variables === */
:root {
    /* Kid Friendly Palette */
    --color-primary: #FF6B6B;      /* Pastel Red */
    --color-secondary: #4ECDC4;    /* Pastel Teal */
    --color-accent: #FFE66D;       /* Pastel Yellow */
    --color-success: #95E1D3;      /* Mint Green */
    --color-text: #2C3E50;         /* Dark Blue-Grey */
    --color-bg: #F7F9FC;           /* Very Light Blue Grey */
    --color-surface: #FFFFFF;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #FF6B6B 0%, #FF8E8E 100%);
    --gradient-secondary: linear-gradient(135deg, #4ECDC4 0%, #6DDBD1 100%);
    --gradient-accent: linear-gradient(135deg, #FFE66D 0%, #FFED91 100%);
    
    /* Typography */
    --font-base: 'Fredoka', 'Comic Sans MS', sans-serif;
    --font-handwriting: "Schoolbell", cursive;
    
    /* Spacing */
    --space-xs: 10px;
    --space-sm: 15px;
    --space-md: 20px;
    --space-lg: 30px;
    
    /* Border Radius */
    --radius-sm: 15px;
    --radius-md: 25px;
    --radius-lg: 35px;
    --radius-round: 50px;

    /* Shadows */
    --shadow-sm: 0 4px 0 rgba(0,0,0,0.1);
    --shadow-md: 0 6px 0 rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 0 rgba(0,0,0,0.1);
    --shadow-hover: 0 10px 20px rgba(0,0,0,0.15);
}

/* === Reset & Base === */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-base);
    background: var(--color-bg);
    background-image: radial-gradient(#E0E7EA 15%, transparent 16%), radial-gradient(#E0E7EA 15%, transparent 16%);
    background-size: 60px 60px;
    background-position: 0 0, 30px 30px;
    color: var(--color-text);
    min-height: 100vh;
    overflow: hidden;
    touch-action: manipulation;
}

.handwriting {
    font-family: var(--font-handwriting);
}

/* === Layout === */
.app-container {
    display: none;
    width: 100%;
    height: 100vh;
    flex-direction: column;
    max-width: 1400px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    box-shadow: 0 0 50px rgba(0,0,0,0.05);
}

@media (min-width: 801px) {
    .app-container {
        display: flex;
    }
}

/* === Mobile Warning === */
.phone-warning {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-lg);
    text-align: center;
    background: var(--md-surface);
}

@media (min-width: 801px) {
    .phone-warning {
        display: none;
    }
}

.phone-warning h1 {
    font-size: 28px;
    margin-bottom: var(--space-md);
    color: var(--md-primary);
}

.phone-warning p {
    font-size: 16px;
    color: var(--md-outline);
    max-width: 400px;
    line-height: 1.6;
}

/* === Header === */
.header {
    background: var(--color-surface);
    padding: var(--space-md) var(--space-lg);
    border-bottom: 3px solid #E0E0E0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-md);
    z-index: 10;
}

.header h1 {
    margin: 0;
    font-size: 32px;
    color: var(--color-primary);
    font-weight: 700;
    text-shadow: 2px 2px 0px rgba(0,0,0,0.05);
    letter-spacing: 1px;
}

.header-controls {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.btn-auto-read {
    padding: 12px 24px;
    background: var(--color-surface);
    color: var(--color-text);
    border: 2px solid #E0E0E0;
    border-radius: var(--radius-round);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.btn-auto-read.active {
    background: var(--gradient-secondary);
    color: white;
    border-color: transparent;
    transform: translateY(2px);
    box-shadow: none;
}

.btn-auto-read:hover:not(.active) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* === Daily Goal === */
.daily-goal {
    font-size: 16px;
    color: var(--color-text);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: #FFF3E0;
    padding: 8px 16px;
    border-radius: var(--radius-round);
    border: 2px solid #FFE0B2;
}

.goal-progress {
    width: 150px;
    height: 12px;
    background: #FFE0B2;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #FFCC80;
}

.goal-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #FF9800, #FFC107);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Content Area === */
.content {
    flex: 1;
    overflow: hidden;
    display: flex;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: flex;
}

/* === Letter Selection Screen === */
#letterSelection {
    padding: var(--space-lg);
    flex-direction: column;
    overflow-y: auto;
    background: transparent;
    gap: 30px;
}

.mode-selector {
    display: flex;
    gap: 12px;
    justify-content: center;
    max-width: 1200px; /* Increased width to fit all buttons */
    margin: 0 auto 25px auto;
    flex-wrap: wrap;
}

.case-selector {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
    max-width: 600px;
    margin: 0 auto;
}

.case-btn {
    padding: 15px 30px;
    font-size: 18px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-round);
    cursor: pointer;
    background: white;
    color: var(--color-text);
    transition: all 0.2s cubic-bezier(0.2, 0, 0.38, 0.9);
    flex: 1;
    min-width: 150px;
    box-shadow: var(--shadow-sm);
    border: 2px solid #E0E0E0;
}

.case-btn.active {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
    transform: translateY(2px);
    box-shadow: none;
}

.case-btn:hover:not(.active) {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.letter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
    max-width: 1000px;
    margin: 0 auto;
    background: rgba(255,255,255,0.6);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 2px solid rgba(255,255,255,0.8);
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}

.letter-btn {
    aspect-ratio: 1;
    min-height: 80px;
    font-size: 36px;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--color-text);
    background: white;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.letter-btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: var(--color-secondary);
    opacity: 0.5;
}

.letter-btn:hover {
    transform: scale(1.1) rotate(3deg);
    box-shadow: var(--shadow-hover);
    z-index: 1;
}

.letter-btn:active {
    transform: scale(0.95);
}

/* === Quiz Screen === */
#quizScreen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    background: var(--color-bg);
    /* Fun background pattern for quiz */
    background-image: radial-gradient(circle at 10% 20%, rgba(255, 107, 107, 0.1) 0%, transparent 20%),
                      radial-gradient(circle at 90% 80%, rgba(78, 205, 196, 0.1) 0%, transparent 20%);
}

#quizScreen.active {
    display: flex;
}

.quiz-container {
    width: 100%;
    max-width: 900px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.1);
    border: 6px solid var(--color-secondary);
    display: flex;
    flex-direction: column;
    gap: 30px;
    position: relative;
}

.quiz-container::before {
    content: '❓';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 60px;
    background: white;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    border: 4px solid var(--color-secondary);
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.difficulty-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #F5F5F5;
    padding: 5px 15px;
    border-radius: var(--radius-round);
}

.difficulty-controls span {
    font-weight: 600;
    color: var(--color-text);
    font-size: 14px;
}

.difficulty-buttons {
    display: flex;
    gap: 5px;
}

.diff-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #E0E0E0;
    background: white;
    font-weight: 700;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.diff-btn:hover {
    transform: scale(1.1);
    border-color: var(--color-secondary);
}

.diff-btn.active {
    background: var(--color-secondary);
    color: white;
    border-color: var(--color-secondary);
    transform: scale(1.1);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.quiz-score {
    font-size: 28px;
    font-weight: 700;
    color: #E65100;
    background: #FFF3E0;
    padding: 12px 24px;
    border-radius: var(--radius-round);
    border: 3px solid #FFE0B2;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 10px;
}

.quiz-score::before {
    content: '⭐';
}

.quiz-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.question-container {
    background: #E3F2FD;
    padding: 15px 30px;
    border-radius: var(--radius-round);
    border: 3px solid #BBDEFB;
    box-shadow: var(--shadow-sm);
}

#quizQuestion {
    font-size: 42px;
    color: #1565C0;
    margin: 0;
    text-align: center;
    font-weight: 700;
    text-shadow: 2px 2px 0 rgba(255,255,255,0.5);
}

#quizReplayBtn {
    background: var(--color-primary);
    color: white;
    border: none;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

#quizReplayBtn:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: var(--shadow-md);
}

.quiz-options {
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    padding: 10px;
}

.quiz-option-btn {
    width: 140px;
    height: 140px;
    font-size: 72px;
    font-weight: 700;
    border: none;
    border-radius: 25px;
    background: white;
    color: var(--color-text);
    box-shadow: 0 10px 0 #BDBDBD, 0 10px 20px rgba(0,0,0,0.15);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 3px solid #E0E0E0;
    font-family: var(--font-base);
    position: relative;
    overflow: hidden;
}

.quiz-option-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: linear-gradient(180deg, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0) 100%);
    opacity: 0.3;
}

.quiz-option-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 0 #9E9E9E, 0 20px 30px rgba(0,0,0,0.2);
    z-index: 1;
    border-color: var(--color-secondary);
}

.quiz-option-btn:active {
    transform: translateY(5px);
    box-shadow: 0 5px 0 #BDBDBD, 0 5px 10px rgba(0,0,0,0.1);
}

.quiz-option-btn.correct {
    background: var(--color-success);
    color: #004D40;
    border-color: #004D40;
    box-shadow: 0 10px 0 #4DB6AC, 0 10px 20px rgba(0,0,0,0.1);
    transform: scale(1.1);
}

.quiz-option-btn.wrong {
    background: #FFEBEE;
    color: #D32F2F;
    border-color: #D32F2F;
    box-shadow: 0 10px 0 #EF9A9A, 0 10px 20px rgba(0,0,0,0.1);
}

.quiz-mode-btn {
    background: linear-gradient(135deg, #9C27B0 0%, #E040FB 100%);
    color: white;
    border: none;
}

.quiz-mode-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(156, 39, 176, 0.3);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* === Tracing Screen === */
#tracingScreen {
    flex-direction: row;
    gap: var(--space-lg);
    padding: var(--space-lg);
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.sidebar {
    width: 300px;
    min-width: 300px;
    background: white;
    border-radius: var(--radius-lg);
    border: none;
    padding: var(--space-lg);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    box-shadow: var(--shadow-lg);
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    min-width: 0;
}

.letter-info {
    background: #E3F2FD;
    border-radius: var(--radius-md);
    border: 2px solid #BBDEFB;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.emoji-display {
    font-size: 80px;
    line-height: 1;
    min-height: 80px;
    animation: bounce 2s infinite;
    filter: drop-shadow(0 4px 0 rgba(0,0,0,0.1));
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.letter-display {
    font-family: var(--font-handwriting);
    font-size: 120px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1;
    text-shadow: 3px 3px 0 rgba(0,0,0,0.1);
}

.listen-btn {
    padding: 15px 24px;
    font-size: 18px;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-round);
    cursor: pointer;
    background: var(--gradient-accent);
    color: #5D4037;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s cubic-bezier(0.2, 0, 0.38, 0.9);
    touch-action: manipulation;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.listen-btn:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.listen-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* === Progress Info === */
.progress-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    width: 100%;
    background: #F3E5F5;
    padding: 15px;
    border-radius: var(--radius-md);
    border: 2px solid #E1BEE7;
}

.stars-display {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    padding: var(--space-sm);
    background: white;
    border-radius: var(--radius-sm);
    color: #FFB300;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.coverage-display {
    font-size: 16px;
    font-weight: 600;
    padding: var(--space-sm);
    background: white;
    border-radius: var(--radius-sm);
    text-align: center;
    color: var(--color-text);
}

.coverage-bar {
    width: 100%;
    height: 12px;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #E1BEE7;
}

.coverage-bar-fill {
    height: 100%;
    background: var(--gradient-secondary);
    transition: width 0.2s ease;
}

/* === Control Buttons === */
.tracing-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.tracing-controls .btn-next {
    grid-column: 1 / -1;
}

.control-btn {
    padding: 15px 24px;
    font-size: 16px;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-round);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s cubic-bezier(0.2, 0, 0.38, 0.9);
    touch-action: manipulation;
    width: 100%;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.control-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-back {
    background: white;
    color: var(--color-text);
    border: 2px solid #E0E0E0;
}

.btn-clear {
    background: #FFEBEE;
    color: #D32F2F;
    border: 2px solid #FFCDD2;
}

.btn-next {
    background: var(--gradient-primary);
    color: white;
    font-size: 20px;
    padding: 20px;
}

/* === Canvas === */
.canvas-container {
    flex: 1;
    background: #FFFFFF;
    border: 4px solid var(--color-text);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

#tracingCanvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
    background: white;
    border-radius: var(--radius-sm);
    /* Dot pattern background for canvas */
    background-image: radial-gradient(#E0E0E0 10%, transparent 11%);
}

/* === Success Message === */
.success-message {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(150px) scale(0.8);
    background: var(--gradient-success);
    color: #004D40;
    padding: 20px 40px;
    border-radius: var(--radius-round);
    font-size: 24px;
    font-weight: 700;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 100;
    pointer-events: none;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-align: center;
    opacity: 0;
    border: 4px solid white;
}

.success-message.show {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
}

/* === Modal === */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.modal-backdrop.show {
    display: block;
}

.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--md-surface);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 4px solid var(--color-secondary);
}

.modal.show {
    display: block;
    animation: modal-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-pop {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #E0E0E0;
    padding-bottom: 10px;
}

.modal-header h2 {
    margin: 0;
    font-size: 28px;
    color: var(--color-primary);
    font-weight: 700;
}

.modal-close {
    background: #FFEBEE;
    border: none;
    font-size: 24px;
    color: var(--color-primary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--color-primary);
    color: white;
    transform: rotate(90deg);
}

/* === Responsive === */
@media (max-width: 800px) {
    .header {
        padding: 12px 16px;
    }

    .header h1 {
        font-size: 24px;
    }

    #tracingScreen {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: 0;
        max-height: 40vh;
    }

    .letter-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: var(--space-xs);
        padding: var(--space-md);
    }

    .letter-btn {
        min-height: 70px;
        font-size: 20px;
    }
}

/* === Confetti Animation === */
.confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 200;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    opacity: 0;
    animation: confetti-fall 3s ease-out forwards;
}

.confetti.star {
    font-size: 24px;
    width: auto;
    height: auto;
}

@keyframes confetti-fall {
    0% {
        opacity: 1;
        transform: translateY(-20px) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg);
    }
}

@keyframes star-bounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
}

.star-burst {
    animation: star-bounce 0.6s ease-in-out;
}

@media (orientation: landscape) and (max-height: 600px) {
    .header {
        padding: 8px 16px;
    }

    .header h1 {
        font-size: 20px;
    }
    
    #letterSelection {
        padding: var(--space-md);
        gap: var(--space-md);
    }

    #tracingScreen {
        padding: 12px;
        gap: 12px;
    }

    .sidebar {
        padding: 12px;
    }
}

/* === Category Selection === */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    padding: 10px;
    width: 100%;
    max-height: 60vh;
    overflow-y: auto;
}

.category-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    border: 3px solid #eee;
    border-radius: 20px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 0 #ddd;
    height: 120px;
    font-family: var(--font-base);
}

.category-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

.category-btn:hover {
    border-color: var(--color-secondary);
    background: #f9ffff;
}

.category-emoji {
    font-size: 3rem;
    margin-bottom: 10px;
    line-height: 1;
}

.category-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--color-text);
    text-align: center;
}

.random-category-btn {
    grid-column: 1 / -1;
    background: var(--gradient-accent);
    border-color: #F0D040;
    box-shadow: 0 4px 0 #E0C030;
    flex-direction: row;
    height: auto;
    padding: 15px;
    gap: 15px;
}

/* === Memory Game === */
#memoryScreen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    background: var(--color-bg);
    background-image: radial-gradient(circle at 15% 20%, rgba(0, 188, 212, 0.15) 0%, transparent 35%),
                      radial-gradient(circle at 80% 70%, rgba(255, 230, 109, 0.25) 0%, transparent 45%);
}

#memoryScreen.active {
    display: flex;
}

#memoryScreen .quiz-container {
    max-width: 900px;
    border-color: var(--color-primary);
    padding: 50px;
    min-height: 520px;
    justify-content: flex-start;
}

#memoryScreen .quiz-container::before {
    content: '🧠';
    top: -45px;
    background: var(--color-bg);
    border-color: var(--color-primary);
}

.memory-board {
    display: grid;
    gap: 20px;
    width: 100%;
    margin: 0 auto;
    padding: 10px 0 20px;
    perspective: 1000px;
    justify-items: center;
}

.memory-card {
    aspect-ratio: 1;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    width: 100%;
    max-width: 150px;
}

.memory-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border-radius: 15px;
}

.memory-card.flipped .memory-card-inner {
    transform: rotateY(180deg);
}

.memory-card-front, .memory-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 15px;
    font-weight: bold;
    user-select: none;
    padding: 10px;
    line-height: 1;
}

.memory-card-front {
    background: linear-gradient(135deg, #FF6B6B 0%, #FF8E8E 100%);
    color: white;
    font-size: clamp(2.4rem, 5vw, 3.2rem);
    line-height: 1;
    border: 4px solid white;
}

.memory-card-back {
    background: white;
    color: var(--color-text);
    transform: rotateY(180deg);
    font-size: clamp(3rem, 6vw, 3.8rem);
    border: 4px solid var(--color-secondary);
}

.memory-card-back--text {
    font-size: clamp(3.2rem, 6.5vw, 4.2rem);
}

.memory-card-back--emoji {
    font-size: clamp(4rem, 7vw, 5rem);
}

.memory-card.matched .memory-card-inner {
    box-shadow: 0 0 20px var(--color-success) !important;
    border-color: var(--color-success) !important;
}

.memory-card.matched .memory-card-back {
    border-color: var(--color-success) !important;
    background: #e8f5e9 !important;
    transform: rotateY(180deg) scale(1.05);
    transition: all 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px) rotate(-5deg); }
    40% { transform: translateX(10px) rotate(5deg); }
    60% { transform: translateX(-10px) rotate(-5deg); }
    80% { transform: translateX(10px) rotate(5deg); }
}

.memory-card.shake {
    animation: shake 0.5s ease-in-out;
    /* transition: none; - Removed to prevent conflict with flip */
}

.memory-win-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.memory-win-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.memory-win-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
    text-align: center;
    border: 4px solid var(--color-secondary);
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 360px;
}

.memory-win-card h2 {
    font-size: 2rem;
    margin: 0;
}

.memory-win-card p {
    margin: 0;
    font-size: 1.2rem;
    color: var(--color-text);
}

.memory-win-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* === Sound Hunt === */
#soundHuntScreen {
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    background: var(--color-bg);
    background-image: radial-gradient(circle at 20% 20%, rgba(255, 152, 0, 0.15) 0%, transparent 35%),
                      radial-gradient(circle at 80% 70%, rgba(0, 188, 212, 0.2) 0%, transparent 45%);
    position: relative;
}

#soundHuntScreen.active {
    display: flex;
}

.sound-hunt-container {
    width: 100%;
    max-width: 920px;
    background: rgba(255,255,255,0.96);
    border-radius: var(--radius-lg);
    border: 6px solid #FFB74D;
    padding: 20px 30px 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.12);
    position: relative;
}

/* Icon removed as requested */

.sound-hunt-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    .sound-hunt-header {
        grid-template-columns: 1fr 1fr;
        grid-template-areas: 
            "back stats"
            "replay replay";
        gap: 15px;
    }
    
    .sound-hunt-header .btn-back {
        grid-area: back;
        justify-self: start;
    }
    
    .sound-hunt-stats {
        grid-area: stats;
        justify-self: end;
        align-items: flex-end;
    }
    
    #soundHuntReplayBtn {
        grid-area: replay;
        width: 100%;
        margin-top: 5px;
    }
}

.sound-hunt-stats {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-weight: 700;
    color: var(--color-text);
    background: #FFF3E0;
    padding: 8px 20px;
    border-radius: var(--radius-md);
    border: 2px solid #FFE0B2;
}

.sound-hunt-stats span:last-child {
    font-size: 1.2rem;
}

.sound-hunt-instructions {
    background: #FFF8E1;
    border: 3px dashed #FFCC80;
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 30px;
}

.sound-hunt-instructions p {
    margin: 0 0 12px 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: #F57C00;
}

.sound-hunt-progress {
    width: 100%;
    height: 12px;
    background: rgba(255, 167, 38, 0.2);
    border-radius: 999px;
    overflow: hidden;
}

.sound-hunt-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(135deg, #FF9800 0%, #FFC107 100%);
    transition: width 0.4s ease;
}

.sound-hunt-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 18px;
}

.sound-hunt-option {
    border: none;
    border-radius: var(--radius-md);
    padding: 20px;
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 700;
    background: white;
    border: 3px solid #FFCC80;
    color: var(--color-text);
    cursor: pointer;
    box-shadow: 0 8px 0 rgba(255, 167, 38, 0.2);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.sound-hunt-option:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 15px rgba(0,0,0,0.08);
}

.sound-hunt-option.correct {
    border-color: var(--color-success);
    background: #E8F5E9;
    color: var(--color-text);
    box-shadow: 0 8px 15px rgba(149, 225, 211, 0.5);
}

.sound-hunt-option.wrong {
    border-color: #FF6B6B;
    background: #FFEBEE;
    animation: shake 0.45s ease;
}

.sound-hunt-finale {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(6px);
}

.sound-hunt-finale.active {
    pointer-events: all;
    opacity: 1;
}

.sound-hunt-finale-card {
    background: linear-gradient(135deg, #FFF3E0 0%, #FFFFFF 100%);
    border: 4px solid #FFB74D;
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
    max-width: 420px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sound-hunt-finale-card h2 {
    margin: 0;
    font-size: 2.4rem;
}

.sound-hunt-finale-card p {
    margin: 0;
    font-size: 1.2rem;
}

.sound-hunt-finale-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* === Game Menu Styling (Shared) === */
.game-menu-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    background: white;
    padding: 35px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 4px solid #E0E0E0;
    transition: all 0.3s ease;
}

/* Specific border colors for games */
#quizControls { border-color: #E040FB; }
#memoryControls { border-color: #4DD0E1; }
#soundHuntControls { border-color: #FFCC80; }

.game-menu-header {
    text-align: center;
    margin-bottom: 10px;
    padding-bottom: 20px;
    border-bottom: 2px dashed #EEEEEE;
}

.game-menu-header h2 {
    font-size: 2.2rem;
    margin: 0 0 10px 0;
    color: var(--color-text);
}

#quizControls h2 { color: #9C27B0; }
#memoryControls h2 { color: #00BCD4; }
#soundHuntControls h2 { color: #F57C00; }

.game-menu-header p {
    color: var(--color-text-light);
    font-size: 1.2rem;
    margin: 0;
}

.game-menu-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.control-group label {
    font-weight: 700;
    color: var(--color-text);
    font-size: 1.1rem;
    margin-left: 5px;
}

.game-start-btn {
    width: 100%;
    font-size: 24px;
    margin-top: 15px;
    border: none;
    color: white;
    padding: 18px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.game-start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

/* Sound Hunt - Bubble Mechanics */
.sound-hunt-game-area {
    position: relative;
    width: 100%;
    height: 600px; /* Increased height */
    background: linear-gradient(180deg, #E0F7FA 0%, #B2EBF2 100%);
    border-radius: var(--radius-lg);
    border: 4px solid #4DD0E1;
    overflow: hidden;
    box-shadow: inset 0 0 30px rgba(0,188,212, 0.2);
    margin-top: 20px;
}

.hunt-bubble {
    position: absolute;
    width: 80px; /* Slightly larger bubbles */
    height: 80px;
    border-radius: 50%;
    background: white;
    border: 3px solid #fff;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1), inset -5px -5px 10px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--color-text);
    cursor: pointer;
    transition: transform 0.2s, background 0.2s, opacity 0.3s;
    animation: floatBubble 3s ease-in-out infinite alternate;
    user-select: none;
    z-index: 1;
}

.hunt-bubble:hover {
    transform: scale(1.1);
    z-index: 10;
    border-color: var(--color-secondary);
}

.hunt-bubble.popped {
    transform: scale(1.4);
    opacity: 0;
    pointer-events: none;
}

.hunt-bubble.wrong-shake {
    animation: shake 0.4s ease-in-out;
    background-color: #FFEBEE;
    border-color: #FF5252;
}

@keyframes floatBubble {
    0% { transform: translateY(0) rotate(-5deg); }
    100% { transform: translateY(-15px) rotate(5deg); }
}

/* === Learning Mode Containers (Letters, Numbers, Words) === */
.learning-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 1100px; /* Much wider */
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.9);
    padding: 30px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 4px solid #E0E0E0;
    transition: all 0.3s ease;
}

.learning-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    padding-bottom: 20px;
    border-bottom: 2px dashed rgba(0,0,0,0.1);
    margin-bottom: 10px;
}

.learning-header h2 {
    font-size: 2.4rem;
    margin: 0;
}

/* Adjust grid inside learning container */
.learning-container .letter-grid {
    box-shadow: none;
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    max-width: 100%;
}

/* Specific styles for Words categories inside the container */
.learning-container .word-categories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 100%;
}

.learning-container .word-categories .case-btn {
    width: 100%;
    min-height: 80px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.random-number-btn {
    font-size: 50px !important;
}
