/* ============================================================
   Bachillerato (Tutti Frutti, STOP) — la hoja y la portada
   (templates/play_bachillerato.html, bachillerato_hub.html).

   La hoja es papel de cuaderno: renglones, margen rojo y perforaciones,
   una tarjeta por categoría con su color propio, la letra como un sello
   enorme y el STOP como señal de tránsito. Todo con los tokens del
   portal (--surface, --ink, --line…) y una paleta de 9 colores de
   categoría con variante para el tema oscuro.
   ============================================================ */

.bach-shell, .bach-hub, .bach-hub-cover, #bach-sheet, #bach-end {
  --paper: #FFFCF3;
  --paper-rule: rgba(64, 118, 196, .16);
  --paper-margin: rgba(214, 56, 48, .55);
  --paper-hole: var(--bg);
  --stop: #D7261E; --stop-2: #B11B14; --stop-ink: #FFFFFF;
  --c1: #2563C9; --c2: #7445CC; --c3: #23884C; --c4: #D9481F; --c5: #C92F78;
  --c6: #8A5526; --c7: #A87C05; --c8: #0B7F82; --c9: #4F6275;
  --bach-ease: cubic-bezier(.22, .9, .25, 1);
  --hand: "Segoe Print", "Bradley Hand", "Chalkboard SE", "Comic Neue", var(--font-display);
}
:root[data-theme="dark"] .bach-shell, :root[data-theme="dark"] .bach-hub, :root[data-theme="dark"] .bach-hub-cover,
:root[data-theme="dark"] #bach-sheet, :root[data-theme="dark"] #bach-end {
  --paper: #1E1C19;
  --paper-rule: rgba(130, 168, 230, .10);
  --paper-margin: rgba(235, 110, 100, .45);
  --stop: #D9342B; --stop-2: #A8241D;
  --c1: #7EA8F2; --c2: #B39AF0; --c3: #6CC891; --c4: #F08C66; --c5: #EF84B5;
  --c6: #D2A57A; --c7: #E3C35C; --c8: #5CC6C4; --c9: #A3B3C4;
}
.bc1 { --h: var(--c1); } .bc2 { --h: var(--c2); } .bc3 { --h: var(--c3); } .bc4 { --h: var(--c4); } .bc5 { --h: var(--c5); }
.bc6 { --h: var(--c6); } .bc7 { --h: var(--c7); } .bc8 { --h: var(--c8); } .bc9 { --h: var(--c9); }

