/* HexNet — dark-fantasy netrunner theme. */
:root {
  --bg: #0d0a17;
  --bg2: #141021;
  --panel: #1a1428;
  --panel2: #221a36;
  --border: #2e2547;
  --text: #e6e0f0;
  --muted: #9a8fb8;
  --gold: #e8b84b;
  --gold-dim: #a8853a;
  --violet: #8d6bff;
  --cyan: #6fd3ff;
  --green: #48d597;
  --red: #ff6b81;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 70% -20%, #2a1e4a 0%, var(--bg) 55%);
  color: var(--text);
  font-family: system-ui, "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: linear-gradient(180deg, rgba(141,107,255,.12), transparent);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; flex-direction: column; }
.logo {
  font-size: 20px; font-weight: 800; letter-spacing: .5px; color: var(--gold);
  text-shadow: 0 0 14px rgba(232,184,75,.35);
}
.tagline { font-size: 12px; color: var(--muted); }

.character { display: flex; align-items: center; gap: 14px; cursor: pointer; padding: 6px 10px; border-radius: 10px; border: 1px solid transparent; transition: background .15s ease, border-color .15s ease; }
.character:hover { background: var(--panel); border-color: var(--border); }
.char-text { display: flex; flex-direction: column; align-items: flex-end; }
.name { font-weight: 700; }
.rank { font-size: 11px; color: var(--gold); text-transform: uppercase; letter-spacing: 1px; }
.streak { font-size: 11px; color: var(--gold); font-family: var(--mono); }
.xp-block { display: flex; align-items: center; gap: 8px; }
.xp-wrap { width: 160px; height: 10px; border-radius: 6px; background: #0a0714; border: 1px solid var(--border); overflow: hidden; }
.xp-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--violet), var(--gold)); transition: width .35s ease; }
.lvl { font-family: var(--mono); font-size: 12px; color: var(--cyan); min-width: 34px; text-align: right; }

/* ---------- Layout ---------- */
.layout { display: flex; flex: 1; min-height: 0; }
.sidebar { width: 270px; flex-shrink: 0; border-right: 1px solid var(--border); background: var(--bg2); overflow-y: auto; padding: 14px 10px; }
.content { flex: 1; padding: 22px 26px; overflow-y: auto; }

/* ---------- Sidebar ---------- */
.chapter { margin-bottom: 12px; }
.chapter-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--violet); margin: 0 0 6px; font-weight: 700; }
.quest-link { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--text); font-size: 14px; border: 1px solid transparent; }
.quest-link:hover { background: var(--panel); }
.quest-link.active { background: var(--panel2); border-color: var(--violet); }
.quest-link.locked { opacity: .45; cursor: not-allowed; }
.quest-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--muted); }
.quest-link.done .quest-dot { background: var(--green); }
.quest-link.unlocked .quest-dot { background: var(--gold); }
.boss-tag { margin-left: auto; font-size: 12px; flex-shrink: 0; }
.progress-line { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; margin-bottom: 12px; border-radius: 8px; background: var(--panel); border: 1px solid var(--border); font-size: 12px; font-family: var(--mono); color: var(--muted); }
.progress-frac { color: var(--gold); }

