/* ===================== Culori și variabile ===================== */

:root {
  --bg: #f5f4fb;
  --surface: #ffffff;
  --surface-2: #f0eef9;
  --text: #1d1a2e;
  --muted: #6b6785;
  --border: #e3e0f0;

  --primary: #6c4cf1;
  --primary-ink: #ffffff;
  --primary-soft: #ece7ff;
  --accent: #ff8a3d;
  --gold: #f5b301;

  --ok: #148a5b;
  --ok-soft: #e1f6ec;
  --bad: #d93b40;
  --bad-soft: #fdeaea;
  --tip: #8a6100;
  --tip-soft: #fff5d9;
  --life: #1f6fb2;
  --life-soft: #e5f2fd;
  --langs: #5a5675;
  --langs-soft: #f2f1f6;

  --code-bg: #1e1b2e;
  --code-text: #ece9f7;
  --tok-k: #c79bff;
  --tok-o: #ff8a3d;
  --tok-n: #ffd27a;
  --tok-s: #8be9a8;
  --tok-c: #8f8aa8;

  --shadow: 0 1px 0 rgba(29, 26, 46, .05), 0 8px 24px rgba(29, 26, 46, .07);
  --radius: 18px;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #13111c;
    --surface: #1d1a2a;
    --surface-2: #26223a;
    --text: #edebf7;
    --muted: #a19cbc;
    --border: #322d48;
    --primary: #8f76ff;
    --primary-ink: #120f1f;
    --primary-soft: #2c2550;
    --ok: #4fd39b;
    --ok-soft: #173a2c;
    --bad: #ff7378;
    --bad-soft: #43202a;
    --tip: #ffd36b;
    --tip-soft: #3a3016;
    --life: #7cc0ff;
    --life-soft: #162f47;
    --langs: #c4c0da;
    --langs-soft: #24212f;
    --code-bg: #0e0c16;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

/* ===================== Bază ===================== */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; font-weight: 900; }
h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); }
h2 { font-size: 1.35rem; }
p { margin: 0 0 .8em; }
a { color: var(--primary); }

code, samp, pre { font-family: var(--mono); font-size: .9em; }
:not(pre) > code {
  background: var(--primary-soft);
  color: var(--text);
  padding: .1em .4em;
  border-radius: 6px;
  overflow-wrap: anywhere;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
main:focus { outline: none; }

.container { max-width: 900px; margin: 0 auto; padding: 24px 16px 80px; }
.muted { color: var(--muted); }
.lead { font-size: 1.1rem; color: var(--muted); }
.eyebrow { display: block; font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--primary); }
.section-title { margin: 36px 0 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* ===================== Butoane ===================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4em;
  font: inherit;
  font-weight: 800;
  padding: .7em 1.3em;
  border-radius: 14px;
  border: 0;
  background: var(--primary);
  color: var(--primary-ink);
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--primary) 60%, #000);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--primary) 60%, #000); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-lg { font-size: 1.1rem; padding: .85em 1.6em; }
.btn-sm { font-size: .9rem; padding: .5em 1em; }
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
  box-shadow: 0 3px 0 var(--border);
}
.btn-danger { background: var(--bad); color: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--bad) 60%, #000); }

.icon-btn {
  font-size: 1.15rem;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex: none;
}

.pill {
  display: inline-block;
  font-size: .8rem;
  font-weight: 800;
  padding: .2em .8em;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--muted);
}

/* ===================== Bara de sus ===================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-size: 1.25rem; }
.brand-logo {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-family: var(--mono);
  font-weight: 600;
  font-size: .95rem;
}
.brand-name b { color: var(--primary); }

.hud { display: flex; align-items: center; gap: 10px; }
.hud-streak { font-weight: 900; white-space: nowrap; }
.hud-streak.off { filter: grayscale(1); opacity: .55; }
.hud-level {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: .9rem;
  white-space: nowrap;
}
.xpbar { width: 80px; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.xpbar span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--accent)); border-radius: inherit; transition: width .5s; }
.hud-xp { color: var(--muted); }

.xp-float {
  position: absolute;
  right: 8px;
  top: calc(100% + 6px);
  font-weight: 900;
  color: var(--accent);
  pointer-events: none;
  animation: float-up 1.2s ease-out forwards;
}
@keyframes float-up {
  from { opacity: 0; transform: translateY(10px); }
  20% { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-8px); }
}

/* ===================== Bare de progres și stele ===================== */

