:root {
    --color-primary: #FFB7B2; /* Pastel Red */
    --color-secondary: #B5EAD7; /* Pastel Green */
    --color-accent: #C7CEEA; /* Pastel Purple */
    --color-bg: #FAF9F6;
    --color-text: #555;
    --color-white: #ffffff;
    --font-main: 'M PLUS Rounded 1c', sans-serif;
    --font-en: 'Fredoka', sans-serif;
}

* {
    box-sizing: border-box;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-bg);
    font-family: var(--font-main);
    color: var(--color-text);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

#app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

/* Header */
header {
    height: 80px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--color-white);
    border-bottom: 2px solid #eee;
    z-index: 10;
}

.back-btn {
    font-size: 1.5rem;
    text-decoration: none;
    padding: 10px;
    border-radius: 50%;
    background: #f0f0f0;
    transition: transform 0.2s;
}

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

#mode-switch {
    display: flex;
    gap: 10px;
    background: #f5f5f5;
    padding: 5px;
    border-radius: 25px;
}

.mode-btn {
    border: none;
    background: transparent;
    padding: 8px 20px;
    border-radius: 20px;
    font-family: var(--font-main);
    font-weight: bold;
    color: #888;
    cursor: pointer;
    transition: all 0.3s;
}

.mode-btn.active {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 4px 10px rgba(255, 183, 178, 0.4);
}

/* Challenge Prompt */
#challenge-prompt {
    flex: 1;
    margin-left: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #FFF9C4;
    padding: 10px 20px;
    border-radius: 15px;
    border: 2px solid #FFECB3;
    animation: slideDown 0.3s;
}

#challenge-prompt.hidden { display: none; }

.prompt-text {
    font-size: 1.2rem;
    font-weight: bold;
    color: #F57F17;
}

#target-word-display {
    font-family: var(--font-en);
    color: #E65100;
    text-decoration: underline;
}

#replay-audio-btn {
    background: #FFCC80;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
}

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

/* Main Layout */
main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
#category-nav {
    width: 90px;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    gap: 15px;
    overflow-y: auto;
    border-right: 1px solid #eee;
}

.cat-btn {
    width: 60px;
    height: 60px;
    border-radius: 15px;
    border: none;
    background: white;
    font-size: 1.8rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    justify-content: center;
    align-items: center;
}

.cat-btn.active {
    background: var(--color-secondary);
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(181, 234, 215, 0.5);
    border: 2px solid #88d4b8;
}

/* Scene Area */
#scene-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #E3F2FD; /* Light Blue BG */
    position: relative;
    overflow: hidden;
}

#scene-title {
    padding: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    color: #1565C0;
    text-align: center;
    background: rgba(255,255,255,0.6);
}

#items-grid {
    flex: 1;
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    grid-auto-rows: 120px;
    gap: 20px;
    overflow-y: auto;
    justify-items: center;
    align-items: center;
}

/* Item Card */
.word-item {
    width: 100px;
    height: 110px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
}

.word-item:active { transform: scale(0.9); }

.item-icon {
    width: 80px;
    height: 80px;
    background: white;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border: 3px solid white;
    transition: all 0.3s;
}

.item-label {
    margin-top: 8px;
    font-family: var(--font-en);
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
    opacity: 0; /* Hidden by default in explore, show on click/unlock */
    transition: opacity 0.3s;
}

/* State: Unlocked / Clicked */
.word-item.unlocked .item-label {
    opacity: 1;
}

.word-item.unlocked .item-icon {
    border-color: var(--color-secondary);
    background: #fff;
}

/* State: Challenge Correct */
.word-item.correct .item-icon {
    background: #C8E6C9;
    border-color: #4CAF50;
    animation: jello 0.8s;
}

/* State: Challenge Wrong */
.word-item.wrong .item-icon {
    animation: shake 0.4s;
    background: #FFCDD2;
}

/* Jello Animation */
@keyframes jello {
    0% { transform: scale3d(1, 1, 1); }
    30% { transform: scale3d(1.25, 0.75, 1); }
    40% { transform: scale3d(0.75, 1.25, 1); }
    50% { transform: scale3d(1.15, 0.85, 1); }
    65% { transform: scale3d(0.95, 1.05, 1); }
    75% { transform: scale3d(1.05, 0.95, 1); }
    100% { transform: scale3d(1, 1, 1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Footer */
footer {
    height: 70px;
    background: white;
    border-top: 2px solid #eee;
    padding: 0 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pocket-container {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    max-width: 600px;
}

.pocket-icon {
    font-size: 2.5rem;
}

.progress-bar-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.progress-text {
    font-size: 0.8rem;
    color: #888;
    text-align: right;
}

.progress-track {
    height: 12px;
    background: #f0f0f0;
    border-radius: 6px;
    overflow: hidden;
}

#progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #FFB7B2, #E2F0CB);
    border-radius: 6px;
    transition: width 0.5s ease-out;
}

#medal-container {
    font-size: 2.5rem;
    animation: popIn 0.5s;
}

@keyframes popIn {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

/* Feedback Overlay */
#feedback-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#feedback-content {
    background: rgba(255, 255, 255, 0.9);
    padding: 30px;
    border-radius: 30px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    transform: scale(0);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#feedback-overlay.show #feedback-content {
    transform: scale(1);
    opacity: 1;
}

#feedback-emoji { font-size: 5rem; margin-bottom: 10px; }
#feedback-word { font-size: 2.5rem; font-family: var(--font-en); color: #333; }

#confetti-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 50;
}
