/* =========================================================
   Makey Lab · sistema visual
   Fondo de papel, tipografía Lexend (diseñada para facilitar la lectura),
   color plano y una paleta asociada a cada entrada del Makey Makey.
   ========================================================= */
:root {
  --bg: #F4F1EA;
  --dot: rgba(30, 28, 39, .075);
  --surface: #FFFFFF;
  --surface-2: #FAF8F3;
  --sunken: rgba(30, 28, 39, .055);
  --ink: #1E1C27;
  --ink-2: #4A4757;
  --muted: #7C7889;
  --line: #E6E1D7;
  --line-2: #D5CEC1;
  --ok: #2E9E68;
  --danger: #D8402B;
  --a: #1E1C27;
  --radius: 18px;
  --shadow-sm: 0 1px 2px rgba(30, 28, 39, .06);
  --shadow-md: 0 1px 2px rgba(30, 28, 39, .05), 0 6px 18px rgba(30, 28, 39, .07);
  --shadow-lg: 0 2px 6px rgba(30, 28, 39, .06), 0 28px 70px rgba(30, 28, 39, .18);
  --font: 'Lexend', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --gutter: clamp(16px, 2.2vw, 32px);
  color-scheme: light;
}

/* Sala oscura para la actividad sensorial (tipo sala multisensorial). */
body.dark-room {
  --bg: #100F18;
  --dot: rgba(255, 255, 255, .05);
  --surface: #1B1A26;
  --surface-2: #22212F;
  --sunken: rgba(255, 255, 255, .07);
  --ink: #F3F1F8;
  --ink-2: #C9C5D6;
  --muted: #8E899E;
  --line: #2D2B3B;
  --line-2: #3A3849;
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.3px);
  background-size: 24px 24px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .4s ease;
}
input, textarea { user-select: text; -webkit-user-select: text; }

.ico { width: 1.15em; height: 1.15em; flex: none; }
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.7em; height: 1.7em; padding: 0 .4em;
  font-family: var(--font); font-size: .82em; font-weight: 500;
  border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px;
  background: var(--surface);
}
.kicker { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

#stage { position: relative; z-index: 1; height: 100%; overflow-y: auto; }
#fx { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
#flash { position: fixed; inset: 0; z-index: 6; pointer-events: none; opacity: 0; }

/* ---------- Botones y controles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 16px;
  font: 500 15px/1 var(--font);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .seg button:focus-visible, .icon-btn:focus-visible, .act:focus-visible { outline: 3px solid color-mix(in srgb, var(--a) 45%, transparent); outline-offset: 2px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 85%, #fff); border-color: var(--ink); }
.btn-quiet { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn-quiet:hover { background: var(--sunken); border-color: transparent; color: var(--ink); }
.btn-accent { background: var(--a); border-color: var(--a); color: #fff; }
.btn-accent:hover { background: color-mix(in srgb, var(--a) 88%, #000); border-color: transparent; }
.btn-rec { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-rec:hover { border-color: transparent; background: color-mix(in srgb, var(--danger) 88%, #000); }
.btn-rec.on { animation: recPulse 1.2s ease-in-out infinite; }
@keyframes recPulse { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--danger) 20%, transparent); } }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-2); }

.seg {
  display: inline-flex; gap: 2px; padding: 4px;
  background: var(--sunken);
  border-radius: 13px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: none;
  height: 34px; padding: 0 14px;
  font: 500 14px/1 var(--font);
  color: var(--ink-2);
  background: transparent;
  border: 0; border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg button:hover:not(:disabled) { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(30, 28, 39, .14); }
.seg button:disabled { opacity: .4; cursor: not-allowed; }

.tag {
  display: inline-flex; align-items: center;
  height: 24px; padding: 0 10px;
  font-size: 12px; font-weight: 600;
  color: color-mix(in srgb, var(--a) 82%, #000);
  background: color-mix(in srgb, var(--a) 13%, var(--surface));
  border-radius: 999px;
}

.keycap {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 9px;
  font-size: 14px; font-weight: 600; line-height: 1;
  color: #fff;
  background: var(--c, var(--ink));
  border-radius: 8px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .2);
}
.keycap.lg { min-width: 40px; height: 40px; font-size: 17px; border-radius: 10px; }
.keycap.sm { min-width: 24px; height: 24px; font-size: 12px; border-radius: 6px; padding: 0 6px; vertical-align: middle; }

.obj { display: block; }
.obj-emoji { line-height: 1; }
.obj-img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; }

/* ---------- Esquina, ajustes, ayuda y avisos ---------- */
#corner { position: fixed; top: 14px; right: var(--gutter); z-index: 20; display: flex; gap: 8px; }

.panel {
  position: fixed; top: 66px; right: var(--gutter); z-index: 21;
  width: 290px; padding: 18px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: rise .2s ease-out;
}
.panel h3 { margin: 0 0 14px; font-size: 16px; font-weight: 600; }
.panel .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; font-size: 15px; }
.panel input[type=range] { width: 130px; accent-color: var(--ink); }
.panel .hint { color: var(--muted); font-size: 13px; margin: 14px 0 0; }
.switch { width: 20px; height: 20px; accent-color: var(--ok); }

