:root {
    --bg-dark: #020617;
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.4);
    --secondary: #f97316;
    --secondary-glow: rgba(249, 115, 22, 0.4);
    --accent: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.4);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass: rgba(15, 23, 42, 0.7);
    --border-glass: rgba(148, 163, 184, 0.1);
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body.geometry-theme {
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: #000;
    color: var(--text-main);
    overflow: hidden;
    touch-action: none;
}

#phet-stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 1280px;
    height: 720px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-dark);
    transform-origin: 0 0;
}

/* Navigation */
nav {
    position: relative !important;
    background: #ffffff !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
    color: #0f172a !important;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    flex-shrink: 0;
    top: 0 !important;
    z-index: 1000;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-divider {
    color: #cbd5e1;
    font-weight: 300;
}

.nav-chapter {
    font-size: 0.95rem;
    color: #64748b;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-experiment {
    font-size: 0.95rem;
    color: var(--primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-right {
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav-btn-help {
    background: none;
    border: none;
    cursor: pointer;
    color: #64748b;
    font-size: 1.2rem;
    transition: color 0.2s;
}

.nav-btn-help:hover {
    color: var(--primary);
}

.btn-exit {
    text-decoration: none;
    color: #94a3b8;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.btn-exit:hover {
    color: #ef4444;
}

/* Simulation Container */
.sim-container {
    flex: 1;
    display: flex;
    width: 100%;
    overflow: hidden;
}

.canvas-panel {
    flex: 1;
    position: relative;
    background:radial-gradient(circle at center, #1e1b4b 0%, #020617 100%);
    overflow: hidden;
}

.canvas-panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}

canvas#simCanvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.canvas-header {
    position: absolute;
    top: 30px;
    left: 40px;
    pointer-events: none;
}

#shape-title {
    font-family: 'Outfit', sans-serif;
    font-size: 3rem;
    margin: 0;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.badge {
    display: inline-block;
    padding: 6px 16px;
    background: var(--primary-glow);
    border: 1px solid var(--primary);
    border-radius: 100px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 10px;
    backdrop-filter: blur(10px);
}

/* Geometry HUD */
.geometry-hud {
    position: absolute;
    bottom: 30px;
    left: 40px;
    display: flex;
    gap: 20px;
    pointer-events: none;
}

.hud-item {
    background: var(--glass);
    border: 1px solid var(--border-glass);
    padding: 15px 25px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    backdrop-filter: blur(15px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.hud-label {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.hud-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.interaction-hint {
    position: absolute;
    top: 50%;
    right: 40px;
    transform: translateY(-50%) rotate(90deg);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Control Panel */
.control-panel {
    width: 320px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(25px);
    border-left: 1px solid var(--border-glass);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    z-index: 10;
    height: 100%;
    overflow-y: auto;
}

.glass-card {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
    border-color: var(--primary);
    background: rgba(30, 41, 59, 0.6);
}

.section-header {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--primary);
    margin-bottom: 20px;
}

.control-group {
    margin-bottom: 20px;
}

.control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.control-header label {
    font-size: 0.95rem;
    font-weight: 400;
}

.highlight-val {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-glow);
    padding: 4px 10px;
    border-radius: 8px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    background: #fff;
    border: 3px solid var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 15px var(--primary-glow);
}

.slider-marks {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 10px;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Modern Checkbox */
.check-modern {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.check-modern input { display: none; }

.checkmark {
    width: 22px;
    height: 22px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 6px;
    position: relative;
    transition: 0.2s;
}

.check-modern input:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.check-modern input:checked + .checkmark::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 11px;
    color: white;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}

.check-modern .label {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Stats */
.stats-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
}

.stat-value {
    font-family: 'Outfit', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
}

.primary .stat-value { color: var(--primary); }
.accent .stat-value { color: var(--secondary); }

.stat-formula {
    font-size: 0.65rem;
    font-family: 'JetBrains Mono', monospace;
    opacity: 0.6;
}

.formula-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
}

.formula-box p { margin: 0; }
.math { color: var(--accent); font-weight: 700; }

.btn-action {
    width: 100%;
    padding: 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    color: var(--text-muted);
    font-weight: 700;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.btn-action:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: #ef4444;
}

/* Help Modal */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
    z-index: 2000;
}

.modal-content {
    background: #fff;
    color: #0f172a;
    width: 550px;
    border-radius: 30px;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    overflow: hidden;
    box-shadow: 0 30px 60px rgba(0,0,0,0.5);
}

.modal-header {
    padding: 30px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
}

.modal-header h2 { margin: 0; font-family: 'Outfit'; font-weight: 700; }

.btn-close-modal {
    background: none; border: none; font-size: 2rem; cursor: pointer; color: #94a3b8;
}

.modal-body {
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.guide-card {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.guide-card i {
    font-size: 1.5rem;
    color: var(--primary);
    width: 30px;
    text-align: center;
}

.modal-footer {
    padding: 25px 40px;
    background: #f8fafc;
    display: flex;
    justify-content: flex-end;
}

.btn-modal-ok {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 12px 30px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 20px var(--primary-glow);
}
