/* Laboratori d'igualació d'equacions
   La interfície es dissenya per a 1440 × 800 px i s'escala amb --ui-zoom (vegeu fitScale a app.js). */

:root {
  color-scheme: light;
  --ui-zoom: 1;
  --bg-1: #cde4ff;
  --bg-2: #f5f9ff;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-solid: #ffffff;
  --line: rgba(148, 163, 184, 0.38);
  --line-strong: rgba(100, 116, 139, 0.5);
  --text: #0f172a;
  --muted: #475569;
  --blue: #2563eb;
  --blue-soft: rgba(37, 99, 235, 0.1);
  --green: #15803d;
  --green-soft: #dcfce7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --l1: #15803d;
  --l2: #b45309;
  --l3: #b91c1c;
  --l4: #6d28d9;
  --shadow: 0 14px 34px rgba(15, 35, 95, 0.13);
  --radius: 18px;
  --formula-h: 46px;
  --stepper-h: 40px;
  --footer-h: 50px;
  --term-gap: 30px;
  --panel-w: 300px;
  font-family: "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  zoom: var(--ui-zoom);
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2)) fixed;
  color: var(--text);
  font-size: 16px;
  line-height: 1.35;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.55);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

svg {
  display: block;
}

/* ---------- Estructura general (una sola pantalla) ---------- */

.app-shell {
  height: calc(100dvh / var(--ui-zoom));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 12px 18px calc(var(--footer-h) + 8px);
}

.panel,
.topbar,
.lab-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- Barra superior ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  min-height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.25);
}

.brand-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: linear-gradient(135deg, #0f172a, #1e40af);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.mode-tabs {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  border: 1px solid var(--line);
}

.mode-tab {
  border: 0;
  background: transparent;
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 700;
  color: var(--muted);
}

.mode-tab.active {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.filters {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

.level-chips {
  display: flex;
  gap: 6px;
}

.level-chip {
  --c: var(--blue);
  border: 2px solid var(--c);
  background: #fff;
  color: var(--c);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
}

.level-chip[aria-pressed="false"] {
  border-color: var(--line-strong);
  color: #64748b;
  background: transparent;
}

.level-chip[aria-pressed="true"] {
  background: var(--c);
  color: #fff;
}

.level-chip.l1,
.tag.l1 { --c: var(--l1); }
.level-chip.l2,
.tag.l2 { --c: var(--l2); }
.level-chip.l3,
.tag.l3 { --c: var(--l3); }
.level-chip.l4,
.tag.l4 { --c: var(--l4); }

.dropdown {
  position: relative;
}

.dropdown-trigger {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 150px;
  display: inline-flex;
  justify-content: space-between;
  gap: 8px;
}

.dropdown-trigger::after {
  content: "▾";
  color: var(--muted);
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px;
}

.dropdown.open .dropdown-menu {
  display: block;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 8px;
  font-size: 0.92rem;
  cursor: pointer;
}

.check-row:hover {
  background: var(--blue-soft);
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.primary-btn {
  border: 0;
  border-radius: 12px;
  padding: 9px 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #60a5fa);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28);
  transition: transform 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.35);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.icon-btn svg,
.action-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn:hover {
  color: var(--blue);
  border-color: rgba(37, 99, 235, 0.4);
}

.icon-btn[aria-pressed="true"] {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

/* ---------- Zona de treball ---------- */

.lab {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  gap: 12px;
  min-height: 0;
}

.lab-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px 12px;
  min-height: 0;
}

.lab-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
}

.eq-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  --c: var(--blue);
  display: inline-flex;
  align-items: center;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, white);
  border: 1px solid color-mix(in srgb, var(--c) 35%, white);
}

.tag.type {
  --c: #047857;
}

.tag.ions {
  --c: #c2410c;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 4px 5px;
  border-radius: 999px;
  font-weight: 700;
  background: #f1f5f9;
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.status-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #cbd5e1;
  color: #fff;
  font-weight: 800;
}

.status.ok {
  background: var(--green-soft);
  color: var(--green);
  border-color: #86efac;
}

.status.ok .status-icon {
  background: #16a34a;
}

.status.bad {
  background: var(--red-soft);
  color: var(--red);
  border-color: #fca5a5;
}

.status.bad .status-icon {
  background: #dc2626;
}

.status.simplify {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: #fcd34d;
}

.status.simplify .status-icon {
  background: #d97706;
}

