@font-face { font-family: "Nunito"; font-style: normal; font-display: swap; font-weight: 200 1000; src: url("fonts/nunito-latin-wght-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Nunito"; font-style: normal; font-display: swap; font-weight: 200 1000; src: url("fonts/nunito-latin-ext-wght-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
/* =========================================================
   Taller ABN · Pentonúi Games — sistema visual
   ========================================================= */
:root {
  --font: "Nunito", ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --ink: #14243b;
  --ink-2: #485a72;
  --ink-3: #8794a6;
  --line: #e2e7ee;
  --line-2: #d3dae4;
  --surface: #ffffff;
  --canvas: #f3f5f9;

  --brand: #1f6fe5;
  --brand-2: #1553c2;
  --brand-soft: #e9f1fe;

  --red: #d93b3b;
  --red-2: #b42727;
  --red-soft: #fdeeee;
  --green: #1d9255;
  --green-2: #137140;
  --green-soft: #e8f6ee;
  --unit: #1f2937;
  --unit-soft: #f4f5f7;
  --amber: #f59e0b;
  --amber-2: #d97706;

  --wood: #efdcb6;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  --sh-1: 0 1px 2px rgba(20, 36, 59, .06), 0 1px 1px rgba(20, 36, 59, .04);
  --sh-2: 0 2px 6px rgba(20, 36, 59, .07), 0 8px 20px rgba(20, 36, 59, .06);
  --sh-3: 0 12px 40px rgba(20, 36, 59, .16);

  --tap: 48px;
  font-family: var(--font);
  color: var(--ink);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; background: var(--canvas); }
body { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
button { border: 0; margin: 0; color: inherit; font: inherit; background: none; cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
[hidden] { display: none !important; }

/* ---------- Botones base ---------- */
.tbtn, .ibtn, .pbtn, .chip-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  border-radius: var(--r-md);
  font-weight: 800;
  font-size: 15px;
  line-height: 1;
  white-space: nowrap;
  transition: transform .08s ease, box-shadow .15s ease, background-color .15s ease, border-color .15s ease;
}
.tbtn { padding: 0 16px 0 13px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }
.ibtn { width: var(--tap); padding: 0; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); box-shadow: var(--sh-1); }
.pbtn { padding: 0 22px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); font-size: 16px; }
.pbtn.primary { border-color: transparent; background: var(--brand); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 32%, transparent); }
.tbtn.is-pressed, .ibtn.is-pressed, .pbtn.is-pressed, .chip-btn.is-pressed, .palette-btn.is-pressed, .cover-button.is-pressed,
.tbtn:active, .ibtn:active, .pbtn:active, .palette-btn:active, .cover-button:active { transform: scale(.96); }

.t-join .ic { color: var(--red); }
.t-split .ic { color: var(--brand); }
.t-goal { border-color: transparent; background: var(--amber); color: #3b2300; box-shadow: 0 4px 12px rgba(245, 158, 11, .32); }
.t-clear { color: var(--red-2); }
.t-clear .ic { color: var(--red); }
.ibtn .off { display: none; }
.ibtn.muted .on { display: none; }
.ibtn.muted .off { display: block; color: var(--ink-3); }
.badge {
  min-width: 24px; height: 24px; padding: 0 7px;
  display: inline-grid; place-items: center;
  border-radius: 999px;
  background: var(--brand); color: #fff;
  font-style: normal; font-size: 13px; font-weight: 900;
}
.badge.ok { background: var(--green); }

/* =========================================================
   Portada
   ========================================================= */
.start-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  overflow: auto;
  background:
    radial-gradient(1200px 600px at 10% -10%, #dce9ff 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, #fff1d6 0%, transparent 60%),
    var(--canvas);
  transition: opacity .3s ease, visibility .3s ease;
}
.start-screen.leaving { opacity: 0; visibility: hidden; pointer-events: none; }
.cover-card {
  width: min(720px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: var(--surface);
  box-shadow: var(--sh-3);
  text-align: center;
}
.cover-hero {
  --hs: 1;
  position: relative;
  height: calc(220px * var(--hs));
  overflow: hidden;
  background:
    radial-gradient(420px 180px at 50% 120%, rgba(255,255,255,.45), transparent 70%),
    linear-gradient(135deg, #1f6fe5 0%, #3a8bf0 55%, #5b6ee8 100%);
}
.cover-hero::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.16) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
}
.hero-stage { position: absolute; left: 50%; top: 0; width: 480px; height: 220px; margin-left: -240px; transform-origin: 50% 0; scale: var(--hs); }
.hero-piece { position: absolute; display: block; filter: drop-shadow(0 10px 12px rgba(10, 30, 80, .28)); }
.hero-piece svg { width: 100%; height: 100%; display: block; overflow: visible; }
.hp-c { left: calc(240px - 64px); top: 40px; width: 128px; height: 128px; animation: float 5s ease-in-out infinite; }
.hp-d { left: calc(240px - 190px); top: 62px; width: 76px; height: 104px; transform: rotate(-9deg); animation: float 4.4s ease-in-out .4s infinite; }
.hp-u1 { left: calc(240px + 110px); top: 58px; width: 18px; height: 104px; transform: rotate(12deg); animation: float 4s ease-in-out .9s infinite; }
.hp-u2 { left: calc(240px + 150px); top: 76px; width: 18px; height: 104px; transform: rotate(24deg); animation: float 4.6s ease-in-out .2s infinite; }
.hero-chip {
  position: absolute; display: grid; place-items: center;
  height: 30px; padding: 0 12px; border-radius: 999px;
  background: #fff; font-weight: 900; font-size: 14px;
  box-shadow: 0 6px 14px rgba(10, 30, 80, .22);
}
.chip-c { left: calc(240px + 40px); top: 26px; color: var(--green-2); }
.chip-d { left: calc(240px - 230px); top: 44px; color: var(--red-2); }
.chip-u { left: calc(240px + 190px); top: 150px; color: var(--unit); }
.cover-body { padding: 30px clamp(24px, 6vw, 60px) 26px; }
.eyebrow { margin: 0 0 8px; color: var(--ink-3); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.cover-body h1 { margin: 0; color: var(--ink); font-size: clamp(46px, 7.5vw, 68px); font-weight: 900; letter-spacing: -.03em; line-height: 1; }
.cover-body h1 span { color: var(--brand); }
.cover-copy { max-width: 470px; margin: 14px auto 26px; color: var(--ink-2); font-size: 17px; font-weight: 600; line-height: 1.5; }
.cover-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cover-button {
  min-height: 78px;
  display: flex; align-items: center; justify-content: flex-start; gap: 14px;
  padding: 14px 20px;
  border-radius: var(--r-lg);
  text-align: left; font-size: 18px; font-weight: 900;
  transition: transform .08s ease;
}
.cover-button .ic { width: 30px; height: 30px; padding: 6px; box-sizing: content-box; border-radius: 12px; }
.cover-button small { display: block; margin-top: 3px; font-size: 13px; font-weight: 700; opacity: .8; }
.primary-cover { color: #fff; background: var(--brand); box-shadow: 0 10px 24px color-mix(in srgb, var(--brand) 30%, transparent); }
.primary-cover .ic { background: rgba(255,255,255,.18); }
.continue-cover { color: var(--ink); border: 1px solid var(--line-2); background: var(--surface); box-shadow: var(--sh-1); }
.continue-cover .ic { color: var(--green); background: var(--green-soft); }
.cover-credits {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; margin-top: 18px; padding: 6px 14px;
  border-radius: 999px; color: var(--ink-3); font-size: 14px; font-weight: 700;
}
.cover-credits strong { color: var(--ink-2); }
.cover-credits img { width: 28px; height: 21px; object-fit: cover; border-radius: 6px; }

/* =========================================================
   Aplicación
   ========================================================= */
#app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
  background: var(--canvas);
}

/* ---------- Barra superior ---------- */
.topbar {
  z-index: 20;
  flex: none;
  display: flex; align-items: center; gap: 10px;
  min-height: 68px;
  padding: 10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: 8px; font-size: 21px; font-weight: 900; letter-spacing: -.02em; white-space: nowrap; }
.brand img { width: 36px; height: 36px; border-radius: 10px; }
.brand b { color: var(--brand); font-weight: 900; }
.toolgroup { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }

/* ---------- Zona central ---------- */
#table { min-height: 0; flex: 1 1 auto; display: flex; overflow: hidden; }

#side {
  z-index: 10;
  width: 220px; flex: 0 0 220px;
  padding: 14px 12px 14px max(12px, env(safe-area-inset-left));
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.palette-title { margin: 4px 6px 10px; color: var(--ink-3); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.palette-title + .palette-btn { margin-top: 0; }
.palette-btn ~ .palette-title { margin-top: 18px; }
.palette-btn {
  width: 100%; min-height: 72px;
  display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 10px;
  margin: 0 0 8px; padding: 8px 10px 8px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--sh-1);
  text-align: left;
  transition: transform .08s ease, border-color .15s ease, box-shadow .15s ease;
}
.palette-btn .pl strong, .palette-btn .pl small { display: block; }
.palette-btn .pl strong { color: var(--ink); font-size: 15px; font-weight: 900; }
.palette-btn .pl small { margin-top: 2px; color: var(--ink-3); font-size: 12px; font-weight: 700; }
.palette-btn .pv { min-width: 30px; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 900; text-align: center; background: var(--unit-soft); color: var(--unit); }
.tool-preview, .tool-icon {
  width: 52px; height: 56px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--unit-soft);
  pointer-events: none;
}
.tool-preview svg { display: block; overflow: visible; filter: drop-shadow(0 2px 2px rgba(110, 80, 30, .2)); }
.p-u .tool-preview svg { width: 8px; height: 44px; }
.p-d .tool-preview svg { width: 32px; height: 44px; }
.p-c .tool-preview svg { width: 40px; height: 40px; }
.p-d .tool-preview { background: var(--red-soft); }
.p-d .pv { background: var(--red-soft); color: var(--red-2); }
.p-c .tool-preview { background: var(--green-soft); }
.p-c .pv { background: var(--green-soft); color: var(--green-2); }
.tool-preview.stack { background: var(--brand-soft); color: var(--brand-2); font-size: 18px; font-weight: 900; }
.tool-icon { background: var(--brand-soft); color: var(--brand); }

/* ---------- Mesa ---------- */
#play {
  position: relative;
  min-width: 0; flex: 1;
  overflow: hidden;
  touch-action: none;
  background-color: var(--wood);
  background-image:
    radial-gradient(1000px 500px at 50% 0%, rgba(255,255,255,.45), transparent 70%),
    repeating-linear-gradient(92deg, rgba(150, 105, 45, .045) 0 2px, transparent 2px 9px, rgba(150, 105, 45, .03) 9px 10px, transparent 10px 23px);
  box-shadow: inset 0 2px 10px rgba(110, 75, 25, .12);
}
#hint {
  position: absolute; left: 50%; top: 46%;
  width: min(380px, calc(100% - 40px));
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 22px;
  border: 1px dashed rgba(120, 85, 35, .35);
  border-radius: var(--r-lg);
  color: #7a5a2c;
  background: rgba(255, 252, 244, .72);
  text-align: center; font-size: 15px; font-weight: 700; line-height: 1.45;
  pointer-events: none;
}
#hint strong { color: #5c4115; font-size: 18px; font-weight: 900; }
#hint b { color: var(--red-2); }