.bar { flex: 1; height: 14px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar.small { flex: none; height: 8px; margin: 12px 0 6px; }
.bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .4s; }

.stars { color: var(--gold); letter-spacing: 2px; font-size: 1.15rem; white-space: nowrap; }
.star-off { color: var(--border); }

/* ===================== Ecran de bun venit și acasă ===================== */

.welcome { text-align: center; padding: 40px 24px; }
.welcome-art { font-size: 4rem; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-10px); } }
.name-form { max-width: 480px; margin: 24px auto 0; text-align: left; }
.name-form label { font-weight: 800; display: block; margin-bottom: 6px; }
.name-row { display: flex; gap: 10px; flex-wrap: wrap; }
.name-form small { color: var(--muted); display: block; margin-top: 8px; }

input[type="text"], input[type="number"], input:not([type]) {
  font: inherit;
  padding: .65em .9em;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  min-width: 0;
}
.name-row input { flex: 1 1 200px; }

.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: center; }
.hero-stats { display: grid; gap: 10px; }
.stat {
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.stat-icon { grid-row: span 2; font-size: 1.8rem; text-align: center; }
.stat small { color: var(--muted); line-height: 1.3; }

.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.module-card { display: flex; flex-direction: column; text-decoration: none; color: var(--text); transition: transform .15s, border-color .15s; }
a.module-card:hover { transform: translateY(-3px); border-color: var(--primary); }
.module-card p { color: var(--muted); flex: 1; }
.module-card .pill { align-self: flex-start; }
.module-icon { font-size: 2.2rem; }
.module-meta { display: flex; justify-content: space-between; font-size: .9rem; font-weight: 700; color: var(--muted); }
.module-card.soon { opacity: .6; box-shadow: none; }

/* ===================== Capitol: drumul lecțiilor ===================== */

.crumbs { margin-bottom: 14px; font-weight: 700; }
.crumbs a { text-decoration: none; }

.page-head { display: flex; gap: 18px; align-items: center; margin-bottom: 24px; }
.page-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  font-size: 2.3rem;
  border-radius: 22px;
  background: var(--primary-soft);
}
.page-head .lead { margin: 0; }

.path { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; position: relative; }
.path::before {
  content: '';
  position: absolute;
  left: 39px;
  top: 30px;
  bottom: 30px;
  border-left: 4px dotted var(--border);
}
.node > a, .node > div {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px 14px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: transform .15s, border-color .15s;
}
.node > a:hover { transform: translateX(4px); border-color: var(--primary); }
.node-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  font-size: 1.6rem;
  border-radius: 50%;
  background: var(--surface-2);
}
.node.open .node-icon { background: var(--primary); box-shadow: 0 0 0 6px var(--primary-soft); }
.node.done .node-icon { background: var(--ok-soft); }
.node-body { flex: 1; display: grid; }
.node-body small { color: var(--muted); line-height: 1.4; }
.node.locked { opacity: .55; }
.node.boss > a, .node.boss > div { border-color: var(--gold); background: linear-gradient(135deg, var(--surface), color-mix(in srgb, var(--gold) 12%, var(--surface))); }

/* ===================== Lecție ===================== */