/* ============================================================ sala */
.bach-shell { max-width: 1180px; margin: 0 auto; width: 100%; }
.bach-room { position: relative; }
.bach-loading { margin: 40px 0; text-align: center; color: var(--muted); }
.bach-lobby { max-width: 620px; margin: 8px auto 0; width: 100%; }
.bach-lobby .arena-lobby, .bach-lobby .arena-join { background: var(--paper); }
.bach-lobby-info { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line-2); }
.bach-lobby-set { list-style: none; margin: 0 0 10px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.bach-lobby-set li { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.bach-lobby-set span { font-size: var(--t-xs); color: var(--muted); }
.bach-lobby-set b { font-weight: 600; font-size: .95rem; }
.bach-lobby-cats { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.bach-chip { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: var(--r-pill); font-size: .78rem; font-weight: 600;
  color: var(--h); background: color-mix(in srgb, var(--h) 13%, transparent); }

.bach-stage { position: relative; display: flex; flex-direction: column; gap: 14px; }

/* ---------- el papel ---------- */
.bach-paper {
  position: relative; isolation: isolate;
  padding: clamp(16px, 2.6vw, 30px) clamp(14px, 3vw, 36px) clamp(18px, 3vw, 34px) clamp(46px, 6vw, 84px);
  border-radius: 6px 18px 18px 6px; color: var(--ink);
  background:
    linear-gradient(90deg, transparent calc(clamp(34px, 4.6vw, 64px) - 1px), var(--paper-margin) calc(clamp(34px, 4.6vw, 64px) - 1px),
                    var(--paper-margin) calc(clamp(34px, 4.6vw, 64px) + 1px), transparent calc(clamp(34px, 4.6vw, 64px) + 1px)),
    repeating-linear-gradient(180deg, transparent 0 31px, var(--paper-rule) 31px 32px),
    var(--paper);
  background-position: 0 0, 0 18px, 0 0;
  box-shadow: 0 1px 0 var(--line), 0 0 0 1px var(--line), 0 24px 50px -30px rgba(60, 40, 20, .45);
}
.bach-paper::after { /* esquina doblada */
  content: ""; position: absolute; right: 0; bottom: 0; width: 26px; height: 26px; z-index: -1;
  background: linear-gradient(315deg, var(--bg) 50%, color-mix(in srgb, var(--paper) 80%, var(--line-2)) 50%);
  border-top-left-radius: 6px; box-shadow: -2px -2px 4px -2px rgba(0, 0, 0, .15);
}
.bach-holes { position: absolute; left: clamp(10px, 1.5vw, 22px); top: 0; bottom: 0; display: flex; flex-direction: column; justify-content: space-around; pointer-events: none; }
.bach-holes i { width: clamp(12px, 1.4vw, 16px); height: clamp(12px, 1.4vw, 16px); border-radius: 50%; background: var(--paper-hole);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, .18); }

/* ---------- cabecera: sello, texto, reloj ---------- */
.bach-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: clamp(12px, 2.4vw, 28px); margin-bottom: clamp(14px, 2vw, 22px); }
.bach-stamp {
  --s: clamp(84px, 9vw, 116px);
  position: relative; display: grid; place-items: center; width: var(--s); height: var(--s); flex: none;
  border-radius: 24px; transform: rotate(-5deg);
  color: var(--stop); background: color-mix(in srgb, var(--stop) 7%, var(--paper));
  border: 4px solid currentColor; box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 5px color-mix(in srgb, currentColor 55%, transparent);
}
.bach-reel { font-family: var(--font-display); font-weight: 700; font-size: calc(var(--s) * .62); line-height: 1; letter-spacing: -.02em; }
.bach-stamp.is-spinning { color: var(--ink-2); animation: bach-wobble .32s ease-in-out infinite alternate; }
.bach-stamp.is-spinning .bach-reel { filter: blur(.4px); opacity: .85; }
.bach-stamp.is-landed { animation: bach-stamp .48s var(--bach-ease); }
@keyframes bach-wobble { from { transform: rotate(-8deg) scale(.97); } to { transform: rotate(-2deg) scale(1.02); } }
@keyframes bach-stamp { 0% { transform: rotate(-14deg) scale(1.5); opacity: .2; } 60% { transform: rotate(-4deg) scale(.94); opacity: 1; } 100% { transform: rotate(-5deg) scale(1); } }
.bach-kicker { margin: 0; font-size: var(--t-xs); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.bach-prompt { margin: 2px 0 0; font-family: var(--font-display); font-size: clamp(1.35rem, 1rem + 1.4vw, 2rem); line-height: 1.15; font-weight: 600; }
.bach-progress { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.bach-progress[hidden] { display: none; }
.bach-pp { display: flex; align-items: center; gap: 6px; font-size: var(--t-xs); color: var(--ink-2); }
.bach-pp-n { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.bach-pp-bar { position: relative; width: 46px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bach-pp-bar i { position: absolute; inset: 0 auto 0 0; background: var(--sel); border-radius: 3px; transition: width .3s ease; }
.bach-pp.is-full .bach-pp-bar i { background: var(--success); }
.bach-pp.is-you .bach-pp-n { color: var(--sel-ink); }

.bach-clock { position: relative; display: grid; place-items: center; width: clamp(62px, 6vw, 76px); height: clamp(62px, 6vw, 76px); }
.bach-clock svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.bach-clock-bg { fill: var(--paper); stroke: var(--line-2); stroke-width: 3; }
.bach-clock-arc { fill: none; stroke: var(--sel); stroke-width: 3.6; stroke-linecap: round; transition: stroke-dashoffset .2s linear, stroke .3s; }
.bach-clock .num { position: relative; font-size: 1.2rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.bach-clock.is-urgent .bach-clock-arc { stroke: var(--stop); }
.bach-clock.is-urgent .num { color: var(--stop); animation: bach-pulse 1s ease-in-out infinite; }
@keyframes bach-pulse { 50% { transform: scale(1.12); } }

/* ---------- las casillas ---------- */
.bach-write { margin: 0; }
.bach-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(10px, 1.4vw, 16px) clamp(12px, 1.8vw, 22px); }
.bach-cell {
  position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0;
  padding: 10px 12px 8px; border-radius: 14px;
  background: color-mix(in srgb, var(--h) 6%, var(--paper));
  border: 1.5px solid color-mix(in srgb, var(--h) 28%, transparent);
  transition: border-color var(--dur), box-shadow var(--dur), transform .2s var(--bach-ease);
}
.bach-cell::before { content: ""; position: absolute; left: 12px; top: -1.5px; width: 34px; height: 4px; border-radius: 0 0 4px 4px; background: var(--h); }
.bach-cell:focus-within { border-color: var(--h); box-shadow: 0 0 0 4px color-mix(in srgb, var(--h) 18%, transparent); transform: translateY(-1px); }
.bach-cell-tag { display: flex; align-items: center; gap: 7px; font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--h); cursor: text; }
.bach-cell-n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: .68rem; letter-spacing: 0;
  color: var(--paper); background: var(--h); }
.bach-in {
  width: 100%; min-width: 0; height: 46px; padding: 0 2px; border: 0; border-bottom: 2px solid color-mix(in srgb, var(--h) 45%, var(--line-2));
  border-radius: 0; background: transparent; color: var(--ink);
  font-family: var(--hand); font-size: 1.42rem; font-style: italic; font-weight: 500; letter-spacing: .01em;
  caret-color: var(--h);
}
.bach-in:focus { outline: none; border-bottom-color: var(--h); }
.bach-in:focus-visible { outline: none; }
.bach-in[readonly] { cursor: default; }
.bach-cell.is-filled::after { content: "✓"; position: absolute; right: 12px; top: 9px; font-size: .85rem; font-weight: 700; color: var(--h); }
.bach-cell.is-bad { border-color: color-mix(in srgb, var(--warn) 70%, transparent); }
.bach-cell.is-bad::after { content: "!"; color: var(--warn); }
.bach-cell-warn { min-height: 1.1em; font-size: var(--t-xs); font-weight: 600; color: var(--warn); }
.is-locked .bach-grid { opacity: .78; }
[data-phase="draw"] .bach-grid { opacity: .5; filter: saturate(.6); }

/* ---------- el STOP ---------- */
.bach-stopbar { display: flex; align-items: center; justify-content: flex-end; gap: 18px; }
.bach-stopbar[hidden] { display: none; }
.bach-stop-hint { margin: 0; font-size: var(--t-sm); color: var(--ink-2); text-align: right; }
.bach-stop {
  --sz: 104px;
  position: relative; display: grid; place-items: center; width: var(--sz); height: var(--sz); flex: none; padding: 0;
  border: 0; background: none; cursor: pointer; color: var(--stop-ink);
  transition: transform .18s var(--bach-ease), filter .2s, opacity .2s;
}
.bach-stop-oct, .bach-banner-oct {
  position: absolute; inset: 0;
  clip-path: polygon(29.3% 0, 70.7% 0, 100% 29.3%, 100% 70.7%, 70.7% 100%, 29.3% 100%, 0 70.7%, 0 29.3%);
  background: #fff;
}
.bach-stop-oct::after, .bach-banner-oct::after {
  content: ""; position: absolute; inset: 5px;
  clip-path: polygon(29.3% 0, 70.7% 0, 100% 29.3%, 100% 70.7%, 70.7% 100%, 29.3% 100%, 0 70.7%, 0 29.3%);
  background: radial-gradient(120% 90% at 30% 20%, color-mix(in srgb, var(--stop) 70%, #fff), var(--stop) 55%, var(--stop-2));
}
.bach-stop { filter: drop-shadow(0 8px 14px rgba(150, 20, 10, .35)) drop-shadow(0 0 0 var(--line-2)); }
.bach-stop b { position: relative; font-family: var(--font-ui); font-size: 1.62rem; font-weight: 800; letter-spacing: .06em; text-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.bach-stop:hover:not(:disabled) { transform: scale(1.05) rotate(-3deg); }
.bach-stop:active:not(:disabled) { transform: scale(.94); }
.bach-stop:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 12px; }
.bach-stop:disabled { cursor: not-allowed; filter: grayscale(.75) opacity(.5); }
.bach-stop.is-ready:not(:disabled) { animation: bach-ready 1.4s ease-in-out infinite; }
.bach-stop.is-ready:not(:disabled) .bach-stop-oct { animation: bach-ready-in 1.4s ease-in-out infinite; }
@keyframes bach-ready { 50% { filter: drop-shadow(0 8px 24px rgba(215, 38, 30, .7)); } }
@keyframes bach-ready-in { 50% { transform: scale(1.06); } }

.bach-banner {
  position: fixed; left: 50%; top: 44%; z-index: 60; display: grid; place-items: center; width: 220px; height: 220px;
  margin: -110px 0 0 -110px; color: #fff; pointer-events: none; text-align: center;
  filter: drop-shadow(0 18px 30px rgba(120, 10, 5, .4));
}
.bach-banner b { position: relative; font-size: 2.6rem; font-weight: 800; letter-spacing: .04em; line-height: 1; margin-top: -10px; }
.bach-banner small { position: absolute; bottom: 52px; left: 22px; right: 22px; font-size: .85rem; font-weight: 600; opacity: .95; }
.bach-banner.is-in { animation: bach-banner 3s var(--bach-ease) forwards; }
@keyframes bach-banner { 0% { transform: scale(.3) rotate(-20deg); opacity: 0; } 12% { transform: scale(1.08) rotate(4deg); opacity: 1; }
  20% { transform: scale(1) rotate(0); } 82% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(.9); } }

/* ---------- barra de acciones (revisión, resultados) ---------- */
.bach-actionbar {
  position: sticky; bottom: 10px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px 12px 18px; border-radius: var(--r-lg); background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line); box-shadow: var(--shadow-md); backdrop-filter: blur(6px);
}
.bach-actionbar[hidden] { display: none; }
.bach-ab-t { margin: 0; font-size: var(--t-sm); color: var(--ink-2); }
.bach-ab-t b { color: var(--ink); }
.bach-actionbar .btn { min-width: 12rem; }

/* ---------- revisión ---------- */
.bach-sec-head { margin-bottom: 14px; }
.bach-sec-t { margin: 0; font-family: var(--font-display); font-size: clamp(1.3rem, 1rem + 1vw, 1.7rem); }
.bach-sec-s { margin: 4px 0 0; font-size: var(--t-sm); color: var(--ink-2); }
.bach-rv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.bach-rv-cat { min-width: 0; padding: 10px 12px 6px; border-radius: 14px; background: color-mix(in srgb, var(--h) 5%, var(--paper));
  border: 1.5px solid color-mix(in srgb, var(--h) 24%, transparent); }
.bach-rv-h { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--h); }
.bach-rv-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--h); transform: rotate(45deg); }
.bach-rv-row { display: grid; grid-template-columns: minmax(0, 5.5em) minmax(0, 1fr) auto; grid-template-areas: "who w act" "who meta act";
  align-items: center; column-gap: 10px; padding: 7px 0; border-top: 1px dashed var(--line-2); }
