/* === FONTS === */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap');

/* === PREVENT ZOOM AND SCROLL ON iOS === */
html {
	touch-action: manipulation;
	overscroll-behavior: none;
}

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

* {
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
}

/* === DESIGN TOKENS === */
:root {
    /* Colors - bright, child-friendly palette */
    --color-bg: #FFF9E6;           /* Warm cream background */
    --color-primary: #4ECDC4;       /* Teal - buttons, accents */
    --color-secondary: #FF6B6B;     /* Coral - highlights */
    --color-success: #95E879;       /* Green - correct answers */
    --color-warning: #FFE66D;       /* Yellow - hints */
    --color-text: #2C3E50;          /* Dark blue-gray text */

    /* Typography */
    --font-main: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-letter: clamp(4rem, 15vw, 10rem);
    --font-size-syllable: clamp(3rem, 10vw, 6rem);
    --font-size-word: clamp(2rem, 8vw, 4rem);

    /* Spacing */
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 2rem;

    /* Border radius - rounded, friendly shapes */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;
}

/* === BASE STYLES === */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--color-bg);
    color: var(--color-text);
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-md);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
}

/* === MENU PAGE === */
.menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    gap: var(--spacing-lg);
}

.menu-container h1 {
    font-size: clamp(2rem, 8vw, 4rem);
    color: var(--color-primary);
    text-shadow: 3px 3px 0 rgba(0,0,0,0.1);
    text-align: center;
}

.stage-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    width: 100%;
    max-width: 300px;
}

.stage-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    text-decoration: none;
    color: var(--color-text);
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stage-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 0 rgba(0,0,0,0.1);
}

.stage-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

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

.stage-label {
    font-size: 1.5rem;
    font-weight: 700;
}

.stage-1 { border-left: 6px solid var(--color-primary); }
.stage-2 { border-left: 6px solid var(--color-secondary); }
.stage-3 { border-left: 6px solid var(--color-success); }

/* === CARD COMPONENT === */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    padding: var(--spacing-lg);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 0 rgba(0,0,0,0.1);
}

.card:active {
    transform: translateY(0);
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

/* === LETTER CARD === */
.letter-card {
    font-size: var(--font-size-letter);
    font-weight: 700;
    width: clamp(100px, 30vw, 180px);
    height: clamp(100px, 30vw, 180px);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === SYLLABLE CARD === */
.syllable-card {
    font-size: var(--font-size-syllable);
    font-weight: 700;
    width: clamp(100px, 30vw, 180px);
    height: clamp(100px, 30vw, 180px);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === FEEDBACK STATES === */
.card.correct {
    animation: correct-pulse 0.5s ease;
    background: var(--color-success);
}

.card.incorrect {
    animation: incorrect-shake 0.5s ease;
}

.card.found {
    opacity: 0.5;
    transform: scale(0.9);
    pointer-events: none;
}

.card.selected {
    border: 4px solid var(--color-primary);
    background: rgba(78, 205, 196, 0.1);
}

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

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

/* === GRID LAYOUTS === */
.grid-2x2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
    max-width: 400px;
}

.grid-1x4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-sm);
}

.scatter-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-sm);
    max-width: 500px;
}

.scatter-item {
    font-size: clamp(2rem, 8vw, 4rem);
    width: clamp(60px, 20vw, 100px);
    height: clamp(60px, 20vw, 100px);
    animation: pop-in 0.3s ease backwards;
    animation-delay: var(--delay, 0s);
}

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

/* === IMAGE CARDS === */
.image-card {
    width: clamp(80px, 20vw, 140px);
    height: clamp(80px, 20vw, 140px);
    padding: var(--spacing-sm);
}

.image-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.target-image {
    width: clamp(120px, 30vw, 200px);
    height: clamp(120px, 30vw, 200px);
    object-fit: contain;
}

/* === EXERCISE CONTAINER === */
.exercise-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
    max-width: 600px;
    width: 100%;
    touch-action: manipulation;
    overscroll-behavior: contain;
}

.prompt-area {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
}

.prompt-text {
    font-size: 1.5rem;
    font-weight: 600;
}

.target-letter {
    font-size: var(--font-size-letter);
    font-weight: 700;
    color: var(--color-primary);
}

