:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f7;
  --card: #ffffff;
  --text: #3c3c3c;
  --muted: #777777;
  --line: #e5e5e5;
  --line-dark: #cfcfcf;
  --green: #58cc02;
  --green-dark: #46a302;
  --green-soft: #d7ffb8;
  --green-text: #58a700;
  --red: #ff4b4b;
  --red-dark: #ea2b2b;
  --red-soft: #ffdfe0;
  --red-text: #ea2b2b;
  --blue: #1cb0f6;
  --blue-dark: #1899d6;
  --blue-soft: #ddf4ff;
  --gold: #ffc800;
  --orange: #ff9600;
  --locked: #e5e5e5;
  --locked-dark: #c8c8c8;
  --radius: 16px;
  --shadow: 0 4px 0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131f24;
    --bg-soft: #1a2a31;
    --card: #131f24;
    --text: #f1f7fb;
    --muted: #9fb3bd;
    --line: #37464f;
    --line-dark: #2a3840;
    --green-soft: #1f3a12;
    --green-text: #79d634;
    --red-soft: #3b1d20;
    --red-text: #ff7a7a;
    --blue-soft: #16354a;
    --locked: #37464f;
    --locked-dark: #24323a;
  }
}
:root[data-theme="dark"] {
  --bg: #131f24; --bg-soft: #1a2a31; --card: #131f24; --text: #f1f7fb; --muted: #9fb3bd;
  --line: #37464f; --line-dark: #2a3840; --green-soft: #1f3a12; --green-text: #79d634;
  --red-soft: #3b1d20; --red-text: #ff7a7a; --blue-soft: #16354a; --locked: #37464f; --locked-dark: #24323a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 700;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- Butoane „3D” ---------- */
.btn {
  border: 0; border-radius: var(--radius);
  padding: 14px 22px; font-size: 15px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .6px;
  background: var(--green); color: #fff;
  box-shadow: var(--shadow) var(--green-dark);
  transition: transform .06s, box-shadow .06s, filter .15s;
  min-height: 50px;
}
.btn:hover:not(:disabled) { filter: brightness(1.05); }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 var(--green-dark); }
.btn:disabled { background: var(--locked); color: var(--muted); box-shadow: var(--shadow) var(--locked-dark); }
.btn.blue { background: var(--blue); box-shadow: var(--shadow) var(--blue-dark); }
.btn.red { background: var(--red); box-shadow: var(--shadow) var(--red-dark); }
.btn.ghost { background: var(--card); color: var(--blue); border: 2px solid var(--line); box-shadow: var(--shadow) var(--line); }
.btn.ghost:active:not(:disabled) { box-shadow: 0 0 0 var(--line); }
.btn.wide { width: 100%; }
.icon-btn { background: none; border: 0; color: var(--muted); padding: 8px; border-radius: 12px; display: inline-flex; }
.icon-btn:hover { background: var(--bg-soft); }

/* ---------- Bara de sus ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg); border-bottom: 2px solid var(--line);
}
.topbar-inner {
  max-width: 1040px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 22px; color: var(--green); letter-spacing: -.5px; }
.brand svg { width: 32px; height: 32px; }
.stats { margin-left: auto; display: flex; gap: 6px; }
.stat { display: inline-flex; align-items: center; gap: 5px; padding: 6px 8px; border-radius: 12px; font-weight: 800; font-size: 16px; }
.stat svg { width: 24px; height: 24px; }
.stat.streak { color: var(--orange); }
.stat.streak.off { color: var(--muted); }
.stat.xp { color: var(--gold); }
.stat.hearts { color: var(--red); }

/* ---------- Layout acasă ---------- */
.home { max-width: 1040px; margin: 0 auto; padding: 20px 16px 80px; display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 40px; }
@media (max-width: 900px) { .home { grid-template-columns: minmax(0, 1fr); gap: 24px; } .side { order: -1; } }
.path-col { min-width: 0; }

.unit { margin-bottom: 36px; }
.unit-head {
  border-radius: var(--radius); padding: 16px 18px; color: #fff;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 4px 0 rgba(0,0,0,.18);
}
.unit-head.locked { background: var(--locked) !important; color: var(--muted); box-shadow: 0 4px 0 var(--locked-dark); }
.unit-head h2 { margin: 0; font-size: 20px; font-weight: 900; line-height: 1.2; }
.unit-head p { margin: 2px 0 0; font-size: 14px; opacity: .92; }
.unit-head .num { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; opacity: .85; }
.unit-head .guide {
  margin-left: auto; border: 2px solid rgba(255,255,255,.55); background: transparent; color: inherit;
  border-radius: 14px; padding: 10px 12px; font-weight: 800; font-size: 13px; text-transform: uppercase;
  display: inline-flex; gap: 6px; align-items: center; flex-shrink: 0;
}
.unit-head.locked .guide { border-color: var(--line-dark); }
.unit-head .guide:hover { background: rgba(255,255,255,.15); }