/* Barra del mode Repte */
.challenge-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.cb-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: #1e3a8a;
  font-size: 0.88rem;
  border: 1px solid rgba(37, 99, 235, 0.2);
  white-space: nowrap;
}

.cb-item.timer {
  font-weight: 600;
}

.cb-item.timer[aria-pressed="false"] {
  background: #fff;
  color: var(--muted);
}

.tries-dots {
  display: inline-flex;
  gap: 4px;
}

.tries-dots i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--blue);
}

.tries-dots i.on {
  background: var(--blue);
}

.star-sm {
  color: #f59e0b;
  font-size: 1.05rem;
}

/* ---------- Escena: reactius ⇒ productes ---------- */

.scene {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 6px;
}

.side {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px 12px;
  border-radius: 16px;
  border: 1px dashed rgba(148, 163, 184, 0.75);
  background: linear-gradient(160deg, rgba(239, 246, 255, 0.9), rgba(226, 232, 240, 0.45));
}

.side.reactants {
  flex: calc(var(--nr, 2) + 0.6) 1 0;
}

.side.products {
  flex: calc(var(--np, 2) + 0.6) 1 0;
  background: linear-gradient(160deg, rgba(236, 253, 245, 0.9), rgba(226, 232, 240, 0.45));
}

.side-label {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue);
}

.products .side-label {
  color: #047857;
}

.side-columns {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: var(--term-gap);
}

.scene-arrow {
  flex: 0 0 54px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: calc(12px + var(--stepper-h) + 8px + (var(--formula-h) - 28px) / 2);
}