/* ---------- Quest view ---------- */
.quest-head { margin-bottom: 18px; }
.quest-kicker { font-size: 12px; color: var(--violet); text-transform: uppercase; letter-spacing: 1px; }
.quest-head h1 { margin: 4px 0 6px; font-size: 26px; }
.quest-xp { font-size: 13px; color: var(--gold); font-family: var(--mono); }
.glyph-badge { display: inline-block; margin-top: 6px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; letter-spacing: .5px; color: #0d0a17; background: linear-gradient(90deg, var(--green), #8ff0c0); box-shadow: 0 0 14px rgba(72,213,151,.45); }

.story, .brief { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--violet); border-radius: 8px; padding: 14px 16px; margin-bottom: 14px; line-height: 1.6; }
.brief { border-left-color: var(--gold); }
.story p, .brief p { margin: 0; color: #cfc7e0; }

.lesson { background: var(--panel2); border: 1px solid var(--border); border-left: 3px solid var(--cyan); border-radius: 8px; padding: 14px 16px; margin-bottom: 14px; line-height: 1.6; }
.lesson p { margin: 0; color: #cfe7f2; }
.lesson p strong { color: var(--cyan); }

.hint-toggle { background: none; border: 1px dashed var(--border); color: var(--muted); border-radius: 6px; padding: 6px 10px; font-size: 13px; cursor: pointer; margin-bottom: 14px; }
.hint-toggle:hover { color: var(--gold); border-color: var(--gold-dim); }
.hint-body { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; color: var(--muted); font-size: 14px; display: none; }
.hint-body.open { display: block; }

/* ---------- Terminal ---------- */
.terminal-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.terminal {
  background: #06040b; border: 1px solid var(--border); border-radius: 10px;
  display: flex; flex-direction: column; overflow: hidden; min-height: 260px;
}
.term-titlebar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: #0a0714; border-bottom: 1px solid var(--border); }
.term-dot { width: 10px; height: 10px; border-radius: 50%; }
.term-dot.r { background: #ff5f57; }
.term-dot.y { background: #febc2e; }
.term-dot.g { background: #28c840; }
.term-title { margin-left: 8px; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.term-output {
  flex: 1; padding: 12px 16px; font-family: var(--mono); font-size: 14px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; color: #bce8d0; overflow-y: auto; max-height: 380px;
}
.term-output .ok { color: var(--green); }
.term-output .warn { color: var(--red); }
.term-output .glyph { color: var(--gold); font-weight: 700; }
.term-output .promptline { color: #8fd3ff; }
.term-line { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); background: #0a0714; }
.term-prompt { color: var(--cyan); font-family: var(--mono); font-size: 14px; white-space: nowrap; }
.term-input { flex: 1; background: transparent; border: none; outline: none; color: #d8f6e4; font-family: var(--mono); font-size: 14px; caret-color: var(--green); }

/* ---------- Result ---------- */
.result { padding: 12px 16px; border-radius: 8px; border: 1px solid var(--border); font-weight: 600; display: none; margin: 14px 0; white-space: pre-wrap; }
.result.pass { display: block; background: rgba(72,213,151,.12); border-color: var(--green); color: var(--green); }
.result.fail { display: block; background: rgba(255,107,129,.1); border-color: var(--red); color: var(--red); }

/* ---------- Footer ---------- */
.footer { text-align: center; font-size: 12px; color: var(--muted); padding: 12px; border-top: 1px solid var(--border); }

/* ---------- Buttons ---------- */
.btn { border: 1px solid var(--border); border-radius: 8px; padding: 9px 18px; cursor: pointer; font-size: 14px; font-weight: 600; background: var(--panel2); color: var(--text); }
.btn:hover { border-color: var(--violet); }

/* ---------- RPG polish ---------- */
#toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px); background: linear-gradient(135deg, var(--violet), #6f4fe0); color: #fff; padding: 10px 20px; border-radius: 24px; font-weight: 700; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease; box-shadow: 0 8px 24px rgba(0,0,0,.5); z-index: 60; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.levelup-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(10,7,20,.82); backdrop-filter: blur(3px); animation: fadeIn .2s ease; }
.levelup-card { background: linear-gradient(160deg, var(--panel2), var(--panel)); border: 1px solid var(--green); border-radius: 18px; padding: 34px 40px; text-align: center; max-width: 360px; width: 90%; box-shadow: 0 0 50px rgba(72,213,151,.35); animation: popIn .35s cubic-bezier(.34,1.4,.64,1); }
.levelup-icon { font-size: 52px; color: var(--green); text-shadow: 0 0 22px rgba(72,213,151,.8); margin-bottom: 8px; }
.levelup-title { font-size: 30px; font-weight: 800; color: var(--green); letter-spacing: 1px; }
.levelup-level { font-size: 18px; font-weight: 700; color: var(--cyan); margin-top: 10px; font-family: var(--mono); }
.levelup-rank { font-size: 14px; color: var(--violet); margin-top: 6px; text-transform: uppercase; letter-spacing: 1px; }
.levelup-glyph { font-size: 14px; color: var(--gold); margin-top: 8px; font-family: var(--mono); }
.levelup-ok { margin-top: 22px; background: linear-gradient(135deg, var(--green), #48d597); color: #0d0a17; font-weight: 800; }

.sheet-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(10,7,20,.82); backdrop-filter: blur(3px); animation: fadeIn .2s ease; }
.sheet { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 26px 28px; width: 92%; max-width: 460px; max-height: 88vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.55); animation: popIn .3s cubic-bezier(.34,1.4,.64,1); }
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.sheet-title { font-size: 22px; font-weight: 800; color: var(--gold); }
.sheet-rank { font-size: 12px; color: var(--violet); text-transform: uppercase; letter-spacing: 1px; }
.sheet-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.sheet-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.sheet-input { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-size: 15px; font-family: inherit; }
.sheet-input:focus { outline: none; border-color: var(--violet); }
.sheet-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.sheet-stat { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; text-align: center; }
.sheet-stat-v { font-size: 20px; font-weight: 800; color: var(--text); font-family: var(--mono); }
.sheet-stat-l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 3px; }
.sheet-progress-wrap { height: 10px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); overflow: hidden; margin-bottom: 18px; }
.sheet-progress-bar { height: 100%; background: linear-gradient(90deg, var(--violet), var(--gold)); transition: width .4s ease; }
.sheet-sub { font-size: 12px; color: var(--gold); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; font-weight: 700; }
.sheet-glyphs { display: flex; flex-direction: column; gap: 5px; margin-bottom: 18px; }
.sheet-glyph { font-size: 14px; color: var(--green); padding: 6px 10px; background: var(--bg2); border-radius: 6px; border: 1px solid var(--border); font-family: var(--mono); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.86); } to { opacity: 1; transform: scale(1); } }

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .topbar { flex-wrap: wrap; }
  .xp-wrap { width: 90px; }
  .content { padding: 16px; }
  .term-output { max-height: 260px; }
}