/* minmax(0, 1fr): coloana nu are voie să crească după cel mai lung rând de cod. */
.lesson { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.sec-h { margin: 18px 0 0; }
.sec-text { font-size: 1.05rem; }

.callout { border-radius: var(--radius); padding: 16px 20px; border-left: 6px solid; }
.callout-title { font-weight: 900; margin-bottom: 4px; }
.callout ul { margin: 6px 0 0; padding-left: 1.2em; }
.callout li { margin: 4px 0; }
.callout.life { background: var(--life-soft); border-color: var(--life); }
.callout.life .callout-title { color: var(--life); }
.callout.tip { background: var(--tip-soft); border-color: var(--gold); }
.callout.tip .callout-title { color: var(--tip); }
.callout.warn { background: var(--bad-soft); border-color: var(--bad); }
.callout.warn .callout-title { color: var(--bad); }
.callout.remember { background: var(--primary-soft); border-color: var(--primary); }
.callout.remember .callout-title { color: var(--primary); }
.callout.langs { background: var(--langs-soft); border-color: var(--langs); }
.callout.langs .callout-title { color: var(--langs); }
.langs-note { margin: 10px 0 0; font-size: .95rem; }
.callout :not(pre) > code { background: var(--surface); }

.code-fig { margin: 0; }
pre.code {
  margin: 0;
  padding: 16px 20px;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: 14px;
  overflow-x: auto;
  line-height: 1.7;
  font-size: .95rem;
}
.code-fig pre.code { border-radius: 14px 14px 0 0; }
.tok-k { color: var(--tok-k); font-weight: 600; }
.tok-o { color: var(--tok-o); font-weight: 600; }
.tok-n { color: var(--tok-n); }
.tok-s { color: var(--tok-s); }
.tok-c { color: var(--tok-c); font-style: italic; }

.output {
  display: flex;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 14px 14px;
  font-size: .9rem;
}
.output span { color: var(--muted); font-weight: 700; }
.output samp { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 600; font-size: 1rem; }

.tbl-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-size: .97rem; }
.tbl th, .tbl td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.tbl th { background: var(--surface-2); font-weight: 800; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl-langs th:first-child, .tbl-langs td:first-child { font-weight: 700; }
/* Tabelele derulează orizontal, deci codul din ele rămâne pe un singur rând. */
.tbl code { white-space: nowrap; overflow-wrap: normal; }

.cta { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 32px; flex-wrap: wrap; }
.cta p { margin: 0; color: var(--muted); }

/* ===================== Laborator ===================== */

.lab {
  border-radius: var(--radius);
  border: 2px dashed var(--primary);
  background: var(--surface);
  padding: 18px 20px;
}
.lab-head h3 { margin: 6px 0 2px; }
.lab-head p { color: var(--muted); margin-bottom: 12px; }
.lab-badge { font-size: .8rem; font-weight: 900; color: var(--primary); background: var(--primary-soft); padding: .2em .7em; border-radius: 99px; }

.lab-inputs { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.num { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-weight: 600; }
.num input { width: 110px; font-family: var(--mono); }

.lab-rows { display: grid; gap: 6px; }
.lab-row {
  display: grid;
  grid-template-columns: minmax(130px, auto) 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-2);
}
.lab-row code { background: none !important; padding: 0 !important; font-weight: 600; white-space: pre; }
.lab-name { color: var(--muted); font-size: .9rem; }
.lab-res { font-family: var(--mono); font-size: 1.05rem; text-align: right; }
.lab-res.t { color: var(--ok); }
.lab-res.f, .lab-res.err { color: var(--bad); }
.lab-res.err { font-size: .85rem; }

.lab-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chip {
  font: inherit;
  padding: .45em .8em;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.chip code { background: none !important; padding: 0 !important; }
.chip:hover { border-color: var(--primary); }
.chip.active { border-color: var(--primary); background: var(--primary-soft); }
.chip-ghost { border-style: dashed; }

.box-stage { display: flex; justify-content: center; padding: 10px 0 4px; }
.var-box {
  position: relative;
  min-width: 140px;
  padding: 26px 24px 18px;
  text-align: center;
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  border: 3px solid var(--accent);
  box-shadow: inset 0 -10px 0 color-mix(in srgb, var(--accent) 22%, transparent);
}
.var-label {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-weight: 600;
  padding: 0 12px;
  border-radius: 8px;
}
.var-value { display: inline-block; font-family: var(--mono); font-size: 2.2rem; font-weight: 600; }
.var-value.bump { animation: bump .35s; }
@keyframes bump { 40% { transform: scale(1.3); color: var(--accent); } }
.lab-log { min-height: 3.5em; font-size: .88rem; }

.toggles { display: grid; gap: 8px; margin-bottom: 14px; }
.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  font: inherit;
  text-align: left;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.toggle-track { flex: none; width: 46px; height: 26px; border-radius: 99px; background: var(--border); position: relative; transition: background .2s; }
.toggle-dot { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle[aria-pressed="true"] .toggle-track { background: var(--ok); }
.toggle[aria-pressed="true"] .toggle-dot { transform: translateX(20px); }
.toggle-label { flex: 1; font-weight: 700; }
.toggle code { background: none !important; color: var(--muted); }

.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; counter-reset: step; }
.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 2px 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  opacity: .65;
}
.steps li::before {
  content: counter(step);
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  font-weight: 900;
  font-size: .85rem;
}
.steps li.current { opacity: 1; background: var(--primary-soft); animation: slide-in .3s; }
.steps li.current::before { background: var(--primary); color: var(--primary-ink); }
.steps li > code { background: none !important; padding: 0 !important; font-size: 1.1rem; font-weight: 600; white-space: pre-wrap; }
.steps mark { background: var(--gold); color: #1d1a2e; border-radius: 4px; padding: 0 3px; }
.step-note { color: var(--muted); font-size: .92rem; }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } }
.lab-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ===================== Scheme logice ===================== */

