:root {
    --primary: #4CAF50;
    --primary-dark: #388E3C;
    --card-bg: transparent; /* Changed from white to transparent */
    --text-main: #ffffff;
    --text-error: #FF5252;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Fredoka', sans-serif;
    /* Immersive Pond Scene Background */
    /* It will try to load 'pond.jpg' from your folder. If missing, it uses a beautiful water gradient */
    background: url('pond.jpg') center/cover no-repeat, linear-gradient(to bottom, #81D4FA 0%, #4DD0E1 50%, #00BCD4 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
    overflow: hidden;
}

#game-container {
    width: 100%;
    max-width: 1200px;
    height: 98vh;
    max-height: 900px; /* Increased to allow the stats table and layout to be taller */
    position: relative;
    border-radius: 24px;
    background: var(--card-bg);
    overflow: hidden;
    /* Removed the blur to let the beautiful pond shine through natively! */
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
}

/* Typography & Buttons */
h1 {
    font-size: 5rem;
    color: var(--text-main);
    margin-bottom: 2rem;
    text-shadow: 3px 3px 8px rgba(0,0,0,0.6);
    text-align: center;
}

h2 {
    font-size: 3rem;
    color: var(--text-main);
    margin-bottom: 1rem;
    text-shadow: 2px 2px 6px rgba(0,0,0,0.6);
}

.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.5rem;
    font-family: inherit;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 5px 0 var(--primary-dark);
    transition: transform 0.1s, box-shadow 0.1s;
}

.primary-btn:active {
    transform: translateY(5px);
    box-shadow: 0 0 0 var(--primary-dark);
}

/* Gameplay Screen */
.top-bar {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    text-shadow: 2px 2px 6px rgba(0,0,0,0.6);
}

.audio-btn {
    font-size: 5rem;
    background: #E8F5E9;
    border: 4px solid var(--primary);
    border-radius: 50%;
    width: 120px;
    height: 120px;
    cursor: pointer;
    margin-bottom: 2rem;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.audio-btn:hover {
    transform: scale(1.05);
    background: #C8E6C9;
}

.play-area-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.input-and-check-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
    max-width: 400px;
    position: relative; /* This anchors the frog! */
    margin-bottom: 0.5rem; /* Reduced margin to bring feedback closer to button */
}

#spelling-input {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    border-radius: 16px;
    background: white;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    position: relative;
    z-index: 5; /* Stays above frog if there's minor overlap */
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

#submit-btn {
    width: 80%;
    max-width: 300px;
    font-size: 2rem;
    position: relative;
    z-index: 5;
    margin-bottom: 5px;
}

.letter-pool {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 60px;
    margin-top: 10px;
    padding: 10px;
    background: transparent;
    border-radius: 12px;
}

.sound-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 12px;
    border: 3px solid rgba(0,0,0,0.2);
    cursor: grab;
    user-select: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    transition: transform 0.1s;
    position: relative;
    overflow: hidden;
}

.sound-box:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.sound-box.dragging {
    opacity: 0.5;
}

