/* ============================================================
   Rams Chess — estilo inspirado en Dieter Rams
   "Menos, pero mejor": pocos colores, formas claras, un acento.
   ============================================================ */

:root {
  /* Tema claro (crema) */
  --bg: #d9d9d9;
  --device: #e8e6e1;
  --device-edge: #cfcdc7;
  --device-shadow: rgba(0, 0, 0, 0.28);
  --panel-rule: #cfcdc6;
  --text: #2c2c2c;
  --text-soft: #7a7a78;
  --text-faint: #a5a49f;
  --sq-light: #dedcd6;
  --sq-dark: #bab8b1;
  --board-edge: #b3b1aa;
  --sq-select: rgba(242, 169, 0, 0.55);
  --sq-last: rgba(0, 0, 0, 0.09);
  --sq-check: rgba(215, 60, 40, 0.55);
  --hint: rgba(60, 60, 60, 0.28);
  --accent: #f2a900;
  --accent-ink: #1e1e1e;
  --accent-edge: #c98b00;
  --accent-soft: #3f9a6a;
  --btn: #e1dfda;
  --btn-edge: #c9c7c1;
  --btn-ink: #3a3a3a;
  --piece-w: #f1f0ec;
  --piece-w-edge: #b9b7b0;
  --piece-b: #262626;
  --piece-b-edge: #050505;
  --dlg: #ecebe6;
  --shadow-piece: rgba(0, 0, 0, 0.35);
  --screen: #1d1d1d;
  --screen-ink: #e9e7e1;
  --screen-dim: #8f8d87;
  --led-off: #cfcdc6;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  /* Tema oscuro (grafito) */
  --bg: #cfd0d2;
  --device: #6b6e72;
  --device-edge: #55585c;
  --device-shadow: rgba(0, 0, 0, 0.45);
  --panel-rule: #7f8286;
  --text: #f0f0f0;
  --text-soft: #c3c5c8;
  --text-faint: #9a9da1;
  --sq-light: #cdcfd1;
  --sq-dark: #9a9da1;
  --board-edge: #4d5054;
  --sq-select: rgba(244, 180, 0, 0.6);
  --sq-last: rgba(0, 0, 0, 0.13);
  --sq-check: rgba(230, 70, 50, 0.6);
  --hint: rgba(30, 30, 30, 0.35);
  --accent: #f4b400;
  --accent-ink: #1e1e1e;
  --accent-edge: #c98b00;
  --accent-soft: #f4b400;
  --btn: #5f6266;
  --btn-edge: #4a4d51;
  --btn-ink: #ececec;
  --piece-w: #f3f2ee;
  --piece-w-edge: #b5b3ad;
  --piece-b: #1f1f1f;
  --piece-b-edge: #000;
  --dlg: #55585c;
  --shadow-piece: rgba(0, 0, 0, 0.5);
  --screen: #141516;
  --screen-ink: #ecebe6;
  --screen-dim: #8d9095;
  --led-off: #4a4d51;
  color-scheme: dark;
}