.modal {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(20, 18, 28, .45);
  backdrop-filter: blur(3px);
}
.modal-card {
  position: relative;
  width: min(820px, 100%); max-height: 90vh; overflow: auto;
  padding: clamp(22px, 3vw, 40px);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: rise .25s cubic-bezier(.2, .9, .3, 1.1);
  user-select: text;
}
.modal-card h2 { margin: 6px 0 20px; font-size: clamp(22px, 2.4vw, 30px); font-weight: 600; letter-spacing: -.01em; }
.modal-x { position: absolute; top: 16px; right: 16px; }
.guide { list-style: none; counter-reset: g; padding: 0; margin: 0 0 22px; display: grid; gap: 10px; }
.guide li { counter-increment: g; display: grid; grid-template-columns: 34px 110px 1fr; align-items: baseline; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.guide li::before { content: counter(g); display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--surface); font-size: 13px; font-weight: 600; }
.guide b { font-weight: 600; }
.guide span { color: var(--ink-2); }
.guide-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.guide-grid div { padding: 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.guide-grid h4 { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.guide-grid p { margin: 0; font-size: 14px; color: var(--ink-2); }

#toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 40;
  transform: translate(-50%, 20px);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--ink); color: var(--surface);
  font-size: 15px;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.pop { animation: pop .3s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: scale(.85); opacity: .3; } }
.wiggle { animation: wiggle .4s ease-in-out; }
@keyframes wiggle { 25%, 75% { transform: translateX(-6px); } 50% { transform: translateX(6px); } }

