@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --bg-dark: #1a1d23;
  --bg-editor: #21252b;
  --bg-sidebar: #282c34;
  --accent: #00bfa5;
  --accent-glow: rgba(0, 191, 165, 0.25);
  --text: #e4e8ee;
  --text-dim: #7a8394;
  --border: #333842;
  --success: #4ec9b0;
  --warning: #e5c07b;
  --error: #e06c75;
  --keyword: #c678dd;
  --string: #98c379;
  --function: #61afef;
  --number: #d19a66;
  --comment: #5c6370;
}

html, body { height: 100%; overflow: hidden; background: var(--bg-dark); color: var(--text); font-family: 'Inter', sans-serif; }

/* ═══════════════════════════════════════════════════
   TOP BAR
   ═══════════════════════════════════════════════════ */
.topbar {
  height: 48px; display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-sidebar); border-bottom: 1px solid var(--border); padding: 0 20px; flex-shrink: 0;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-brand svg { width: 26px; height: 26px; }
.topbar-brand span { font-weight: 700; font-size: 15px; letter-spacing: 0.5px; }
.topbar-brand .av { color: var(--accent); }
.topbar-status { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 16px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.status-dot.on { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.off { background: var(--error); }

/* ═══════════════════════════════════════════════════
   MAIN LAYOUT — 30 / 70
   ═══════════════════════════════════════════════════ */
.main { display: flex; height: calc(100% - 48px); }

/* ═══════════════════════════════════════════════════
   EDITOR PANEL (30%)
   ═══════════════════════════════════════════════════ */
.editor-panel {
  width: 30%; min-width: 320px; display: flex; flex-direction: column;
  background: var(--bg-editor); border-right: 1px solid var(--border);
}
.editor-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--bg-sidebar);
}
.editor-toolbar .tab {
  font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-dim);
  padding: 4px 12px; border-radius: 4px; cursor: default;
}
.editor-toolbar .tab.active { background: var(--bg-editor); color: var(--text); }
.editor-actions { display: flex; gap: 6px; }
.btn {
  border: none; border-radius: 6px; padding: 7px 16px; font-size: 13px; font-weight: 600;
  font-family: 'Inter', sans-serif; cursor: pointer; display: flex; align-items: center; gap: 6px;
  transition: all 0.15s;
}
.btn-run { background: var(--accent); color: #111; }
.btn-run:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn-run:active { transform: translateY(0); }
.btn-stop { background: var(--error); color: #fff; }
.btn-stop:hover { filter: brightness(1.15); }
.btn-reset { background: var(--border); color: var(--text-dim); }
.btn-reset:hover { background: #444; color: var(--text); }

.editor-wrap { flex: 1; position: relative; overflow: hidden; }
.line-numbers {
  position: absolute; left: 0; top: 0; bottom: 0; width: 44px;
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
  padding: 14px 0; font-family: 'JetBrains Mono', monospace; font-size: 13px;
  line-height: 1.7; color: var(--text-dim); text-align: right; overflow: hidden;
  user-select: none;
}
.line-numbers span { display: block; padding-right: 10px; }
#code-editor {
  position: absolute; left: 44px; top: 0; right: 0; bottom: 0;
  background: transparent; color: var(--text); border: none; outline: none; resize: none;
  font-family: 'JetBrains Mono', monospace; font-size: 13px; line-height: 1.7;
  padding: 14px 16px; tab-size: 4; white-space: pre; overflow: auto;
}
#code-editor::selection { background: rgba(0,191,165,0.2); }

/* ═══════════════════════════════════════════════════
   CONSOLE
   ═══════════════════════════════════════════════════ */
.console-panel {
  height: 180px; border-top: 1px solid var(--border); background: var(--bg-dark);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.console-header {
  padding: 6px 14px; font-size: 11px; font-weight: 600; color: var(--text-dim);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px;
  text-transform: uppercase; letter-spacing: 0.8px;
}
.console-header svg { width: 13px; height: 13px; opacity: 0.6; }
#console-output {
  flex: 1; padding: 10px 14px; overflow-y: auto; font-family: 'JetBrains Mono', monospace;
  font-size: 12px; line-height: 1.6;
}
.log-line { margin-bottom: 2px; }
.log-info { color: var(--success); }
.log-warn { color: var(--warning); }
.log-error { color: var(--error); }
.log-cmd { color: var(--function); }
.log-system { color: var(--text-dim); }

/* ═══════════════════════════════════════════════════
   3D SCENE PANEL (70%)
   ═══════════════════════════════════════════════════ */
.scene-panel { flex: 1; position: relative; background: #1a1d23; }
#scene-canvas { display: block; width: 100%; height: 100%; }
.scene-overlay {
  position: absolute; bottom: 14px; left: 14px;
  display: flex; gap: 8px; z-index: 10;
}
.overlay-badge {
  background: rgba(0,0,0,0.65); backdrop-filter: blur(8px); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 12px; font-size: 11px; color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}
.overlay-badge .val { color: var(--accent); font-weight: 600; }
.camera-controls {
  position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 4px; z-index: 10;
}
.cam-btn {
  width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--border);
  background: rgba(0,0,0,0.55); backdrop-filter: blur(8px); color: var(--text-dim);
  cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px;
  transition: all 0.15s;
}
.cam-btn:hover { background: rgba(0,191,165,0.15); color: var(--accent); border-color: var(--accent); }

/* ═══════════════════════════════════════════════════
   LEVEL BADGE
   ═══════════════════════════════════════════════════ */
.level-badge {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 10;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(10px); border: 1px solid var(--accent);
  border-radius: 8px; padding: 6px 18px; font-size: 13px; font-weight: 600;
  color: var(--accent); font-family: 'JetBrains Mono', monospace;
  box-shadow: 0 0 20px rgba(0,191,165,0.15);
}

/* ═══════════════════════════════════════════════════
   REFERENCE PANEL
   ═══════════════════════════════════════════════════ */
.ref-toggle {
  position: absolute; top: 14px; left: 14px; z-index: 10;
}
.ref-panel {
  position: absolute; top: 52px; left: 14px; z-index: 10;
  background: rgba(0,0,0,0.8); backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; width: 280px; max-height: 70%;
  overflow-y: auto; display: none; font-size: 12px;
}
.ref-panel.open { display: block; }
.ref-panel h3 { color: var(--accent); font-size: 13px; margin-bottom: 10px; }
.ref-panel code {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  background: rgba(255,255,255,0.06); padding: 1px 5px; border-radius: 3px;
}
.ref-panel .ref-item { margin-bottom: 8px; line-height: 1.5; color: var(--text-dim); }
.ref-panel .ref-item strong { color: var(--text); font-weight: 500; }

/* ═══════════════════════════════════════════════════
   MODALS (Success & Crash)
   ═══════════════════════════════════════════════════ */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(6px);
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--bg-sidebar); border: 1px solid var(--accent);
  border-radius: 16px; padding: 0; width: 420px; max-width: 90vw;
  box-shadow: 0 0 60px rgba(0,191,165,0.25), 0 20px 40px rgba(0,0,0,0.5);
  overflow: hidden; animation: modalIn 0.4s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.85) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  background: linear-gradient(135deg, var(--accent), #00897b);
  padding: 28px 32px 22px; text-align: center;
}
.modal-header .trophy { font-size: 52px; margin-bottom: 8px; display: block; }
.modal-header h2 {
  font-size: 22px; font-weight: 700; color: #fff; margin: 0;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.modal-header p {
  color: rgba(255,255,255,0.85); font-size: 13px; margin-top: 6px;
}
.modal-body { padding: 24px 32px 28px; text-align: center; }
.modal-body .stats {
  display: flex; justify-content: center; gap: 24px; margin-bottom: 20px;
}
.modal-body .stat-item {
  background: var(--bg-dark); border-radius: 10px; padding: 12px 18px; min-width: 90px;
}
.modal-body .stat-val {
  font-family: 'JetBrains Mono', monospace; font-size: 20px;
  font-weight: 700; color: var(--accent);
}
.modal-body .stat-label { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.btn-restart {
  background: var(--accent); color: #111; border: none; border-radius: 10px;
  padding: 12px 36px; font-size: 15px; font-weight: 700; cursor: pointer;
  font-family: 'Inter', sans-serif; transition: all 0.15s;
  box-shadow: 0 4px 16px rgba(0,191,165,0.3);
}
.btn-restart:hover { filter: brightness(1.15); transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,191,165,0.4); }
.btn-restart:active { transform: translateY(0); }

/* ═══════════════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }
