/* Guitar Fretboard Trainer — Light Theme */

:root {
    --bg-primary: #FAFAF9;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --text-primary: #1C1917;
    --text-secondary: #57534E;
    --text-muted: #A8A29E;
    --border-color: #E7E5E4;
    --accent: #3B82F6;
    --accent-light: #EFF6FF;
    --correct: #10B981;
    --correct-light: #ECFDF5;
    --incorrect: #EF4444;
    --incorrect-light: #FEF2F2;
    --warning: #F59E0B;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --radius: 8px;
    --radius-lg: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* --- Nav --- */
.nav {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s;
}

.nav-link:hover, .nav-link.active {
    background: var(--accent-light);
    color: var(--accent);
}

/* --- Layout --- */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem;
}

.page { display: none; }
.page.active { display: block; }

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

/* --- Dashboard --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.25rem;
}

.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.mode-btn {
    padding: 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.mode-btn:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.mode-btn .mode-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.mode-btn .mode-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.mode-btn .mode-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- Fretboard --- */
.fretboard-container {
    overflow-x: auto;
    margin: 1rem 0;
    -webkit-overflow-scrolling: touch;
}

.fretboard-svg {
    display: block;
    margin: 0 auto;
}

/* Pulse animation for highlighted notes */
@keyframes pulse {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 0.6; }
}

.pulse circle:first-child {
    animation: pulse 1s ease-in-out infinite;
}

/* --- Game UI --- */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.game-prompt {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    padding: 1rem;
    color: var(--text-primary);
}

.game-stats {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin: 0.75rem 0;
    font-size: 0.9rem;
}

.game-stats span {
    color: var(--text-secondary);
}

.game-stats .stat-num {
    font-weight: 700;
    color: var(--text-primary);
}

.streak-display {
    color: var(--warning) !important;
    font-weight: 700 !important;
}

/* Note buttons for Name That Note */
.note-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin: 1rem 0;
}

.note-btn {
    width: 60px;
    height: 48px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-card);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-primary);
}

.note-btn:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.note-btn.correct {
    background: var(--correct-light);
    border-color: var(--correct);
    color: var(--correct);
}

.note-btn.incorrect {
    background: var(--incorrect-light);
    border-color: var(--incorrect);
    color: var(--incorrect);
}

/* Timer */
.timer-display {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.timer-display.warning { color: var(--warning); }
.timer-display.danger { color: var(--incorrect); }

/* --- Feedback Flash --- */
.feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 1rem 2rem;
    border-radius: var(--radius-lg);
    font-size: 1.5rem;
    font-weight: 700;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 100;
}

.feedback.show { opacity: 1; }
.feedback.correct { background: var(--correct); color: white; }
.feedback.incorrect { background: var(--incorrect); color: white; }

/* --- Progress / Heat Map --- */
.legend {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
}

/* --- Achievements --- */
.badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.badge {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    text-align: center;
    opacity: 0.4;
}

.badge.unlocked {
    opacity: 1;
    border-color: var(--warning);
    background: #FFFBEB;
}

.badge-icon { font-size: 1.5rem; }
.badge-name { font-size: 0.85rem; font-weight: 600; margin-top: 0.25rem; }
.badge-desc { font-size: 0.7rem; color: var(--text-muted); }

/* --- Buttons --- */
.btn {
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

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

.btn-primary:hover { background: #2563EB; }

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover { background: var(--border-color); }

.btn-danger {
    background: var(--incorrect);
    color: white;
}

.btn-lg {
    padding: 0.8rem 2rem;
    font-size: 1.1rem;
}

.btn-block {
    width: 100%;
    display: block;
}

/* --- Settings --- */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.setting-row:last-child { border-bottom: none; }

.setting-label {
    font-weight: 500;
}

.setting-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Toggle switch */
.toggle {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-color);
    border-radius: 24px;
    cursor: pointer;
    transition: 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
}

.toggle input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* --- End Screen --- */
.end-screen {
    text-align: center;
    padding: 2rem 0;
}

.end-score {
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent);
}

.end-stats {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin: 1.5rem 0;
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .container { padding: 1rem; }
    .nav { padding: 0.5rem 1rem; }
    .nav-links { gap: 0.25rem; }
    .nav-link { padding: 0.3rem 0.5rem; font-size: 0.8rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .mode-grid { grid-template-columns: 1fr; }
    .game-prompt { font-size: 1.2rem; }
    .note-btn { width: 50px; height: 42px; font-size: 0.9rem; }
    .end-stats { flex-direction: column; gap: 0.5rem; }
}

/* Landscape prompt for mobile */
@media (max-width: 640px) and (orientation: portrait) {
    .landscape-prompt {
        display: block;
        text-align: center;
        padding: 0.5rem;
        background: var(--accent-light);
        color: var(--accent);
        font-size: 0.8rem;
        border-radius: var(--radius);
        margin-bottom: 0.5rem;
    }
}

@media (min-width: 641px), (orientation: landscape) {
    .landscape-prompt { display: none; }
}

/* Session history */
.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.history-item:last-child { border-bottom: none; }