.bach-rv-row:first-of-type { border-top: 0; }
[data-phase="review"] .bach-rv-row { min-height: 52px; }
.bach-rv-who { grid-area: who; font-size: var(--t-xs); font-weight: 700; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bach-rv-row.is-mine .bach-rv-who { color: var(--sel-ink); }
.bach-rv-w { grid-area: w; min-width: 0; font-family: var(--hand); font-style: italic; font-size: 1.2rem; overflow-wrap: anywhere; }
.bach-rv-row.is-rej .bach-rv-w { text-decoration: line-through; text-decoration-color: var(--stop); color: var(--muted); }
.bach-rv-meta { grid-area: meta; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.bach-rv-act { grid-area: act; display: flex; gap: 6px; align-items: center; }
.bach-badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: var(--r-pill); font-size: .68rem; font-weight: 700; letter-spacing: .03em; }
.bach-badge.is-ok { color: var(--success); background: var(--success-weak); }
.bach-badge.is-revisar { color: var(--warn); background: var(--warn-weak); }
.bach-badge.is-no { color: var(--danger); background: var(--danger-weak); }
.bach-rv-row.is-revisar { background: linear-gradient(90deg, color-mix(in srgb, var(--present) 14%, transparent), transparent 70%); border-radius: 8px; padding-left: 6px; margin-left: -6px; }
.bach-rv-sug { font-size: var(--t-xs); color: var(--ink-2); font-style: italic; }
.bach-vote { display: inline-flex; align-items: center; gap: 5px; min-width: 52px; height: 42px; padding: 0 10px; border-radius: 12px;
  border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink-2); font: inherit; font-weight: 700; cursor: pointer;
  transition: background var(--dur), border-color var(--dur), color var(--dur), transform .12s; }