/* ---------- Inicio ---------- */
.home { min-height: 100%; display: flex; flex-direction: column; }
.topbar, .bar {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  min-height: 70px;
  padding: 12px calc(var(--gutter) + 160px) 12px var(--gutter);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand-mark { width: 36px; height: 36px; }
.brand b { display: block; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.brand small { display: block; font-size: 13px; color: var(--muted); }

.home-grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: clamp(20px, 2.5vw, 36px);
  padding: clamp(20px, 3.5vh, 40px) var(--gutter) var(--gutter);
  max-width: 1500px; width: 100%; margin: 0 auto;
}
.intro { margin-bottom: clamp(18px, 3vh, 30px); max-width: 760px; }
.intro h1 { margin: 8px 0 10px; font-size: clamp(28px, 3.4vw, 46px); font-weight: 600; line-height: 1.1; letter-spacing: -.025em; }
.lead { margin: 0; font-size: clamp(15px, 1.25vw, 18px); color: var(--ink-2); max-width: 62ch; }

.acts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(12px, 1.4vw, 18px); }
.act {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 20px;
  text-align: left;
  font-family: var(--font);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s;
  animation: rise .4s ease-out both;
  animation-delay: calc(var(--i) * 40ms);
}
.act::before { content: ''; position: absolute; left: 0; top: 0; right: 0; height: 4px; background: var(--a); transform: scaleX(0); transform-origin: left; transition: transform .25s ease; }
.act:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-2); }
.act:hover::before { transform: scaleX(1); }
.act-top { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-bottom: 6px; }
.act-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; background: color-mix(in srgb, var(--a) 13%, var(--surface)); color: var(--a); font-size: 22px; }
.act-num { font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.act-title { font-size: clamp(17px, 1.35vw, 20px); font-weight: 600; letter-spacing: -.01em; }
.act-desc { font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.act-foot { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); width: 100%; }
.act-goal { font-size: 13px; color: var(--muted); }
.act-goal::before { content: 'Objetivo · '; font-weight: 600; color: var(--ink-2); }

.objects-panel {
  align-self: start;
  position: sticky; top: 94px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.panel-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.panel-head small { color: var(--muted); font-size: 13px; }
.panel-ico { color: var(--muted); font-size: 20px; }
.obj-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.obj-row {
  display: grid; grid-template-columns: 44px 1fr auto 24px; align-items: center; gap: 12px;
  padding: 8px 10px 8px 8px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, transform .15s;
}
.obj-row.inactive { opacity: .45; }
.obj-thumb { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 11px; background: color-mix(in srgb, var(--c) 12%, var(--surface)); font-size: 26px; overflow: hidden; }
.obj-thumb .obj-img { border-radius: 0; }
.obj-meta { min-width: 0; }
.obj-meta b { display: block; font-weight: 500; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.obj-meta small { display: block; font-size: 12.5px; color: var(--muted); }
.status { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1.5px dashed var(--line-2); color: transparent; font-size: 13px; }
.obj-row.ok .status { background: var(--ok); border: 0; color: #fff; }
.obj-row.lit { background: color-mix(in srgb, var(--c) 12%, var(--surface)); border-color: var(--c); transform: scale(1.02); }
.panel-tip { margin: 0 0 14px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }

/* ---------- Pantallas de actividad ---------- */
.mode { height: 100%; display: flex; flex-direction: column; }
.bar-title { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.bar-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: color-mix(in srgb, var(--a) 14%, var(--surface)); color: var(--a); font-size: 20px; }
.bar-title h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
.bar-area { font-size: 13px; color: var(--muted); }
.bar-controls { display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%; }
.bar-label { font-size: 13px; color: var(--muted); }
.howto {
  display: flex; align-items: center; gap: 10px;
  margin: 14px var(--gutter) 0;
  padding: 10px 14px;
  width: fit-content; max-width: calc(100% - 2 * var(--gutter));
  font-size: 14.5px; color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.howto .ico { color: var(--a); }
.main { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 12px var(--gutter); }

/* ---------- Tarjetas de objeto (las «teclas» en pantalla) ---------- */
.pads {
  display: grid;
  grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr));
  gap: clamp(8px, 1.1vw, 16px);
  height: clamp(150px, 29vh, 270px);
  padding: 0 var(--gutter) clamp(16px, 2.6vh, 28px);
  max-width: 1600px; width: 100%; margin: 0 auto;
}
.pad {
  position: relative;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 6px;
  padding: 12px 12px 16px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 20px;
  box-shadow: inset 0 -6px 0 var(--c), var(--shadow-md);
  cursor: pointer;
  transition: transform .09s ease, box-shadow .12s, background .12s, border-color .12s;
}
.pad-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; }
.pad-sub {
  font-size: 12.5px; font-weight: 600;
  padding: 4px 9px; border-radius: 999px;
  color: color-mix(in srgb, var(--c) 78%, #000);
  background: color-mix(in srgb, var(--c) 13%, var(--surface));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pad-visual { display: grid; place-items: center; min-height: 0; padding: 4px; }
.pad-visual .obj-emoji { font-size: clamp(40px, min(6vw, 11vh), 104px); }
.pad-visual .obj-img { max-height: 100%; }
.pad-name { font-size: clamp(14px, 1.35vw, 20px); font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pad-mini { position: absolute; right: 10px; bottom: 16px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 18px; overflow: hidden; }
.pad-mini .obj-img { border-radius: 0; }
.pad.down {
  transform: translateY(4px);
  background: var(--c);
  border-color: var(--c);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18), 0 0 0 6px color-mix(in srgb, var(--c) 22%, transparent), 0 14px 34px color-mix(in srgb, var(--c) 40%, transparent);
  color: #fff;
}
.pad.down .keycap { background: #fff; color: var(--c); box-shadow: none; }
.pad.down .pad-sub { background: rgba(255, 255, 255, .22); color: #fff; }
.pad.hit .pad-visual > * { animation: bounce .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes bounce { 35% { transform: scale(1.18) rotate(-4deg); } 70% { transform: scale(.96); } }
.pad.next { border-color: var(--c); box-shadow: inset 0 -6px 0 var(--c), 0 0 0 5px color-mix(in srgb, var(--c) 28%, transparent), var(--shadow-md); animation: nudge 1.1s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(-6px); } }

/* ---------- Configurar objetos ---------- */
.slots {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(12px, 1.4vw, 18px);
  padding: 18px var(--gutter) var(--gutter);
  max-width: 1400px; width: 100%; margin: 0 auto;
}
.slot {
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s, transform .15s, opacity .2s;
}
.slot.inactive { opacity: .55; }
.slot.inactive .slot-visual { filter: grayscale(1); }
.slot.lit { border-color: var(--c); box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 22%, transparent), var(--shadow-md); transform: translateY(-2px); }
.slot.drop { border-style: dashed; border-color: var(--c); background: color-mix(in srgb, var(--c) 6%, var(--surface)); }
.slot-head { display: flex; align-items: center; gap: 12px; }
.slot-title { flex: 1; min-width: 0; }
.slot-title b { display: block; font-weight: 600; font-size: 15px; }
.slot-title small { display: block; font-size: 12.5px; color: var(--muted); }
.slot.lit .detect { color: var(--ok); font-weight: 600; }
.slot-visual {
  position: relative;
  display: grid; place-items: center;
  height: 150px;
  padding: 14px;
  border: 1.5px dashed var(--line-2);
  border-radius: 14px;
  background: color-mix(in srgb, var(--c) 7%, var(--surface));
  cursor: pointer;
  overflow: hidden;
}
.slot-visual .obj-emoji { font-size: 84px; }
.slot-hint {
  position: absolute; right: 10px; bottom: 10px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 8px;
  font: 500 12.5px var(--font); color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line);
  opacity: 0; transform: translateY(4px); transition: all .15s;
}
.slot-visual:hover .slot-hint { opacity: 1; transform: none; }
.field { display: grid; gap: 6px; }
.field span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field input {
  height: 44px; padding: 0 14px;
  font: 500 16px var(--font); color: var(--ink);
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--c); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 18%, transparent); background: var(--surface); }
.slot-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--s); cursor: pointer; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .08); transition: transform .12s; }
.sw:hover { transform: scale(1.12); }
.sw.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--s); }

