:root {
    --bg-color: #f4f6f8;
    --text-color: #333;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --card-bg: rgba(255, 255, 255, 0.5);
    --border-color: rgba(0, 0, 0, 0.1);
    --primary-color: #467230;
    --distractor-color: #f44336;
}

[data-theme="dark"] {
    --bg-color: #1a1a2e;
    --text-color: #e0e0e0;
    --glass-bg: rgba(20, 20, 35, 0.8);
    --card-bg: rgba(30, 30, 50, 0.8);
    --border-color: rgba(255, 255, 255, 0.1);
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    font-family: 'Inter', sans-serif;
    user-select: none; /* Mobile first protection */
    -webkit-user-select: none;
}

.glass {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
}

.btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 15px rgba(70, 114, 48, 0.3);
    transition: transform 0.1s, box-shadow 0.1s;
}
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(70, 114, 48, 0.4);
}
.btn.outline {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    box-shadow: none;
}
.btn.outline:hover {
    background: var(--primary-color);
    color: white;
}

.app-container {
    width: 95%;
    max-width: 1000px;
    min-height: 85vh;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    padding: 30px;
    margin: 40px auto;
}

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 0 auto;
    flex: 1;
    transition: opacity 0.3s ease;
}
.screen.hidden {
    display: none !important;
    opacity: 0;
}
.screen.active {
    display: flex;
    opacity: 1;
}

h1 { font-size: 3rem; text-align: center; margin-bottom: 20px; }
.instruction { font-size: 1.2rem; text-align: center; margin-bottom: 30px; line-height: 1.6; }

.settings-container {
    width: 100%;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.setting-title {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 1.1rem;
    text-align: center;
}
.custom-select {
    width: 100%;
    max-width: 300px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
}

.game-header {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 20px;
    font-size: 1.1rem;
}

/* Words layout */
.words-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    width: 100%;
    margin-bottom: 20px;
}
.words-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    width: 100%;
    margin-bottom: 20px;
}

.word-box {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 15px 10px;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-color);
    cursor: default;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
}
.word-box.interactive {
    cursor: pointer;
}
.word-box.interactive:active {
    transform: scale(0.95);
}

.word-box.correct {
    background: #4caf50;
    border-color: #4caf50;
    color: white;
}
.word-box.wrong {
    background: var(--distractor-color);
    border-color: var(--distractor-color);
    color: white;
    animation: shake 0.3s;
}
.word-box.missed {
    background: #9e9e9e;
    border-color: #9e9e9e;
    color: white;
}

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

@media (max-width: 600px) {
    .words-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .word-box {
        font-size: 1.1rem;
        padding: 12px 8px;
        min-height: 48px; /* Touch target minimum */
    }
    .game-header {
        font-size: 1rem;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
    }
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
    width: 100%;
}
.stat-box {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
}
.stat-label {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 5px;
}
.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.result-words-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
}
.res-word {
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
}
.res-word.correct { background: #4caf50; }
.res-word.wrong { background: #f44336; }
.res-word.missed { background: #9e9e9e; }
