:root {
    --bg-color: #f0f4f8;
    --panel-bg: rgba(255, 255, 255, 0.88);
    --panel-border: rgba(0, 0, 0, 0.1);
    --text-main: #1e293b;
    --text-muted: #64748b;
    
    --color-primary: #0284c7;
    --color-correct: #059669;
    --color-wrong: #dc2626;
    --color-near: #d97706;
    --color-learned: #0369a1;
    
    --street-default: rgba(30, 41, 59, 0.3);
    --street-hover: rgba(2, 132, 199, 0.8);
    
    --font-main: 'Inter', system-ui, sans-serif;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.12);
    --z-map: 1;
    --z-panels: 1000;
    --z-overlay: 2000;
    --z-sidebar: 3000;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    /* Mobile viewport fix */
    height: 100dvh; 
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* --- Map --- */
#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-map);
    background-color: #e8edf2;
}

/* Override leaflet styles for light mode */
.leaflet-container {
    background: #e8edf2 !important;
    font-family: var(--font-main);
}
.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
}
.leaflet-control-zoom a {
    background-color: var(--panel-bg) !important;
    color: var(--text-main) !important;
    border-color: var(--panel-border) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.leaflet-control-zoom a:hover {
    background-color: rgba(0,0,0,0.05) !important;
}

/* --- Glass Panels --- */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow-glass);
    z-index: var(--z-panels);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 600px;
    border-radius: var(--radius-lg);
}

/* --- Header --- */
header {
    top: 16px;
    top: calc(16px + env(safe-area-inset-top));
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}

#menu-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}
#menu-btn:hover { background: rgba(0,0,0,0.06); }

.question-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.question-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

#target-street-name {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-primary);
}

.difficulty-indicator {
    background: rgba(0,0,0,0.06);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 700;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}
.difficulty-indicator.hard {
    color: var(--color-wrong);
    background: rgba(239, 68, 68, 0.15);
}

/* --- Footer (Progress) --- */
footer {
    bottom: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.progress-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
}

.progress-percent {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-primary);
}

.progress-track {
    width: 100%;
    height: 8px;
    background: rgba(0,0,0,0.08);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-learned));
    border-radius: 4px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Feedback Overlay --- */
.feedback-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: var(--z-overlay);
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.feedback-overlay.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.feedback-overlay.correct {
    background: rgba(16, 185, 129, 0.2);
    border: 2px solid var(--color-correct);
    box-shadow: 0 0 40px rgba(16, 185, 129, 0.4);
}
.feedback-overlay.correct #feedback-icon::after {
    content: '✓';
    color: var(--color-correct);
    font-size: 4rem;
    font-weight: bold;
}

.feedback-overlay.wrong {
    background: rgba(239, 68, 68, 0.2);
    border: 2px solid var(--color-wrong);
    box-shadow: 0 0 40px rgba(239, 68, 68, 0.4);
}
.feedback-overlay.wrong #feedback-icon::after {
    content: '✗';
    color: var(--color-wrong);
    font-size: 4rem;
    font-weight: bold;
}

.feedback-overlay.near {
    background: rgba(245, 158, 11, 0.2);
    border: 2px solid var(--color-near);
    box-shadow: 0 0 40px rgba(245, 158, 11, 0.4);
}
.feedback-overlay.near #feedback-icon::after {
    content: '≈';
    color: var(--color-near);
    font-size: 4rem;
    font-weight: bold;
}

/* --- Sidebar --- */
.sidebar-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: calc(var(--z-sidebar) - 1);
    opacity: 1;
    transition: opacity 0.3s;
}
.sidebar-backdrop.hidden {
    opacity: 0;
    pointer-events: none;
}

.sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 360px;
    height: 100%;
    background: #ffffff;
    z-index: var(--z-sidebar);
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--panel-border);
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}

.sidebar.hidden {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--panel-border);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

#close-menu-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.settings-section h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
}

/* Difficulty Toggle */
.difficulty-toggle {
    display: flex;
    background: rgba(255,255,255,0.05);
    border-radius: var(--radius-md);
    padding: 4px;
}
.difficulty-toggle button {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}
.difficulty-toggle button.active {
    background: var(--panel-border);
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* District List */
.district-actions {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}
.text-btn {
    background: transparent;
    border: none;
    color: var(--color-primary);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
}
.district-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.district-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.2s;
}
.district-item:hover {
    background: rgba(255,255,255,0.08);
}
.district-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--color-primary);
}
.district-item span {
    font-weight: 500;
    font-size: 0.95rem;
}

/* Stats */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.stat-item {
    background: rgba(255,255,255,0.03);
    padding: 16px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}
.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}
