/* ============================================================
   Memory Leak Hunter — Styles
   IDE-themed dark aesthetic with memory usage gauges
   ============================================================ */
:root {
  --green: #22C55E;
  --red: #EF4444;
  --amber: #F59E0B;
  --cyan: #06B6D4;
  --purple: #A855F7;
  --bg: #1E1E2E;
  --bg-darker: #181825;
  --bg-editor: #11111B;
  --bg-card: rgba(30, 30, 46, 0.9);
  --text: #CDD6F4;
  --text-dim: #6C7086;
  --text-muted: #45475A;
  --border: rgba(205, 214, 244, 0.06);
  --line-highlight: rgba(239, 68, 68, 0.08);
  --font: 'JetBrains Mono', monospace;
  --radius: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg-darker); color: var(--text); min-height: 100vh; display: flex; justify-content: center; }
#app { width: 100%; max-width: 760px; margin: 1rem; display: flex; flex-direction: column; gap: 0; }

/* Top Bar */
.top-bar { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0.75rem; background: var(--bg); border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.logo { font-size: 0.9rem; font-weight: 700; }
.header-stats { display: flex; gap: 0.75rem; align-items: center; font-size: 0.7rem; }

/* Memory Gauge */
.mem-gauge { display: flex; align-items: center; gap: 0.3rem; }
.gauge-label { font-size: 0.55rem; color: var(--text-muted); }
.gauge-bar { width: 60px; height: 8px; background: var(--bg-editor); border-radius: 4px; overflow: hidden; }
.gauge-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--amber), var(--red)); width: 0%; transition: width 0.5s ease; border-radius: 4px; }
.gauge-value { font-size: 0.6rem; color: var(--amber); min-width: 28px; }

#score-display { color: var(--cyan); font-weight: 600; }
#timer-display { color: var(--amber); font-weight: 600; }

/* Screens */
.screen { flex: 1; display: flex; flex-direction: column; background: var(--bg); padding: 1rem; min-height: 400px; border-radius: 0 0 var(--radius) var(--radius); }

/* Menu */
.menu-content { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; flex: 1; text-align: center; }
.ascii-title { font-size: 0.6rem; color: var(--cyan); line-height: 1.4; }
.subtitle { font-size: 0.75rem; color: var(--text-dim); }
.menu-actions { display: flex; flex-direction: column; gap: 0.4rem; min-width: 200px; }

/* Buttons */
.btn-primary { padding: 0.6rem 1.5rem; background: var(--cyan); color: var(--bg-darker); font-weight: 700; font-family: var(--font); border: none; border-radius: var(--radius); cursor: pointer; font-size: 0.8rem; transition: transform 0.1s; }
.btn-primary:hover { transform: scale(1.02); }
.btn-secondary { padding: 0.5rem 1.2rem; background: rgba(6,182,212,0.1); color: var(--cyan); font-family: var(--font); border: 1px solid rgba(6,182,212,0.2); border-radius: var(--radius); cursor: pointer; font-size: 0.75rem; }
.btn-ghost { padding: 0.4rem 1rem; background: transparent; color: var(--text-dim); font-family: var(--font); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: 0.7rem; }
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }
.btn-hint { padding: 0.25rem 0.6rem; background: rgba(245,158,11,0.08); color: var(--amber); font-family: var(--font); border: 1px solid rgba(245,158,11,0.15); border-radius: 6px; cursor: pointer; font-size: 0.65rem; }

/* Level Bar */
.level-bar { display: flex; justify-content: space-between; align-items: center; font-size: 0.7rem; color: var(--text-dim); margin-bottom: 0.75rem; }
.diff-badge { padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.6rem; font-weight: 600; }

/* Code Editor */
.code-editor { background: var(--bg-editor); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; flex: 1; }
.code-line {
  display: flex; padding: 0.15rem 0; cursor: pointer; transition: background 0.15s;
  border-left: 3px solid transparent;
}
.code-line:hover { background: rgba(205,214,244,0.03); }
.code-line.selected { background: var(--line-highlight); border-left-color: var(--red); }
.code-line.correct { background: rgba(34,197,94,0.1); border-left-color: var(--green); }
.code-line.wrong { background: rgba(239,68,68,0.15); border-left-color: var(--red); }
.line-num { min-width: 36px; text-align: right; padding-right: 0.5rem; color: var(--text-muted); font-size: 0.7rem; user-select: none; }
.line-code { flex: 1; font-size: 0.72rem; white-space: pre-wrap; word-break: break-all; padding-right: 0.5rem; }

/* Syntax colors */
.kw { color: #CBA6F7; } /* keyword */
.fn { color: #89B4FA; } /* function */
.st { color: #A6E3A1; } /* string */
.cm { color: var(--text-muted); font-style: italic; } /* comment */
.nm { color: #FAB387; } /* number */
.op { color: #F38BA8; } /* operator */

.hint-text { font-size: 0.7rem; color: var(--amber); background: rgba(245,158,11,0.05); border: 1px solid rgba(245,158,11,0.1); border-radius: var(--radius); padding: 0.5rem 0.75rem; margin-top: 0.5rem; }

/* Explain */
.explain-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.explain-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.result-badge { font-weight: 700; font-size: 1rem; }
.result-badge.success { color: var(--green); }
.result-badge.fail { color: var(--red); }
#round-score { font-size: 0.8rem; color: var(--cyan); font-weight: 600; }
.explain-code { background: var(--bg-editor); border-radius: 6px; padding: 0.5rem; font-size: 0.7rem; margin-bottom: 0.75rem; overflow-x: auto; }
.explain-desc { font-size: 0.75rem; color: var(--text-dim); line-height: 1.6; margin-bottom: 1rem; }

/* Results */
.results-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem 1rem; font-size: 0.8rem; text-align: left; margin-bottom: 1rem; }
.r-label { color: var(--text-muted); }
.r-value { font-weight: 700; color: var(--cyan); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.6); }
.modal-inner { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; max-width: 380px; width: 90%; text-align: center; }
.modal-inner h2 { margin-bottom: 0.75rem; font-size: 1rem; }
.score-entry { display: flex; justify-content: space-between; font-size: 0.7rem; padding: 0.2rem 0; border-bottom: 1px solid var(--border); }

@media (max-width: 480px) {
  #app { margin: 0; }
  .top-bar, .screen { border-radius: 0; }
}
