* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
    --primary: #4CAF50; --primary-dark: #388E3C;
    --secondary: #FF9800; --danger: #f44336;
    --bg-sky: #87CEEB; --bg-ocean: #1E90FF;
    --card-bg: rgba(255,255,255,0.95);
    --shadow: 0 4px 15px rgba(0,0,0,0.2);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.3);
    --radius: 15px; --radius-lg: 25px;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;
    background: linear-gradient(180deg, var(--bg-sky) 0%, var(--bg-ocean) 100%);
    min-height: 100vh; overflow: hidden; color: #333;
}
.screen {
    display: none; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%; padding: 20px; overflow-y: auto;
}
.screen.active { display: flex; flex-direction: column; align-items: center; }
.screen.overlay { background: rgba(0,0,0,0.7); justify-content: center; z-index: 100; }

/* Clouds */
.cloud { position: absolute; background: white; border-radius: 50px; opacity: 0.9; animation: float 20s infinite ease-in-out; }
.cloud::before, .cloud::after { content: ''; position: absolute; background: white; border-radius: 50%; }
.cloud-1 { width: 100px; height: 40px; top: 10%; left: -100px; animation-delay: 0s; }
.cloud-1::before { width: 50px; height: 50px; top: -25px; left: 15px; }
.cloud-1::after { width: 70px; height: 70px; top: -35px; left: 40px; }
.cloud-2 { width: 120px; height: 50px; top: 20%; left: -120px; animation-delay: 5s; }
.cloud-2::before { width: 60px; height: 60px; top: -30px; left: 20px; }
.cloud-2::after { width: 80px; height: 80px; top: -40px; left: 50px; }
.cloud-3 { width: 80px; height: 35px; top: 15%; left: -80px; animation-delay: 10s; }
.cloud-3::before { width: 45px; height: 45px; top: -22px; left: 10px; }
.cloud-3::after { width: 55px; height: 55px; top: -28px; left: 35px; }
@keyframes float { 0% { transform: translateX(0); } 100% { transform: translateX(calc(100vw + 200px)); } }

/* Start Screen */
#start-screen { justify-content: center; background: linear-gradient(180deg, #87CEEB 0%, #98D8C8 50%, #1E90FF 100%); }
.island-logo { text-align: center; margin-bottom: 30px; animation: bounce 2s infinite; }
.palm-tree { font-size: 60px; margin-bottom: 10px; }
.game-title { font-size: 42px; color: #fff; text-shadow: 3px 3px 0 #FF9800, 6px 6px 0 rgba(0,0,0,0.2); font-weight: bold; letter-spacing: 2px; }
.subtitle { font-size: 16px; color: #fff; background: var(--secondary); padding: 5px 20px; border-radius: 20px; margin-top: 10px; display: inline-block; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.start-info { background: var(--card-bg); padding: 20px 40px; border-radius: var(--radius); margin-bottom: 30px; box-shadow: var(--shadow); }
.start-info div { margin: 10px 0; font-size: 18px; }
.start-info .icon { margin-right: 10px; }
.footer-info { position: absolute; bottom: 20px; color: rgba(255,255,255,0.8); font-size: 14px; }

/* Buttons */
.btn {
    display: flex; align-items: center; justify-content: center;
    width: 280px; padding: 15px 30px; margin: 10px; border: none;
    border-radius: var(--radius); font-size: 20px; font-weight: bold;
    cursor: pointer; transition: all 0.3s ease; box-shadow: var(--shadow);
}
.btn:active { transform: scale(0.95); }
.btn-icon { margin-right: 10px; }
.btn-start { background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%); color: white; }
.btn-practice { background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%); color: white; }