.toggle { position: relative; width: 44px; height: 26px; flex: none; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.toggle span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); transition: background .15s; pointer-events: none; }
.toggle span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.toggle input:checked + span { background: var(--ok); }
.toggle input:checked + span::after { transform: translateX(18px); }
.toggle input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--ok) 40%, transparent); outline-offset: 2px; }

/* --- Selector de emojis --- */
.picker-backdrop { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; padding: 16px; background: rgba(20, 18, 28, .45); backdrop-filter: blur(3px); }
.picker {
  display: flex; flex-direction: column;
  width: min(860px, 100%); height: min(680px, 92vh);
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: rise .22s ease-out;
}
.picker-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 22px 12px; }
.picker-head h3 { margin: 4px 0 0; font-size: 20px; font-weight: 600; }
.picker-search {
  display: flex; align-items: center; gap: 10px;
  margin: 0 22px 12px; padding: 0 14px;
  height: 48px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
  color: var(--muted);
}
.picker-search:focus-within { border-color: var(--ink-2); background: var(--surface); }
.picker-search input { flex: 1; border: 0; outline: 0; background: transparent; font: 500 16px var(--font); color: var(--ink); }
.picker-tabs { padding: 0 22px 12px; border-bottom: 1px solid var(--line); }
.picker-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; padding: 14px 22px; align-content: start; }
.emo-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px 8px;
  border: 1.5px solid transparent; border-radius: 12px;
  background: transparent; cursor: pointer;
  font-family: var(--font);
  transition: background .12s, border-color .12s;
}
.emo-btn span { font-size: 38px; line-height: 1.1; }
.emo-btn small { font-size: 11.5px; color: var(--ink-2); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emo-btn:hover { background: var(--surface-2); border-color: var(--line); }
.emo-btn.on { border-color: var(--ink); background: var(--surface-2); }
.empty { grid-column: 1 / -1; color: var(--muted); text-align: center; padding: 40px 0; }
.picker-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); font-size: 13px; color: var(--ink-2); }