.color-red { background: #FF5252; }
.color-blue { background: #448AFF; }
.color-green { background: #69F0AE; }
.color-yellow { background: #FFD740; }
.color-purple { background: #E040FB; }

.silent-box {
    background: #FFF;
    border: 3px dashed #9E9E9E;
}

/* Make inner text inputs perfectly fill the box for Phase 2 */
.sound-box input {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    outline: none;
    text-align: center;
    font-size: 2.2rem;
    font-weight: bold;
    font-family: inherit;
    color: #111;
    z-index: 5; /* So it sits above the quiet-indicator if needed */
}

#feedback-container {
    height: 100px;
    display: flex;
    align-items: flex-start; /* Aligns text to top of the block so it sits just under the button */
    justify-content: center;
    width: 100%;
}

.correct-tick {
    color: #4CAF50;
    font-size: 8rem;
    text-shadow: 0 0 20px white;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.incorrect-feedback {
    color: white;
    text-shadow: 2px 2px 6px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 3.5rem;
    font-weight: bold;
    animation: fadeIn 0.3s ease;
}

/* Frog Animation */
.frog {
    position: absolute;
    right: calc(100% + 20px); /* Safely anchored outside the left of the input area */
    top: -65px; /* Aligns legs exactly with the bottom of the input container */
    height: 150px;
    width: auto;
    z-index: 10;
}

.frog.hidden {
    display: none;
}

.frog.hop {
    /* Frog leaping ACROSS the word from left to right */
    animation: hopAcross 1.5s forwards;
}

.frog.spiral {
    animation: spiralDown 1.5s forwards;
}

@keyframes spiralDown {
    0% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 1; }
    100% { transform: translate(0, 500px) scale(0) rotate(1080deg); opacity: 0; }
}

@keyframes hopAcross {
    0% { transform: translate(0, 0) rotate(0deg); }
    20% { transform: translate(250px, -200px) rotate(0deg); }
    40% { transform: translate(450px, -300px) rotate(180deg); }
    60% { transform: translate(750px, -200px) rotate(360deg); }
    80% { transform: translate(1100px, -50px) rotate(360deg); }
    100% { transform: translate(1500px, 0) rotate(360deg); opacity: 0; }
}

@keyframes popIn {
    0% { transform: scale(0); }
    80% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Fireworks Screen */
#fireworks-screen {
    background: rgba(0, 0, 0, 0.85);
}

#fireworks-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.firework {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: explode 1.5s ease-out infinite;
}

@keyframes explode {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
        box-shadow: 
            0 0 0 0 #ff0000, 0 0 0 0 #00ff00, 0 0 0 0 #0000ff, 
            0 0 0 0 #ffff00, 0 0 0 0 #ff00ff, 0 0 0 0 #00ffff;
    }
    100% {
        transform: translateY(-200px) scale(5);
        opacity: 0;
        box-shadow: 
            -600px -600px 0 8px #ff0000, 600px -600px 0 8px #00ff00, -600px 600px 0 8px #0000ff, 
            600px 600px 0 8px #ffff00, 0 -800px 0 8px #ff00ff, 0 800px 0 8px #00ffff,
            -400px 0 0 8px #FF1493, 400px 0 0 8px #FFA500, 0 -400px 0 8px #7FFF00,
            800px 200px 0 8px #00BFFF, -800px 200px 0 8px #FF4500, -800px -200px 0 8px #8A2BE2;
    }
}

.firework:nth-child(1) { left: 20%; top: 40%; animation-delay: 0s; }
.firework:nth-child(2) { left: 50%; top: 30%; animation-delay: 0.2s; }
.firework:nth-child(3) { left: 80%; top: 50%; animation-delay: 0.4s; }
.firework:nth-child(4) { left: 30%; top: 60%; animation-delay: 0.6s; }
.firework:nth-child(5) { left: 70%; top: 20%; animation-delay: 0.8s; }
.firework:nth-child(6) { left: 45%; top: 10%; animation-delay: 1.0s; }
.firework:nth-child(7) { left: 10%; top: 50%; animation-delay: 1.2s; }
.firework:nth-child(8) { left: 90%; top: 60%; animation-delay: 1.4s; }
.firework:nth-child(9) { left: 60%; top: 80%; animation-delay: 1.6s; }
.firework:nth-child(10) { left: 40%; top: 35%; animation-delay: 1.8s; }
.firework:nth-child(11) { left: 85%; top: 25%; animation-delay: 2.0s; }
.firework:nth-child(12) { left: 15%; top: 70%; animation-delay: 2.2s; }

.fireworks-text {
    animation: popIn 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* End Screen */
#end-screen {
    background: rgba(0,0,0,0.7); /* Dark semi-transparent overlay just for readability at the end */
    border-radius: 24px;
}

.score-display {
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 2rem;
    color: #4CAF50;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.stats-container {
    width: 100%;
    max-width: 650px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    max-height: 450px; /* Vastly increased to allow ~15 rows to be fully visible at once */
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 1.2rem;
    color: #333;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    color: #666;
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.95);
}

.mistakes-review {
    background: rgba(255, 235, 238, 0.95);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    width: 100%;
    max-width: 650px;
}

.mistakes-review h3 {
    color: #C62828;
    margin-bottom: 0.5rem;
}

#mistakes-list {
    list-style-type: none;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

#mistakes-list li {
    background: white;
    padding: 8px 20px;
    border-radius: 20px;
    color: var(--text-error);
    font-weight: bold;
    font-size: 1.2rem;
    border: 1px solid #ef5350;
}

/* Phase 3 single text box */
.full-word-input {
    width: 80%;
    margin: 10px auto;
    display: block;
    font-size: 3.5rem;   /* Extremely large font */
    padding: 15px;
    border-radius: 12px;
    border: 4px solid #8e5bd9;
    text-align: center;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
    outline: none;
    font-family: inherit;
    background: white;
    color: #111;
}
.full-word-input:focus {
    border-color: #4CAF50;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.4);
}
