:root {
    --bg-dark: #020617;
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.4);
    --secondary: #10b981;
    --secondary-glow: rgba(16, 185, 129, 0.4);
    --accent: #22d3ee;
    --accent-glow: rgba(34, 211, 238, 0.4);
    --warn: #ef4444;
    --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.math-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: #0f172a;
    font-weight: 700;
    background: #f1f5f9;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-exit:hover {
    background: #e2e8f0;
}

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

/* Central Table Panel */
.table-panel {
    flex: 1;
    position: relative;
    background: radial-gradient(ellipse at center 60%, #065f46 0%, #022c22 80%, #020617 100%);
    overflow: hidden;
    perspective: 1500px;
}

/* Dark Green Felt Grid */
.table-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: 100px 100px;
    pointer-events: none;
    opacity: 0.5;
}

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

/* Glass Dashboard (Targeting Mockup Visuals) */
.glass-dashboard {
    position: absolute;
    top: 40px;
    right: 40px;
    transform: perspective(1200px) rotateY(-15deg);
    width: 240px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(15, 23, 42, 0.6) 100%);
    backdrop-filter: blur(45px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 
        0 40px 80px rgba(0, 0, 0, 0.8), 
        inset 0 0 30px rgba(34, 211, 238, 0.05);
    pointer-events: none;
    z-index: 50;
    transition: all 0.5s ease;
}

.glass-dashboard header {
    font-family: 'Inter', sans-serif;
    font-size: 0.6rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 2px;
    margin-bottom: 16px;
    text-transform: uppercase;
}

.dash-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.dash-row .label {
    font-size: 0.6rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.dash-row .value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
}

.dash-row .value.accent {
    color: var(--accent);
    text-shadow: 0 0 15px var(--accent-glow);
}

.dash-row .value.highlight {
    color: #fff;
    font-weight: 700;
    background: rgba(34, 211, 238, 0.15);
    border: 1px solid rgba(34, 211, 238, 0.3);
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

.dash-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 20px 0;
}

/* Action Cluster (Bottom Buttons) */
.action-cluster {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%) perspective(800px) rotateX(25deg);
    display: flex;
    gap: 30px;
    align-items: center;
    z-index: 60;
}

.btn-glass {
    min-width: 120px;
    padding: 14px 28px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 100px;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-glass:hover {
    background: rgba(30, 41, 59, 1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.btn-glass.active {
    border-color: var(--accent);
    background: rgba(34, 211, 238, 0.1);
    color: var(--accent);
    box-shadow: 0 0 25px var(--accent-glow);
}

.interaction-hint {
    position: absolute;
    bottom: 30px;
    left: 40px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.2);
    text-transform: uppercase;
}

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

.glass-card {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 20px;
}

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

.button-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.cat-btn {
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: 0.2s;
}

.cat-btn i { width: 16px; text-align: center; font-size: 0.9rem; }

.cat-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
}

.cat-btn.primary {
    grid-column: span 2;
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.3);
    color: #a78bfa;
}

.cat-btn.primary:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: #a78bfa;
}

/* Formula Box */
.formula-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
}

.fraction {
    display: inline-flex;
    flex-direction: column;
    vertical-align: middle;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    font-weight: 700;
}

.fraction span:first-child {
    border-bottom: 2px solid #fff;
    padding: 0 4px;
}

.fraction span:last-child {
    padding: 0 4px;
}

.math { font-weight: 800; color: var(--accent); }

/* 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: 600px;
    border-radius: 32px;
    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: 30px;
}

.guide-card {
    display: flex;
    gap: 24px;
    align-items: center;
}

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

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

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