/* ---------- 01 Piano ---------- */
.piano-stage { width: 100%; max-width: 1100px; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(10px, 2vh, 22px); }
.note-display { width: 100%; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: clamp(16px, 3vw, 40px); padding: clamp(14px, 2vh, 24px) clamp(18px, 2.5vw, 32px); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-sm); }
.note-name { min-width: 3.2ch; font-size: clamp(56px, 11vh, 120px); font-weight: 600; line-height: 1; letter-spacing: -.03em; color: var(--ink); text-align: center; }
.staff { width: 100%; height: clamp(80px, 15vh, 150px); }
.st-line { stroke: var(--line-2); stroke-width: 1.4; }
.st-clef { font-size: 64px; fill: var(--ink-2); font-family: 'Apple Symbols', 'Segoe UI Symbol', 'Noto Music', serif; }
.st-txt { font: 600 11px var(--font); }
.st-new { animation: rise .3s ease-out; }
.song-panel { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.song-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.score-wrap { width: 100%; overflow-x: auto; scrollbar-width: none; mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); }
.score-wrap::-webkit-scrollbar { display: none; }
.score { display: flex; gap: 8px; padding: 10px 45%; width: max-content; }
.sn {
  flex: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 58px; height: 70px; padding: 6px;
  border-radius: 14px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  box-shadow: inset 0 -3px 0 var(--c);
  font-size: 26px;
  transition: all .2s;
}
.sn .obj-img { width: 32px; height: 32px; }
.sn.long { width: 84px; }
.sn small { font-size: 11px; font-weight: 600; color: var(--ink-2); }
.sn.done { opacity: .3; transform: scale(.88); }
.sn.cur { border-color: var(--c); transform: scale(1.14); box-shadow: inset 0 -3px 0 var(--c), 0 0 0 5px color-mix(in srgb, var(--c) 22%, transparent); }