/* Colores de acento (Ajustes) */
:root[data-accent="orange"] { --accent: #ed8008; --accent-ink: #1e1e1e; --accent-edge: #b86104; }
:root[data-accent="red"]    { --accent: #d9331a; --accent-ink: #ffffff; --accent-edge: #a02412; }
:root[data-accent="olive"]  { --accent: #8a8226; --accent-ink: #ffffff; --accent-edge: #5f5a17; }
:root[data-accent="blue"]   { --accent: #2f6fb5; --accent-ink: #ffffff; --accent-edge: #204f85; }
[data-theme="dark"][data-accent="orange"], [data-theme="dark"][data-accent="red"],
[data-theme="dark"][data-accent="olive"], [data-theme="dark"][data-accent="blue"] { --accent-soft: var(--accent); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Helvetica Neue", Helvetica, Inter, "Segoe UI", Arial, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s;
}
button { font: inherit; cursor: pointer; }

/* ---------- El aparato ---------- */
/* Ruido fino (feTurbulence) fundido con el color del aparato: grano de plástico/aluminio */
:root { --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0.75 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.device {
  position: relative;
  width: min(1180px, 100%);
  background-color: var(--device);
  background-image: var(--noise);
  background-size: 220px 220px;
  background-blend-mode: soft-light;
  border-radius: 28px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -2px 0 var(--device-edge),
    0 30px 60px -20px var(--device-shadow),
    0 2px 6px rgba(0, 0, 0, 0.12);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  padding: 22px 40px 28px 40px;
  transition: background-color 0.3s;
}
[data-theme="dark"] .device { background-blend-mode: overlay; }

/* ---------- Barra global ---------- */
.topbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--panel-rule);
}
.topbar-right { display: flex; align-items: center; gap: 18px; }
.brand {
  font-size: 11px;
  letter-spacing: 0.22em;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
}
.nav {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: var(--btn-edge);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.25);
}
.nav button {
  border: 0; background: transparent;
  color: var(--text-soft);
  padding: 8px 22px;
  border-radius: 999px;
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.nav button.on {
  background: var(--btn);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.4);
}
.nav button:not(.on):hover { color: var(--text); }
.gear {
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: var(--btn); color: var(--btn-ink);
  display: grid; place-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.45), inset 0 -2px 0 var(--btn-edge), 0 2px 5px rgba(0,0,0,0.18);
  transition: transform 0.4s;
}
.gear svg { width: 20px; height: 20px; }
.gear:hover { transform: rotate(30deg); }
.gear:active { transform: rotate(30deg) translateY(1px); }

/* ---------- Tablero ---------- */
.board-area {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  grid-template-rows: auto 26px;
  align-content: start;
  gap: 6px;
  padding-right: 32px;
  border-right: 1px solid var(--panel-rule);
}
.ranks, .files {
  display: grid;
  color: var(--text-soft);
  font-size: 12px;
}
.ranks { grid-template-rows: repeat(8, 1fr); align-items: center; }
.files { grid-column: 2; grid-template-columns: repeat(8, 1fr); text-align: center; align-items: start; }
.board-frame {
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: 10px;
  padding: 6px;
  background: var(--board-edge);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255, 255, 255, 0.4);
}
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%; height: 100%;
  border-radius: 4px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.sq { position: relative; background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.last::after { content: ""; position: absolute; inset: 0; background: var(--sq-last); }
.sq.selected::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 4px var(--sq-select); }
.sq.check::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, var(--sq-check) 0%, transparent 70%); }
.sq.hint::before {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 26%; height: 26%; border-radius: 50%;
  background: var(--hint);
  transform: translate(-50%, -50%);
  z-index: 1;
}
.sq.hint.capture::before {
  width: 88%; height: 88%; background: transparent;
  border: 4px solid var(--hint);
  box-sizing: border-box;
}
.sq.star::before {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 46%; height: 46%;
  transform: translate(-50%, -50%);
  background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6L2.5 9.4l6.6-.8z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6L2.5 9.4l6.6-.8z'/%3E%3C/svg%3E") center / contain no-repeat;
  filter: drop-shadow(0 2px 1px rgba(0,0,0,0.25));
  z-index: 1;
}
.sq.star.hint::before { background: var(--accent); }
.sq.drop-target::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 4px var(--accent); }