.nodes { display: flex; flex-direction: column; align-items: center; padding: 26px 0 6px; gap: 18px; }
.node-wrap { position: relative; }
.node {
  width: 72px; height: 66px; border-radius: 50%; border: 0;
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 7px 0 rgba(0,0,0,.2);
  transition: transform .08s, box-shadow .08s;
}
.node svg { width: 34px; height: 34px; }
.node:active:not(.locked) { transform: translateY(6px); box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.node.locked { background: var(--locked) !important; color: var(--locked-dark); box-shadow: 0 7px 0 var(--locked-dark); cursor: not-allowed; }
.node.done { background: var(--gold) !important; box-shadow: 0 7px 0 #e0a800; }
.node.current::after {
  content: ""; position: absolute; inset: -9px; border-radius: 50%;
  border: 5px solid var(--line); pointer-events: none;
}
.start-bubble {
  position: absolute; left: 50%; bottom: calc(100% + 12px); transform: translateX(-50%);
  background: var(--card); border: 2px solid var(--line); color: var(--green);
  padding: 8px 12px; border-radius: 12px; font-weight: 900; font-size: 14px; text-transform: uppercase;
  white-space: nowrap; animation: bob 1.4s ease-in-out infinite; pointer-events: none;
}
.start-bubble::after {
  content: ""; position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
  border: 8px solid transparent; border-top-color: var(--line);
}
@keyframes bob { 50% { transform: translate(-50%, -5px); } }

/* ---------- Coloana laterală ---------- */
.side { display: flex; flex-direction: column; gap: 16px; }
.panel { border: 2px solid var(--line); border-radius: var(--radius); padding: 18px; background: var(--card); }
.panel h3 { margin: 0 0 6px; font-size: 18px; font-weight: 900; }
.panel p { margin: 0 0 14px; color: var(--muted); font-size: 15px; line-height: 1.45; }
.panel .row { display: flex; align-items: center; gap: 12px; }
.panel .big-ico { width: 52px; height: 52px; flex-shrink: 0; }
.goal-bar { height: 16px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.goal-bar > span { display: block; height: 100%; background: var(--gold); border-radius: 99px; transition: width .5s; }
.goal-text { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin-top: 6px; }
.panel.news { background: var(--blue-soft); border-color: transparent; }
.panel.news ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.5; font-weight: 600; }
.panel.news li { margin-bottom: 6px; }
.small-print { font-size: 12.5px; color: var(--muted); line-height: 1.5; font-weight: 600; }
.small-print a { color: var(--blue); }
.settings-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 2px solid var(--line); background: var(--card); color: var(--text); border-radius: 12px; padding: 8px 12px; font-weight: 800; font-size: 13px; }
.chip.on { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }

/* ---------- Lecție ---------- */
.lesson { min-height: 100vh; display: flex; flex-direction: column; }
.lesson-top, .lesson-body, .lesson > .exam-bar { max-width: 680px; width: 100%; margin-left: auto; margin-right: auto; }
.lesson-top { display: flex; align-items: center; gap: 12px; padding: 18px 16px 8px; }
.progress { flex: 1; height: 16px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--green); border-radius: 99px; transition: width .35s ease; position: relative; }
.progress > span::after { content: ""; position: absolute; left: 8px; right: 8px; top: 3px; height: 4px; background: rgba(255,255,255,.3); border-radius: 99px; }
.lesson-body { flex: 1; padding: 12px 16px 24px; }
.combo { color: var(--orange); font-weight: 900; font-size: 14px; text-transform: uppercase; letter-spacing: .6px; min-height: 20px; margin-bottom: 4px; }
.q-tag { display: inline-block; font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-bottom: 6px; }
.q-text { font-size: 22px; font-weight: 800; line-height: 1.35; margin: 0 0 18px; }
@media (max-width: 480px) { .q-text { font-size: 19px; } }
.sign { width: 120px; height: 120px; margin: 4px auto 18px; display: block; filter: drop-shadow(0 3px 4px rgba(0,0,0,.18)); }
.hint { font-size: 13px; color: var(--muted); margin: -8px 0 14px; font-weight: 700; }
.options { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: left;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text);
  padding: 14px; font-size: 16px; font-weight: 700; line-height: 1.35;
  box-shadow: 0 3px 0 var(--line); transition: background .12s, border-color .12s;
}
.opt:hover:not(:disabled) { background: var(--bg-soft); }
.opt .key {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 9px; border: 2px solid var(--line);
  display: grid; place-items: center; font-size: 14px; color: var(--muted); font-weight: 900;
}
.opt.sel { border-color: var(--blue); background: var(--blue-soft); box-shadow: 0 3px 0 var(--blue); }
.opt.sel .key { border-color: var(--blue); color: var(--blue); }
.opt.right { border-color: var(--green); background: var(--green-soft); box-shadow: 0 3px 0 var(--green); }
.opt.right .key { border-color: var(--green); color: var(--green-text); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); box-shadow: 0 3px 0 var(--red); }
.opt.wrong .key { border-color: var(--red); color: var(--red-text); }
.opt.missed { border-style: dashed; border-color: var(--green); }
.opt:disabled { cursor: default; }
.opt:focus:not(:focus-visible) { outline: none; }
.opts-tf { flex-direction: row; }
.opts-tf .opt { flex: 1; justify-content: center; font-size: 18px; padding: 18px 14px; }