.chip-btn {
  position: absolute; z-index: 35; right: 14px; top: 14px;
  display: none;
  min-height: 44px; padding: 0 16px 0 12px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2);
  box-shadow: var(--sh-2); font-size: 14px;
}
#goal {
  position: absolute; z-index: 30;
  left: 50%; top: 14px; transform: translateX(-50%);
  max-width: calc(100% - 240px);
  display: none; align-items: center; gap: 12px;
  padding: 8px 8px 8px 10px;
  border: 1px solid #fcd889;
  border-radius: 999px;
  background: #fffaeb;
  color: #6b4405;
  box-shadow: var(--sh-2);
  font-size: 16px; font-weight: 900;
}
#goal.on { display: flex; animation: drop-in .3s ease-out; }
.goal-ic { width: 34px; height: 34px; display: grid; place-items: center; flex: none; border-radius: 50%; background: var(--amber); color: #3b2300; }
.goal-ic .ic { width: 20px; height: 20px; }
#goalTxt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#goalX { width: 34px; height: 34px; display: grid; place-items: center; flex: none; border-radius: 50%; color: #8a6111; background: #fdefc8; }
#goalX .ic { width: 18px; height: 18px; }

#lasso { position: absolute; z-index: 60; display: none; border: 2px dashed var(--brand); border-radius: 10px; background: rgba(31, 111, 229, .1); pointer-events: none; }

#trash {
  position: absolute; z-index: 18; right: 16px; bottom: 16px;
  width: 92px; height: 92px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 2px dashed rgba(150, 90, 70, .45);
  border-radius: 50%;
  background: rgba(255, 250, 245, .7);
  color: #8a5a4c;
  pointer-events: none;
  transition: transform .15s ease, background-color .15s ease, border-color .15s ease, color .15s ease;
}
#trash .ic { width: 28px; height: 28px; }
#trash small { font-size: 10px; font-weight: 800; line-height: 1.1; text-align: center; max-width: 70px; }
#trash.active { transform: scale(1.12); border-style: solid; border-color: var(--red); background: var(--red-soft); color: var(--red-2); }

#toast {
  position: absolute; z-index: 90; left: 50%; bottom: 20px;
  max-width: min(560px, calc(100% - 150px));
  display: flex; align-items: center; gap: 12px;
  transform: translate(-50%, 16px);
  padding: 12px 18px;
  border-radius: var(--r-md);
  color: #fff;
  background: rgba(20, 36, 59, .94);
  box-shadow: var(--sh-3);
  font-size: 15px; font-weight: 800; line-height: 1.3;
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#toast.on.has-action { pointer-events: auto; }
#toast.error { background: rgba(160, 35, 35, .95); }
#toastAction {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; margin: -4px -6px -4px 0; padding: 0 12px;
  border-radius: 10px; background: rgba(255,255,255,.16); color: #fff; font-size: 14px; font-weight: 900;
}
#toastAction .ic { width: 18px; height: 18px; }

/* ---------- Piezas ---------- */
.it {
  position: absolute; z-index: 5;
  display: grid; place-items: center;
  border: 2px solid transparent;
  border-radius: 12px;
  touch-action: none;
  transition: border-color .12s, background-color .12s;
}
.it::before { content: ""; position: absolute; inset: -14px; }
.zone .it::before { inset: -3px; }
.it svg { width: 100%; height: 100%; overflow: visible; pointer-events: none; filter: drop-shadow(1px 3px 2px rgba(110, 80, 30, .25)); }
.it.sel { z-index: 12; border-color: var(--brand); background: rgba(31, 111, 229, .12); box-shadow: 0 0 0 4px rgba(31, 111, 229, .16); }
.it.sel::after {
  content: ""; position: absolute; right: -9px; top: -9px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center/14px no-repeat;
  box-shadow: 0 0 0 2px #fff;
}
.it.pop { animation: pop-in .45s cubic-bezier(.2, .9, .3, 1.4); }
.it.tie { animation: tie-in .6s cubic-bezier(.2, .8, .25, 1.25); }
.it.split { animation: split-in .5s ease-out; }
.ghost { position: fixed !important; z-index: 1200 !important; pointer-events: none; opacity: .85; filter: drop-shadow(0 14px 12px rgba(30, 40, 30, .3)); }