.scene-arrow svg {
  width: 54px;
  height: 28px;
  fill: none;
  stroke: var(--blue);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.term {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.term + .term::before {
  content: "+";
  position: absolute;
  left: calc(var(--term-gap) / -2);
  bottom: calc(var(--stepper-h) + 8px + var(--formula-h) / 2);
  transform: translate(-50%, 50%);
  font-size: 1.7rem;
  font-weight: 700;
  color: #64748b;
}

.bucket {
  flex: 1;
  min-height: 60px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  overflow: hidden;
}

.sprites {
  display: grid;
  gap: 4px;
  justify-content: center;
  align-content: center;
}

.sprite {
  width: var(--sprite-w, 48px);
  height: var(--sprite-h, 48px);
}

.sprite svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.sprite .bond {
  stroke: #64748b;
  stroke-width: 4;
  stroke-linecap: round;
}

.sprite .atom circle {
  stroke: rgba(15, 23, 42, 0.38);
  stroke-width: 1.2;
}

.sprite .atom circle.light {
  stroke: #94a3b8;
  stroke-width: 1.4;
}

.sprite .atom circle.shine {
  fill: #fff;
  opacity: 0.35;
  stroke: none;
}

.sprite text {
  font-family: "Segoe UI", Arial, sans-serif;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
}

.sprite .charge circle {
  fill: #fff;
  stroke-width: 2;
}

.sprite .charge.pos circle {
  stroke: #ea580c;
}

.sprite .charge.pos text {
  fill: #c2410c;
}

.sprite .charge.neg circle {
  stroke: #2563eb;
}

.sprite .charge.neg text {
  fill: #1d4ed8;
}

.bucket.tiny .atom text {
  display: none;
}

.count-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
}

.formula {
  height: var(--formula-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 1.6rem;
  font-weight: 700;
  white-space: nowrap;
}

.formula .coef {
  color: var(--blue);
  font-weight: 800;
  font-size: 1.12em;
}

.formula .coef.is-one {
  color: #94a3b8;
}

.formula sub,
.formula sup {
  font-size: 0.62em;
  line-height: 0;
}

.stepper {
  height: var(--stepper-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.step {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: #fff;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.15s;
}

.step.minus {
  color: #b91c1c;
}

.step.plus {
  color: #15803d;
}

.step:hover:not(:disabled) {
  background: var(--blue-soft);
}

.coef-input {
  width: 54px;
  height: 36px;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  -moz-appearance: textfield;
}

.coef-input::-webkit-outer-spin-button,
.coef-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.term.highlight .bucket,
.term.highlight .formula {
  outline: 3px solid #f59e0b;
  outline-offset: 2px;
  border-radius: 12px;
  animation: pulse 1.2s ease-in-out 2;
}

@keyframes pulse {
  50% {
    outline-color: rgba(245, 158, 11, 0.25);
  }
}

/* ---------- Accions i missatges ---------- */

.action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 12px;
  padding: 9px 18px;
  font-weight: 700;
  transition: transform 0.15s, box-shadow 0.15s;
}

.action-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.action-btn.check {
  background: linear-gradient(135deg, #22c55e, #10b981);
  color: #052e1b;
  font-size: 1.05rem;
  padding: 10px 24px;
}

.action-btn.soft {
  background: rgba(148, 163, 184, 0.22);
}

.action-btn.icon-only {
  padding: 9px 12px;
}

.action-btn.ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--muted);
}

.action-btn.next {
  background: linear-gradient(135deg, #2563eb, #60a5fa);
  color: #fff;
  margin-left: auto;
}

.action-btn.small {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.feedback {
  flex: 1 1 100%;
  margin: 0;
  min-height: 2.7em;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.35;
}

.feedback:empty {
  background: transparent;
}

.feedback.success {
  background: var(--green-soft);
  color: #14532d;
}

.feedback.error {
  background: var(--red-soft);
  color: #7f1d1d;
}

.feedback.hint {
  background: #e0ecff;
  color: #1e3a8a;
}

.feedback strong {
  font-weight: 800;
}

/* ---------- Panell lateral ---------- */

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.panel {
  padding: 12px 14px;
}

.panel-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
}

.aid-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.aid-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  gap: 3px;
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.18);
}

.aid-opt {
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 5px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.aid-opt svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.aid-opt[aria-checked="true"] {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

.aid-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.aid-empty {
  margin: auto 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.bars-head {
  display: grid;
  grid-template-columns: 1fr 30px 1fr;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.bars-head span:first-child {
  text-align: right;
  color: var(--blue);
}

.bars-head span:last-child {
  color: #047857;
}

.bar-row {
  display: grid;
  grid-template-columns: 1fr 30px 1fr;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  border-radius: 10px;
}

.bar-row.ok {
  background: var(--green-soft);
}

.bar {
  display: grid;
  align-items: center;
  gap: 5px;
  height: 22px;
}

.bar.left {
  grid-template-columns: 24px 1fr;
}

.bar.right {
  grid-template-columns: 1fr 24px;
}

.bar-fill {
  height: 16px;
  width: var(--w);
  background: var(--c);
  border: 1px solid rgba(15, 23, 42, 0.3);
  border-radius: 5px;
  transition: width 0.25s ease;
}

.bar.left .bar-fill {
  justify-self: end;
}

.bar.right .bar-fill {
  justify-self: start;
}

.bar-num {
  font-weight: 800;
  font-size: 0.95rem;
  text-align: center;
}

.bar-row.ok .bar-num {
  color: var(--green);
}

.dot {
  --c: #64748b;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--c);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  border: 1px solid rgba(15, 23, 42, 0.3);
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.55);
}

.dot.light {
  color: #1e293b;
  text-shadow: none;
  border-color: #94a3b8;
}

.scales {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.scale {
  margin: 0;
  padding: 2px;
  border-radius: 10px;
}

.scale.ok {
  background: var(--green-soft);
}

.scale svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.scale .stand,
.scale .beam,
.scale .hang {
  fill: none;
  stroke: #475569;
  stroke-width: 3;
  stroke-linecap: round;
}

.scale .hang {
  stroke-width: 1.5;
}

.scale .plate {
  fill: #94a3b8;
}

.scale.ok .beam {
  stroke: #16a34a;
}

.scale .num {
  font-size: 15px;
  font-weight: 800;
  text-anchor: middle;
  fill: var(--text);
}

.scale .pivot {
  stroke: rgba(15, 23, 42, 0.35);
  stroke-width: 1.2;
}

.scale .pivot.light {
  stroke: #94a3b8;
}

.scale .sym {
  font-size: 11px;
  font-weight: 800;
  text-anchor: middle;
}

.charge-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 10px;
  background: #fff7ed;
  color: #9a3412;
  font-weight: 800;
  text-align: center;
  border: 1px solid #fed7aa;
}

.charge-row strong {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.charge-row.ok {
  background: var(--green-soft);
  color: var(--green);
  border-color: #86efac;
}

.legend-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
  color: var(--muted);
}

.legend .dot {
  width: 24px;
  height: 24px;
  font-size: 0.7rem;
}

.score-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px;
}

.score {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px;
  border-radius: 12px;
  background: var(--blue-soft);
  border: 1px solid rgba(37, 99, 235, 0.18);
}

.score-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #1e40af;
}

.score-value {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.1;
}

/* ---------- Diàlegs ---------- */

.modal {
  border: 0;
  border-radius: 20px;
  padding: 0;
  width: min(820px, 92vw);
  box-shadow: 0 30px 70px rgba(15, 23, 42, 0.35);
  color: var(--text);
}

.modal.small {
  width: min(460px, 92vw);
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 6px;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.25rem;
}

.modal-body {
  padding: 8px 20px 20px;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.progress-row {
  display: grid;
  grid-template-columns: 170px 1fr 52px;
  align-items: center;
  gap: 10px;
}

.progress-name {
  font-weight: 650;
  font-size: 0.9rem;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.progress-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
}

.progress-num {
  font-weight: 700;
  font-size: 0.9rem;
  text-align: right;
}

.result-body {
  text-align: center;
}

.stars {
  display: flex;
  justify-content: center;
  gap: 10px;
  font-size: 3.2rem;
  line-height: 1;
  color: #e2e8f0;
}

.stars .on {
  color: #f59e0b;
  text-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.result-points {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 10px 0 4px;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* ---------- Guia del laboratori ---------- */

.info-modal {
  /* vw i vh es multipliquen pel zoom de la interfície: cal dividir-los. */
  width: min(1000px, calc(94vw / var(--ui-zoom)));
  max-height: calc(88vh / var(--ui-zoom));
  overflow: hidden;
  background: #f8fbff;
}

.info-modal[open] {
  display: flex;
  flex-direction: column;
}

.info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px 14px;
  background: linear-gradient(120deg, #1d4ed8, #4f46e5 60%, #7c3aed);
  color: #fff;
}

.info-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.info-title h2 {
  margin: 0;
  font-size: 1.35rem;
}

.info-title p {
  margin: 2px 0 0;
  font-size: 0.92rem;
  opacity: 0.9;
}

.info-badge {
  width: 46px;
  height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.info-badge svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: #fff;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.info-head .icon-btn {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
}

.info-head .icon-btn svg {
  stroke: #fff;
}

.info-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 22px 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.info-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 11px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  font: inherit;
  font-weight: 650;
  font-size: 0.95rem;
  color: var(--muted);
  cursor: pointer;
}

.info-tab svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.info-tab:hover {
  color: var(--text);
}

.info-tab[aria-selected="true"] {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.info-tab:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: -3px;
  border-radius: 8px 8px 0 0;
}

.info-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px 22px;
}

.pane-title {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #475569;
}

.info-pane > .pane-title:not(:first-child) {
  margin-top: 20px;
}

.pane-intro {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.95rem;
}

.guide-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 22px;
  align-items: start;
}

/* Equació en línia (guia i exemples) */

.eq-line {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 4px 8px;
}

.eq-term {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 10px;
  border: 2px solid transparent;
}

.eq-term.marked {
  border-color: #f59e0b;
  background: var(--amber-soft);
}

.eq-formula {
  font-size: 1.12rem;
  font-weight: 650;
  white-space: nowrap;
}

.eq-coef {
  color: var(--blue);
  font-weight: 800;
  margin-right: 2px;
}

.eq-op {
  align-self: flex-end;
  padding-bottom: 6px;
  font-weight: 700;
  color: #64748b;
}

.eq-op.arrow {
  font-size: 1.25rem;
  padding-bottom: 3px;
  color: var(--text);
}

.mini-mols {
  display: flex;
  gap: 4px;
  align-items: center;
  min-height: 30px;
}

.mini-mol {
  display: inline-block;
  height: 30px;
  width: auto;
}

.mini-mol svg {
  height: 30px;
  width: auto;
}

/* Passos de l'exemple */

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  counter-reset: none;
}

.step-card {
  position: relative;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(15, 35, 95, 0.05);
}

.step-card:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 30px;
  bottom: -11px;
  height: 10px;
  border-left: 2px dashed #93c5fd;
}

