:root {
    --primary-bg: #87CEEB; /* Sky Blue */
    --primary-text: #FFFFFF;
    --button-bg: #FFD700; /* Gold */
    --button-text: #4B4B4B;
    --title-font: 'Fredoka One', cursive;
    --body-font: 'Inter', sans-serif;
}

body {
    margin: 0;
    font-family: var(--body-font);
    background-color: var(--primary-bg);
    color: var(--primary-text);
    text-align: center;
}

#app {
    width: 100%;
    max-width: 420px; /* Max width for a phone-like experience */
    height: 100%; /* Use 100% to fill the parent with 100dvh */
    max-height: 900px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 0 auto; /* Center horizontally */
    background-color: var(--primary-bg);
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    overflow: hidden;
    position: relative;
}

.screen {
    display: none;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    position: absolute;
    transition: transform 0.5s ease-in-out;
}

#welcome-screen, #collection-screen {
    justify-content: center;
}

.title {
    font-family: var(--title-font);
    font-size: 4rem;
    color: var(--primary-text);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.button {
    font-family: var(--body-font);
    font-size: 1.5rem;
    font-weight: 600;
    background-color: var(--button-bg);
    color: var(--button-text);
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.button:hover {
    transform: scale(1.05);
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
}

#game-screen {
    justify-content: space-between;
}

#game-header {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    padding: 1rem;
    box-sizing: border-box;
}

#home-btn {
    flex: 0 0 auto;
    margin-right: auto;
    padding-left: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: white;
    font-size: 2rem;
}

#game-header > *:nth-child(2) {
    flex: 1;
    text-align: center;
}

#game-header .icon-group {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.icon-button {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

#word-counter {
    font-size: 1.2rem;
    font-weight: 600;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--title-font);
    font-size: 2rem;
}

#image-container {
    position: relative;
    width: 100%;
    flex-grow: 1; /* Allow the container to fill available space */
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-position 0.3s ease-out;
}

#scene-image {
    display: none; /* We will use background-image on the container now */
}

#highlight-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allows clicks to pass through to the image */
}

.highlight-box {
    position: absolute;
    border-radius: 50%; /* This will create an ellipse */
    box-sizing: border-box;
    animation: magic-glow 1.5s ease-out;
    background: radial-gradient(ellipse at center, rgba(255, 215, 0, 0.5) 0%, rgba(255, 215, 0, 0) 70%);
    box-shadow: 0 0 15px 5px rgba(255, 215, 0, 0.7), 0 0 30px 10px rgba(255, 215, 0, 0.5) inset;
}

@keyframes magic-glow {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    100% {
        opacity: 0;
        transform: scale(1.2);
    }
}

#input-container {
    width: 100%;
    padding: 1rem;
    box-sizing: border-box;
    flex-shrink: 0; /* Prevent the input container from shrinking */
}

#word-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.2rem;
    border: 2px solid var(--button-bg);
    border-radius: 20px;
    text-align: center;
    box-sizing: border-box;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.overlay.active {
    display: flex;
}

.flashcard {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

#flashcard-overlay .flashcard {
    animation: swivel-in 1.5s cubic-bezier(0.25, 1, 0.5, 1);
}

.flashcard-frame {
    position: relative;
    background-color: #fff;
    border: 10px solid #f0e68c; /* Khaki-like frame */
    border-radius: 20px;
    padding: 15px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.3), inset 0 0 10px rgba(0,0,0,0.2);
    width: 280px; /* 9:16 aspect ratio */
    height: 498px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.flashcard-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

.flashcard-ribbon {
    position: absolute;
    bottom: 20px;
    left: -20px;
    right: -20px;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 1rem;
    transform: skewY(-3deg);
}

.flashcard-word {
    font-size: 2.5rem;
    font-weight: 600;
    font-family: var(--title-font);
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    transform: skewY(3deg);
    margin: 0;
}


.flashcard-audio-btn {
    position: absolute;
    top: 25px;
    right: 25px;
    color: white;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

.flashcard-audio-btn i {
    width: 24px;
    height: 24px;
    display: block;
}

#flashcard-ok-btn {
    color: white;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#flashcard-ok-btn i {
    width: 40px;
    height: 40px;
}