/* ---------- Valor posicional ---------- */
#bottom {
  flex: 0 0 auto;
  height: calc(clamp(160px, 25vh, 228px) + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(170px, 20vw); gap: 12px;
  padding: 12px max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
#boxes { min-width: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.box {
  position: relative; min-width: 0; overflow: hidden;
  border: 2.5px solid var(--unit);
  border-radius: var(--r-lg);
  background: var(--surface);
  transition: box-shadow .15s ease, background-color .15s ease;
}
.box.c { border-color: var(--green); background: linear-gradient(180deg, var(--green-soft), #fff 70%); }
.box.d { border-color: var(--red); background: linear-gradient(180deg, var(--red-soft), #fff 70%); }
.box.u { border-color: var(--unit); background: linear-gradient(180deg, var(--unit-soft), #fff 70%); }
.box.over { box-shadow: 0 0 0 5px rgba(31, 111, 229, .22); background: var(--brand-soft); }
.box-head { position: absolute; z-index: 5; left: 0; right: 0; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 9px 10px 0 12px; pointer-events: none; }
.lab { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.lab i { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.box.c .lab { color: var(--green-2); }
.box.d .lab { color: var(--red-2); }
.box.u .lab { color: var(--unit); }
.cnt { min-width: 30px; height: 26px; padding: 0 9px; display: grid; place-items: center; border-radius: 999px; color: #fff; background: var(--unit); font-size: 14px; font-weight: 900; font-variant-numeric: tabular-nums; }
.box.c .cnt { background: var(--green); }
.box.d .cnt { background: var(--red); }
.zone { position: absolute; inset: 40px 6px 6px; display: flex; align-content: flex-start; align-items: center; justify-content: center; flex-wrap: wrap; gap: 3px; overflow: hidden; }
.zone .it { position: relative; inset: auto; flex: 0 0 auto; border: 0; border-radius: 5px; }

#sum {
  position: relative; overflow: hidden;
  container-type: size;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3cqh;
  padding: 6px;
  border-radius: var(--r-lg);
  color: #fff;
  background: linear-gradient(150deg, #1f6fe5 0%, #2f5fd6 55%, #4b54d1 100%);
  box-shadow: 0 10px 24px rgba(31, 111, 229, .25);
  text-align: center;
}
#sum::before { content: ""; position: absolute; inset: 0; background: radial-gradient(260px 120px at 50% -10%, rgba(255,255,255,.25), transparent 70%); pointer-events: none; }
.sum-label { position: relative; font-size: clamp(9px, 9cqh, 12px); font-weight: 900; letter-spacing: .14em; text-transform: uppercase; opacity: .8; }
.sum-value { position: relative; font-size: min(48cqh, 34cqw, 80px); font-weight: 900; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.sum-value.bump { animation: bump .35s ease-out; }
.sum-break { position: relative; display: flex; align-items: center; gap: 4px; font-size: clamp(10px, 10cqh, 13px); font-weight: 800; opacity: .95; }
.sum-break i { min-width: 26px; padding: 2px 6px; border-radius: 999px; background: #fff; font-style: normal; font-weight: 900; font-variant-numeric: tabular-nums; }
.sum-break .g { color: var(--green-2); }
.sum-break .r { color: var(--red-2); }
.sum-break .k { color: var(--unit); }
@container (max-height: 135px) { .sum-label { display: none; } .sum-value { font-size: min(56cqh, 34cqw); } }
@container (max-height: 95px) { .sum-break { display: none; } .sum-value { font-size: min(70cqh, 34cqw); } }

.fx-burst { position: absolute; z-index: 150; width: 8px; height: 8px; border-radius: 50%; pointer-events: none; animation: burst .7s ease-out forwards; }

/* ---------- Diálogos ---------- */
#win {
  position: fixed; inset: 0; z-index: 850;
  display: none; place-items: center;
  padding: 24px;
  background: rgba(20, 36, 59, .45);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
#win.on { display: grid; }
#win .card {
  position: relative; z-index: 2;
  width: min(440px, 100%);
  padding: 34px 30px 28px;
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--sh-3);
  text-align: center;
  animation: win-pop .45s cubic-bezier(.2, .9, .3, 1.3);
}
.win-badge { width: 76px; height: 76px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: #fff; box-shadow: 0 0 0 10px var(--green-soft); }
.win-badge .ic { width: 40px; height: 40px; stroke-width: 3; }
#win h2 { margin: 0; color: var(--ink); font-size: 32px; font-weight: 900; }
#win p { margin: 8px 0 22px; color: var(--ink-2); font-size: 17px; font-weight: 700; line-height: 1.45; }
.row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.conf { position: absolute; top: -20px; z-index: 1; width: 10px; height: 16px; border-radius: 3px; pointer-events: none; animation: confetti-fall 2.8s linear infinite; }

#credits-dialog {
  width: min(420px, calc(100% - 36px));
  padding: 26px 28px 26px;
  border: 0; border-radius: var(--r-xl);
  color: var(--ink); background: var(--surface);
  box-shadow: var(--sh-3);
  text-align: center;
}
#credits-dialog::backdrop { background: rgba(20, 36, 59, .5); backdrop-filter: blur(6px); }
#credits-dialog img { width: min(220px, 70%); height: auto; margin: -6px auto 4px; display: block; }
#credits-dialog h2 { margin: 0 0 8px; font-size: 28px; font-weight: 900; }
#credits-dialog p:not(.eyebrow) { margin: 0 0 14px; color: var(--ink-2); font-weight: 700; line-height: 1.55; }
#credits-dialog strong { color: var(--ink); }
#credits-dialog .muted { color: var(--ink-3); font-size: 13px; }
.dialog-close { position: absolute; right: 12px; top: 12px; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--ink-2); background: var(--canvas); }

/* ---------- Animaciones ---------- */
@keyframes float { 50% { translate: 0 -8px; } }
@keyframes drop-in { from { opacity: 0; translate: 0 -10px; } }
@keyframes pop-in { 0% { opacity: 0; transform: scale(.3); } 70% { opacity: 1; transform: scale(1.1); } }
@keyframes tie-in { 0% { transform: scale(.4) rotate(-14deg); } 65% { transform: scale(1.18) rotate(4deg); } }
@keyframes split-in { 0% { opacity: .2; transform: scale(1.5); } 100% { opacity: 1; transform: scale(1); } }
@keyframes burst { from { opacity: 1; transform: translate(0, 0) scale(1); } to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.3); } }
@keyframes win-pop { from { opacity: 0; transform: scale(.7); } }
@keyframes bump { 40% { transform: scale(1.12); } }
@keyframes confetti-fall { to { transform: translateY(110vh) rotate(540deg); } }

/* =========================================================
   Adaptación a tamaños
   ========================================================= */
@media (max-width: 1050px) {
  .brand > span { display: none; }
  .brand { margin-right: 2px; }
}
@media (max-width: 860px) {
  .brand { display: none; }
  .topbar { gap: 8px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .toolgroup { gap: 6px; }
  .tbtn { padding: 0 13px 0 11px; font-size: 14px; }
  #side { width: 176px; flex-basis: 176px; padding-left: 10px; padding-right: 10px; }
  .palette-btn { grid-template-columns: 46px 1fr; min-height: 66px; gap: 9px; }
  .palette-btn .pv { display: none; }
  .tool-preview, .tool-icon { width: 46px; height: 50px; }
  #bottom { grid-template-columns: minmax(0, 1fr) 150px; gap: 10px; }
  #boxes { gap: 8px; }
  .lab { font-size: 11px; letter-spacing: .05em; }
  #goal { left: 14px; transform: none; max-width: calc(100% - 214px); font-size: 14px; }
  #goal.on { animation: none; }
}
@media (max-width: 700px) {
  .tbtn span:not(.n) { display: none; }
  .tbtn { width: var(--tap); padding: 0; }
  .tbtn .badge { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; font-size: 11px; }
  #side { width: 130px; flex-basis: 130px; padding: 10px 8px; }
  .palette-btn { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 8px 6px; gap: 4px; }
  .palette-btn .pl small { display: none; }
  .palette-btn .pl strong { font-size: 13px; }
  #bottom { grid-template-columns: minmax(0, 1fr) 110px; padding-left: 8px; padding-right: 8px; }
  .lab i { display: none; }
  .lab { font-size: 9px; }
  .sum-break { display: none; }
  .cover-actions { grid-template-columns: 1fr; }
  #goal { left: 12px; right: 12px; max-width: none; transform: none; top: 12px; }
}
@media (max-height: 700px) {
  .topbar { min-height: 60px; padding-top: 6px; padding-bottom: 6px; }
  .tbtn, .ibtn { min-height: 44px; }
  .ibtn { width: 44px; }
  #bottom { height: calc(150px + env(safe-area-inset-bottom)); }
  .p-u .tool-preview svg { height: 38px; width: 7px; }
  .p-d .tool-preview svg { height: 38px; width: 28px; }
  .p-c .tool-preview svg { height: 36px; width: 36px; }
  .zone { top: 36px; }
  .palette-btn { min-height: 60px; margin-bottom: 6px; }
  .tool-preview, .tool-icon { height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Música de portada ---------- */
.cover-music {
  position: fixed; z-index: 5; top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right));
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px 0 12px;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--ink-2);
  box-shadow: var(--sh-2); font-size: 14px; font-weight: 800;
}
.cover-music.playing { color: var(--brand); border-color: #bcd3fb; }
.cover-music.playing .ic { animation: beat .5s ease-in-out infinite alternate; }
.cover-music.off { color: var(--ink-3); }
@keyframes beat { to { transform: scale(1.18) rotate(-6deg); } }

/* ---------- Premios ---------- */
.t-stars { gap: 6px; padding: 0 14px 0 11px; border-color: #fcd889; background: #fffaeb; color: #6b4405; }
.t-stars .ic { color: var(--amber); }
.t-stars .n { font-variant-numeric: tabular-nums; font-size: 16px; }
.t-stars.bump { animation: bump .5s ease-out; }
.prize {
  display: flex; align-items: center; gap: 14px; margin: -6px 0 18px; padding: 12px 14px;
  border: 1px solid #fcd889; border-radius: var(--r-lg); background: #fffaeb; text-align: left;
}
.prize-star { position: relative; width: 58px; height: 58px; flex: none; display: grid; place-items: center; }
.prize-star .ic { width: 58px; height: 58px; color: var(--amber); filter: drop-shadow(0 4px 6px rgba(217, 119, 6, .35)); animation: star-in .7s cubic-bezier(.2, .9, .3, 1.5) .2s both; }
.prize-star b { position: absolute; right: -8px; bottom: -4px; padding: 2px 7px; border-radius: 999px; background: var(--green); color: #fff; font-size: 13px; font-weight: 900; animation: pop-in .4s ease-out .7s both; }
.prize-info { flex: 1; min-width: 0; }
.prize-info strong { display: block; color: #6b4405; font-size: 16px; font-weight: 900; }
.prize-info small { display: block; margin-top: 6px; color: #8a6111; font-size: 13px; font-weight: 700; }
.bar { height: 10px; margin-top: 8px; overflow: hidden; border-radius: 999px; background: #fdecc0; }
.bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--amber), #fbbf24); transition: width .8s cubic-bezier(.3, .8, .3, 1) .5s; }
.trophy-unlock {
  display: flex; align-items: center; justify-content: center; gap: 14px; margin: -6px 0 18px; padding: 12px 16px;
  border-radius: var(--r-lg); background: linear-gradient(135deg, #14243b, #2a3f63); color: #fff; text-align: left;
  animation: win-pop .55s cubic-bezier(.2, .9, .3, 1.4) .9s both;
}
.trophy-unlock small { display: block; color: #fcd34d; font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.trophy-unlock strong { font-size: 19px; font-weight: 900; }
.trophy { width: 56px; height: 56px; flex: none; filter: drop-shadow(0 4px 8px rgba(0,0,0,.35)); }
#prizes-dialog {
  width: min(520px, calc(100% - 36px)); padding: 26px 26px 24px;
  border: 0; border-radius: var(--r-xl); color: var(--ink); background: var(--surface); box-shadow: var(--sh-3); text-align: center;
}
#prizes-dialog::backdrop { background: rgba(20, 36, 59, .5); backdrop-filter: blur(6px); }
#prizes-dialog h2 { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0; font-size: 30px; font-weight: 900; }
.star-big { width: 34px; height: 34px; color: var(--amber); }
.prizes-sub { margin: 8px 0 18px; color: var(--ink-2); font-weight: 700; line-height: 1.45; }
.trophies { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; margin-bottom: 20px; }
.tro { padding: 12px 6px 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--canvas); }
.tro .trophy { width: 48px; height: 48px; }
.tro strong { display: block; margin-top: 4px; font-size: 13px; font-weight: 900; }
.tro small { display: block; color: var(--ink-3); font-size: 11px; font-weight: 800; }
.tro.locked .trophy { color: #cfd6e0 !important; filter: none; }
.tro.locked strong { color: var(--ink-3); }
@keyframes star-in { 0% { opacity: 0; transform: scale(0) rotate(-180deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }

/* ---------- Ratón y teclado (ordenador) ---------- */
@media (hover: hover) and (pointer: fine) {
  .tbtn:hover, .ibtn:hover, .pbtn:hover, .chip-btn:hover { border-color: #b8c4d4; box-shadow: var(--sh-2); }
  .pbtn.primary:hover { background: var(--brand-2); }
  .t-goal:hover { background: #fbab1d; }
  .palette-btn:hover { border-color: #b8c4d4; box-shadow: var(--sh-2); transform: translateY(-1px); }
  .cover-button:hover { transform: translateY(-2px); }
  .it { cursor: grab; }
  .it:active { cursor: grabbing; }
  .box.over { cursor: copy; }
}
@media (min-width: 1500px) {
  #side { width: 250px; flex-basis: 250px; }
  .topbar { min-height: 76px; }
}

/* =========================================================
   Móviles
   ========================================================= */
@media (max-width: 520px) {
  .cover-body { padding: 22px 20px 18px; }
  .cover-copy { font-size: 15px; margin-bottom: 20px; }
  #credits { display: none; }
  .toolgroup { gap: 4px; }
  .topbar { gap: 4px; }
  .tbtn, .ibtn { min-height: 42px; }
  .tbtn { width: 42px; }
  .ibtn { width: 42px; }
  .t-stars { width: auto; padding: 0 10px 0 8px; }
  .win-badge { width: 60px; height: 60px; }
}

/* Móvil / tablet pequeño en vertical: paleta en fila horizontal */
@media (max-width: 700px) and (orientation: portrait) {
  #table { flex-direction: column; }
  #side {
    flex: 0 0 auto; width: auto;
    display: flex; gap: 8px; align-items: stretch;
    padding: 8px max(10px, env(safe-area-inset-left));
    overflow-x: auto; overflow-y: hidden;
    border-right: 0; border-bottom: 1px solid var(--line);
    touch-action: pan-x;
  }
  #side .palette-title { display: none; }
  #side .palette-btn {
    flex: 1 1 0; width: auto; min-width: 54px; min-height: 76px; margin: 0;
    grid-template-columns: 1fr; grid-template-rows: auto auto; justify-items: center; align-content: center; gap: 4px; padding: 6px 4px;
  }
  .palette-btn .pl small, .palette-btn .pv { display: none; }
  .palette-btn .pl strong { font-size: 11px; text-align: center; line-height: 1.15; }
  #side { overflow: hidden; }
  .tool-preview, .tool-icon { width: 44px; height: 44px; }
  .p-u .tool-preview svg { width: 6px; height: 34px; }
  .p-d .tool-preview svg { width: 24px; height: 34px; }
  .p-c .tool-preview svg { width: 32px; height: 32px; }
  #bottom { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 54px; gap: 8px; height: calc(208px + env(safe-area-inset-bottom)); }
  #sum { flex-direction: row; gap: 12px; padding: 0 14px; }
  #sum .sum-label { display: block; font-size: 12px; }
  #sum .sum-value { font-size: 34px; }
  #sum .sum-break { display: flex; font-size: 12px; }
  .lab .full { display: none; }
  .lab .short { display: inline; }
  .lab { font-size: 11px; }
  .lab i { display: inline-block; }
  .zone { top: 34px; }
}
.lab .short { display: none; }

/* Móvil en horizontal / pantallas bajas */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar { min-height: 48px; padding-top: 4px; padding-bottom: 4px; gap: 6px; }
  .tbtn, .ibtn { min-height: 40px; }
  .ibtn { width: 40px; }
  .brand { display: none; }
  #side { width: 66px; flex-basis: 66px; padding: 6px 7px; }
  #side .palette-title { display: none; }
  #side .palette-btn { min-height: 44px; margin-bottom: 5px; padding: 3px; grid-template-columns: 1fr; justify-items: center; }
  .palette-btn .pl, .palette-btn .pv { display: none; }
  .tool-preview, .tool-icon { width: 46px; height: 38px; }
  .p-u .tool-preview svg { width: 5px; height: 28px; }
  .p-d .tool-preview svg { width: 22px; height: 30px; }
  .p-c .tool-preview svg { width: 28px; height: 28px; }
  .tool-preview.stack { font-size: 15px; }
  #bottom { height: calc(112px + env(safe-area-inset-bottom)); padding-top: 7px; padding-bottom: 7px; gap: 8px; grid-template-columns: minmax(0, 1fr) 118px; }
  #boxes { gap: 7px; }
  .box { border-width: 2px; border-radius: 14px; }
  .box-head { padding: 5px 7px 0 9px; }
  .lab { font-size: 10px; letter-spacing: .04em; }
  .lab i { display: none; }
  .cnt { height: 20px; min-width: 22px; font-size: 12px; padding: 0 6px; }
  .zone { top: 26px; inset-inline: 4px; bottom: 4px; }
  #trash { width: 58px; height: 58px; right: 10px; bottom: 10px; }
  #trash small { display: none; }
  #trash .ic { width: 22px; height: 22px; }
  #goal { top: 8px; left: 8px; transform: none; max-width: calc(100% - 190px); font-size: 13px; padding: 5px 5px 5px 7px; gap: 8px; }
  .goal-ic, #goalX { width: 28px; height: 28px; }
  .chip-btn { top: 8px; right: 8px; min-height: 36px; font-size: 13px; }
  #toast { bottom: 8px; padding: 8px 14px; font-size: 13px; max-width: calc(100% - 100px); }
  .cover-hero { display: none; }
  .cover-card { border-radius: 24px; }
  .cover-body { padding: 20px 28px 16px; }
  .cover-body h1 { font-size: 44px; }
  .cover-copy { margin: 8px auto 14px; font-size: 14px; }
  .cover-button { min-height: 62px; padding: 8px 16px; }
  .cover-credits { margin-top: 6px; min-height: 36px; }
  #win .card { padding: 18px 24px 16px; }
  .win-badge { display: none; }
  #win h2 { font-size: 26px; }
  #win p { margin: 4px 0 12px; font-size: 15px; }
  .prize, .trophy-unlock { margin: 0 0 10px; padding: 8px 12px; }
  .prize-star, .prize-star .ic { width: 42px; height: 42px; }
  .trophy { width: 40px; height: 40px; }
  #win { overflow-y: auto; }
}
@media (max-height: 400px) and (orientation: landscape) {
  .topbar { min-height: 44px; }
  .tbtn, .ibtn { min-height: 38px; }
  .ibtn { width: 38px; }
  .tbtn { padding: 0 11px 0 9px; font-size: 13px; }
  #side .palette-btn { min-height: 38px; margin-bottom: 4px; }
  .tool-preview, .tool-icon { height: 32px; }
  .p-u .tool-preview svg { height: 24px; }
  .p-d .tool-preview svg { height: 26px; width: 19px; }
  .p-c .tool-preview svg { height: 24px; width: 24px; }
  #bottom { height: calc(98px + env(safe-area-inset-bottom)); }
  .cover-body { padding: 14px 24px 10px; }
  .cover-body h1 { font-size: 36px; }
  .cover-copy { display: none; }
  .eyebrow { display: none; }
}
#win { overflow-y: auto; }

/* Móvil vertical bajo (p. ej. iPhone SE) */
@media (max-width: 700px) and (orientation: portrait) and (max-height: 700px) {
  #bottom { height: calc(168px + env(safe-area-inset-bottom)); grid-template-rows: minmax(0, 1fr) 46px; padding-top: 8px; }
  #side { padding-top: 6px; padding-bottom: 6px; }
  #side .palette-btn { min-height: 62px; }
  .tool-preview, .tool-icon { width: 38px; height: 36px; }
  .p-u .tool-preview svg { height: 28px; }
  .p-d .tool-preview svg { height: 28px; width: 20px; }
  .p-c .tool-preview svg { height: 28px; width: 28px; }
  #sum .sum-value { font-size: 28px; }
  .zone { top: 30px; }
}
@media (max-height: 400px) and (orientation: landscape) {
  #side { padding-top: 4px; padding-bottom: 4px; }
  #side .palette-btn { min-height: 36px; margin-bottom: 3px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .start-screen { padding-top: 56px; }
  .cover-music { top: 8px; right: 8px; min-height: 38px; padding: 0 12px 0 10px; font-size: 13px; }
  .cover-actions { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) and (orientation: portrait) { .lab .short { display: inline; } }
#prizes-dialog, #credits-dialog { max-height: calc(100dvh - 24px); overflow-y: auto; }
@media (max-height: 500px) and (orientation: landscape) {
  #prizes-dialog { width: min(640px, calc(100% - 28px)); padding: 14px 20px 14px; }
  #prizes-dialog h2 { font-size: 24px; }
  .prizes-sub { margin: 4px 0 10px; font-size: 13px; }
  .trophies { grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 10px; }
  .tro { padding: 8px 2px 6px; }
  .tro .trophy { width: 34px; height: 34px; }
  .tro strong { font-size: 11px; }
  #credits-dialog img { width: 120px; }
}

/* =========================================================
   Paleta sin desplazamientos: los botones se reparten el alto
   disponible y se compactan según el espacio (sin scroll)
   ========================================================= */
#side { container: side / size; display: flex; flex-direction: column; gap: 6px; overflow: hidden; touch-action: manipulation; }
#side .palette-title { flex: none; margin: 2px 6px 2px; }
#side .palette-btn ~ .palette-title { margin-top: 10px; }
#side .palette-btn { flex: 1 1 0; min-height: 0; max-height: 78px; margin: 0; align-items: stretch; padding-top: 6px; padding-bottom: 6px; }
#side .palette-btn .pl { align-self: center; min-width: 0; }
#side .tool-preview, #side .tool-icon { height: auto; align-self: stretch; }
@container side (max-height: 470px) {
  .palette-btn .pl small, .palette-btn .pv { display: none; }
  #side .palette-btn ~ .palette-title { margin-top: 6px; }
}
@container side (max-height: 360px) {
  #side .palette-title { display: none; }
  #side .palette-btn { padding-top: 3px; padding-bottom: 3px; }
  .palette-btn .pl strong { font-size: 13px; }
}
@container side (max-height: 250px) {
  #side { gap: 4px; }
  .palette-btn .pl strong { font-size: 12px; }
}
@container side (min-height: 0px) {
  #side .p-u .tool-preview svg { height: clamp(18px, 8cqh, 44px); width: calc(clamp(18px, 8cqh, 44px) * .17); }
  #side .p-d .tool-preview svg { height: clamp(18px, 8cqh, 44px); width: calc(clamp(18px, 8cqh, 44px) * .73); }
  #side .p-c .tool-preview svg { height: clamp(20px, 8cqh, 42px); width: clamp(20px, 8cqh, 42px); }
}
@container side (max-height: 360px) {
  #side .p-u .tool-preview svg { height: clamp(16px, 9cqh, 34px); width: calc(clamp(16px, 9cqh, 34px) * .17); }
  #side .p-d .tool-preview svg { height: clamp(16px, 9cqh, 34px); width: calc(clamp(16px, 9cqh, 34px) * .73); }
  #side .p-c .tool-preview svg { height: clamp(18px, 9cqh, 34px); width: clamp(18px, 9cqh, 34px); }
  .tool-preview.stack { font-size: 15px; }
}

/* Móvil/tablet pequeño en vertical: paleta en fila, 5 botones iguales que caben siempre */
@media (max-width: 700px) and (orientation: portrait) {
  #side { container-type: normal; flex-direction: row; overflow: hidden; gap: 6px; touch-action: manipulation; }
  #side .palette-btn { flex: 1 1 0; min-width: 0; max-height: none; padding-left: 2px; padding-right: 2px; }
  #side .palette-btn .pl strong { font-size: 11px; overflow-wrap: anywhere; }
}
@media (max-width: 360px) {
  .topbar { gap: 3px; padding-left: 6px; padding-right: 6px; }
  .tbtn, .ibtn { width: 38px; min-height: 38px; }
  .t-stars { padding: 0 8px 0 6px; gap: 4px; }
  .t-stars .n { font-size: 14px; }
}
/* Portada completa sin deslizar en móviles bajos */
@media (max-height: 640px) and (orientation: portrait) {
  .start-screen { padding-top: 60px; padding-bottom: 12px; }
  .cover-body { padding: 14px 16px 10px; }
  .cover-body h1 { font-size: 42px; }
  .eyebrow { display: none; }
  .cover-copy { margin: 8px auto 12px; font-size: 14px; }
  .cover-button { min-height: 62px; padding: 8px 14px; }
  .cover-credits { margin-top: 4px; min-height: 36px; }
}
#hint span { display: block; }
@media (max-height: 500px) and (orientation: landscape) { #hint { padding: 10px 14px; font-size: 13px; } #hint strong { font-size: 15px; } }

/* =========================================================
   Portada: el taller es el protagonista; extras en fila secundaria
   ========================================================= */
.cover-actions { display: none; }
.cover-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tile {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 12px;
  border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-1);
  color: var(--ink); text-align: left; transition: transform .08s ease;
}
.tile:active, .tile.is-pressed { transform: scale(.97); }
.tile-tx { min-width: 0; }
.tile-tx b { display: block; font-size: 15px; font-weight: 900; line-height: 1.15; }
.tile-tx small { display: block; margin-top: 2px; color: var(--ink-3); font-size: 12px; font-weight: 700; line-height: 1.25; }
.tile-ic { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--canvas); }
.tile-ic svg { width: 36px; height: 36px; overflow: visible; }
.tile-main {
  grid-column: 1 / -1; min-height: 88px; padding: 14px 20px; gap: 16px;
  border-color: transparent; background: var(--brand); color: #fff;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--brand) 30%, transparent);
}
.tile-main .tile-ic { width: 60px; height: 60px; background: rgba(255,255,255,.2); }
.tile-main .tile-ic svg { width: 30px; height: 42px; }
.tile-main .tile-tx b { font-size: 22px; }
.tile-main .tile-tx small { color: rgba(255,255,255,.85); font-size: 14px; }
.tile-casita .tile-ic { background: var(--red-soft); }
.tile-casa .tile-ic { background: var(--brand-soft); }
.tile-abn .tile-ic { background: var(--brand-soft); }
@media (max-width: 620px) {
  .cover-grid { gap: 8px; }
  .tile:not(.tile-main) { flex-direction: column; justify-content: center; text-align: center; gap: 6px; padding: 10px 6px; }
  .tile:not(.tile-main) .tile-tx small { display: none; }
  .tile:not(.tile-main) .tile-tx b { font-size: 13px; }
  .tile-main { min-height: 76px; padding: 12px 16px; }
  .tile-main .tile-tx b { font-size: 19px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .cover-grid { grid-template-columns: 2.2fr 1fr 1fr 1fr; }
  .tile-main { grid-column: auto; min-height: 64px; padding: 8px 14px; }
  .tile-main .tile-ic { width: 44px; height: 44px; }
  .tile-main .tile-tx b { font-size: 17px; }
  .tile-main .tile-tx small { font-size: 12px; }
  .tile:not(.tile-main) { flex-direction: column; justify-content: center; text-align: center; gap: 4px; padding: 6px; min-height: 64px; }
  .tile:not(.tile-main) .tile-tx small { display: none; }
  .tile:not(.tile-main) .tile-tx b { font-size: 12.5px; }
  .tile:not(.tile-main) .tile-ic { width: 32px; height: 32px; }
  .tile:not(.tile-main) .tile-ic svg { width: 26px; height: 26px; }
}

/* ---------- Botón Juntar flotante, encima de la papelera ---------- */
.fab-join {
  position: absolute; z-index: 19; right: 16px; bottom: 120px;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 56px; padding: 0 18px 0 14px;
  border-radius: 999px; background: var(--surface); color: var(--ink);
  border: 2px solid var(--red); box-shadow: var(--sh-2);
  font-size: 17px; font-weight: 900; transition: transform .08s ease;
}
.fab-join .ic { width: 26px; height: 26px; color: var(--red); }
.fab-join .badge { margin-left: 2px; }
.fab-join.ready { background: var(--green); border-color: var(--green); color: #fff; animation: bump .5s ease-out; }
.fab-join.ready .ic { color: #fff; }
.fab-join.ready .badge { background: #fff; color: var(--green-2); }
.fab-join:active, .fab-join.is-pressed { transform: scale(.95); }
#trash { right: 16px; }
@media (max-height: 500px) and (orientation: landscape) {
  .fab-join { right: 10px; bottom: 76px; min-height: 44px; padding: 0 14px 0 10px; font-size: 14px; }
  .fab-join .ic { width: 20px; height: 20px; }
}
@media (max-width: 700px) and (orientation: portrait) {
  .fab-join { bottom: 116px; }
}

/* =========================================================
   Pantallas extra (casitas y guía)
   ========================================================= */
.screen {
  position: fixed; inset: 0; z-index: 600;
  display: none; flex-direction: column;
  padding-top: env(safe-area-inset-top);
  background: var(--canvas);
}
.screen.on { display: flex; }
.scr-title { font-size: 20px; font-weight: 900; letter-spacing: -.01em; white-space: nowrap; }
.scr-title b { color: var(--brand); }
.subbar {
  flex: none; display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 14px;
  padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 14px; background: var(--canvas); border: 1px solid var(--line); }
.seg button { min-height: 40px; padding: 0 14px; border-radius: 11px; color: var(--ink-2); font-size: 14px; font-weight: 800; }
.seg button.on { background: var(--surface); color: var(--brand-2); box-shadow: var(--sh-1); }
.tbtn.on { border-color: var(--brand); color: var(--brand-2); background: var(--brand-soft); }
.scr-body {
  flex: 1; min-height: 0; display: flex; gap: 14px;
  padding: 14px max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.house-area { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; container-type: size; }
.side-panel {
  flex: 0 0 clamp(230px, 26vw, 320px); display: flex; flex-direction: column; justify-content: center; gap: 14px;
  padding: 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-1);
}
.panel-tip { margin: 0; color: var(--ink-2); font-size: 15px; font-weight: 700; line-height: 1.4; text-align: center; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key {
  min-height: 56px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface);
  font-size: 26px; font-weight: 900; color: var(--ink); box-shadow: 0 2px 0 var(--line-2);
  display: grid; place-items: center; transition: transform .06s ease;
}
.key:active, .key.is-pressed { transform: translateY(2px); box-shadow: none; }
.key .ic { width: 26px; height: 26px; }
.key-ok { background: var(--green); border-color: var(--green); color: #fff; box-shadow: 0 2px 0 var(--green-2); }
.key-ok .ic { stroke-width: 3; }
.key-del { color: var(--ink-2); }
.scr-toast {
  position: absolute; left: 50%; bottom: 6px; z-index: 5; max-width: calc(100% - 20px);
  transform: translate(-50%, 10px); padding: 10px 16px; border-radius: var(--r-md);
  background: rgba(20, 36, 59, .94); color: #fff; font-size: 15px; font-weight: 800; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease;
}
.scr-toast.on { opacity: 1; transform: translate(-50%, 0); }
.scr-toast.error { background: rgba(160, 35, 35, .95); }

/* ---------- Casa común ---------- */
.house { --roof: 22cqh; display: flex; flex-direction: column; container-type: size; }
.roof {
  flex: 0 0 var(--roof); position: relative; display: grid; place-items: center;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: var(--red); color: #fff;
}
.roof span { margin-top: 32%; font-size: min(11cqh, 12cqw); font-weight: 900; line-height: 1; text-align: center; }
.roof-edit { display: inline-flex; align-items: center; justify-content: center; gap: .13em; padding: .04em .16em; border-radius: 8px; font: inherit; color: inherit; line-height: 1; background: rgba(255,255,255,.14); border-bottom: 2px dashed rgba(255,255,255,.7); }
.roof-edit:hover, .roof-edit:focus-visible { background: rgba(255,255,255,.3); }
.roof-edit svg { width: .32em; height: .32em; min-width: 12px; min-height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }
#roof-dialog { width: min(420px, calc(100% - 28px)); max-height: calc(100dvh - 24px); overflow-y: auto; padding: 24px; border: 0; border-radius: 24px; color: var(--ink); box-shadow: var(--sh-3); }
#roof-dialog::backdrop { background: rgba(20,36,59,.5); backdrop-filter: blur(4px); }
#roof-dialog h2 { margin: 0 0 10px; font-size: 24px; }
#roof-dialog p { line-height: 1.4; }
#roof-dialog label { display: block; margin-bottom: 8px; font-weight: 800; }
#roof-number { width: 100%; padding: 10px; border: 2px solid var(--brand); border-radius: 12px; font: 900 36px var(--font); text-align: center; user-select: text; -webkit-user-select: text; }
#roof-error { min-height: 1.4em; color: var(--red-2); font-weight: 700; margin: 8px 0; }
.roof-actions { display: flex; gap: 10px; justify-content: flex-end; }
@media (max-height: 500px) { #roof-dialog { padding: 14px 20px; } #roof-dialog h2 { font-size: 20px; } #roof-description { margin: 6px 0; } #roof-number { font-size: 26px; padding: 6px; } }

/* ---------- La casita ---------- */
.house-casita { width: min(540px, 100cqw, calc((100cqh - 58px) * .95)); height: calc(100cqh - 58px); }
.house-casita .floors {
  flex: 1; min-height: 0; display: grid; grid-template-rows: repeat(var(--floors), 1fr);
  border: 3px solid var(--ink); border-top: 0; border-radius: 0 0 14px 14px; background: var(--surface); overflow: hidden;
}
.floor { display: grid; grid-template-columns: 1fr 1fr; border-top: 3px solid var(--ink); transition: background-color .3s ease; }
.floor > .win + .win { border-left: 3px solid var(--ink); }
.floor.lit { background: #fff7d6; }
.win {
  margin: 0; display: grid; place-items: center; min-height: 0;
  font-size: min(7.5cqh, 11cqw); font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums;
}
.win.given { color: var(--ink-2); }
.win.blank { position: relative; color: var(--brand-2); }
.win.blank::after { content: ""; position: absolute; inset: 14% 16%; border: 3px dashed #b8c4d4; border-radius: 12px; pointer-events: none; }
.win.blank.sel::after { border-color: var(--brand); border-style: solid; background: rgba(31,111,229,.08); }
.win.blank.ok { color: var(--green-2); }
.win.blank.ok::after { border-color: var(--green); border-style: solid; background: rgba(29,146,85,.1); }
.win.blank.wrong { animation: shake .4s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.hintbar { flex: none; height: 48px; width: min(540px, 100cqw); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; visibility: hidden; }
.hintbar.on { visibility: visible; }
.hint-label { color: var(--ink-2); font-size: 12px; font-weight: 800; }
.hint-row { display: flex; gap: 2px; height: 26px; align-items: flex-end; flex-wrap: nowrap; }
.hk { display: block; height: 26px; }
.hk svg { width: 100%; height: 100%; display: block; overflow: visible; }
.hk-u { width: 5px; }
.hk-d { width: 19px; }
.hk.missing { opacity: .22; filter: grayscale(1); }

/* ---------- La casa del número ---------- */
.house-casa { --roof: 24cqh; width: min(860px, 100cqw); height: 100cqh; }
.house-casa .roof { background: var(--brand); }
.house-casa .roof span { margin-top: 13%; display: flex; flex-direction: column; align-items: center; gap: .1em; font-size: min(9cqh, 9cqw); }
.house-casa .roof em { font-style: normal; font-size: .38em; font-weight: 800; opacity: .9; }
.house-casa .roof small { font-size: .3em; font-weight: 800; padding: .2em .6em; border-radius: 999px; background: rgba(255,255,255,.2); }
.house-casa .roof .typed { font-size: 1em; min-width: 2.5ch; text-align: center; border-bottom: 3px solid rgba(255,255,255,.6); }
.house-casa .roof .typed.empty { opacity: .6; }
.rooms {
  flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, 1fr);
  border: 3px solid var(--ink); border-top: 0; border-radius: 0 0 16px 16px; background: var(--surface); overflow: hidden;
}
.room { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-top: 3px solid var(--ink); }
.room + .room { border-left: 3px solid var(--ink); }
.room-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 10px; font-size: 13px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.room-head b { min-width: 34px; height: 30px; padding: 0 8px; display: grid; place-items: center; border-radius: 999px; color: #fff; font-size: 17px; letter-spacing: 0; }
.room-c .room-head { color: var(--green-2); background: var(--green-soft); }
.room-c .room-head b { background: var(--green); }
.room-d .room-head { color: var(--red-2); background: var(--red-soft); }
.room-d .room-head b { background: var(--red); }
.room-u .room-head { color: var(--unit); background: var(--unit-soft); }
.room-u .room-head b { background: var(--unit); }
.room-pieces { flex: 1; min-height: 0; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 3px; padding: 3px; overflow: hidden; }
.pc { display: block; flex: none; }
.pc svg { width: 100%; height: 100%; display: block; overflow: visible; }
.stepper { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px; }
.step { min-height: 50px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); box-shadow: 0 2px 0 var(--line-2); font-size: 28px; font-weight: 900; color: var(--ink); line-height: 1; }
.step:active, .step.is-pressed { transform: translateY(2px); box-shadow: none; }
.room-c .step[data-dir="1"] { background: var(--green); border-color: var(--green); color: #fff; box-shadow: 0 2px 0 var(--green-2); }
.room-d .step[data-dir="1"] { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 2px 0 var(--red-2); }
.room-u .step[data-dir="1"] { background: var(--unit); border-color: var(--unit); color: #fff; box-shadow: 0 2px 0 #000; }
.live-sum { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px; border-radius: var(--r-md); background: var(--canvas); }
.live-sum span { color: var(--ink-3); font-size: 12px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.live-sum b { font-size: 40px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.live-sum small { font-size: 14px; font-weight: 800; color: var(--ink-3); }
.live-sum i { font-style: normal; font-weight: 900; }
.live-sum .g { color: var(--green-2); } .live-sum .r { color: var(--red-2); } .live-sum .k { color: var(--unit); }
.big-check { min-height: 60px; font-size: 19px; }
.big-check .ic { stroke-width: 3; }

/* ---------- Guía ABN ---------- */
.abn-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
.abn { max-width: 820px; margin: 0 auto; padding: 24px max(18px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); -webkit-user-select: text; user-select: text; }
.abn-hero { padding: 26px 28px; border-radius: var(--r-xl); background: linear-gradient(135deg, #1f6fe5, #4b54d1); color: #fff; }
.abn-hero .eyebrow { color: rgba(255,255,255,.8); }
.abn-hero h1 { margin: 0 0 10px; font-size: clamp(30px, 5vw, 44px); font-weight: 900; line-height: 1.05; }
.abn-lead { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.55; }
.abn-sec { margin-top: 30px; }
.abn-sec h2 { margin: 0 0 12px; font-size: 24px; font-weight: 900; }
.abn-sec p { margin: 0 0 10px; color: var(--ink-2); font-size: 16px; font-weight: 600; line-height: 1.6; }
.abn-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.abn-card { padding: 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-1); }
.abn-card .big { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 8px; border-radius: 12px; background: var(--brand); color: #fff; font-size: 24px; font-weight: 900; }
.abn-card strong { display: block; margin-bottom: 4px; font-size: 17px; font-weight: 900; }
.abn-card p { margin: 0; font-size: 14.5px; }
.abn-time { margin: 0; padding: 0; list-style: none; border-left: 3px solid var(--brand-soft); }
.abn-time li { position: relative; display: flex; gap: 14px; padding: 0 0 18px 18px; }
.abn-time li::before { content: ""; position: absolute; left: -8px; top: 6px; width: 13px; height: 13px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px var(--canvas); }
.abn-time li > span { flex: 0 0 52px; color: var(--brand-2); font-size: 17px; font-weight: 900; }
.abn-time strong { display: block; font-size: 16px; font-weight: 900; }
.abn-time p { margin: 2px 0 0; font-size: 15px; }
.abn-table { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.abn-table .row { display: grid; grid-template-columns: 1fr 1.2fr 1.2fr; }
.abn-table .row > span { padding: 10px 12px; border-top: 1px solid var(--line); font-size: 14.5px; font-weight: 700; color: var(--ink-2); }
.abn-table .row.head > span { border-top: 0; background: var(--canvas); color: var(--ink); font-weight: 900; }
.abn-table .row > span:first-child { color: var(--ink); font-weight: 900; }
.abn-table .row > span:last-child { color: var(--brand-2); }
.abn-list { margin: 0 0 14px; padding-left: 20px; color: var(--ink-2); font-size: 16px; font-weight: 600; line-height: 1.6; }
.abn-list b { color: var(--ink); }
.abn-note { padding: 16px 18px; border-left: 4px solid var(--amber); border-radius: var(--r-md); background: #fffaeb; }
.abn-note strong { display: block; margin-bottom: 4px; color: #6b4405; font-size: 16px; font-weight: 900; }
.abn-note p { margin: 0; color: #6b4405; }
.abn-shots { display: grid; gap: 16px; }
.abn-shots figure { margin: 0; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-1); }
.abn-shots img { width: 100%; height: auto; display: block; border-radius: 12px; border: 1px solid var(--line); }
.abn-shots figcaption { color: var(--ink-2); font-size: 15px; font-weight: 600; line-height: 1.5; }
.abn-shots figcaption strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 18px; font-weight: 900; }
.abn-sources ul { margin: 0 0 12px; padding-left: 20px; }
.abn-sources li { margin-bottom: 6px; font-size: 14px; font-weight: 600; line-height: 1.45; }
.abn-sources a { color: var(--brand-2); }
.abn-sources .muted { color: var(--ink-3); font-size: 13px; }
@media (max-width: 640px) {
  .abn-cards { grid-template-columns: 1fr; }
  .abn-shots figure { grid-template-columns: 1fr; }
  .abn-hero { padding: 20px; }
  .abn-lead { font-size: 16px; }
  .abn-table .row > span { padding: 8px; font-size: 13px; }
}

/* ---------- Pantallas extra: tamaños ---------- */
@media (orientation: portrait) {
  .scr-body { flex-direction: column; }
  .side-panel { flex: none; padding: 12px; gap: 10px; }
  .keypad { grid-template-columns: repeat(6, 1fr); }
  .keypad .key:nth-child(1) { order: 7; } .keypad .key:nth-child(2) { order: 8; } .keypad .key:nth-child(3) { order: 9; }
  .keypad .key:nth-child(4) { order: 4; } .keypad .key:nth-child(5) { order: 5; } .keypad .key:nth-child(6) { order: 6; }
  .keypad .key:nth-child(7) { order: 1; } .keypad .key:nth-child(8) { order: 2; } .keypad .key:nth-child(9) { order: 3; }
  .keypad .key-del { order: 11; } .keypad .key[data-key="0"] { order: 10; } .keypad .key-ok { order: 12; }
  #casaPanel { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  #casaPanel .panel-tip { flex: 1 1 100%; }
  #casaPanel .live-sum { flex: 1 1 0; padding: 8px; }
  #casaPanel .live-sum b { font-size: 30px; }
  #casaPanel .big-check { flex: 1 1 0; }
  #casaPanel .keypad { flex: 1 1 100%; }
}
@media (max-width: 860px) {
  .scr-title { font-size: 17px; }
}
@media (max-width: 520px) {
  .scr-title { display: none; }
  .seg button { padding: 0 10px; font-size: 13px; }
  .key { min-height: 48px; font-size: 22px; }
  .panel-tip { font-size: 13px; }
  .room-head { padding: 6px; font-size: 10px; letter-spacing: .02em; }
  .room-head b { min-width: 26px; height: 24px; font-size: 14px; }
  .step { min-height: 42px; font-size: 24px; }
}
@media (max-height: 640px) and (orientation: portrait) {
  .side-panel .panel-tip { display: none; }
  .key { min-height: 44px; }
  #casaPanel .live-sum small { display: none; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .scr-title { font-size: 16px; }
  .subbar { padding-top: 4px; padding-bottom: 4px; }
  .seg button { min-height: 32px; font-size: 12.5px; padding: 0 10px; }
  .scr-body { padding-top: 8px; gap: 10px; }
  .side-panel { flex-basis: 220px; padding: 8px; gap: 6px; }
  .side-panel .panel-tip { display: none; }
  .keypad { gap: 5px; }
  .key { min-height: 0; height: calc((100dvh - 160px) / 4.4); max-height: 52px; font-size: 20px; border-radius: 10px; }
  .hintbar { height: 40px; }
  .house-casita { height: calc(100cqh - 46px); width: min(540px, 100cqw, calc((100cqh - 46px) * 1.4)); }
  .room-head { padding: 4px 8px; font-size: 10px; }
  .room-head b { height: 22px; font-size: 13px; }
  .step { min-height: 34px; font-size: 22px; }
  .live-sum { padding: 6px; } .live-sum b { font-size: 28px; } .live-sum small { display: none; }
  .big-check { min-height: 46px; font-size: 16px; }
}

#side .palette-btn .pv { align-self: center; }

.cover-hero.squeezed { display: none; }
@media (max-height: 600px) and (orientation: portrait) { .cover-copy { display: none; } .cover-body h1 { font-size: 38px; margin-bottom: 12px; } }

.cover-credits { white-space: nowrap; }
@media (max-width: 360px) { .cover-credits { font-size: 12.5px; } }

/* =========================================================
   Guía para padres · tutorial
   ========================================================= */
.tut { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tut[hidden], .abn-scroll[hidden] { display: none !important; }
.tut-stage { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; padding: 22px max(18px, env(safe-area-inset-right)) 22px max(18px, env(safe-area-inset-left)); }
.tut-step { display: none; max-width: 760px; margin: 0 auto; animation: drop-in .25s ease-out; -webkit-user-select: text; user-select: text; }
.tut-step.on { display: block; }
.tut-kicker { margin: 0 0 4px; color: var(--brand-2); font-size: 14px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.tut-step h2 { margin: 0 0 10px; font-size: clamp(26px, 4.4vw, 36px); font-weight: 900; line-height: 1.1; }
.tut-lead { margin: 0 0 16px; color: var(--ink); font-size: 18px; font-weight: 700; line-height: 1.5; }
.tut-text { margin: 14px 0; color: var(--ink-2); font-size: 16px; font-weight: 600; line-height: 1.6; }
.tut-visual { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; border-radius: var(--r-lg); background: var(--wood); box-shadow: inset 0 2px 8px rgba(110,75,25,.12); }
.tut-eq { flex-direction: row; flex-wrap: wrap; }
.tut-row { display: flex; gap: 6px; align-items: flex-end; }
.tut-pc { display: block; width: 14px; height: 80px; }
.tut-pc svg { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(1px 3px 2px rgba(110,80,30,.25)); }
.tut-pc.big { width: 64px; height: 88px; }
.tut-op { font-size: 40px; font-weight: 900; color: #6b4d1d; }
.tut-label { color: #5c4115; font-size: 17px; font-weight: 800; }
.tut-home { margin-top: 16px; padding: 14px 16px; border-left: 4px solid var(--green); border-radius: var(--r-md); background: var(--green-soft); }
.tut-home strong { display: block; margin-bottom: 4px; color: var(--green-2); font-size: 15px; font-weight: 900; }
.tut-home p { margin: 0; color: #14412a; font-size: 15.5px; font-weight: 600; line-height: 1.55; }
.tut-go { margin-top: 18px; width: 100%; min-height: 56px; font-size: 17px; }
.tut-path { margin: 0 0 18px; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tut-path li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); font-size: 15px; font-weight: 800; }
.tut-path b { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--brand); color: #fff; font-size: 15px; }
.tut-tips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tut-tips div { padding: 14px; border-radius: var(--r-md); background: #fffaeb; border: 1px solid #fcd889; }
.tut-tips strong { display: block; color: #6b4405; font-size: 15px; font-weight: 900; }
.tut-tips span { display: block; margin-top: 4px; color: #6b4405; font-size: 14px; font-weight: 600; line-height: 1.45; }
.mini-casita { width: 200px; }
.mc-roof { height: 64px; display: grid; place-items: end center; padding-bottom: 6px; clip-path: polygon(50% 0, 100% 100%, 0 100%); background: var(--red); color: #fff; font-size: 26px; font-weight: 900; }
.mc-floor { display: grid; grid-template-columns: 1fr 1fr; border: 3px solid var(--ink); border-top: 0; background: #fff; }
.mc-floor span { padding: 6px; text-align: center; font-size: 22px; font-weight: 900; }
.mc-floor span + span { border-left: 3px solid var(--ink); }
.mc-floor:first-of-type { border-top: 3px solid var(--ink); }
.mc-floor:last-child span:last-child { color: var(--brand); }
.tut-forms { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tut-forms div { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); text-align: center; }
.tut-forms b { font-size: 30px; font-weight: 900; color: var(--brand-2); }
.tut-forms span { color: var(--ink-2); font-size: 14px; font-weight: 800; line-height: 1.3; }
.tut-table { max-width: 460px; margin: 0 auto; border: 2px solid var(--ink); border-radius: var(--r-md); overflow: hidden; background: var(--surface); font-variant-numeric: tabular-nums; }
.tut-table .tr { display: grid; grid-template-columns: 1.2fr 1fr 1fr; }
.tut-table .tr span { padding: 9px 12px; border-top: 1px solid var(--line); font-size: 18px; font-weight: 800; text-align: center; }
.tut-table .tr span + span { border-left: 1px solid var(--line); }
.tut-table .th span { border-top: 0; background: var(--canvas); color: var(--ink-2); font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; }
.tut-table .tr:not(.th) span:first-child { color: var(--brand-2); }
.tut-table .ok span { background: var(--green-soft); color: var(--green-2) !important; font-weight: 900; }
.tut-do { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.tut-do li { padding: 12px 14px; border-radius: var(--r-md); font-size: 16px; font-weight: 600; line-height: 1.5; }
.tut-do .yes { background: var(--green-soft); color: #14412a; }
.tut-do .no { background: var(--red-soft); color: #5e1a1a; }
.tut-nav { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: var(--surface); }
.tut-dots { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.dot { width: 28px; height: 28px; padding: 0; border-radius: 50%; position: relative; }
.dot::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--line-2); transition: transform .15s ease, background-color .15s ease; }
.dot.seen::after { background: #a9c4f5; }
.dot.on::after { background: var(--brand); transform: scale(1.35); }
.t-next { border-color: transparent; background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(31,111,229,.3); padding: 0 13px 0 16px; }
.ic.flip { transform: scaleX(-1); }
@media (max-width: 640px) {
  .tut-tips, .tut-forms { grid-template-columns: 1fr; }
  .tut-forms div { flex-direction: row; justify-content: center; gap: 12px; padding: 10px; }
  .tut-forms b { font-size: 24px; }
  .tut-lead { font-size: 16.5px; }
  .tut-pc { width: 10px; height: 58px; }
  .tut-pc.big { width: 46px; height: 64px; }
  .tut-row { gap: 4px; }
  .tut-table .tr span { padding: 8px 6px; font-size: 16px; }
}
@media (max-width: 420px) {
  .tut-nav .tbtn span { display: none; }
  .tut-nav .tbtn { width: 48px; padding: 0; }
  .dot { width: 24px; height: 24px; }
  .dot::after { inset: 8px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .tut-stage { padding-top: 12px; padding-bottom: 12px; }
  .tut-nav { padding-top: 5px; padding-bottom: 5px; }
  .tut-step h2 { font-size: 24px; }
  .tut-lead { font-size: 15.5px; margin-bottom: 10px; }
  .tut-visual { padding: 10px; }
}

/* ---------- Ejemplos interactivos del tutorial ---------- */
.demo { gap: 12px; min-height: 180px; }
.demo-sticks { display: flex; gap: 8px; align-items: flex-end; justify-content: center; flex-wrap: wrap; }
.dstick { position: relative; width: 30px; height: 100px; padding: 0 7px; border-radius: 10px; transition: transform .15s ease, background-color .15s ease; }
.dstick svg { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(1px 3px 2px rgba(110,80,30,.25)); pointer-events: none; }
.dstick.on { transform: translateY(-10px); background: rgba(31,111,229,.14); box-shadow: 0 0 0 2px var(--brand); }
.dstick.on[data-n]::after { content: attr(data-n); position: absolute; left: 50%; top: -30px; transform: translateX(-50%); min-width: 24px; height: 24px; padding: 0 5px; display: grid; place-items: center; border-radius: 999px; background: var(--brand); color: #fff; font-size: 13px; font-weight: 900; }
.demo-msg { margin: 0; color: #5c4115; font-size: 17px; font-weight: 700; line-height: 1.4; text-align: center; min-height: 1.4em; }
.demo-msg b { color: #3d2a0c; }
.big-n { font-size: 30px; font-variant-numeric: tabular-nums; }
.demo-again, .demo-btns .pbtn { min-height: 48px; }
.demo-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.demo-btns .pbtn:disabled { opacity: .4; }
.demo-bundle { display: grid; place-items: center; min-height: 110px; }
.dpc { display: inline-block; flex: none; }
.dpc svg { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(1px 2px 1px rgba(110,80,30,.25)); }
.dpc.pd { width: 40px; height: 55px; }
.dpc.pu { width: 10px; height: 55px; }
.dpc.pd.huge { width: 80px; height: 110px; animation: tie-in .6s cubic-bezier(.2,.8,.25,1.25); }
.mini-casita .mc-floor.target span { background: var(--brand-soft); color: var(--brand-2); }
.mini-casita .mc-floor.ok span { background: var(--green-soft); color: var(--green-2); }
.demo-nums { display: grid; grid-template-columns: repeat(11, 1fr); gap: 5px; width: 100%; max-width: 520px; }
.dnum { min-height: 46px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); box-shadow: 0 2px 0 var(--line-2); font-size: 20px; font-weight: 900; color: var(--ink); }
.dnum.wrong { animation: shake .4s ease; background: var(--red-soft); }
.demo-groups { display: flex; gap: 12px; width: 100%; justify-content: center; flex-wrap: wrap; }
.dg { flex: 1 1 200px; max-width: 340px; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: var(--r-md); background: rgba(255,255,255,.6); }
.dg.pop .pile { animation: bump .45s ease-out; }
.dg-h { display: flex; align-items: center; justify-content: space-between; color: #5c4115; font-size: 14px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
.dg-h b { min-width: 40px; padding: 2px 10px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 17px; letter-spacing: 0; text-align: center; }
.dg-out .dg-h b { background: var(--red); }
.pile { display: flex; flex-wrap: wrap; gap: 4px; align-items: flex-end; min-height: 55px; }
.pile .empty { color: #a08758; font-size: 14px; font-weight: 700; align-self: center; }
.demo .tut-table { width: 100%; }
.demo .tut-table .tr.new { animation: drop-in .3s ease-out; }
@media (max-width: 640px) {
  .dstick { width: 24px; height: 78px; padding: 0 5px; }
  .demo-sticks { gap: 5px; }
  .demo-nums { grid-template-columns: repeat(6, 1fr); }
  .dpc.pd { width: 30px; height: 41px; }
  .dpc.pu { width: 8px; height: 41px; }
  .pile { min-height: 41px; gap: 3px; }
  .demo-msg { font-size: 15.5px; }
  .demo-btns .pbtn { flex: 1 1 auto; padding: 0 12px; font-size: 14.5px; }
}
@media (hover: hover) and (pointer: fine) { .dstick:hover, .dnum:hover { transform: translateY(-3px); } }

.cover-music.waiting .ic { animation: beat .8s ease-in-out infinite alternate; color: var(--amber-2); }

/* Botón de música en su propia franja superior: nunca tapa la portada */
.start-screen { padding-top: calc(max(10px, env(safe-area-inset-top)) + 54px) !important; }
.cover-music { top: max(10px, env(safe-area-inset-top)) !important; right: max(12px, env(safe-area-inset-right)) !important; min-height: 40px !important; padding: 0 14px 0 11px !important; font-size: 13px !important; }
@media (max-width: 520px), (max-height: 500px) {
  .cover-music { width: 40px; padding: 0 !important; justify-content: center; }
  .cover-music #coverMusicTxt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .start-screen { padding-top: calc(max(6px, env(safe-area-inset-top)) + 46px) !important; padding-bottom: 6px !important; }
  .cover-music { top: max(6px, env(safe-area-inset-top)) !important; }
}

/* ---------- Tutorial más claro ---------- */
.tut-how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 18px; }
.tut-how div { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--r-md); background: var(--brand-soft); color: var(--brand-2); font-size: 14.5px; font-weight: 700; line-height: 1.35; }
.tut-how b { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--brand); color: #fff; font-size: 16px; }
.tut-how strong { font-weight: 900; }
.demo { position: relative; border: 3px solid #f2c94c; padding-top: 0; overflow: hidden; }
.demo.done { border-color: var(--green); }
.try-head { align-self: stretch; margin: 0 -20px 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; background: #fff3c4; color: #5c3d00; }
.try-head.done { background: var(--green); color: #fff; }
.try-tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: rgba(0,0,0,.08); font-size: 12px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.try-head.done .try-tag { background: rgba(255,255,255,.22); }
.try-ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.try-text { flex: 1 1 200px; font-size: 17px; font-weight: 900; line-height: 1.3; }
.try-prog { padding: 4px 10px; border-radius: 999px; background: #fff; color: #5c3d00; font-size: 14px; font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }
.next-tap { position: relative; z-index: 2; animation: tap-ring 1.3s ease-out infinite; }
@keyframes tap-ring { 0% { box-shadow: 0 0 0 0 rgba(31,111,229,.65); } 70% { box-shadow: 0 0 0 14px rgba(31,111,229,0); } 100% { box-shadow: 0 0 0 0 rgba(31,111,229,0); } }
.dstick.next-tap { background: rgba(31,111,229,.12); border-radius: 10px; }
.dstick.next-tap::before { content: ""; position: absolute; left: 50%; bottom: -30px; width: 26px; height: 26px; transform: translateX(-50%); background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffffff' stroke='%231553c2' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 11V5.5a1.5 1.5 0 0 1 3 0V10m0-1.5a1.5 1.5 0 0 1 3 0V11m0-1a1.5 1.5 0 0 1 3 0v4.5a6 6 0 0 1-6 6h-1a6 6 0 0 1-5-2.7l-2.6-4a1.5 1.5 0 0 1 2.4-1.8L9 14'/%3E%3C/svg%3E") center/contain no-repeat; animation: hand-tap 1.3s ease-in-out infinite; pointer-events: none; }
@keyframes hand-tap { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -8px); } }
.demo-sticks { padding-bottom: 30px; }
.mc-q.next-tap { animation: tap-ring 1.3s ease-out infinite; }
.demo-nums.next-zone { padding: 6px; border-radius: 14px; outline: 3px dashed rgba(31,111,229,.55); outline-offset: 2px; }
.demo-btns .pbtn.next-tap { border-color: var(--brand); }
.tut-go { background: var(--surface); color: var(--brand-2); border: 2px solid var(--brand); box-shadow: none; }
.tut-mid { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tut-count { color: var(--ink-2); font-size: 13px; font-weight: 900; }
.dot.done::after { background: var(--green); }
.dot.on.done::after { background: var(--green); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--green); }
.t-next.pulse { animation: next-pulse 1.4s ease-in-out infinite; }
@keyframes next-pulse { 0%, 100% { box-shadow: 0 4px 12px rgba(31,111,229,.3), 0 0 0 0 rgba(31,111,229,.5); } 50% { box-shadow: 0 4px 12px rgba(31,111,229,.3), 0 0 0 10px rgba(31,111,229,0); } }
@media (max-width: 640px) {
  .tut-how { grid-template-columns: 1fr; }
  .try-head { margin: 0 -20px 2px; padding: 8px 12px; }
  .try-text { font-size: 15.5px; }
  .demo-sticks { padding-bottom: 28px; }
}
@media (prefers-reduced-motion: reduce) { .next-tap, .t-next.pulse, .dstick.next-tap::before { animation: none !important; } }
.demo-sticks { padding-top: 34px; }
@media (max-width: 640px) {
  .demo-sticks { padding-top: 30px; }
  .mini-casita { width: 170px; }
  .mc-roof { height: 50px; font-size: 22px; }
  .mc-floor span { padding: 3px; font-size: 19px; }
}

/* ---------- Franja del tablero de práctica ---------- */
#practiceBar { flex: none; display: flex; align-items: center; gap: 12px; padding: 8px max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left)); background: #fff3c4; border-bottom: 2px solid #f2c94c; color: #5c3d00; }
#practiceBar[hidden] { display: none; }
.pb-tag { flex: none; padding: 5px 11px; border-radius: 999px; background: var(--amber); color: #3b2300; font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.pb-msg { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pb-msg b { font-size: 15px; font-weight: 900; line-height: 1.3; }
.pb-msg small { font-size: 12.5px; font-weight: 700; opacity: .85; }
#practiceBack { flex: none; min-height: 42px; border-color: #e0b43a; }
.tut-back { border-color: #e0b43a; background: #fff3c4; color: #5c3d00; }
@media (max-width: 700px) {
  #practiceBar { gap: 8px; padding-top: 6px; padding-bottom: 6px; }
  .pb-tag { display: none; }
  .pb-msg b { font-size: 13px; }
  .pb-msg small { font-size: 11px; }
  #practiceBack .pb-short { font-size: 12.5px; }
  #practiceBack { width: auto !important; padding: 0 10px 0 8px !important; }
}
@media (max-height: 500px) and (orientation: landscape) {
  #practiceBar { padding-top: 4px; padding-bottom: 4px; }
  .pb-msg small { display: none; }
  #practiceBack { min-height: 36px; }
}
.tut-back span { display: inline !important; }
.tut-back { width: auto !important; padding: 0 12px 0 9px !important; }
.pb-short { display: none !important; }
@media (max-width: 700px) { .pb-long { display: none !important; } .pb-short { display: inline !important; } }
@media (max-width: 380px) { .pb-msg small { display: none; } }

/* ---------- Fila principal: taller + nueva pizarra ---------- */
.main-row { grid-column: 1 / -1; display: flex; gap: 10px; min-width: 0; }
.main-row .tile-main { flex: 1; min-width: 0; }
.tile-new { flex: 0 0 132px; flex-direction: column; justify-content: center; text-align: center; gap: 6px; padding: 10px 8px; border: 2px solid var(--brand); color: var(--brand-2); }
.tile-new[hidden] { display: none; }
.tile-new .tile-ic { width: 40px; height: 40px; background: var(--brand-soft); }
.tile-new .tile-ic .ic { width: 24px; height: 24px; stroke-width: 2.6; color: var(--brand); }
.tile-new .tile-tx b { font-size: 14px; }
@media (max-width: 620px) {
  .main-row { gap: 8px; }
  .tile-new { flex-basis: 92px; padding: 8px 4px; }
  .tile-new .tile-tx b { font-size: 12.5px; }
  .tile-new .tile-ic { width: 34px; height: 34px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .main-row { grid-column: auto; gap: 6px; }
  .tile-new { flex-basis: 74px; gap: 3px; padding: 4px; }
  .tile-new .tile-ic { width: 28px; height: 28px; }
  .tile-new .tile-tx b { font-size: 11.5px; }
}
@media (max-width: 380px) {
  .tile-main .tile-ic { display: none; }
  .tile-main { padding: 10px 12px; }
  .tile-main .tile-tx b { font-size: 17px; }
  .tile-main .tile-tx small { font-size: 12px; }
  .tile-new { flex-basis: 84px; }
}
.tile-main .tile-tx small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-height: 500px) and (orientation: landscape) {
  .cover-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .main-row { grid-column: 1 / -1; }
  .tile-main { min-height: 54px; padding: 6px 14px; }
  .tile-main .tile-ic { width: 40px; height: 40px; }
  .tile-main .tile-tx b { font-size: 16px; }
  .tile-main .tile-tx small { -webkit-line-clamp: 1; font-size: 12px; }
  .tile-new { flex-direction: row; flex-basis: 150px; gap: 8px; min-height: 54px; }
  .tile:not(.tile-main):not(.tile-new) { flex-direction: row; min-height: 46px; padding: 4px 8px; gap: 8px; text-align: left; justify-content: flex-start; }
}

/* ---------- Sumar y restar con la casita ---------- */
.opboard { width: min(760px, 100cqw); height: calc(100cqh - 58px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5cqh; container-type: size; }
.op-main { display: flex; align-items: center; gap: .3em; font-size: min(13cqh, 10cqw); font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums; }
.slot { display: inline-grid; place-items: center; min-width: 1.7em; height: 1.3em; padding: 0 .15em; border: 3px dashed #b8c4d4; border-radius: .22em; color: var(--brand-2); background: var(--surface); vertical-align: middle; font-variant-numeric: tabular-nums; line-height: 1; }
.slot.wait { color: #c3ccd8; }
.slot.sel { border-style: solid; border-color: var(--brand); background: var(--brand-soft); animation: tap-ring 1.4s ease-out infinite; }
.slot.ok { border-style: solid; border-color: var(--green); background: var(--green-soft); color: var(--green-2); }
.slot.wrong { animation: shake .4s ease; }
.op-flow { display: flex; align-items: center; justify-content: center; gap: 6cqw; width: 100%; }
.op-casita { width: min(34cqw, 52cqh); display: flex; flex-direction: column; align-items: stretch; }
.op-casita .mc-roof { height: min(16cqh, 12cqw); font-size: min(9cqh, 6.5cqw); }
.op-casita .mc-floor { border-top: 3px solid var(--ink); }
.op-casita .mc-floor .slot { width: 100%; height: min(17cqh, 12cqw); border-radius: 0; border-width: 0; font-size: min(10cqh, 7cqw); font-weight: 900; }
.op-casita .mc-floor .slot + .slot { border-left: 3px solid var(--ink); }
.op-casita .mc-floor .slot.sel { box-shadow: inset 0 0 0 4px var(--brand); }
.op-casita small { margin-top: 6px; text-align: center; color: var(--ink-2); font-size: min(4.2cqh, 3.4cqw); font-weight: 800; }
.op-lines { display: flex; flex-direction: column; gap: 3cqh; font-size: min(9cqh, 6cqw); font-weight: 900; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.op-line { display: flex; align-items: center; gap: .25em; padding: .15em .35em; border-radius: .3em; transition: background-color .3s ease; white-space: nowrap; }
.op-line b { color: var(--ink); }
.op-n { color: var(--ink); }
.op-line.lit { background: #fff7d6; }
.hint-big { font-size: 15px !important; color: var(--brand-2) !important; font-weight: 900 !important; }
#casitaTip b { color: var(--brand-2); }
@container (max-aspect-ratio: 1/1) {
  .op-flow { flex-direction: column; gap: 3cqh; }
  .op-casita { width: min(56cqw, 30cqh); }
  .op-casita .mc-roof { height: min(9cqh, 16cqw); font-size: min(6cqh, 9cqw); }
  .op-casita .mc-floor .slot { height: min(9cqh, 16cqw); font-size: min(6cqh, 10cqw); }
  .op-casita small { display: none; }
  .op-main { font-size: min(9cqh, 12cqw); }
  .op-lines { font-size: min(6.5cqh, 9cqw); gap: 1.5cqh; }
}

/* ---------- Pregunta del paso dentro del tablero ---------- */
.op-ask { margin: 0; padding: .45em .9em; border-radius: 999px; background: var(--brand-soft); color: var(--brand-2); font-size: min(5cqh, 3.6cqw); font-weight: 800; text-align: center; max-width: 100%; }
.op-ask b { font-weight: 900; }
.opboard { gap: 4cqh; }
@container (max-aspect-ratio: 1/1) {
  .op-ask { font-size: min(4.2cqh, 5cqw); border-radius: 16px; }
  .op-main { font-size: min(11cqh, 14cqw); }
  .op-casita { width: min(64cqw, 40cqh); }
  .op-casita .mc-roof { height: min(11cqh, 18cqw); font-size: min(7cqh, 10cqw); }
  .op-casita .mc-floor .slot { height: min(11cqh, 18cqw); font-size: min(7.5cqh, 11cqw); }
  .op-lines { font-size: min(8cqh, 10.5cqw); }
}
.t-sticks { border-color: var(--red); color: var(--red-2); }
.t-sticks .ic { color: var(--red); }

/* ---------- Casita flotante sobre el panel de palillos ---------- */
#floatCasita { position: absolute; z-index: 40; top: 12px; right: 12px; width: 300px; max-width: calc(100% - 24px); border-radius: var(--r-lg); background: var(--surface); border: 2px solid var(--red); box-shadow: var(--sh-3); overflow: hidden; touch-action: none; }
#floatCasita[hidden] { display: none; }
.fc-head { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; background: var(--red); color: #fff; cursor: grab; touch-action: none; }
.fc-head b { flex: 1; font-size: 14px; font-weight: 900; }
.fc-grip { width: 14px; height: 18px; background: radial-gradient(circle, rgba(255,255,255,.9) 1.5px, transparent 2px) 0 0 / 7px 6px; }
.fc-min { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.2); color: #fff; }
.fc-min .ic { width: 18px; height: 18px; }
#floatCasita.min .fc-body { display: none; }
#floatCasita.min .fc-min .ic { transform: rotate(45deg); }
#floatCasita.min { width: auto; }
.fc-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 8px; }
.fc-ask { margin: 0; color: var(--brand-2); font-size: 13px; font-weight: 800; line-height: 1.3; text-align: center; }
.fc-op { text-align: center; font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.fc-row { display: flex; align-items: center; gap: 10px; justify-content: center; }
.fc-casita { width: 104px; flex: none; }
.fc-board > .fc-casita { width: 150px; margin: 0 auto; }
.fc-casita .mc-roof { height: 34px; font-size: 16px; }
.fc-casita .mc-floor { border-top: 3px solid var(--ink); }
.fc-casita .mc-floor + .mc-floor { border-top: 0; }
.fc-casita .mc-floor .slot { width: 100%; height: 30px; min-width: 0; border-radius: 0; border-width: 0; font-size: 17px; font-weight: 900; }
.fc-casita .mc-floor .slot + .slot { border-left: 3px solid var(--ink); }
.fc-casita .mc-floor .slot.sel { box-shadow: inset 0 0 0 3px var(--brand); animation: none; }
.fc-casita .mc-floor .slot.given { color: var(--ink-2); background: #fff; }
.fc-casita .mc-floor.lit .slot { background: #fff7d6; }
.fc-lines { display: flex; flex-direction: column; gap: 6px; font-size: 16px; font-weight: 900; color: var(--ink-2); white-space: nowrap; }
.fc-lines .slot, .fc-op .slot { height: 1.4em; min-width: 1.9em; border-width: 2px; }
.fc-pad { grid-template-columns: repeat(6, 1fr) !important; gap: 4px; }
.fc-pad .key { min-height: 36px; height: 36px; font-size: 17px; border-radius: 9px; }
.fc-pad .key .ic { width: 18px; height: 18px; }
.fc-pad .key:nth-child(1) { order: 7; } .fc-pad .key:nth-child(2) { order: 8; } .fc-pad .key:nth-child(3) { order: 9; }
.fc-pad .key:nth-child(4) { order: 4; } .fc-pad .key:nth-child(5) { order: 5; } .fc-pad .key:nth-child(6) { order: 6; }
.fc-pad .key:nth-child(7) { order: 1; } .fc-pad .key:nth-child(8) { order: 2; } .fc-pad .key:nth-child(9) { order: 3; }
.fc-pad .key-del { order: 11; } .fc-pad .key[data-key="0"] { order: 10; } .fc-pad .key-ok { order: 12; }
@media (max-width: 520px), (max-height: 500px) {
  #floatCasita { width: 252px; top: 6px; right: 6px; }
  .fc-body { padding: 6px 8px 8px; gap: 5px; }
  .fc-op { font-size: 18px; }
  .fc-lines { font-size: 14px; }
  .fc-casita { width: 90px; }
  .fc-pad .key { height: 32px; min-height: 32px; font-size: 15px; }
  .fc-ask { font-size: 12px; }
}

/* Casita flotante compacta para mesas bajas */
#floatCasita { max-height: calc(100% - 12px); overflow: auto; }
#floatCasita.compact { width: min(500px, calc(100% - 12px)); top: 6px; right: 6px; }
#floatCasita.compact .fc-head { padding: 3px 4px 3px 8px; }
#floatCasita.compact .fc-min { width: 28px; height: 28px; }
#floatCasita.compact .fc-body { flex-direction: row; align-items: center; gap: 8px; padding: 5px 6px 6px; }
#floatCasita.compact .fc-board { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
#floatCasita.compact .fc-ask { font-size: 11px; }
#floatCasita.compact .fc-op { font-size: 16px; }
#floatCasita.compact .fc-lines { font-size: 13px; gap: 3px; }
#floatCasita.compact .fc-casita { width: 84px; }
#floatCasita.compact .fc-board > .fc-casita { width: 120px; }
#floatCasita.compact .fc-casita .mc-roof { height: 24px; font-size: 13px; }
#floatCasita.compact .fc-casita .mc-floor .slot { height: 24px; font-size: 14px; }
#floatCasita.compact .fc-pad { flex: 0 0 150px; grid-template-columns: repeat(3, 1fr) !important; gap: 3px; }
#floatCasita.compact .fc-pad .key { order: 0 !important; height: 27px; min-height: 27px; font-size: 14px; }
#floatCasita.compact .fc-pad .key-del { order: 1 !important; } #floatCasita.compact .fc-pad .key[data-key="0"] { order: 2 !important; } #floatCasita.compact .fc-pad .key-ok { order: 3 !important; }

.fc-min .fc-plus { display: none; }
#floatCasita.min .fc-min .fc-plus { display: inline; }
#floatCasita.min .fc-min .ic { transform: none; }
.fab-join { z-index: 45; }

/* ---------- «Juntar» se aparta cuando hay casa flotante ---------- */
#play.floating .fab-join { right: auto !important; left: 12px !important; bottom: 12px !important; }
@media (max-height: 500px) and (orientation: landscape) { #play.floating .fab-join { left: 8px !important; bottom: 8px !important; } }

/* ---------- Casa del número flotante ---------- */
.fc-casa { width: 120px !important; margin: 0 auto; }
.fc-casa .mc-roof { background: var(--brand); height: 46px; }
.fc-casa .mc-roof span { font-size: 18px; }
.fc-need { margin: 0; text-align: center; color: var(--brand-2); font-size: 12px; font-weight: 800; }
.fc-live { text-align: center; color: var(--ink-2); font-size: 14px; font-weight: 800; }
.fc-live b { margin-left: 6px; font-size: 24px; color: var(--ink); font-variant-numeric: tabular-nums; }
.fc-check { min-height: 44px; font-size: 15px; width: 100%; }
#floatCasita.nopad .fc-pad { display: none; }
#floatCasita.compact .fc-board:has(.fc-check) { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: center; }
#floatCasita.compact .fc-casa { width: 90px !important; margin: 0; }
#floatCasita.compact .fc-casa .mc-roof { height: 34px; }
#floatCasita.compact .fc-check { width: auto; min-height: 36px; padding: 0 14px; }
#floatCasita.compact .fc-board:has(.fc-check) .fc-ask { flex: 1 1 100%; }

#play.compactf .fab-join { left: 6px !important; bottom: 6px !important; min-height: 44px; width: 44px; padding: 0; justify-content: center; gap: 0; }
#play.compactf .fab-join span { display: none; }
#play.compactf .fab-join .badge { position: absolute; top: -8px; right: -8px; min-width: 22px; height: 22px; font-size: 12px; }
#play.floating #hint { display: none !important; }

.privacy-note { margin: 0 0 10px !important; font-size: 13px !important; line-height: 1.5; text-align: left; padding: 10px 12px; border-radius: 10px; background: var(--canvas); }
.privacy-note strong { color: var(--ink); }

/* Limits update: keep every piece reachable at a usable minimum size. */
.zone { overflow-y: auto; overflow-x: hidden; padding-right: 34px; overscroll-behavior: contain; }
.zone .it { flex-shrink: 0; }
.zone-nav { position: absolute; right: 2px; top: 42px; bottom: 2px; display: flex; flex-direction: column; justify-content: space-between; z-index: 3; }
.zone-nav[hidden] { display: none; }
.zone-nav button { width: 32px; min-height: 32px; flex: 1; max-height: 48px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: 900 20px Nunito,sans-serif; touch-action: manipulation; }
.room-pieces { overflow-y: auto; overflow-x: hidden; align-content: flex-start; touch-action: pan-y; }
.room-pieces .pc { flex-shrink: 0; }
@media (max-width: 700px) and (orientation: portrait) {
  #bottom { height: calc(192px + env(safe-area-inset-bottom)); }
  .zone-nav { top: 30px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  #bottom { height: calc(116px + env(safe-area-inset-bottom)); }
  .zone-nav { top: 26px; }
}