.piece {
  position: absolute; inset: 0;
  display: block;
  width: 100%; height: 100%;
  padding: 8%;
  pointer-events: none;
  z-index: 2;
  filter: drop-shadow(0 3px 2px var(--shadow-piece));
  transition: transform 0.12s;
}
.piece svg { width: 100%; height: 100%; display: block; }
.piece.w svg { fill: url(#pw); }
.piece.b svg { fill: url(#pb); }
.piece.w svg .cut { fill: #b9b7b0; }
.piece.b svg .cut { fill: #6a6a6a; }
.sq.selected .piece { transform: translateY(-4%) scale(1.04); }

.drag-ghost {
  position: fixed; left: 0; top: 0;
  pointer-events: none; z-index: 100;
  filter: drop-shadow(0 12px 10px rgba(0, 0, 0, 0.35));
  transform: translate(-50%, -50%) scale(1.1);
}
.drag-ghost svg { width: 100%; height: 100%; }
.drag-ghost.w svg { fill: url(#pw); }
.drag-ghost.b svg { fill: url(#pb); }
.sq.dragging .piece { opacity: 0.25; }

/* ---------- Panel derecho ---------- */
.panel {
  display: flex;
  flex-direction: column;
  padding-left: 32px;
  min-width: 0;
}
.rule { height: 1px; background: var(--panel-rule); margin: 14px 0; }

.player {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
}
.player .name { display: flex; align-items: center; gap: 10px; font-size: 16px; color: var(--text); }
.player .dot { width: 22px; height: 22px; border-radius: 50%; display: inline-block; box-shadow: inset 0 -2px 3px rgba(0,0,0,0.25), 0 1px 1px rgba(0,0,0,0.2); }
.player[data-color="b"] .dot { background: #232323; }
.player[data-color="w"] .dot { background: #f4f3ef; }
.player .tag { font-size: 11px; color: var(--text-faint); letter-spacing: 0.06em; text-transform: uppercase; }
.clock {
  font-size: clamp(38px, 4.2vw, 54px);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin-top: 6px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  transition: color 0.2s;
}
.player.active .clock { color: var(--text); }
.player:not(.active) .clock { color: var(--text-soft); }
.clock.low { color: #d2452e !important; }

.captured { border-left: 1px solid var(--panel-rule); padding-left: 16px; min-width: 120px; min-height: 84px; }
.captured-title { font-size: 11px; color: var(--text-soft); margin-bottom: 6px; }
.captured-list { display: flex; flex-wrap: wrap; gap: 2px; max-width: 132px; }
.captured-list .cap { width: 24px; height: 24px; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3)); }
.captured-list .cap svg { width: 100%; height: 100%; }
.captured-list .cap.w svg { fill: url(#pw); }
.captured-list .cap.b svg { fill: url(#pb); }
.captured-list .cap.w svg .cut { fill: #b9b7b0; }
.captured-list .cap.b svg .cut { fill: #6a6a6a; }
.captured .adv { font-size: 12px; color: var(--text-soft); align-self: center; margin-left: 4px; }

.moves-wrap { flex: 1; min-height: 160px; display: flex; flex-direction: column; gap: 10px; }
.moves {
  list-style: none; margin: 0; padding: 4px 0;
  flex: 1; overflow-y: auto; max-height: 220px;
  font-size: 15px;
  scrollbar-width: thin;
}
.moves li { display: grid; grid-template-columns: 28px 1fr 1fr 14px; gap: 8px; padding: 5px 4px; align-items: center; }
.moves li .n { color: var(--text-faint); font-size: 13px; }
.moves li .m { color: var(--text); }
.moves li .m.cur { font-weight: 600; }
.moves li .mark { width: 10px; height: 10px; border-radius: 50%; }
.moves li .mark.on { background: var(--accent-soft); }
.moves:empty::before { content: "—"; color: var(--text-faint); padding: 6px 4px; display: block; }

/* ---------- Botones circulares ---------- */
.controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 4px; }
.ctl {
  background: none; border: 0; padding: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: var(--text-soft);
}
.ctl-icon {
  width: 62px; height: 62px; border-radius: 50%;
  background: var(--btn);
  color: var(--btn-ink);
  display: grid; place-items: center;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.45),
    inset 0 -2px 0 var(--btn-edge),
    0 3px 6px rgba(0,0,0,0.18);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.ctl-icon svg { width: 26px; height: 26px; fill: currentColor; }
.ctl-icon svg[fill="none"] { fill: none; }
.ctl:hover .ctl-icon { filter: brightness(1.04); }
.ctl:active .ctl-icon { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), inset 0 -1px 0 var(--btn-edge), 0 1px 2px rgba(0,0,0,0.18); }
.ctl:disabled { opacity: 0.4; cursor: default; }
.ctl:disabled .ctl-icon { filter: none; transform: none; }
.ctl.accent .ctl-icon { background: var(--accent); color: var(--accent-ink); box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), inset 0 -2px 0 var(--accent-edge), 0 3px 6px rgba(0,0,0,0.2); }
.ctl-label { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap; }

/* ---------- Interruptores ---------- */
.switches { display: grid; gap: 14px; margin-bottom: 8px; }
.dlg .switch-row { font-size: 14px; color: var(--text); }
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--text-soft);
  cursor: pointer;
}
.switch-row input { position: absolute; opacity: 0; width: 0; height: 0; }
.track {
  width: 44px; height: 24px; border-radius: 12px;
  background: var(--btn-edge);
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
  transition: background 0.2s;
  flex: none;
}
.knob {
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #f6f5f1;
  box-shadow: 0 1px 2px rgba(0,0,0,0.35);
  transition: left 0.18s;
}
.switch:checked + .track { background: var(--accent); }
.switch:checked + .track .knob { left: 23px; }
.switch:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Segmentados ---------- */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  border: 1px solid var(--btn-edge);
  background: var(--btn);
  color: var(--text-soft);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}
.seg button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.seg.small button { padding: 3px 10px; font-size: 11px; }
.lang-row { cursor: default; }

/* ---------- Diálogos ---------- */
.dlg {
  border: 0; padding: 0;
  background: var(--dlg);
  color: var(--text);
  border-radius: 20px;
  width: min(520px, calc(100vw - 32px));
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.5);
}
.dlg::backdrop { background: rgba(20, 20, 20, 0.45); backdrop-filter: blur(2px); }
.dlg-body { padding: 28px 28px 24px; margin: 0; }
.dlg h2 { margin: 0 0 18px; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.muted { color: var(--text-soft); font-size: 14px; margin: 0 0 16px; }
.field { margin-bottom: 18px; }
.field-label { display: block; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-soft); margin-bottom: 8px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.btn { border: 0; border-radius: 999px; padding: 11px 20px; font-size: 14px; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: inset 0 -2px 0 var(--accent-edge); }
.btn.ghost { background: var(--btn); color: var(--text); box-shadow: inset 0 -2px 0 var(--btn-edge); }
.btn:active { transform: translateY(1px); }

.promo-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.promo-row button {
  border: 1px solid var(--btn-edge); background: var(--btn); border-radius: 14px;
  padding: 10px; aspect-ratio: 1; display: grid; place-items: center;
}
.promo-row button:hover { border-color: var(--accent); }
.promo-row svg { width: 100%; height: 100%; }
.promo-row .w svg { fill: url(#pw); }
.promo-row .b svg { fill: url(#pb); }

.pause-veil[hidden] { display: none; }
.pause-veil {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(30, 30, 30, 0.35);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
}
.pause-card {
  background: var(--dlg); color: var(--text);
  border-radius: 20px; padding: 32px 40px;
  text-align: center; box-shadow: 0 30px 60px -20px rgba(0,0,0,0.5);
}
.pause-title { font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-soft); margin-bottom: 18px; }

.foot { margin-top: 18px; font-size: 12px; color: #6f6f6f; display: flex; gap: 14px; align-items: center; }
.foot a { color: inherit; }

/* ---------- Responsive ---------- */
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
.device { min-width: 0; }

@media (max-width: 900px) {
  body { padding: 10px 8px; }
  .device {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    padding: 14px 14px 20px;
    border-radius: 22px;
  }
  /* Barra: marca y botones arriba, pestañas a ancho completo debajo */
  .topbar { flex-wrap: wrap; gap: 10px; padding-bottom: 12px; margin-bottom: 12px; }
  .topbar-right { order: 1; width: 100%; gap: 10px; }
  .brand { display: inline; margin-right: auto; font-size: 10px; }
  .gear { width: 36px; height: 36px; }
  .gear svg { width: 18px; height: 18px; }
  .nav { order: 2; flex: 1 1 100%; display: flex; }
  .nav button { flex: 1; padding: 8px 4px; font-size: 10px; letter-spacing: 0.12em; }

  .board-area { grid-template-columns: 18px minmax(0, 1fr); grid-template-rows: auto 18px; gap: 4px; border-right: 0; padding-right: 0; }
  .ranks, .files { font-size: 10.5px; }
  .board-frame { padding: 5px; border-radius: 8px; }

  .panel { padding-left: 0; margin-top: 14px; }
  .rule { margin: 10px 0; }
  .player { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .player .name { font-size: 15px; }
  .clock { font-size: 34px; margin-top: 4px; }
  .captured { min-width: 96px; min-height: 0; padding-left: 12px; }
  .captured-list { max-width: 104px; }
  .captured-list .cap { width: 20px; height: 20px; }
  .moves-wrap { min-height: 0; }
  .moves { max-height: 110px; font-size: 14px; }
  .screen { min-height: 60px; padding: 12px 14px; font-size: 12px; }

  .controls { gap: 6px; }
  .ctl-icon { width: 52px; height: 52px; }
  .ctl-icon svg { width: 22px; height: 22px; }
  .ctl-label { font-size: 9px; letter-spacing: 0.08em; }

  .lesson-groups, .game-list { max-height: none; }
  .lesson-item { padding: 8px 4px; }
  .foot { flex-wrap: wrap; justify-content: center; text-align: center; margin-top: 14px; }
  .input { font-size: 16px; }   /* evita el zoom automático de iOS */
}

@media (max-width: 420px) {
  body { padding: 6px 6px 12px; }
  .device { padding: 12px 10px 16px; border-radius: 18px; }
  .board-area { grid-template-columns: 14px minmax(0, 1fr); gap: 3px; }
  .ranks, .files { font-size: 9.5px; }
  .player .dot { width: 18px; height: 18px; }
  .player .tag { font-size: 10px; }
  .clock { font-size: 30px; }
  .captured { min-width: 88px; padding-left: 10px; }
  .captured-title { font-size: 10px; }
  .controls { gap: 4px; }
  .ctl-icon { width: 46px; height: 46px; }
  .ctl-icon svg { width: 20px; height: 20px; }
  .ctl-label { font-size: 8.5px; letter-spacing: 0.06em; }
  .dlg { width: calc(100vw - 20px); border-radius: 16px; }
  .dlg-body { padding: 20px 16px 18px; }
  .seg button { padding: 7px 10px; font-size: 12px; }
  .swatches { gap: 10px; }
  .swatch { width: 32px; height: 32px; }
  .dlg .switch-row { font-size: 13px; }
  .meter { padding: 10px 8px; }
  .meter .m-total { font-size: 22px; }
  .xp-chip { font-size: 10px; padding: 4px 8px; }
  .lesson-title { grid-template-columns: 38px 1fr; }
  .lesson-title .xp-chip { grid-column: 1 / -1; justify-self: start; }
}

/* ---------- Aprender ---------- */
#panel-learn { min-height: 0; }
.learn-head h2, .lesson-title h2 { margin: 0 0 6px; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.learn-head .muted { margin-bottom: 14px; }
.lesson-groups { overflow-y: auto; max-height: 560px; padding-right: 4px; scrollbar-width: thin; }
.lesson-group-title {
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-soft); margin: 14px 0 6px;
}
.lesson-item {
  width: 100%; border: 0; background: transparent; color: var(--text);
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px;
  padding: 8px 6px; border-radius: 12px; text-align: left;
  transition: background 0.15s;
}
.lesson-item:hover { background: rgba(0,0,0,0.06); }
[data-theme="dark"] .lesson-item:hover { background: rgba(255,255,255,0.06); }
.lesson-item .title { font-size: 14.5px; }
.lesson-item .sub { font-size: 11.5px; color: var(--text-soft); margin-top: 2px; }
.lesson-icon { width: 34px; height: 34px; display: grid; place-items: center; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3)); }
.lesson-icon svg { width: 100%; height: 100%; fill: url(#pw); }
.lesson-icon svg .cut { fill: #b9b7b0; }
.lesson-prog { display: flex; gap: 4px; align-items: center; }
.lesson-prog .p { width: 8px; height: 8px; border-radius: 50%; background: var(--btn-edge); }
.lesson-prog .p.on { background: var(--accent); }
.lesson-prog .done { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.lesson-prog .done svg { width: 14px; height: 14px; }

.link-back {
  border: 0; background: transparent; color: var(--text-soft);
  display: inline-flex; align-items: center; gap: 4px; padding: 0 0 12px;
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 600;
}
.link-back svg { width: 16px; height: 16px; }
.link-back:hover { color: var(--text); }
.lesson-title { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: center; margin-bottom: 8px; }
.lesson-title .lesson-icon { width: 44px; height: 44px; }
.stage-dots { display: flex; gap: 6px; }
.stage-dots .sd { width: 10px; height: 10px; border-radius: 50%; background: var(--btn-edge); box-shadow: inset 0 1px 2px rgba(0,0,0,0.2); }
.stage-dots .sd.done { background: var(--accent-soft); }
.stage-dots .sd.cur { box-shadow: 0 0 0 2px var(--accent); background: var(--btn); }
.stage-dots .sd.cur.done { background: var(--accent-soft); }
.xp-chip { align-self: start; font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; color: var(--text-soft); padding: 5px 10px; border-radius: 6px; background: var(--screen); color: var(--screen-ink); white-space: nowrap; box-shadow: inset 0 1px 3px rgba(0,0,0,0.6); }
.lesson-title { grid-template-columns: 44px 1fr auto; }
.controls-2 { grid-template-columns: repeat(2, 1fr); max-width: 220px; margin-left: auto; margin-right: auto; }
.ctl.accent:disabled .ctl-icon { background: var(--btn); color: var(--btn-ink); box-shadow: inset 0 1px 0 rgba(255,255,255,0.45), inset 0 -2px 0 var(--btn-edge), 0 3px 6px rgba(0,0,0,0.18); }

/* ---------- Selector de acento ---------- */
.swatches { display: flex; gap: 14px; }
.swatch {
  width: 38px; height: 38px; border-radius: 50%; border: 0; padding: 0;
  background: var(--c);
  box-shadow:
    inset 0 3px 4px rgba(255,255,255,0.35),
    inset 0 -4px 5px rgba(0,0,0,0.28),
    0 2px 3px rgba(0,0,0,0.35);
  position: relative;
  transition: transform 0.1s;
}
.swatch:hover { transform: translateY(-1px); }
.swatch:active { transform: translateY(1px); box-shadow: inset 0 2px 3px rgba(255,255,255,0.25), inset 0 -2px 3px rgba(0,0,0,0.3), 0 1px 1px rgba(0,0,0,0.3); }
.swatch.on::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid var(--text);
}

/* ---------- Display (pantalla oscura, texto monoespaciado, trama de puntos) ---------- */
.mono { font-family: var(--mono); }
.display { display: grid; gap: 6px; }
.screen {
  background: var(--screen);
  color: var(--screen-ink);
  border-radius: 12px;
  padding: 14px 16px;
  min-height: 74px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  letter-spacing: 0.01em;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.7), inset 0 0 0 1px rgba(255,255,255,0.05), 0 1px 0 rgba(255,255,255,0.35);
  background-image: radial-gradient(rgba(255,255,255,0.07) 0.6px, transparent 0.7px);
  background-size: 4px 4px;
  position: relative;
}
.screen.small { min-height: 0; padding: 10px 12px; font-size: 12px; }
.screen.small:empty { display: none; }
.screen.alert { color: #ff8a73; }
.screen .dim { color: var(--screen-dim); }
.screen .fb { margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(255,255,255,0.18); }
.screen .fb:empty { display: none; }
.screen .fb-title { display: inline-flex; align-items: center; gap: 8px; text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; margin-bottom: 2px; }
.screen .fb-xp { display: block; margin-top: 4px; color: var(--accent); }
.led { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent); flex: none; }
.led.err { background: #ff5a3c; box-shadow: 0 0 6px #ff5a3c; }
.led.ok { background: #5ad38a; box-shadow: 0 0 6px #5ad38a; }
.module-label {
  font-family: var(--mono);
  font-size: 9.5px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--text-faint); text-align: center; margin-top: 4px;
}
.controls + .module-label { margin-top: 10px; }

/* ---------- Medidor (experiencia / cuenta) ---------- */
.meter {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: end;
  padding: 12px 14px 12px; margin-bottom: 8px;
  border-top: 1px solid var(--panel-rule); border-bottom: 1px solid var(--panel-rule);
}
.meter .m-label { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-faint); }
.meter .m-value { font-family: var(--mono); font-size: 13px; color: var(--text); letter-spacing: 0.02em; display: flex; align-items: center; gap: 10px; }
.meter .m-value .lesson-icon { width: 22px; height: 22px; }
.meter .m-total { grid-row: span 2; align-self: center; font-size: 26px; font-weight: 300; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; text-align: right; line-height: 1; }
.meter .m-total small { display: block; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-faint); margin-top: 4px; font-weight: 400; }
.led-bar { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; margin-top: 6px; }
.led-bar i { display: block; height: 6px; border-radius: 2px; background: var(--led-off); box-shadow: inset 0 1px 1px rgba(0,0,0,0.2); }
.led-bar i.on { background: var(--accent); box-shadow: 0 0 4px var(--accent); }
.meter .m-sub { grid-column: 1 / -1; font-family: var(--mono); font-size: 10.5px; color: var(--text-soft); }

/* ---------- Partidas ---------- */
.game-list { overflow-y: auto; max-height: 560px; scrollbar-width: thin; }
.game-item {
  width: 100%; border: 0; background: transparent; color: var(--text); text-align: left;
  display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 12px;
  padding: 10px 6px; border-radius: 10px; border-bottom: 1px solid var(--panel-rule);
}
.game-item:hover { background: rgba(0,0,0,0.06); }
[data-theme="dark"] .game-item:hover { background: rgba(255,255,255,0.06); }
.game-item .res { width: 10px; height: 10px; border-radius: 50%; background: var(--btn-edge); }
.game-item .res.w { background: #f4f3ef; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.3); }
.game-item .res.b { background: #232323; }
.game-item .res.d { background: linear-gradient(90deg, #f4f3ef 50%, #232323 50%); }
.game-item .g-title { font-size: 14px; }
.game-item .g-sub { font-family: var(--mono); font-size: 10.5px; color: var(--text-soft); margin-top: 3px; letter-spacing: 0.02em; }
.game-item .g-right { font-family: var(--mono); font-size: 11px; color: var(--text-soft); text-align: right; }
.game-list:empty::before { content: attr(data-empty); display: block; font-family: var(--mono); font-size: 12px; color: var(--text-faint); padding: 14px 6px; }
.controls-3 { grid-template-columns: repeat(3, 1fr); max-width: 300px; margin-left: auto; margin-right: auto; }

/* ---------- Entradas ---------- */
.input {
  width: 100%; border: 1px solid var(--btn-edge); background: var(--btn); color: var(--text);
  border-radius: 10px; padding: 11px 12px; font-size: 15px; outline: none;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.input.mono { letter-spacing: 0.3em; font-size: 20px; text-align: center; }
.gear { position: relative; }
.gear .led { position: absolute; right: 2px; top: 2px; width: 9px; height: 9px; border: 2px solid var(--device); box-sizing: content-box; }