/* ---------- 02 Batería ---------- */
.drum-stage { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(14px, 2.4vh, 26px); height: 100%; }
.pulse {
  --c: var(--ink);
  position: relative;
  width: clamp(130px, 25vh, 240px); aspect-ratio: 1;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md), inset 0 0 0 14px var(--surface-2);
}
.pulse-in { width: 46%; aspect-ratio: 1; border-radius: 50%; background: var(--c); transition: background .15s; }
.pulse-label { position: absolute; bottom: -34px; font-size: 15px; font-weight: 600; color: var(--ink-2); }
.pulse.thump .pulse-in { animation: thump .25s ease-out; }
@keyframes thump { 30% { transform: scale(1.45); } }
.steps { display: flex; gap: clamp(4px, .7vw, 8px); margin-top: 22px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.steps i { width: clamp(14px, 1.6vw, 22px); height: clamp(22px, 2.4vw, 32px); border-radius: 6px; background: var(--sunken); transition: background .06s; }
.steps i.beat { background: color-mix(in srgb, var(--ink) 14%, transparent); }
.steps i.on { background: var(--a); }
.rec-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.rec-status { color: var(--ink-2); font-size: 14.5px; }

/* ---------- 03 Luz y sonido ---------- */
.magic-stage { width: 100%; height: 100%; display: grid; place-items: center; }
.magic-word { font-size: clamp(40px, 8vw, 120px); font-weight: 600; letter-spacing: -.03em; text-align: center; color: var(--c, var(--muted)); text-shadow: 0 0 60px color-mix(in srgb, var(--c, transparent) 60%, transparent); }
.magic-word.pop { animation: grow .6s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes grow { from { transform: scale(.4); opacity: 0; } }
body.dark-room .pad { box-shadow: inset 0 -6px 0 var(--c), 0 0 30px color-mix(in srgb, var(--c) 14%, transparent); }

/* ---------- 04 Palabras ---------- */
.words-stage { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(12px, 2vh, 22px); height: 100%; width: 100%; }
.mode-switch { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.word-card {
  --c: var(--line-2);
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: clamp(20px, 3.5vw, 56px);
  width: min(1000px, 100%);
  padding: clamp(18px, 3vh, 34px) clamp(22px, 3.5vw, 48px);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 26px;
  box-shadow: inset 6px 0 0 var(--c), var(--shadow-md);
}
.word-card.pop { animation: rise .35s ease-out; }
.wc-visual { display: grid; place-items: center; width: clamp(120px, 22vh, 220px); aspect-ratio: 1; border-radius: 20px; background: color-mix(in srgb, var(--c) 10%, var(--surface)); }
.wc-visual .obj-emoji { font-size: clamp(76px, 15vh, 150px); }
.wc-visual .obj-img { width: 86%; height: 86%; }
.word-card.pop .wc-visual > * { animation: bounce .6s cubic-bezier(.2, 1.6, .4, 1); }
.wc-placeholder { color: var(--line-2); font-size: clamp(50px, 9vh, 90px); }
.wc-q { font-size: clamp(80px, 15vh, 150px); font-weight: 600; color: var(--ink); line-height: 1; }
.wc-label { font-size: 13px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.wc-syl { display: flex; flex-wrap: wrap; gap: 10px; }
.wc-syl span {
  display: inline-flex; align-items: center;
  padding: .12em .38em;
  font-size: clamp(36px, 7.5vh, 84px); font-weight: 600; letter-spacing: .02em; line-height: 1.1;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  transition: background .2s, color .2s, border-color .2s, transform .2s;
}
.wc-syl span.lit { background: var(--c); border-color: var(--c); color: #fff; transform: translateY(-3px); }
.wc-syl .q { font-size: clamp(26px, 5vh, 52px); border: 0; background: none; padding: 0; line-height: 1.2; max-width: 18ch; }
.word-card.asking { box-shadow: inset 6px 0 0 var(--ink), var(--shadow-md); }

/* ---------- 05 Simón y 06 Atrapa ---------- */
.simon-stage, .catch-stage { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(14px, 2.6vh, 28px); height: 100%; width: 100%; }
.stats { display: flex; gap: 12px; }
.stat { min-width: clamp(100px, 10vw, 140px); padding: 12px 18px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.stat small { display: block; font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat b { display: block; font-size: clamp(28px, 3.4vw, 44px); font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.simon-msg { font-size: clamp(30px, 5vw, 68px); font-weight: 600; letter-spacing: -.02em; text-align: center; }
.simon-msg.watch { color: var(--ink-2); }
.simon-msg.turn { color: var(--a); }
.simon-msg.win { color: var(--ok); }
.simon-msg.oops { color: var(--danger); }
.simon-dots { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 80vw; min-height: 16px; }
.simon-dots i { width: 16px; height: 16px; border-radius: 50%; background: var(--sunken); border: 1.5px solid var(--line-2); transition: all .2s; }
.simon-dots i.done { background: var(--c); border-color: var(--c); }

.target {
  --c: var(--ink);
  position: relative;
  width: clamp(160px, 30vh, 290px); aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md), inset 0 0 0 10px color-mix(in srgb, var(--c) 10%, var(--surface));
  transition: opacity .2s, transform .2s;
}
.target.idle { color: var(--muted); }
.target.idle .t-visual { font-size: 56px; }
.target.hidden { opacity: 0; transform: scale(.6); }
.target.caught { transform: scale(1.2); opacity: 0; }
.target.escaped { transform: scale(.5) translateY(60px); opacity: 0; }
.target.spawn { animation: spawn .35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes spawn { from { transform: scale(0); } }
.ring { position: absolute; inset: -12px; width: calc(100% + 24px); height: calc(100% + 24px); transform: rotate(-90deg); pointer-events: none; }
.ring circle { fill: none; stroke-width: 5; }
.ring .track { stroke: var(--line); }
.ring .prog { stroke: var(--c); stroke-linecap: round; stroke-dasharray: 339.3; stroke-dashoffset: 0; }
.target.idle .ring .prog { stroke-dashoffset: 339.3; }
.t-visual { display: grid; place-items: center; width: 56%; height: 50%; }
.t-visual .obj-emoji { font-size: clamp(70px, 13vh, 130px); }
.t-name { font-size: clamp(14px, 1.9vh, 20px); font-weight: 600; text-align: center; padding: 0 16px; }
.center-msg { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; opacity: 0; }
.center-msg.show { opacity: 1; }
.center-msg .count { font-size: clamp(90px, 22vh, 220px); font-weight: 600; letter-spacing: -.04em; color: var(--a); }
.center-msg.pop { animation: grow .5s cubic-bezier(.2, 1.5, .4, 1); }
.result { text-align: center; padding: clamp(22px, 3.5vh, 36px) clamp(32px, 4vw, 56px); border-radius: 24px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.result .stars { display: flex; justify-content: center; gap: 8px; margin: 10px 0 6px; }
.result .stars svg { width: clamp(38px, 6vh, 56px); fill: var(--line); }
.result .stars svg.on { fill: #E9A11B; }
.result .r-big { font-size: clamp(40px, 7vh, 72px); font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.result .r-big span { font-size: .4em; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.result .r-small { font-size: clamp(15px, 2vh, 19px); color: var(--ink-2); }
.result .r-hint { margin-top: 16px; font-size: 14px; color: var(--muted); }

/* ---------- Pantallas medianas y pequeñas ---------- */
@media (max-width: 1180px) {
  .home-grid { grid-template-columns: 1fr; }
  .objects-panel { position: static; order: -1; }
  .obj-list { grid-template-columns: repeat(2, 1fr); }
  .acts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .bar { padding-right: var(--gutter); padding-top: 66px; }
  .topbar { padding-right: calc(var(--gutter) + 160px); }
  .bar-controls { width: 100%; }
  .guide-grid { grid-template-columns: 1fr; }
  .guide li { grid-template-columns: 34px 1fr; }
  .guide li span { grid-column: 2; }
}
@media (max-width: 640px) {
  .topbar .btn-primary span { display: none; }
  .acts, .slots, .obj-list { grid-template-columns: 1fr; }
  .pads { grid-template-columns: repeat(3, minmax(0, 1fr)); height: auto; grid-auto-rows: 140px; }
  .note-display { grid-template-columns: 1fr; }
  .word-card { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .wc-syl { justify-content: center; }
  .howto { font-size: 13.5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.mode.setup { height: auto; min-height: 100%; }

/* Las imágenes subidas se ajustan siempre a su caja sin recortarse. */
.slot-visual, .pad-visual, .wc-visual, .t-visual, .obj-thumb, .pad-mini { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.slot-visual > .obj-img, .pad-visual > .obj-img, .wc-visual > .obj-img, .t-visual > .obj-img, .obj-thumb > .obj-img, .pad-mini > .obj-img { width: 100%; height: 100%; min-height: 0; justify-self: stretch; align-self: stretch; }
.slot-hint { z-index: 1; }
.pads { grid-template-rows: minmax(0, 1fr); }
@media (max-width: 640px) { .pads { grid-template-rows: none; } }
body.dark-room .pad-sub { color: color-mix(in srgb, var(--c) 55%, #fff); background: color-mix(in srgb, var(--c) 22%, transparent); }

/* Requisito de hardware y pie del sitio */
.req {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 16px 0 0; padding: 12px 14px;
  width: fit-content; max-width: 100%;
  font-size: 14.5px; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.req .ico { color: #1a3a5c; margin-top: 2px; }
.req b { color: var(--ink); font-weight: 600; }
.site-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 24px;
  padding: 18px var(--gutter) 24px;
  max-width: 1500px; width: 100%; margin: 0 auto;
  font-size: 13px; color: var(--muted);
  border-top: 1px solid var(--line);
}
.site-foot a { color: var(--ink-2); text-underline-offset: 3px; }
.site-foot .legal { font-size: 12px; }