.lesson-foot { border-top: 2px solid var(--line); padding: 16px; position: sticky; bottom: 0; background: var(--bg); }
.lesson-foot.ok { background: var(--green-soft); border-color: transparent; }
.lesson-foot.bad { background: var(--red-soft); border-color: transparent; }
.foot-inner { max-width: 680px; margin: 0 auto; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.foot-inner .btn { margin-left: auto; min-width: 160px; }
@media (max-width: 560px) { .foot-inner .btn { width: 100%; margin-left: 0; } }
.verdict { flex: 1; min-width: 220px; }
.verdict h4 { margin: 0 0 4px; font-size: 21px; font-weight: 900; display: flex; align-items: center; gap: 8px; }
.ok .verdict h4 { color: var(--green-text); }
.bad .verdict h4 { color: var(--red-text); }
.verdict p { margin: 0; font-size: 15px; line-height: 1.45; font-weight: 600; }
.verdict .ref { display: inline-block; margin-top: 6px; font-size: 12.5px; font-weight: 800; opacity: .8; }
.ok .verdict p, .ok .verdict .ref { color: var(--green-text); }
.bad .verdict p, .bad .verdict .ref { color: var(--red-text); }
.foot-secondary { display: flex; gap: 10px; }

/* ---------- Ecran final ---------- */
.result { max-width: 560px; margin: 0 auto; min-height: 100vh; padding: 40px 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; }
.result h1 { margin: 0; font-size: 30px; font-weight: 900; color: var(--gold); }
.result h1.fail { color: var(--red); }
.result h1.pass { color: var(--green); }
.result .sub { color: var(--muted); font-size: 16px; margin: 0; }
.result-ico { width: 120px; height: 120px; }
.kpis { display: flex; gap: 12px; width: 100%; }
.kpi { flex: 1; border-radius: var(--radius); border: 2px solid; overflow: hidden; }
.kpi .lab { font-size: 12px; font-weight: 900; text-transform: uppercase; padding: 6px; color: #fff; letter-spacing: .5px; }
.kpi .val { padding: 12px 6px; font-size: 22px; font-weight: 900; background: var(--card); display: flex; align-items: center; justify-content: center; gap: 6px; }
.kpi .val svg { width: 22px; height: 22px; }
.kpi.k-xp { border-color: var(--gold); } .kpi.k-xp .lab { background: var(--gold); } .kpi.k-xp .val { color: var(--gold); }
.kpi.k-acc { border-color: var(--green); } .kpi.k-acc .lab { background: var(--green); } .kpi.k-acc .val { color: var(--green); }
.kpi.k-time { border-color: var(--blue); } .kpi.k-time .lab { background: var(--blue); } .kpi.k-time .val { color: var(--blue); }
.kpi.k-bad { border-color: var(--red); } .kpi.k-bad .lab { background: var(--red); } .kpi.k-bad .val { color: var(--red); }
.result .actions { width: 100%; display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }

.review { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.review-item { border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; }
.review-item .rq { font-weight: 800; margin-bottom: 6px; }
.review-item .ra { color: var(--green-text); font-size: 14px; margin-bottom: 4px; }
.review-item .re { color: var(--muted); font-size: 14px; font-weight: 600; line-height: 1.45; }

/* ---------- Examen ---------- */
.exam-bar { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 16px 6px; max-width: 680px; margin: 0 auto; width: 100%; }
.pill { border-radius: 99px; padding: 6px 12px; font-size: 14px; font-weight: 900; background: var(--bg-soft); border: 2px solid var(--line); }
.pill.t { color: var(--blue); }
.pill.g { color: var(--green-text); }
.pill.r { color: var(--red-text); }
.pill.warn { color: #fff; background: var(--red); border-color: var(--red); }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--card); border-radius: 20px; max-width: 560px; width: 100%; max-height: 88vh; overflow: auto; padding: 22px; border: 2px solid var(--line); }
.modal h3 { margin: 0 0 4px; font-size: 22px; font-weight: 900; }
.modal .msub { color: var(--muted); margin: 0 0 14px; font-size: 14px; }
.modal ul { padding: 0; margin: 0 0 18px; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.modal li { background: var(--bg-soft); border-radius: 14px; padding: 12px 14px; font-weight: 600; line-height: 1.5; font-size: 15px; }
.modal li b { font-weight: 900; }
@keyframes fade { from { opacity: 0; } }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0;
  background: #3c3c3c; color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 800; font-size: 15px;
  transition: all .25s; z-index: 60; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; width: 100%; height: 100%; }

.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.pop { animation: pop .3s; }
@keyframes pop { 50% { transform: scale(1.04); } }

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