.code-chart { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: start; }
.code-chart.stacked { grid-template-columns: minmax(0, 1fr); }
.fc-wrap {
  display: flex;
  justify-content: center;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow-x: auto;
}
.flowchart { display: block; max-width: 100%; height: auto; }
.fc-shape { fill: var(--surface); stroke: var(--text); stroke-width: 1.6; transition: fill .2s, stroke .2s; }
.fc-term .fc-shape { fill: var(--surface-2); }
.fc-io .fc-shape { fill: var(--life-soft); stroke: var(--life); }
.fc-proc .fc-shape { fill: color-mix(in srgb, var(--accent) 12%, var(--surface)); stroke: var(--accent); }
.fc-text { font-family: var(--mono); font-size: 13px; fill: var(--text); }
.fc-line { stroke: var(--muted); stroke-width: 1.6; fill: none; }
.fc-head, .fc-dot { fill: var(--muted); }
.fc-dec .fc-shape { fill: color-mix(in srgb, var(--primary) 12%, var(--surface)); stroke: var(--primary); }
.fc-label { font-family: var(--font); font-size: 12px; font-weight: 800; fill: var(--muted); }
.fc-node.active .fc-shape { fill: var(--gold); stroke: var(--text); stroke-width: 2.4; }
.fc-node.active .fc-text { fill: #1d1a2e; font-weight: 600; }

.blocks { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.block-card {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 4px;
  padding: 16px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}
.block-shape { min-height: 46px; display: grid; place-items: center; }
.block-card small { color: var(--muted); }

.output .err { color: var(--bad); }

/* ===================== Laboratorul „Rulează programul” ===================== */

.run-panels, .run-state { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 14px; }
.run-panel { min-width: 0; }
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  margin-bottom: 6px;
  font-weight: 800;
  font-size: .92rem;
  color: var(--muted);
}
.chip-sm { font-size: .82rem; padding: .25em .7em; }
.run-code { padding: 12px 0; }
.run-code .ln { display: block; padding: 0 16px; border-left: 4px solid transparent; min-height: 1.7em; }
.run-code .ln.active { background: color-mix(in srgb, var(--gold) 28%, transparent); border-left-color: var(--gold); }
.run-panels .fc-wrap { min-height: 100%; }
.run-editor textarea {
  width: 100%;
  font-family: var(--mono);
  font-size: .95rem;
  line-height: 1.7;
  padding: 12px 16px;
  border-radius: 14px;
  border: 2px solid var(--primary);
  background: var(--code-bg);
  color: var(--code-text);
  resize: vertical;
}
.run-editor .lab-buttons { margin: 8px 0 0; }

.run-input { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0 10px; font-weight: 800; }
.run-input input { flex: 1 1 160px; font-family: var(--mono); }
.run-status {
  min-height: 2.8em;
  padding: 10px 14px;
  margin-bottom: 14px;
  border-radius: 12px;
  background: var(--primary-soft);
  font-weight: 600;
}
.run-status.done { background: var(--ok-soft); color: var(--ok); }
.run-status.err { background: var(--bad-soft); color: var(--bad); }

.mem { display: flex; flex-wrap: wrap; gap: 14px 10px; min-height: 66px; padding: 18px 12px 10px; border-radius: 14px; background: var(--surface-2); align-content: flex-start; }
.mem-box {
  position: relative;
  min-width: 64px;
  padding: 12px 10px 6px;
  text-align: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border: 2px solid var(--accent);
}
.mem-name {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 8px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: .78rem;
  white-space: nowrap;
}
.mem-val { font-family: var(--mono); font-weight: 600; font-size: 1.1rem; }
.mem-box.changed { animation: bump .4s; box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 55%, transparent); }
.screen {
  margin: 0;
  min-height: 66px;
  padding: 12px 16px;
  border-radius: 14px;
  background: #0b0a10;
  color: #7dff9b;
  font-size: 1rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ===================== Test ===================== */

.quiz { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.quiz-top { display: flex; align-items: center; gap: 12px; }
.combo { font-weight: 900; color: var(--accent); white-space: nowrap; animation: pop .3s; }
.lives { white-space: nowrap; letter-spacing: 2px; }
@keyframes pop { 50% { transform: scale(1.35); } }

.timer { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.timer span { display: block; height: 100%; background: var(--ok); transition: width .1s linear; }
.timer span.low { background: var(--bad); }

.quiz-card { animation: slide-in .25s; }
.q-meta { font-size: .85rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.q-text { font-size: 1.3rem; margin: 6px 0 16px; }
.quiz-card pre.code { margin-bottom: 16px; }

.options { display: grid; gap: 10px; }
.opt {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  font: inherit;
  font-weight: 700;
  text-align: left;
  padding: 12px 16px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 3px 0 var(--border);
  transition: transform .08s, border-color .15s;
}
.opt.mono span:last-child { font-family: var(--mono); font-size: .95rem; }
.opt:not(:disabled):hover { border-color: var(--primary); }
.opt:not(:disabled):active { transform: translateY(2px); box-shadow: none; }
.opt:disabled { cursor: default; }
.opt-key {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 2px solid var(--border);
  font-size: .85rem;
  color: var(--muted);
}
.opt.is-ok { border-color: var(--ok); background: var(--ok-soft); box-shadow: 0 3px 0 var(--ok); }
.opt.is-bad { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 3px 0 var(--bad); animation: shake .35s; }

.q-program { margin-bottom: 12px; }
.q-program .fc-wrap { justify-self: center; }
.q-inputs { margin-bottom: 16px; font-weight: 700; }

.order-answer {
  list-style: none;
  counter-reset: ord;
  padding: 10px;
  margin: 0 0 12px;
  min-height: 58px;
  display: grid;
  gap: 8px;
  border-radius: 14px;
  border: 2px dashed var(--border);
  background: var(--surface-2);
}
.order-answer li { counter-increment: ord; display: flex; align-items: center; gap: 10px; }
.order-answer li:not(.order-hint)::before { content: counter(ord); font-weight: 900; color: var(--primary); width: 1.4em; text-align: right; }
.order-hint { color: var(--muted); padding: 6px; }
.order-pool { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.order-item {
  font: inherit;
  font-weight: 700;
  text-align: left;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 3px 0 var(--border);
}
.order-answer .order-item { flex: 1; }
.order-item.mono { font-family: var(--mono); font-size: .92rem; }
.order-item:not(:disabled):hover { border-color: var(--primary); }
.order-item:disabled { cursor: default; }
.order-item.is-ok { border-color: var(--ok); background: var(--ok-soft); box-shadow: 0 3px 0 var(--ok); }
.order-item.is-bad { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 3px 0 var(--bad); }

.q-input { display: flex; gap: 10px; flex-wrap: wrap; }
.q-input input { flex: 1 1 180px; font-family: var(--mono); font-size: 1.15rem; }
.q-input input.is-ok { border-color: var(--ok); background: var(--ok-soft); }
.q-input input.is-bad { border-color: var(--bad); background: var(--bad-soft); animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.feedback { margin-top: 18px; padding: 16px 18px; border-radius: 14px; animation: slide-in .25s; }
.feedback.ok { background: var(--ok-soft); }
.feedback.bad { background: var(--bad-soft); }
.fb-head { font-size: 1.15rem; font-weight: 900; }
.feedback.ok .fb-head { color: var(--ok); }
.feedback.bad .fb-head { color: var(--bad); }
.fb-xp { color: var(--accent); font-size: .95rem; margin-left: 6px; }
.fb-answer { margin-top: 4px; }
.fb-explain { margin: 8px 0 12px; }
.feedback .btn { margin-top: 6px; }

/* ===================== Rezultate și provocare ===================== */

.result, .boss-intro { text-align: center; padding: 36px 24px; }
.result-emoji { display: inline-block; font-size: 4rem; animation: pop .5s; }
.result-stars .stars { font-size: 2.6rem; letter-spacing: 6px; }
.result-score { font-size: 1.15rem; }
.xp-list { list-style: none; padding: 0; margin: 16px auto; max-width: 340px; text-align: left; }
.xp-list li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.xp-list b { color: var(--accent); }
.xp-list .total { border-bottom: 0; font-weight: 900; font-size: 1.1rem; }
.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.rules { list-style: none; padding: 0; margin: 18px auto 24px; max-width: 420px; text-align: left; display: grid; gap: 8px; }
.rules li { padding: 10px 14px; border-radius: 12px; background: var(--surface-2); }

/* ===================== Profil ===================== */

.profile-head { display: flex; gap: 20px; align-items: center; }
.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  font-size: 2.6rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-soft), color-mix(in srgb, var(--accent) 25%, var(--surface)));
}
.profile-main { flex: 1; min-width: 0; }
.profile-main .muted { margin: 4px 0 8px; }
.name-edit { display: flex; gap: 8px; flex-wrap: wrap; }
.name-edit input { flex: 1 1 160px; font-weight: 800; font-size: 1.2rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 16px; }
.stat-card { padding: 16px; text-align: center; }
.stat-card b { display: block; font-size: 1.5rem; }
.stat-card span { color: var(--muted); font-size: .9rem; }

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.badge {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 2px;
  padding: 16px 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 2px solid var(--border);
}
.badge-icon { font-size: 2.2rem; }
.badge small { color: var(--muted); font-size: .8rem; line-height: 1.35; }
.badge.got { border-color: var(--gold); }
.badge.locked .badge-icon { filter: grayscale(1); opacity: .35; }
.badge.locked b { color: var(--muted); }

.settings { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.setting { display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.setting input { width: 20px; height: 20px; accent-color: var(--primary); }

/* ===================== Notificări și confetti ===================== */

.toasts {
  position: fixed;
  top: 72px;
  right: 16px;
  z-index: 50;
  display: grid;
  gap: 8px;
  width: min(340px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  font-size: .92rem;
  line-height: 1.4;
  border-radius: 14px;
  background: var(--surface);
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
  animation: toast-in .35s cubic-bezier(.2, 1.4, .4, 1);
  transition: opacity .4s, transform .4s;
}
.toast.out { opacity: 0; transform: translateY(10px); }
.toast-icon { font-size: 1.6rem; }
.toast-badge { border-color: var(--gold); }
.toast-level { border-color: var(--primary); }
@keyframes toast-in { from { opacity: 0; transform: translateY(30px) scale(.9); } }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

/* ===================== Ecrane mici ===================== */

@media (max-width: 640px) {
  body { font-size: 16px; }
  .card { padding: 18px; }
  .hero { grid-template-columns: 1fr; }
  .page-head { gap: 12px; }
  .page-icon { width: 56px; height: 56px; font-size: 1.8rem; border-radius: 16px; }
  .path::before { left: 33px; }
  .node > a, .node > div { gap: 12px; padding: 12px; }
  .node-icon { width: 42px; height: 42px; font-size: 1.3rem; }
  .code-chart, .run-panels, .run-state { grid-template-columns: 1fr; }
  .lab-row { grid-template-columns: 1fr auto; }
  .lab-name { grid-column: 1 / -1; grid-row: 2; }
  .profile-head { flex-direction: column; text-align: center; }
  .settings { flex-direction: column; align-items: stretch; }
  .toasts { top: auto; bottom: 16px; right: 50%; transform: translateX(50%); }
}

@media (max-width: 480px) {
  .brand-name { display: none; }
  .xpbar, .hud-xp { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
