: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;
}

[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;
}

.glass {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    /* No backdrop-filter to prevent subpixel antialiasing issues */
}

.btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background: var(--primary-color, #467230);
    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, #467230);
    border: 2px solid var(--primary-color, #467230);
    box-shadow: none;
}
.btn.outline:hover {
    background: var(--primary-color, #467230);
    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%;
    max-width: 600px;
    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;
}
.setting-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.setting-title {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 1.1rem;
}
.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;
}

/* Grid styles */
.grid-container {
    display: grid;
    gap: 12px;
    width: 100%;
    margin: 0 auto;
    perspective: 1000px;
}

/* Mobile optimizations for Grid */
@media (max-width: 600px) {
    .grid-container {
        gap: 8px;
    }
    .game-header {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
}

.grid-cell {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem;
    font-weight: 800;
    cursor: default;
    aspect-ratio: 1;
    transition: all 0.2s ease;
    user-select: none;
    color: transparent; /* Text hidden by default */
}

/* On mobile, ensure cells are tappable */
@media (max-width: 600px) {
    .grid-cell { font-size: 2rem; border-radius: 8px; }
}

.grid-cell.showing {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(70, 114, 48, 0.4);
}

.grid-cell.interactive {
    cursor: pointer;
}
.grid-cell.interactive:hover {
    background: rgba(140, 156, 110, 0.2);
}

.grid-cell.correct {
    background: #4caf50;
    border-color: #4caf50;
    color: white;
    transform: scale(1.05);
}

.grid-cell.wrong {
    background: #f44336;
    border-color: #f44336;
    color: white;
    animation: shake 0.4s;
}

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

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

.chart-bar-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
}
.chart-bar {
    width: 100%;
    max-width: 40px;
    background: var(--primary-color);
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease;
}
.chart-label {
    font-size: 0.8rem;
    color: var(--text-color);
    margin-top: 5px;
}