/* === TARGET LETTER CARD WITH REPLAY === */
.target-card-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.target-letter-card {
    font-size: clamp(3rem, 12vw, 6rem);
    font-weight: 700;
    width: clamp(100px, 25vw, 140px);
    height: clamp(100px, 25vw, 140px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary) 0%, #3DBDB5 100%);
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    box-shadow: 0 6px 0 rgba(0,0,0,0.15), 0 8px 20px rgba(78, 205, 196, 0.3);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.target-letter-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 10px 0 rgba(0,0,0,0.15), 0 12px 30px rgba(78, 205, 196, 0.4);
}

.target-letter-card:active {
    transform: translateY(0);
    box-shadow: 0 3px 0 rgba(0,0,0,0.15), 0 4px 10px rgba(78, 205, 196, 0.2);
}

.replay-btn {
    position: absolute;
    bottom: -12px;
    right: -12px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--color-warning);
    color: var(--color-text);
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,0.15), 0 4px 12px rgba(255, 230, 109, 0.4);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.replay-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 0 rgba(0,0,0,0.15), 0 6px 16px rgba(255, 230, 109, 0.5);
}

.replay-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 0 rgba(0,0,0,0.15), 0 2px 8px rgba(255, 230, 109, 0.3);
}

/* Syllable target card */
.target-syllable-card {
    font-size: clamp(2rem, 10vw, 4rem);
    font-weight: 700;
    min-width: clamp(100px, 25vw, 160px);
    height: clamp(100px, 25vw, 140px);
    padding: 0 var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-secondary) 0%, #FF5252 100%);
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    box-shadow: 0 6px 0 rgba(0,0,0,0.15), 0 8px 20px rgba(255, 107, 107, 0.3);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.target-syllable-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 10px 0 rgba(0,0,0,0.15), 0 12px 30px rgba(255, 107, 107, 0.4);
}

.target-syllable-card:active {
    transform: translateY(0);
    box-shadow: 0 3px 0 rgba(0,0,0,0.15), 0 4px 10px rgba(255, 107, 107, 0.2);
}

/* Word target card */
.target-word-card {
    font-size: clamp(1.5rem, 6vw, 2.5rem);
    font-weight: 700;
    min-width: clamp(120px, 40vw, 240px);
    height: clamp(80px, 20vw, 100px);
    padding: 0 var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-success) 0%, #7DD566 100%);
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    box-shadow: 0 6px 0 rgba(0,0,0,0.15), 0 8px 20px rgba(149, 232, 121, 0.3);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    letter-spacing: 0.05em;
}

.target-word-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 10px 0 rgba(0,0,0,0.15), 0 12px 30px rgba(149, 232, 121, 0.4);
}

.target-word-card:active {
    transform: translateY(0);
    box-shadow: 0 3px 0 rgba(0,0,0,0.15), 0 4px 10px rgba(149, 232, 121, 0.2);
}

/* Image target card */
.target-image-card-container {
    position: relative;
}

.target-image-card {
    width: clamp(120px, 30vw, 180px);
    height: clamp(120px, 30vw, 180px);
    padding: var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #FFF 0%, #F8F8F8 100%);
    box-shadow: 0 6px 0 rgba(0,0,0,0.1), 0 8px 20px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.target-image-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 10px 0 rgba(0,0,0,0.1), 0 12px 30px rgba(0,0,0,0.15);
}

.target-image-card:active {
    transform: translateY(0);
    box-shadow: 0 3px 0 rgba(0,0,0,0.1), 0 4px 10px rgba(0,0,0,0.08);
}

.target-image-card img,
.target-image-card .placeholder-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.target-word {
    font-size: var(--font-size-word);
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: 0.1em;
}

.counter {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-secondary);
}

/* === DRAG AND DROP === */
.drop-zones {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
}

.drop-zone {
    border: 4px dashed var(--color-primary);
    border-radius: var(--radius-md);
    min-width: 80px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-syllable);
    font-weight: 700;
    transition: background-color 0.2s ease, border-style 0.2s ease;
}

.drop-zone.drag-over {
    background-color: rgba(78, 205, 196, 0.2);
}