.bach-vote:active { transform: scale(.94); }
.bach-vote:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.bach-vote-i { font-size: 1.05rem; }
.bach-vote-c { font-size: .8rem; opacity: .8; }
.bach-vote.is-up[aria-pressed="true"] { background: var(--success); border-color: var(--success); color: #fff; }
.bach-vote.is-down[aria-pressed="true"] { background: var(--stop); border-color: var(--stop); color: #fff; }
.bach-rv-tally { font-size: var(--t-xs); color: var(--muted); white-space: nowrap; }
.bach-rv-pts { font-weight: 700; color: var(--success); }
.bach-rv-row.is-no .bach-rv-pts { color: var(--muted); }
[data-mode] .bach-review .bach-rv-row { grid-template-columns: minmax(0, 5.5em) minmax(0, 1fr) auto; }
.bach-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 42px; }
.bach-switch input { appearance: none; -webkit-appearance: none; position: relative; width: 46px; height: 26px; margin: 0; border-radius: 13px;
  background: var(--line-2); cursor: pointer; transition: background .2s; }
.bach-switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s var(--bach-ease); }
.bach-switch input:checked { background: var(--success); }
.bach-switch input:checked::after { transform: translateX(20px); }
.bach-switch input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.bach-switch-t { font-size: var(--t-xs); font-weight: 700; min-width: 4.2em; }
/* individual: sin columna de nombre */
.bach-shell[data-mode] .bach-rv-cat .bach-rv-row:not(:has(.bach-rv-who)) { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "w act" "meta act"; }