.step-card.final {
  background: var(--green-soft);
  border-color: rgba(21, 128, 61, 0.35);
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.step-card.final .step-num {
  background: var(--green);
}

.step-main h4 {
  margin: 4px 0 8px;
  font-size: 1rem;
}

.step-main p {
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.count-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.count-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 3px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  background: var(--green-soft);
  color: var(--green);
}

.count-chip.bad {
  background: var(--red-soft);
  color: var(--red);
}

.count-chip .dot {
  width: 22px;
  height: 22px;
  font-size: 0.68rem;
}

.count-chip i {
  font-style: normal;
  opacity: 0.45;
}

.count-chip em {
  font-style: normal;
}

/* Regles d'or */

.rules {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rule {
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
}

.rule h4 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 0.98rem;
}

.rule p,
.rule ul {
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.rule ul {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rule b {
  color: var(--text);
}

.rule-icon {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 0.85rem;
  font-weight: 800;
}

.rule.tools {
  background: var(--blue-soft);
  border-color: rgba(37, 99, 235, 0.25);
}

.rule.tools .rule-icon {
  background: var(--blue);
  color: #fff;
}

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.compare figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px;
  border-radius: 12px;
  border: 2px solid;
  text-align: center;
}

.compare .good {
  border-color: rgba(21, 128, 61, 0.4);
  background: #f0fdf4;
}

.compare .bad {
  border-color: rgba(185, 28, 28, 0.35);
  background: #fef2f2;
}

.compare figcaption {
  font-size: 1.05rem;
  font-weight: 650;
}

.compare small {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
}

.compare .good small {
  color: var(--green);
}

.compare .bad small {
  color: var(--red);
}

.simplify {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem !important;
  color: var(--text) !important;
}

.simplify span:first-child {
  text-decoration: line-through;
  color: var(--red);
}

.simplify .arrow {
  color: var(--muted);
  font-weight: 700;
}

.simplify strong {
  color: var(--green);
}

/* Tipus de reacció */

.type-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
}

.type-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(15, 35, 95, 0.05);
}