.drop-zone.filled {
    border-style: solid;
    background: white;
}

.syllable-zone {
    min-width: 100px;
    min-height: 100px;
}

.word-zones {
    flex-wrap: wrap;
}

.letter-pool,
.syllable-pool {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    justify-content: center;
    max-width: 400px;
}

.letter-pool .letter-card,
.syllable-pool .syllable-card {
    font-size: clamp(2rem, 6vw, 3rem);
    width: clamp(60px, 15vw, 80px);
    height: clamp(60px, 15vw, 80px);
}

.draggable {
    cursor: grab;
    touch-action: none;
}

.draggable:active {
    cursor: grabbing;
}

.draggable.dragging {
    opacity: 0.5;
}

/* === BUTTONS === */
.btn {
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,0.2);
    transition: transform 0.1s ease;
    font-family: var(--font-main);
}

.btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.2);
}

.btn-hint {
    background: var(--color-warning);
    color: var(--color-text);
}

.btn-next {
    background: var(--color-success);
}

/* === NAVIGATION === */
.nav-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    max-width: 600px;
}

.back-btn {
    font-size: 2rem;
    text-decoration: none;
    color: var(--color-text);
    background: white;
    border-radius: var(--radius-full);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    transition: transform 0.15s ease;
}

.back-btn:hover {
    transform: translateY(-2px);
}

.back-btn:active {
    transform: translateY(0);
}

.exercise-indicator {
    display: flex;
    gap: var(--spacing-sm);
}

.indicator-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ddd;
    transition: background 0.3s ease, transform 0.3s ease;
}

.indicator-dot.active {
    background: var(--color-primary);
    transform: scale(1.2);
}

.indicator-dot.completed {
    background: var(--color-success);
}

/* === START SCREEN === */
.start-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.start-btn {
    width: clamp(120px, 30vw, 180px);
    height: clamp(120px, 30vw, 180px);
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--color-primary) 0%, #3DBDB5 100%);
    font-size: clamp(3rem, 10vw, 5rem);
    cursor: pointer;
    box-shadow: 0 8px 0 rgba(0,0,0,0.15), 0 12px 30px rgba(78, 205, 196, 0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse-glow 2s ease-in-out infinite;
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 0 rgba(0,0,0,0.15), 0 16px 40px rgba(78, 205, 196, 0.5);
}

.start-btn:active {
    transform: scale(0.95);
    box-shadow: 0 4px 0 rgba(0,0,0,0.15), 0 6px 15px rgba(78, 205, 196, 0.3);
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 8px 0 rgba(0,0,0,0.15), 0 12px 30px rgba(78, 205, 196, 0.4); }
    50% { box-shadow: 0 8px 0 rgba(0,0,0,0.15), 0 12px 50px rgba(78, 205, 196, 0.6); }
}

/* === COMPLETION DIALOG === */
.completion-dialog {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
    text-align: center;
    animation: celebrate-pop 0.5s ease;
}

@keyframes celebrate-pop {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.completion-stars {
    font-size: 3rem;
    animation: stars-bounce 1s ease infinite;
}

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

.completion-title {
    font-size: clamp(2.5rem, 10vw, 4rem);
    color: var(--color-primary);
    margin: 0;
    text-shadow: 3px 3px 0 rgba(0,0,0,0.1);
}

.completion-message {
    font-size: 1.3rem;
    color: var(--color-text);
    margin: 0;
}

.completion-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    width: 100%;
    max-width: 250px;
    margin-top: var(--spacing-md);
}

.completion-buttons .btn {
    width: 100%;
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.btn-replay {
    background: var(--color-primary);
}

.btn-home {
    background: var(--color-secondary);
    text-decoration: none;
}

/* === RESPONSIVE === */
@media (max-width: 480px) {
    .grid-2x2 {
        gap: var(--spacing-sm);
    }

    .letter-card {
        width: clamp(80px, 40vw, 140px);
        height: clamp(80px, 40vw, 140px);
    }

    .syllable-card {
        width: clamp(80px, 40vw, 140px);
        height: clamp(80px, 40vw, 140px);
    }

    .scatter-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* === LOADING/PLACEHOLDER STATE === */
.placeholder-img {
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    border-radius: var(--radius-md);
}
