/* =========================================
   1. VARIABLES & RESET (DYNAMIC THEME SUPPORT)
   ========================================= */
:root {
    --panel-bg: rgba(15, 23, 42, 0.85); 
    --panel-border: 1px solid rgba(255, 255, 255, 0.15);
    --text-main: #f1f5f9;       
    --text-muted: #f4f9ff;      
    --text-highlight: #38bdf8;  
    --accent-cyan: #06b6d4;     
    --accent-glow: 0 0 10px rgba(6, 182, 212, 0.5);
    --btn-play: #10b981;
    --btn-pause: #f59e0b;
    --btn-reset: #ef4444;
    --base-font: max(1.5vh, 11px); 
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: radial-gradient(circle at center, #0f172a 0%, #000000 100%);
    height: 100vh; width: 100vw;
    display: flex; justify-content: center; align-items: center;
    overflow: hidden; color: var(--text-main);
    /* BUG FIX: Transisi background dihapus agar tidak nge-glitch hitam saat ganti atmosfer */
}

/* =========================================
   SIMBOL FISIKA (MATH FONT STYLES)
   ========================================= */
.math-sym {
    font-family: 'Cambria Math', 'Times New Roman', serif;
    font-style: italic;
    font-weight: 600;
    color: var(--accent-cyan);
    margin: 0 2px;
}
.math-sub {
    font-family: 'Cambria Math', 'Times New Roman', serif;
    font-style: normal;
    font-size: 0.75em;
    vertical-align: baseline;
    position: relative;
    top: 0.25em;
}
/* Font khusus untuk satuan agar tegak tapi tetap bergaya math */
.unit-label {
    font-family: 'Cambria Math', 'Times New Roman', serif;
    font-style: normal;
    font-weight: 500;
    font-size: calc(var(--base-font) * 0.85);
    color: #94a3b8;
    margin-left: 2px;
}

/* =========================================
   2. LAYOUT & CONTAINER 
   ========================================= */
.container {
    aspect-ratio: 16 / 9;
    width: min(100vw, 177.78vh); height: min(100vh, 56.25vw);
    background: transparent;
    display: grid; grid-template-columns: 22fr 43fr 35fr; 
    gap: 1.5vh; padding: 1.5vh; position: relative;
}

.panel {
    background: var(--panel-bg); backdrop-filter: blur(8px);
    border: var(--panel-border); border-radius: 1.5vh; padding: 1.5vh;
    box-shadow: 0 1vh 3vh rgba(0, 0, 0, 0.5);
    display: flex; flex-direction: column; max-height: 100%;
    overflow: hidden; transition: background 0.3s;
}

.panel-title {
    margin-bottom: 1vh; font-size: calc(var(--base-font) * 1.2);
    font-weight: 700; text-align: center; padding: 0.8vh;
    background: linear-gradient(90deg, transparent, rgba(6, 182, 212, 0.2), transparent);
    color: var(--text-highlight); border-bottom: 1px solid rgba(6, 182, 212, 0.3);
    text-transform: uppercase; letter-spacing: 1px;
}

.panel.scrollable { overflow-y: auto; overflow-x: hidden; }
.panel.scrollable::-webkit-scrollbar { width: 0.6vh; }
.panel.scrollable::-webkit-scrollbar-thumb { background: #475569; border-radius: 1vh; }
.panel.scrollable::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }

/* =========================================
   3. INPUT SECTIONS
   ========================================= */
.section {
    margin-bottom: 1vh; padding: 1vh; background: rgba(0, 0, 0, 0.3);
    border-radius: 0.8vh; border: 1px solid rgba(255, 255, 255, 0.05);
}
.section-header {
    font-weight: 600; color: var(--text-main); padding: 0.5vh;
    background: rgba(255, 255, 255, 0.05); border-radius: 0.5vh;
    text-align: center; margin-bottom: 0.8vh; font-size: var(--base-font);
    border-left: 3px solid var(--accent-cyan);
}
.input-group { margin: 0.5vh 0; display: flex; justify-content: space-between; align-items: center; }
.input-group label { color: var(--text-muted); font-size: calc(var(--base-font) * 0.9); }

/* Mengubah font angka input menjadi Math Font */
.input-group input[type="number"], .range-value-input {
    font-family: 'Cambria Math', 'Times New Roman', serif;
    font-weight: bold;
    background: rgba(15, 23, 42, 0.8);
    color: var(--text-highlight); border: 1px solid #334155; border-radius: 0.5vh;
    font-size: calc(var(--base-font) * 0.9); text-align: right;
}
.input-group input[type="number"] { width: 35%; padding: 0.4vh; }
.range-value-input { width: 6vh; min-width: 45px; padding: 0.2vh 0.5vh; }

.input-group input[type="number"]:focus, .range-value-input:focus { outline: none; border-color: var(--accent-cyan); box-shadow: 0 0 5px rgba(6, 182, 212, 0.5); }
.input-group input[type="range"] { flex: 1; margin: 0 0.8vh; cursor: pointer; height: 0.6vh; accent-color: var(--accent-cyan); }
.range-value-input::-webkit-outer-spin-button, .range-value-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* STYLE MATERIAL DROPDOWN */
.material-select {
    width: 45%; padding: 0.3vh; background: rgba(15, 23, 42, 0.8);
    color: var(--text-highlight); border: 1px solid #334155; border-radius: 0.5vh;
    font-size: calc(var(--base-font) * 0.85); font-family: 'Segoe UI', sans-serif;
    font-weight: 600; outline: none; cursor: pointer; text-align: center;
}
.material-select:focus { border-color: var(--accent-cyan); box-shadow: 0 0 5px rgba(6, 182, 212, 0.5); }
.material-select option { background: #0f172a; color: #fff; text-align: left; }

.height-group { flex-direction: column; gap: 0.4vh; align-items: stretch; }
.height-group .height-top-row { display: flex; justify-content: space-between; align-items: center; }
.height-group input[type="range"] { width: 100%; margin: 0; flex: unset; height: 0.7vh; min-height: 6px; accent-color: var(--accent-cyan); cursor: pointer; }

.radio-group.horizontal { display: flex; gap: 0.5vh; margin: 0.5vh 0; }
.radio-group.horizontal .radio-option { flex: 1; display: flex; align-items: center; justify-content: center; padding: 0.5vh; background: rgba(255, 255, 255, 0.05); border: 1px solid #334155; border-radius: 0.5vh; transition: all 0.2s; }
.radio-group.horizontal .radio-option:hover { background: rgba(6, 182, 212, 0.1); border-color: var(--accent-cyan); }
.radio-group.horizontal label { font-size: calc(var(--base-font) * 0.85); cursor: pointer; color: var(--text-muted); margin-left: 5px; }
.radio-group.horizontal input[type="radio"]:checked + label { color: var(--accent-cyan); font-weight: bold; text-shadow: 0 0 5px rgba(6, 182, 212, 0.5); }

/* =========================================
   4. INFO BOXES & HINTS
   ========================================= */
.info-box { background: rgba(0, 0, 0, 0.4); padding: 0.8vh; border-radius: 0.6vh; margin: 0.5vh 0; border: 1px solid rgba(255, 255, 255, 0.05); }
.info-row { display: flex; justify-content: space-between; align-items: center; margin: 0.4vh 0; font-size: calc(var(--base-font) * 0.85); border-bottom: 1px dashed #334155; padding-bottom: 0.2vh; }
.info-label { color: var(--text-muted); display: flex; align-items: center; gap: 2px;}

/* Mengubah font angka hasil simulasi menjadi Math Font */
.info-value { 
    font-family: 'Cambria Math', 'Times New Roman', serif; 
    font-weight: bold; 
    color: var(--text-highlight); 
    font-size: 1.05em;
}

.hint-box { text-align: center; padding: 0.8vh; background: rgba(245, 158, 11, 0.1); border: 1px dashed #f59e0b; border-radius: 0.6vh; margin: 0.8vh 0; color: #fbbf24; font-size: calc(var(--base-font) * 0.85); }

/* =========================================
   5. CANVAS & CONTROLS
   ========================================= */
.canvas-container { position: relative; border-radius: 1vh; border: 1px solid var(--accent-cyan); box-shadow: var(--accent-glow); background: black; overflow: hidden; flex: 1; width: 100%; }
#simulationCanvas { display: block; width: 100%; height: 100%; object-fit: fill; }
.controls { display: flex; justify-content: center; gap: 1.5vh; margin-top: 1vh; padding: 0.5vh; min-height: 5vh; }
.control-btn { width: 5vh; height: 5vh; border-radius: 50%; font-size: 2.2vh; border: none; cursor: pointer; box-shadow: 0 0.5vh 1vh rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; color: #fff; transition: transform 0.2s, box-shadow 0.2s; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); }
.control-btn:hover { transform: scale(1.1); box-shadow: 0 0 15px currentColor; border: none; }
.play-btn:hover { background: var(--btn-play); color: white; box-shadow: 0 0 15px var(--btn-play); }
.pause-btn:hover { background: var(--btn-pause); color: white; box-shadow: 0 0 15px var(--btn-pause); }
.reset-btn:hover { background: var(--btn-reset); color: white; box-shadow: 0 0 15px var(--btn-reset); }
.fullscreen-btn:hover { background: #8b5cf6; color: white; box-shadow: 0 0 15px #8b5cf6; }
.back-btn:hover { background: #64748b; color: white; box-shadow: 0 0 15px #64748b; }
/* =========================================
   6. GRAPHICS & CHARTS
   ========================================= */
.graph-wrapper { flex: 1; display: flex; flex-direction: column; min-height: 0; margin-bottom: 0.5vh; border-bottom: 1px dashed #334155; padding-bottom: 0.5vh; }
.graph-wrapper:last-child { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }
.graph-header { display: flex; align-items: center; gap: 1vh; margin-bottom: 0.5vh; }
.graph-label { font-size: calc(var(--base-font) * 0.85); font-weight: bold; color: var(--text-main); }
.graph-selector { display: flex; gap: 0.3vh; flex: 1; }
.graph-container { flex: 1; position: relative; background: rgba(0, 0, 0, 0.4); border: 1px solid #334155; border-radius: 0.5vh; width: 100%; min-height: 0; overflow: hidden; }
.graph-btn { flex: 1; display: flex; justify-content: center; align-items: center; padding: 0.3vh 0; border: 1px solid #334155; background: rgba(255, 255, 255, 0.05); color: var(--text-muted); border-radius: 0.4vh; cursor: pointer; font-size: calc(var(--base-font) * 0.85); transition: all 0.2s; }
.graph-btn:hover { background: rgba(255, 255, 255, 0.1); color: white; }
.graph-btn.active { background: var(--accent-cyan); color: #0f172a; border-color: var(--accent-cyan); box-shadow: 0 0 10px rgba(6, 182, 212, 0.4); }
.graph-btn.active .math-sym { color: #0f172a; font-weight: 700; }
.zoom-controls { position: absolute; top: 0.5vh; right: 0.5vh; display: flex; gap: 0.3vh; z-index: 10; }
.zoom-btn { width: 2vh; height: 2vh; font-size: 1.2vh; border-radius: 0.3vh; border: 1px solid #475569; background: rgba(15, 23, 42, 0.9); color: var(--accent-cyan); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.zoom-btn:hover { background: var(--accent-cyan); color: white; }

@media (orientation: portrait) {
    body::after { content: "⚠️ Harap putar perangkat ke Landscape untuk tampilan optimal."; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.95); color: white; display: flex; justify-content: center; align-items: center; text-align: center; z-index: 9999; font-size: 1.2rem; padding: 20px; }
}

/* =============================================
   7. DEMO / TUTORIAL OVERLAY SYSTEM
   ============================================= */
#demo-overlay { position: fixed; inset: 0; z-index: 9000; pointer-events: none; transition: opacity 0.4s ease; }
#demo-overlay.hidden { opacity: 0; pointer-events: none; }
.demo-mask { position: fixed; inset: 0; background: rgba(4, 8, 20, 0.82); pointer-events: all; transition: opacity 0.4s; backdrop-filter: blur(1px); }
#demo-spotlight { position: fixed; border-radius: 10px; box-shadow: 0 0 0 4000px rgba(4, 8, 20, 0.82), 0 0 0 2px rgba(34, 211, 238, 0.8), 0 0 20px rgba(34, 211, 238, 0.4); pointer-events: none; transition: all 0.45s cubic-bezier(0.4, 0, 0.2, 1); z-index: 9001; }
#demo-card { position: fixed; z-index: 9002; background: rgba(8, 15, 35, 0.97); border: 1px solid rgba(34, 211, 238, 0.4); border-radius: 12px; padding: 1.4rem 1.6rem; max-width: 340px; min-width: 260px; box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 30px rgba(34,211,238,0.08); pointer-events: all; transition: all 0.45s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s; }
#demo-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, transparent, #22d3ee, #3b82f6, transparent); border-radius: 12px 12px 0 0; }
.demo-step-badge { font-family: 'Consolas', monospace; font-size: 0.65rem; letter-spacing: 0.18em; text-transform: uppercase; color: #22d3ee; background: rgba(34, 211, 238, 0.1); border: 1px solid rgba(34, 211, 238, 0.25); padding: 3px 10px; border-radius: 2px; display: inline-block; margin-bottom: 0.8rem; }
#demo-card h3 { font-family: 'Segoe UI', sans-serif; font-size: 0.95rem; font-weight: 700; color: #f0f4ff; margin-bottom: 0.5rem; line-height: 1.3; }
#demo-card p { font-size: 0.85rem; color: #8899bb; line-height: 1.65; margin: 0; }
#demo-card p strong { color: #93c5fd; }
#demo-card p em { color: #22d3ee; font-style: normal; }
.demo-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 1.2rem; gap: 0.6rem; }
.demo-progress { display: flex; gap: 4px; align-items: center; }
.demo-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.15); transition: background 0.2s; }
.demo-dot.active { background: #22d3ee; }
.demo-dot.done { background: rgba(34,211,238,0.4); }
.demo-btn-group { display: flex; gap: 0.5rem; }
.demo-btn { font-family: 'Segoe UI', sans-serif; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; cursor: pointer; border-radius: 5px; border: none; padding: 7px 18px; transition: transform 0.15s, box-shadow 0.15s; }
.demo-btn:hover { transform: translateY(-1px); }
.demo-btn:active { transform: scale(0.97); }
.demo-btn-next { background: linear-gradient(135deg, #2563eb, #22d3ee); color: #060b17; box-shadow: 0 2px 12px rgba(34,211,238,0.25); }
.demo-btn-next:hover { box-shadow: 0 4px 20px rgba(34,211,238,0.4); }
.demo-btn-skip { background: rgba(255,255,255,0.07); color: #64748b; border: 1px solid rgba(255,255,255,0.12); }
.demo-btn-skip:hover { color: #94a3b8; background: rgba(255,255,255,0.12); }

/* --- WELCOME SCREEN --- */
#demo-welcome { position: fixed; inset: 0; z-index: 9100; background: rgba(4, 8, 20, 0.97); display: flex; align-items: center; justify-content: center; backdrop-filter: blur(8px); transition: opacity 0.5s ease; overflow-y: auto; padding: 20px; box-sizing: border-box; }
#demo-welcome.hidden { opacity: 0; pointer-events: none; }
.welcome-card { background: linear-gradient(135deg, rgba(13,21,48,0.98), rgba(8,15,35,0.98)); border: 1px solid rgba(59,130,246,0.3); border-radius: 16px; padding: 3rem 3.5rem; max-width: 520px; width: 100%; text-align: center; position: relative; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 60px rgba(34,211,238,0.05); margin: auto; }
.welcome-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, transparent, #3b82f6, #22d3ee, #3b82f6, transparent); }
.welcome-icon { font-size: 3rem; margin-bottom: 1rem; display: block; }
.welcome-card h2 { font-family: 'Segoe UI', sans-serif; font-size: 1.4rem; font-weight: 700; color: #f0f4ff; margin-bottom: 0.6rem; }
.welcome-card h2 span { background: linear-gradient(135deg, #3b82f6, #22d3ee); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.welcome-card p { font-size: 0.9rem; color: #7c92b8; line-height: 1.7; margin-bottom: 2rem; }
.welcome-feature-list { display: flex; flex-direction: column; gap: 0.6rem; text-align: left; margin-bottom: 2rem; }
.welcome-feature { display: flex; align-items: center; gap: 10px; padding: 0.6rem 1rem; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07); border-radius: 6px; font-size: 0.84rem; color: #94a3b8; }
.welcome-feature .wf-icon { font-size: 1rem; }
.welcome-feature strong { color: #60a5fa; }
.welcome-btn-group { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }
.welcome-btn-start { font-family: 'Segoe UI', sans-serif; font-size: 0.92rem; font-weight: 700; letter-spacing: 0.08em; color: #060b17; background: linear-gradient(135deg, #2563eb, #22d3ee); padding: 12px 32px; border-radius: 6px; border: none; cursor: pointer; box-shadow: 0 4px 20px rgba(34,211,238,0.25); transition: transform 0.2s, box-shadow 0.2s; display: flex; align-items: center; gap: 8px; }
.welcome-btn-start:hover { transform: translateY(-2px); box-shadow: 0 6px 30px rgba(34,211,238,0.4); }
.welcome-btn-skip-all { font-family: 'Segoe UI', sans-serif; font-size: 0.85rem; font-weight: 500; color: #4b5880; background: transparent; padding: 12px 24px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.1); cursor: pointer; transition: all 0.2s; }
.welcome-btn-skip-all:hover { color: #7c8fb3; border-color: rgba(255,255,255,0.2); }
@keyframes spotPulse { 0%,100% { box-shadow: 0 0 0 4000px rgba(4,8,20,0.82), 0 0 0 2px rgba(34,211,238,0.8), 0 0 20px rgba(34,211,238,0.4); } 50% { box-shadow: 0 0 0 4000px rgba(4,8,20,0.82), 0 0 0 2px rgba(34,211,238,1.0), 0 0 35px rgba(34,211,238,0.6); } }
#demo-spotlight.pulse { animation: spotPulse 1.8s ease-in-out infinite; }

/* RESPONSIVITAS KHUSUS HP MODE LANDSCAPE */
@media (max-height: 600px) {
    #demo-welcome { align-items: flex-start; }
    .welcome-card { padding: 1.5rem; border-radius: 12px; }
    .welcome-icon { font-size: 1.8rem; margin-bottom: 0.5rem; }
    .welcome-card h2 { font-size: 1.15rem; margin-bottom: 0.3rem; }
    .welcome-card p { font-size: 0.8rem; margin-bottom: 1rem; line-height: 1.4; }
    .welcome-feature-list { margin-bottom: 1.2rem; gap: 0.3rem; }
    .welcome-feature { padding: 0.4rem 0.6rem; font-size: 0.75rem; }
    .welcome-feature .wf-icon { font-size: 0.85rem; }
    .welcome-btn-group { gap: 0.5rem; }
    .welcome-btn-start, .welcome-btn-skip-all { padding: 8px 16px; font-size: 0.8rem; }
}

/* =========================================
   8. WIDGET LKPD (LEMBAR KERJA)
   ========================================= */
.lkpd-btn:hover { background: #3b82f6; color: white; box-shadow: 0 0 15px #3b82f6; }

#lkpd-widget {
    position: fixed;
    bottom: 20px;
    left: 20px; 
    width: 340px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(34, 211, 238, 0.4);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.7), 0 0 20px rgba(34,211,238,0.1);
    z-index: 8500;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
    display: flex;
    flex-direction: column;
}

#lkpd-widget.lkpd-hidden {
    transform: translateY(120%) scale(0.9);
    opacity: 0;
    pointer-events: none;
}

#lkpd-widget.minimized .lkpd-content {
    display: none;
}

.lkpd-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(90deg, rgba(37,99,235,0.2), rgba(34,211,238,0.1));
    border-bottom: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px 12px 0 0;
}

.lkpd-header h3 { font-size: 1rem; color: #f0f4ff; margin: 0; }

#btn-toggle-lkpd {
    background: transparent; border: none; color: #64748b; font-weight: bold; cursor: pointer; padding: 0 5px; font-size: 1rem;
}
#btn-toggle-lkpd:hover { color: #22d3ee; }

#btn-close-lkpd { transition: transform 0.2s; }
#btn-close-lkpd:hover { color: #f87171 !important; transform: scale(1.1); }

.lkpd-content {
    padding: 16px;
    max-height: 60vh;
    overflow-y: auto;
}

.mission-card { display: none; animation: fadeIn 0.3s; }
.mission-card.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.mission-badge {
    font-family: 'Consolas', monospace; font-size: 0.7rem; color: #22d3ee;
    background: rgba(34,211,238,0.1); padding: 3px 8px; border-radius: 4px; border: 1px solid rgba(34,211,238,0.3);
}

.mission-card h4 { margin: 10px 0 5px 0; color: #f0f4ff; font-size: 1.05rem; }
.mission-card p { font-size: 0.85rem; color: #94a3b8; margin-bottom: 12px; }

.mission-inst {
    background: rgba(0,0,0,0.4); border-left: 3px solid #3b82f6; padding: 10px;
    font-size: 0.85rem; color: #cbd5e1; border-radius: 4px; margin-bottom: 12px;
}

.mission-qna label { font-size: 0.85rem; color: #f0f4ff; display: block; margin-bottom: 5px; font-weight: 500; }
.mission-qna textarea {
    width: 100%; background: rgba(0,0,0,0.3); border: 1px solid #334155;
    border-radius: 6px; padding: 8px; color: #22d3ee; font-family: 'Consolas', monospace;
    font-size: 0.85rem; margin-bottom: 12px; resize: vertical;
}
.mission-qna textarea:focus { outline: none; border-color: #22d3ee; box-shadow: 0 0 5px rgba(34,211,238,0.3); }

.mission-btn {
    width: 100%; padding: 8px; background: linear-gradient(135deg, #2563eb, #22d3ee);
    color: #000; border: none; border-radius: 6px; font-weight: 600; cursor: pointer;
    margin-top: 5px; flex: 1; transition: filter 0.2s;
}
.mission-btn.outline { background: transparent; color: #22d3ee; border: 1px solid #22d3ee; }
.mission-btn:hover { filter: brightness(1.1); }

.mission-success { text-align: center; color: #10b981; font-weight: bold; margin-top: 15px; font-size: 0.9rem; }