.type-card header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.type-card h4 {
  margin: 0;
  font-size: 1.05rem;
  color: #1e3a8a;
}

.type-count {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.type-card > p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.pattern {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 10px;
  border-radius: 10px;
  background: #f1f5f9;
}

.pattern .eq-op {
  padding: 0;
  align-self: center;
}

.tiles {
  display: inline-flex;
  gap: 2px;
}

.tile {
  width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--c);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
}

.pattern .word {
  font-weight: 650;
  font-size: 0.9rem;
}

.pattern .eq-formula {
  font-size: 1rem;
}

.type-example {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px dashed var(--line-strong);
}

.type-example .label {
  display: block;
  margin-bottom: 2px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

.type-example .eq-term {
  padding: 2px 0;
}

.type-example .eq-formula {
  font-size: 1rem;
}

.type-example .eq-line {
  align-items: baseline;
}

.type-example .eq-op {
  align-self: baseline;
  padding: 0;
}

/* El meu progrés */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  --c: var(--blue);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-top: 4px solid var(--c);
}

.stat-card.green { --c: var(--green); }
.stat-card.slate { --c: #64748b; }
.stat-card.amber { --c: #d97706; }
.stat-card.violet { --c: var(--l4); }

.stat-value {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--c);
}

.stat-value small {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 700;
}

.stat-label {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--muted);
}

.level-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.level-card {
  --c: var(--l1);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
}

.level-card.l2 { --c: var(--l2); }
.level-card.l3 { --c: var(--l3); }
.level-card.l4 { --c: var(--l4); }

.level-card.complete {
  background: #f0fdf4;
  border-color: rgba(21, 128, 61, 0.35);
}

.ring {
  --p: 0;
  width: 58px;
  height: 58px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), #e2e8f0 0);
}

.ring span {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--c);
}

.level-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.level-info strong {
  color: var(--c);
}

.level-num {
  font-weight: 700;
  font-size: 0.92rem;
}

.level-info small {
  font-size: 0.78rem;
  color: var(--muted);
}

.type-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
}

.progress-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.progress-foot .muted {
  margin: 0;
  flex: 1 1 320px;
}

/* ---------- Celebració ---------- */

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

.confetti i {
  position: absolute;
  top: -12px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation: confetti-fall 1.5s cubic-bezier(0.25, 0.6, 0.4, 1) forwards;
}

@keyframes confetti-fall {
  to {
    transform: translate(var(--dx), 105vh) rotate(var(--rot));
    opacity: 0.2;
  }
}

/* ---------- Peu de pàgina ---------- */

.felip-app-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 6px clamp(16px, 3vw, 38px);
  border-top: 1px solid #dce3f3;
  background: rgba(244, 246, 252, 0.97);
  backdrop-filter: blur(8px);
  color: #66728e;
  font-size: 0.8rem;
  line-height: 1.22;
}