/* Level Screen */
#level-screen { background: linear-gradient(180deg, #87CEEB 0%, #B0E0E6 100%); }
.screen-header { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 10px 0; margin-bottom: 20px; }
.screen-header h2 { color: #fff; text-shadow: 2px 2px 0 rgba(0,0,0,0.2); font-size: 24px; }
.btn-back { width: 40px; height: 40px; border: none; border-radius: 50%; background: white; font-size: 20px; cursor: pointer; box-shadow: var(--shadow); flex-shrink: 0; }
.btn-back-small { width: 32px; height: 32px; border: none; border-radius: 50%; background: white; font-size: 16px; cursor: pointer; box-shadow: var(--shadow); flex-shrink: 0; }
.header-level { background: var(--secondary); color: white; padding: 5px 15px; border-radius: 20px; font-weight: bold; }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; width: 100%; max-width: 400px; margin-bottom: 20px; max-height: 45vh; overflow-y: auto; padding: 5px; }
.level-btn {
    aspect-ratio: 1; border: none; border-radius: 12px; font-size: 16px; font-weight: bold;
    cursor: pointer; transition: all 0.3s ease; position: relative; box-shadow: var(--shadow);
}
.level-btn.unlocked, .level-btn.current { background: linear-gradient(135deg, #fff 0%, #e0e0e0 100%); color: #333; }
.level-btn.completed { background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%); color: white; }
.level-btn.locked { background: linear-gradient(135deg, #9e9e9e 0%, #757575 100%); color: #666; cursor: not-allowed; }
.level-btn.current { background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%); color: white; animation: pulse 1.5s infinite; }
.level-btn.selected { outline: 3px solid #2196F3; outline-offset: 2px; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.level-btn .level-stars { position: absolute; bottom: 2px; left: 0; right: 0; font-size: 7px; }
.level-info-panel {
    background: var(--card-bg); padding: 20px; border-radius: var(--radius);
    width: 100%; max-width: 400px; box-shadow: var(--shadow); text-align: center;
}
.level-detail h3 { font-size: 22px; margin-bottom: 5px; }
.level-detail p { color: #666; margin-bottom: 8px; }
.level-difficulty { color: #FF9800; font-weight: bold; margin-bottom: 5px; font-size: 14px; }
.level-stars { font-size: 24px; margin-bottom: 15px; }
.btn-play { background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%); color: white; width: 100%; }

/* Game Screen */
#game-screen { background: linear-gradient(180deg, #E3F2FD 0%, #BBDEFB 100%); padding: 15px; }
.game-header { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-bottom: 10px; }
.game-info-left, .game-info-right { display: flex; align-items: center; gap: 10px; }
.level-badge { background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%); color: white; padding: 5px 15px; border-radius: 20px; font-weight: bold; font-size: 14px; }
.practice-badge { background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%); }
.question-count { background: white; padding: 5px 12px; border-radius: 15px; font-weight: bold; box-shadow: var(--shadow); }
.timer { display: flex; align-items: center; gap: 5px; background: white; padding: 5px 12px; border-radius: 15px; font-weight: bold; box-shadow: var(--shadow); }
.timer.warning { background: #FFF3E0; color: #F57C00; animation: blink 0.5s infinite; }
.timer.danger { background: #FFEBEE; color: #f44336; animation: blink 0.3s infinite; }
@keyframes blink { 50% { opacity: 0.7; } }
.score-display { display: flex; align-items: center; gap: 5px; background: white; padding: 5px 12px; border-radius: 15px; font-weight: bold; box-shadow: var(--shadow); }
.progress-bar { width: 100%; height: 8px; background: #ddd; border-radius: 4px; margin-bottom: 20px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #4CAF50 0%, #8BC34A 100%); border-radius: 4px; transition: width 0.3s ease; width: 0%; }
.question-area { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; width: 100%; }
.question-card {
    background: var(--card-bg); padding: 30px 35px; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); margin-bottom: 30px; text-align: center; width: 100%; max-width: 400px;
}
.question-text { font-size: 32px; font-weight: bold; color: #333; line-height: 1.4; word-break: break-all; }
.answers-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; width: 100%; max-width: 400px; }
.answer-btn {
    padding: 18px 10px; font-size: 22px; font-weight: bold; border: none;
    border-radius: var(--radius); background: var(--card-bg); color: #333;
    cursor: pointer; transition: all 0.2s ease; box-shadow: var(--shadow);
}
.answer-btn:active { transform: scale(0.95); }
.answer-btn.correct { background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%); color: white; animation: correctPulse 0.5s ease; }
.answer-btn.wrong { background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%); color: white; animation: shake 0.5s ease; }
@keyframes correctPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }
.game-footer { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-top: 20px; }
.combo-display { background: linear-gradient(135deg, #FF5722 0%, #FF9800 100%); color: white; padding: 8px 20px; border-radius: 20px; font-weight: bold; box-shadow: var(--shadow); }
.btn-pause { width: 50px; height: 50px; border: none; border-radius: 50%; background: white; font-size: 24px; cursor: pointer; box-shadow: var(--shadow); }

/* Pause / Result Modals */
.pause-modal, .result-modal {
    background: var(--card-bg); padding: 30px; border-radius: var(--radius-lg);
    text-align: center; max-width: 350px; width: 90%; box-shadow: var(--shadow-lg);
}
.result-modal { animation: slideUp 0.5s ease; }
@keyframes slideUp { from { transform: translateY(50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.pause-modal h2 { margin-bottom: 20px; font-size: 28px; }
.pause-stats { margin-bottom: 25px; }
.pause-stats p { margin: 10px 0; font-size: 18px; }
.btn-resume { background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%); color: white; margin-bottom: 10px; }
.btn-quit { background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%); color: white; }
.result-header { margin-bottom: 20px; }
.result-icon { font-size: 60px; margin-bottom: 10px; }
.result-header h2 { font-size: 28px; color: #333; }
.result-stars { font-size: 40px; margin-bottom: 20px; }
.result-stars .star { opacity: 0.3; transition: opacity 0.3s ease; }
.result-stars .star.active { opacity: 1; }
.result-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; margin-bottom: 20px; }
.stat-item { background: #f5f5f5; padding: 15px; border-radius: var(--radius); }
.stat-label { display: block; font-size: 14px; color: #666; margin-bottom: 5px; }
.stat-value { display: block; font-size: 24px; font-weight: bold; color: #333; }
.result-rewards { background: #FFF8E1; padding: 15px; border-radius: var(--radius); margin-bottom: 20px; }
.result-rewards p { margin: 5px 0; font-size: 16px; }
.result-rewards span { font-weight: bold; color: #FF9800; }
.result-buttons { display: flex; flex-direction: column; gap: 10px; }
.btn-retry { background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%); color: white; }
.btn-next { background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%); color: white; }
.btn-back-menu { background: #e0e0e0; color: #333; }

/* Practice Screen - Mobile First Layout */
#practice-screen {
    background: linear-gradient(180deg, #E8F5E9 0%, #C8E6C9 100%);
    display: flex; flex-direction: column;
    padding: 10px; gap: 8px;
}

.practice-top {
    display: flex; align-items: center; gap: 10px;
    flex-shrink: 0;
}

.practice-question {
    flex: 1; display: flex; align-items: center; justify-content: center;
    min-height: 0; overflow: hidden;
}

.practice-question .question-card {
    width: 100%; padding: 20px; margin: 0;
}

.practice-question .question-text { font-size: 28px; }

.practice-input {
    display: flex; gap: 8px; width: 100%;
    flex-shrink: 0;
}

.practice-input .answer-input {
    flex: 1; padding: 14px; font-size: 22px; font-weight: bold; text-align: center;
    border: 3px solid #ddd; border-radius: 12px; background: white;
}

.practice-input .answer-input:focus { outline: none; border-color: var(--primary); }

.practice-input .btn-submit {
    padding: 14px 20px; font-size: 16px; font-weight: bold; border: none;
    border-radius: 12px; background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white; cursor: pointer; box-shadow: var(--shadow);
}

.practice-bottom {
    flex-shrink: 0; display: flex; flex-direction: column; gap: 6px;
}

.practice-stats-row {
    display: flex; gap: 8px; justify-content: center;
}

.stat-pill {
    padding: 4px 12px; border-radius: 15px; font-weight: bold; font-size: 13px;
    background: white; box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.stat-pill.correct { color: #4CAF50; }
.stat-pill.wrong { color: #f44336; }
.stat-pill.score { color: #FF9800; }

.practice-settings-row {
    display: flex; gap: 6px; align-items: center;
}

.practice-select {
    flex: 1; padding: 8px 6px; border: 2px solid #ddd; border-radius: 8px;
    background: white; font-size: 12px; font-weight: bold; cursor: pointer;
}

.btn-end-practice {
    padding: 8px 14px; border: none; border-radius: 8px;
    background: #f44336; color: white; font-size: 12px; font-weight: bold;
    cursor: pointer; white-space: nowrap;
}

.practice-settings { display: none; }
.game-footer { display: none; }

/* Score Popup */
.score-popup {
    position: fixed; font-size: 24px; font-weight: bold; color: #4CAF50;
    pointer-events: none; animation: scoreFloat 1s ease-out forwards; z-index: 200;
}
.score-popup.combo { color: #FF9800; font-size: 28px; }
.score-popup.wrong-popup { color: #f44336; }
@keyframes scoreFloat { 0% { transform: translateY(0) scale(1); opacity: 1; } 100% { transform: translateY(-50px) scale(1.5); opacity: 0; } }

/* Scrollbar */
.level-grid::-webkit-scrollbar { width: 4px; }
.level-grid::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 2px; }

@media (max-width: 380px) {
    .game-title { font-size: 32px; }
    .question-text { font-size: 24px; }
    .answer-btn { padding: 14px 8px; font-size: 18px; }
    .level-grid { grid-template-columns: repeat(5, 1fr); gap: 6px; }
    .level-btn { font-size: 14px; }
}