/* ---------- resultados ---------- */
.bach-res-scroll { overflow-x: auto; margin: 0 -4px 16px; padding: 0 4px; -webkit-overflow-scrolling: touch; }
.bach-res-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
.bach-res-table th, .bach-res-table td { padding: 8px 10px; text-align: left; vertical-align: middle; border-bottom: 1px dashed var(--line-2); }
.bach-res-table thead th { font-size: var(--t-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid var(--line-2); white-space: nowrap; }
.bach-res-table thead th.is-you, .bach-res-table td.is-you { background: color-mix(in srgb, var(--sel) 7%, transparent); }
.bach-res-cat { font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--h); white-space: nowrap; }
.bach-res-table td { min-width: 8.5em; }
.bach-res-table td .bach-res-w { display: block; font-family: var(--hand); font-style: italic; font-size: 1.08rem; overflow-wrap: anywhere; }
.bach-res-table td.is-no .bach-res-w { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--stop) 60%, transparent); }
.bach-res-table tfoot th, .bach-res-table tfoot td { font-weight: 700; border-bottom: 0; }
.bach-res-table tfoot tr:last-child td { font-size: 1.15rem; }
.bach-pts { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; margin-top: 2px; border-radius: var(--r-pill); font-size: .74rem; font-weight: 700; }
.bach-pts.is-20 { color: #5A3A00; background: linear-gradient(135deg, #FFE08A, #F2B931); }
.bach-pts.is-10 { color: var(--success); background: var(--success-weak); }
.bach-pts.is-5 { color: var(--sel-ink); background: var(--sel-weak); }
.bach-pts.is-0 { color: var(--muted); background: var(--surface-2); }
.bach-board { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.bach-board li { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--surface); font-size: var(--t-sm); }
.bach-board li.is-you { border-color: var(--sel); }
.bach-board li.is-left { opacity: .55; }
.bach-board-p { color: var(--muted); }
.bach-res-solo { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 16px; }
.bach-res-li { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "cat pts" "w pts" "why pts"; align-items: center; column-gap: 8px;
  padding: 8px 12px; border-radius: 12px; border: 1.5px solid color-mix(in srgb, var(--h) 24%, transparent); background: color-mix(in srgb, var(--h) 5%, var(--paper)); }
.bach-res-cat { grid-area: cat; }
.bach-res-li .bach-res-w { grid-area: w; font-family: var(--hand); font-style: italic; font-size: 1.18rem; overflow-wrap: anywhere; }
.bach-res-li.is-no .bach-res-w { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--stop); }
.bach-res-why { grid-area: why; font-size: var(--t-xs); color: var(--danger); }
.bach-res-li .bach-pts { grid-area: pts; height: 26px; font-size: .85rem; }
.bach-res-sum { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.bach-res-big { margin: 0; font-size: var(--t-sm); color: var(--ink-2); }
.bach-res-big b { font-family: var(--font-display); font-size: 2rem; color: var(--ink); }
.bach-res-bonus { margin: 0; display: inline-flex; padding: 4px 12px; border-radius: var(--r-pill); font-weight: 700; color: #5A3A00; background: linear-gradient(135deg, #FFE08A, #F2B931); }
.bach-res-rec { margin: 0; font-size: var(--t-sm); font-weight: 600; color: var(--sel-ink); min-height: 1.2em; }

/* ---------- final ---------- */
.bach-end-card { max-width: 560px; }
.bach-end-note { margin: 0 0 10px; padding: 8px 12px; border-radius: var(--r-md); background: var(--warn-weak); color: var(--warn); font-size: var(--t-sm); }
.bach-podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 12px 0 14px; min-height: 0; }
.bach-podium:empty, .bach-podium[hidden] { display: none; }
.bach-pod { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 2px; width: 32%; max-width: 150px; padding: 10px 6px 8px;
  border-radius: 14px 14px 4px 4px; background: color-mix(in srgb, var(--c1) 12%, var(--surface)); border: 1.5px solid color-mix(in srgb, var(--c1) 30%, transparent);
  animation: bach-rise .7s var(--bach-ease) both; }
.bach-pod.p1 { min-height: 150px; background: linear-gradient(180deg, #FFE7A3, #F6C744); border-color: #E2AE22; color: #4A3300; animation-delay: .25s; }
.bach-pod.p2 { min-height: 118px; background: color-mix(in srgb, #9FB3C8 30%, var(--surface)); border-color: #9FB3C8; animation-delay: .1s; }
.bach-pod.p3 { min-height: 96px; background: color-mix(in srgb, #D49A6A 28%, var(--surface)); border-color: #C98A57; animation-delay: .4s; }
.bach-pod-n { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: .9rem; }
.bach-pod-s { font-family: var(--font-display); font-size: 1.6rem; line-height: 1.1; }
.bach-pod-b { margin-top: auto; font-size: .8rem; font-weight: 700; opacity: .75; }
.bach-pod.is-you { box-shadow: 0 0 0 3px var(--sel); }
@keyframes bach-rise { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.bach-rank { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.bach-rank li { display: grid; grid-template-columns: 2.2em minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 7px 10px; border-radius: var(--r-md); background: var(--surface-2); font-size: var(--t-sm); }
.bach-rank li.is-you { box-shadow: inset 0 0 0 1.5px var(--sel); }
.bach-rank li.is-left { opacity: .6; }
.bach-rank { text-align: left; }
.bach-rank-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.bach-rank-r { font-size: var(--t-xs); white-space: nowrap; }
.bach-rank b { font-size: 1.05rem; }
.bach-end-stats { margin-bottom: 8px; }
.bach-end-wait { margin: 0; font-size: var(--t-sm); flex-basis: 100%; text-align: center; }

/* ---------- la hoja (todas las rondas) ---------- */
.bach-sheet-card { max-width: min(1100px, calc(100vw - 32px)); }
.bach-sheet-scroll { overflow-x: auto; margin: 6px 0 4px; -webkit-overflow-scrolling: touch;
  background: var(--paper); border-radius: 10px; border: 1px solid var(--line); text-align: left; }
.bach-hoja tbody tr { border-bottom: 1px solid var(--paper-rule); }
.bach-hoja tbody tr:last-child { border-bottom: 0; }
.bach-hoja tbody td { vertical-align: middle; }
.bach-hoja { border-collapse: collapse; min-width: 100%; font-size: .88rem; }
.bach-hoja th, .bach-hoja td { padding: 8px 10px; border-right: 1px solid var(--line); text-align: left; vertical-align: top; }
.bach-hoja thead th { font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--h, var(--muted)); border-bottom: 2px solid var(--paper-margin); white-space: nowrap; }
.bach-hoja td { min-width: 7.5em; }
.bach-hoja td .bach-res-w { display: block; font-family: var(--hand); font-style: italic; font-size: 1rem; }
.bach-hoja td small { color: var(--muted); font-size: .72rem; }
.bach-hoja td.is-no .bach-res-w { color: var(--muted); text-decoration: line-through; }
.bach-hoja .bach-hoja-l { min-width: 0; font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; color: var(--stop); text-align: center; }
.bach-hoja thead .bach-hoja-l { font-family: var(--font-ui); font-size: .7rem; color: var(--muted); }
.bach-hoja .bach-hoja-p { min-width: 0; font-weight: 700; text-align: right; }

/* sonido */
.bach-sound-pop { min-width: 220px; }
.bach-vol { display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-size: var(--t-sm); }
.bach-vol input { flex: 1; accent-color: var(--accent); }

/* ============================================================ responsive */
@media (max-width: 1000px) {
  .bach-grid, .bach-res-solo { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .bach-rv { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .play-bach .play-report { padding-bottom: 110px; }
  .bach-paper { padding: 14px 12px 18px 38px; border-radius: 4px 14px 14px 4px;
    background:
      linear-gradient(90deg, transparent 27px, var(--paper-margin) 27px, var(--paper-margin) 29px, transparent 29px),
      repeating-linear-gradient(180deg, transparent 0 31px, var(--paper-rule) 31px 32px), var(--paper); }
  .bach-holes { left: 7px; }
  .bach-holes i { width: 11px; height: 11px; }
  .bach-head { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; }
  .bach-stamp { --s: 72px; border-radius: 18px; border-width: 3px; }
  .bach-prompt { font-size: 1.2rem; }
  .bach-clock { width: 56px; height: 56px; }
  .bach-clock .num { font-size: 1.02rem; }
  .bach-grid, .bach-res-solo { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .bach-in { height: 48px; font-size: 1.36rem; }
  .bach-stopbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; justify-content: space-between; gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 94%, transparent);
    border-top: 1px solid var(--line); box-shadow: 0 -10px 24px -16px rgba(0, 0, 0, .3); backdrop-filter: blur(8px);
  }
  .bach-stop-hint { text-align: left; font-size: .82rem; }
  .bach-stop { --sz: 78px; }
  .bach-stop b { font-size: 1.22rem; }
  .bach-stage { padding-bottom: 92px; }
  [data-phase="review"] .bach-stage, [data-phase="results"] .bach-stage, [data-phase="over"] .bach-stage { padding-bottom: 0; }
  .bach-actionbar { bottom: 8px; padding: 10px 12px; }
  .bach-actionbar .btn { flex: 1 1 100%; min-width: 0; }
  .bach-rv-row, .bach-shell[data-mode] .bach-rv-cat .bach-rv-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who act" "w act" "meta act"; column-gap: 8px; row-gap: 1px; }
  .bach-rank-r { display: none; }
  .bach-vote { min-width: 46px; padding: 0 8px; }
  .bach-banner { width: 180px; height: 180px; margin: -90px 0 0 -90px; }
  .bach-banner b { font-size: 2.1rem; }
  .bach-banner small { bottom: 42px; font-size: .74rem; }
  .bach-res-table td { min-width: 7em; }
}
@media (max-width: 360px) {
  .bach-paper { padding-left: 32px; padding-right: 10px;
    background:
      linear-gradient(90deg, transparent 22px, var(--paper-margin) 22px, var(--paper-margin) 24px, transparent 24px),
      repeating-linear-gradient(180deg, transparent 0 31px, var(--paper-rule) 31px 32px), var(--paper); }
  .bach-holes { left: 5px; }
  .bach-holes i { width: 9px; height: 9px; }
  .bach-stamp { --s: 60px; border-radius: 14px; }
  .bach-clock { width: 50px; height: 50px; }
  .bach-prompt { font-size: 1.05rem; }
  .bach-shell .tt-hud-sep { display: none; }
}
/* apaisado bajo (844×390): la cabecera se compacta */
@media (max-height: 460px) and (orientation: landscape) {
  .bach-stamp { --s: 64px; }
  .bach-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bach-stopbar { position: sticky; bottom: 0; z-index: 30; padding: 6px 14px; border-radius: var(--r-lg);
    background: color-mix(in srgb, var(--surface) 94%, transparent); border: 1px solid var(--line); box-shadow: var(--shadow-md); backdrop-filter: blur(8px); }
  .bach-stop { --sz: 64px; }
  .bach-stop b { font-size: 1.05rem; }
}
@media (prefers-reduced-motion: reduce) {
  .bach-stamp.is-spinning, .bach-stamp.is-landed, .bach-stop.is-ready, .bach-stop.is-ready .bach-stop-oct, .bach-clock.is-urgent .num, .bach-pod { animation: none; }
  .bach-banner.is-in { animation: bach-fade 3s linear forwards; }
  @keyframes bach-fade { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }
  .bach-cell { transition: none; }
}

/* ============================================================ portada */
.bach-hub-cover { margin: 4px 0 18px; }
.bach-hub-cover:empty { display: none; }
.bach-hub-stats { display: flex; gap: 18px; flex-wrap: wrap; margin: 12px 0 0; font-size: var(--t-sm); color: var(--muted); }
.bach-hub-stats b { color: var(--ink); font-size: 1.05rem; }
.bach-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.bach-points li { display: grid; grid-template-columns: 3.2em minmax(0, 1fr); gap: 12px; align-items: center; color: var(--ink-2); }
.bach-points b { display: grid; place-items: center; height: 36px; border-radius: 10px; font-size: 1.05rem; }
.bach-points li:nth-child(1) b { color: #5A3A00; background: linear-gradient(135deg, #FFE08A, #F2B931); }
.bach-points li:nth-child(2) b { color: var(--success); background: var(--success-weak); }
.bach-points li:nth-child(3) b { color: var(--sel-ink); background: var(--sel-weak); }
.bach-points li:nth-child(4) b { color: var(--muted); background: var(--surface-2); }
.bach-hub-note { margin-top: 12px; font-size: var(--t-sm); }

.bach-start { position: relative; overflow: hidden; background: var(--paper);
  background-image: repeating-linear-gradient(180deg, transparent 0 27px, var(--paper-rule) 27px 28px); }
.bach-start::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px;
  background: linear-gradient(90deg, var(--c1), var(--c2), var(--c3), var(--c4), var(--c5), var(--c6), var(--c7), var(--c8), var(--c9)); }
.bach-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: var(--r-pill); background: var(--surface-2); }
.bach-tabs button { min-height: 42px; border: 0; border-radius: var(--r-pill); background: transparent; font: inherit; font-size: .95rem; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.bach-tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); font-weight: 650; box-shadow: var(--shadow-sm); }
.bach-tabs button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.bach-settings { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.bach-start fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.bach-start legend { display: flex; align-items: baseline; gap: 8px; width: 100%; margin-bottom: 6px; padding: 0; font-size: var(--t-xs); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.bach-start legend small { margin-left: auto; letter-spacing: 0; text-transform: none; font-weight: 500; }
.bach-seg { display: flex; gap: 6px; flex-wrap: wrap; }
.bach-seg label { flex: 1 1 auto; position: relative; }
.bach-seg input, .bach-cat-opt input { position: absolute; opacity: 0; pointer-events: none; }
.bach-seg span { display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--r-pill);
  font-size: var(--t-sm); font-weight: 500; color: var(--ink-2); background: var(--surface); cursor: pointer; white-space: nowrap; transition: background var(--dur), color var(--dur); }
.bach-seg input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.bach-seg input:focus-visible + span, .bach-cat-opt input:focus-visible + span, .bach-check input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.bach-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.bach-cat-opt { position: relative; }
.bach-cat-opt span { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: var(--r-pill); cursor: pointer;
  font-size: var(--t-sm); font-weight: 600; color: var(--muted); border: 1.5px dashed var(--line-2); background: var(--surface); transition: all var(--dur); }
.bach-cat-opt span::before { content: ""; width: 10px; height: 10px; border-radius: 3px; border: 1.5px solid currentColor; }
.bach-cat-opt input:checked + span { color: var(--h); border-style: solid; border-color: color-mix(in srgb, var(--h) 45%, transparent); background: color-mix(in srgb, var(--h) 11%, var(--surface)); }
.bach-cat-opt input:checked + span::before { background: var(--h); border-color: var(--h); }
.bach-cats-hint { margin: 6px 0 0; font-size: var(--t-xs); color: var(--warn); }
.bach-check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: var(--t-sm); color: var(--ink-2); cursor: pointer; }
.bach-check input { width: 20px; height: 20px; accent-color: var(--ink); margin: 0; }
.bach-check small { color: var(--muted); }
.bach-tab { display: flex; flex-direction: column; gap: 10px; }
.bach-tab[hidden] { display: none; }
.bach-online .arena-input { margin: 0; height: 46px; }
.bach-join-form { display: flex; gap: 8px; }
.bach-code-in { margin: 0 !important; text-transform: uppercase; letter-spacing: .14em; font-family: var(--font-num); }
.bach-online-note, .bach-note { margin: 0; font-size: var(--t-xs); }

/* resultados en pantallas angostas: la columna de categorías queda fija al desplazar */
@media (max-width: 640px) {
  .bach-res-table th:first-child { position: sticky; left: 0; z-index: 1; background: var(--paper); box-shadow: 6px 0 8px -8px rgba(0, 0, 0, .3); }
  .bach-res-cat { font-size: .7rem; }
}

.bach-jump { display: none; }
@media (max-width: 860px) { .bach-jump { display: inline-flex; margin-top: 4px; } #bach-play { scroll-margin-top: 16px; } }