.felip-license-image-link {
  display: block;
  line-height: 0;
}

.felip-license-image {
  display: block;
  width: 78px;
  height: auto;
}

.felip-footer-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.felip-footer-text p {
  margin: 0;
}

.felip-footer-text a {
  color: #3c5a99;
  font-weight: 600;
  text-decoration: none;
}

.felip-footer-text a:hover,
.felip-footer-text a:focus-visible {
  text-decoration: underline;
}

/* ---------- Mode projector i amplada efectiva reduïda ---------- */

.projector .formula {
  font-size: 1.75rem;
}

.compact {
  --term-gap: 22px;
  --panel-w: 260px;
}

.compact .brand-title {
  display: none;
}

.compact .lab-head {
  flex-wrap: wrap;
  row-gap: 6px;
}

.compact .challenge-bar {
  margin-left: 0;
}

/* ---------- Mòbil i tauleta vertical (sense escalat, amb desplaçament) ---------- */

@media (max-width: 899px) {
  :root {
    --formula-h: 40px;
    --footer-h: 58px;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
    padding: 10px 10px calc(var(--footer-h) + 12px);
    gap: 10px;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 10px;
  }

  .brand {
    flex: 1 1 100%;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
  }

  .brand-title {
    font-size: 1.05rem;
    white-space: normal;
  }

  .filters {
    order: 3;
    flex: 1 1 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .level-chips {
    flex-wrap: wrap;
  }

  .top-actions {
    margin-left: auto;
  }

  .lab {
    grid-template-columns: 1fr;
  }

  .lab-head {
    flex-wrap: wrap;
  }

  .challenge-bar {
    flex-wrap: wrap;
    margin-left: 0;
  }

  .scene {
    flex-direction: column;
    gap: 4px;
  }

  .side-columns {
    flex-wrap: wrap;
    gap: 10px 28px;
  }

  .term {
    flex: 1 1 130px;
  }

  .bucket {
    flex: none;
    height: 120px;
  }

  .scene-arrow {
    flex: none;
    padding: 0;
    transform: rotate(90deg);
    height: 40px;
  }

  .side-panel {
    display: grid;
    grid-template-columns: 1fr;
  }

  .aid-body {
    overflow: visible;
  }

  .action-btn.next {
    margin-left: 0;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .felip-license-image {
    width: 64px;
  }

  .felip-app-footer {
    font-size: 0.74rem;
  }
}

/* Guia del laboratori en pantalles estretes */
@media (max-width: 899px) {
  .info-modal {
    width: 96vw;
    max-height: 92dvh;
  }

  .info-head {
    padding: 14px 14px 12px;
  }

  .info-title p,
  .info-badge {
    display: none;
  }

  .info-tabs {
    padding: 6px 8px 0;
    gap: 0;
  }

  .info-tab {
    flex: 1;
    justify-content: center;
    padding: 9px 4px 10px;
    font-size: 0.82rem;
    text-align: center;
  }

  .info-tab svg {
    display: none;
  }

  .info-body {
    padding: 14px;
  }

  .guide-grid {
    grid-template-columns: 1fr;
  }

  .level-cards {
    grid-template-columns: 1fr 1fr;
  }

  .level-card {
    flex-direction: column;
    text-align: center;
  }

  .level-info {
    align-items: center;
  }

  .step-card {
    grid-template-columns: 26px 1fr;
    gap: 8px;
    padding: 10px;
  }

  .step-num {
    width: 26px;
    height: 26px;
    font-size: 0.85rem;
  }

  .step-card:not(:last-child)::after {
    left: 22px;
  }

  .eq-line {
    gap: 2px 4px;
  }

  .eq-term {
    padding: 3px;
  }

  .eq-formula {
    font-size: 1rem;
  }

  .mini-mols,
  .mini-mol svg {
    min-height: 22px;
    height: 22px;
  }

  .mini-mol {
    height: 22px;
  }

  .guide-grid > div + div {
    margin-top: 4px;
  }

  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-cards .stat-card:first-child {
    grid-column: 1 / -1;
  }

  .type-cards {
    grid-template-columns: 1fr;
  }

  .progress-row {
    grid-template-columns: 1fr 52px;
    gap: 4px 10px;
  }

  .progress-row .progress-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}