@keyframes swivel-in {
    from {
        transform: scale(0.5) rotateY(90deg);
        opacity: 0;
    }
    to {
        transform: scale(1) rotateY(0deg);
        opacity: 1;
    }
}

.loader {
    border: 8px solid #f3f3f3;
    border-top: 8px solid var(--button-bg);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#settings-panel {
    background-color: white;
    color: black;
    padding: 2rem;
    border-radius: 20px;
    width: 80%;
    max-width: 300px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    animation: pop-in 0.3s ease-out;
}

#settings-panel h2 {
    font-family: var(--title-font);
    font-size: 2rem;
    margin-top: 0;
    margin-bottom: 2rem;
    color: #333;
}

.setting-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    font-size: 1.2rem;
}

.setting-option i {
    margin-right: 2rem;
    color: #555;
}

.setting-option span {
    flex-grow: 1;
    text-align: left;
}

.setting-btn {
    background-color: #eee;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    min-width: 80px;
}

#done-btn {
    margin-top: 1rem;
}

#hint-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 10;
}

.hint-btn {
    background-color: rgba(0, 0, 0, 0.4);
    border: none;
    color: white;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hint-btn:hover {
    background-color: rgba(0, 0, 0, 0.6);
}

#unlocked-words-panel {
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2rem;
    border-radius: 20px;
    width: 80%;
    max-width: 300px;
    text-align: center;
}

#unlocked-words-panel h2 {
    font-family: var(--title-font);
    font-size: 2rem;
    margin-top: 0;
    margin-bottom: 1.5rem;
}

#unlocked-words-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem 0;
    max-height: 200px;
    overflow-y: auto;
    font-size: 1.2rem;
}

#unlocked-words-list li {
    padding: 0.25rem 0;
}

#next-scene-btn {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
    z-index: 20;
}

#scene-select-panel {
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2rem;
    border-radius: 20px;
    width: 80%;
    max-width: 300px;
    text-align: center;
}

#scene-select-panel h2 {
    font-family: var(--title-font);
    font-size: 2rem;
    margin-top: 0;
    margin-bottom: 1.5rem;
}

#scene-select-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem 0;
    max-height: 200px;
    overflow-y: auto;
}

#scene-select-list li {
    padding: 0.75rem 0;
    font-size: 1.2rem;
    cursor: pointer;
    border-bottom: 1px solid #444;
}

#scene-select-list li:last-child {
    border-bottom: none;
}

#scene-select-list li.disabled {
    color: #777;
    cursor: not-allowed;
}

#flashcard-collection-panel {
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#flashcard-collection-panel h2 {
    font-family: var(--title-font);
    font-size: 2rem;
    margin-top: 0;
    margin-bottom: 1.5rem;
}

#filmstrip {
    display: flex;
    gap: 20px;
    padding: 20px;
    width: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
}

#filmstrip .flashcard {
    flex: 0 0 280px; /* Don't shrink, don't grow, base width */
    scroll-snap-align: center;
}

#collection-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    width: 40px;
    height: 40px;
}

#toast {
    position: absolute;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 1rem 2rem;
    border-radius: 20px;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s, visibility 0.5s;
}

#toast.show {
    opacity: 1;
    visibility: visible;
}

/* Login Panel Styles */
#login-panel {
    background-color: white;
    color: black;
    padding: 2rem;
    border-radius: 20px;
    width: 80%;
    max-width: 320px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    animation: pop-in 0.3s ease-out;
}

#login-panel h2 {
    font-family: var(--title-font);
    font-size: 2rem;
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: #333;
    text-align: center;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

#login-form input {
    padding: 1rem;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-family: var(--body-font);
    transition: border-color 0.2s;
}

#login-form input:focus {
    outline: none;
    border-color: var(--button-bg);
}

#login-form button[type="submit"] {
    margin-top: 0.5rem;
}

#login-close-btn {
    width: 100%;
    background-color: #eee;
    color: #333;
}

@keyframes pop-in {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}
