/* =========================================================
   Pizarra Táctica Pro — estilos (Dark Mode deportivo)
   ========================================================= */
:root {
  --bg: #0b0f14;
  --bg-2: #111820;
  --surface: #151d27;
  --surface-2: #1b2533;
  --border: #263345;
  --text: #e8edf3;
  --text-2: #9aa8b8;
  --muted: #6b7a8c;
  --accent: #f28c28;        /* naranja balón */
  --accent-2: #ffb15c;
  --off: #2f8cff;           /* atacantes */
  --off-2: #7db7ff;
  --def: #ff4d5e;           /* defensores */
  --def-2: #ff8a95;
  --ok: #33d17a;
  --warn: #ffcc4d;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: "JetBrains Mono", Consolas, "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 60% -10%, #16243a 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center;
  padding: 10px 18px;
  background: rgba(11, 15, 20, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background:
    radial-gradient(circle at 35% 30%, #ffc27a, var(--accent) 55%, #b85d10);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.25), 0 0 18px rgba(242,140,40,.35);
  position: relative;
}
.brand-logo::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 47%, #2a1406 47% 53%, transparent 53%),
    linear-gradient(0deg, transparent 47%, #2a1406 47% 53%, transparent 53%);
  opacity: .7;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; letter-spacing: .2px; }
.brand-text small { color: var(--text-2); font-size: 11px; }

.mode-switch {
  justify-self: center;
  display: inline-flex; padding: 4px; gap: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
}
.mode-btn {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 7px 16px; border: 0; border-radius: 10px; background: transparent; color: var(--text-2);
  transition: background .2s, color .2s;
}
.mode-btn .mode-title { font-weight: 700; text-transform: uppercase; letter-spacing: .6px; font-size: 13px; }
.mode-btn .mode-sub { font-size: 11px; opacity: .85; }
.mode-btn.active[data-mode="attack"] { background: linear-gradient(135deg, #1d4f99, #2f8cff); color: #fff; }
.mode-btn.active[data-mode="defense"] { background: linear-gradient(135deg, #8f1d2a, #ff4d5e); color: #fff; }

.top-actions { display: flex; align-items: center; gap: 8px; }
.search {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 0 10px; height: 38px; width: min(340px, 30vw);
}
.search:focus-within { border-color: var(--accent); }
.search-ico { color: var(--muted); font-size: 18px; }
.search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; }

.btn {
  height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
.btn:hover { border-color: #3b4d66; }
.btn.ghost { background: transparent; }
.btn.small { height: 30px; font-size: 12px; padding: 0 10px; }
.btn.toggle[aria-pressed="true"] { background: rgba(255, 204, 77, .15); border-color: var(--warn); color: var(--warn); }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 18px; }
.only-mobile { display: none; }

/* ---------- Filtros ---------- */
.filters {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 18px; border-bottom: 1px solid var(--border); background: rgba(17, 24, 32, .6);
}
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.chip {
  flex: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); font-size: 12.5px;
}
.chip .n { opacity: .6; margin-left: 4px; font-size: 11px; }
.chip.active { color: #fff; border-color: transparent; background: var(--mode-color, var(--off)); }
body[data-mode="defense"] { --mode-color: var(--def); }
body[data-mode="attack"] { --mode-color: var(--off); }
.filter-extra { display: flex; gap: 8px; flex: none; }
select {
  height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); padding: 0 10px;
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 380px;
  gap: 14px; padding: 14px 18px 24px;
  align-items: start;
}

/* Lista */
.playlist {
  position: sticky; top: 122px;
  max-height: calc(100vh - 136px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.playlist-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text-2); font-size: 12px;
}
.playlist-body { overflow-y: auto; padding: 6px; scrollbar-width: thin; }
.group-title {
  position: sticky; top: -6px; z-index: 1;
  padding: 8px 8px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted); background: var(--surface);
}
.play-item {
  width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: start;
  text-align: left; padding: 9px 9px; border: 1px solid transparent; border-radius: 10px;
  background: transparent; margin-bottom: 2px;
}
.play-item:hover { background: var(--surface-2); }
.play-item.active { background: var(--surface-2); border-color: var(--mode-color); }
.pi-id {
  font: 600 11px var(--mono); color: var(--mode-color); padding: 2px 5px; border-radius: 6px;
  background: color-mix(in srgb, var(--mode-color) 14%, transparent);
}
.pi-name { font-weight: 600; font-size: 13px; line-height: 1.3; }
.pi-vs { display: block; color: var(--text-2); font-size: 11.5px; margin-top: 2px; font-weight: 400; }
.pi-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.pi-star { color: var(--warn); font-size: 13px; }
.lvl { font-size: 10px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.lvl.Iniciación { color: var(--ok); border-color: rgba(51, 209, 122, .4); }
.lvl.Formación { color: var(--warn); border-color: rgba(255, 204, 77, .4); }
.lvl.Senior { color: var(--def-2); border-color: rgba(255, 77, 94, .4); }
.empty-list { padding: 24px 12px; color: var(--muted); text-align: center; }
mark { background: rgba(242, 140, 40, .35); color: inherit; border-radius: 3px; }

/* Escenario */
.stage { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.stage-head { display: flex; flex-direction: column; gap: 2px; }
.play-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.play-title h1 { margin: 0; font-size: 20px; line-height: 1.25; }
.play-id { font: 700 12px var(--mono); padding: 3px 7px; border-radius: 7px; background: var(--mode-color); color: #fff; flex: none; }
.play-vs { color: var(--text-2); font-size: 13px; }
.fav-btn { margin-left: auto; flex: none; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 18px; color: var(--warn); }
.fav-btn[aria-pressed="true"] { background: rgba(255, 204, 77, .14); border-color: var(--warn); }

.court-wrap {
  position: relative;
  background: #0a0e13; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  touch-action: pan-y; /* permite hacer scroll de la página y deslizar para cambiar de fase */
}
#court { display: block; width: 100%; height: auto; max-height: calc(100vh - 300px); max-height: calc(100dvh - 300px); min-height: 260px; user-select: none; -webkit-user-select: none; }
.court-wrap.tele { touch-action: none; } /* dibujando: el dedo no desplaza la página */
.lbl-m { display: none; }
.court-wrap.tele #court { cursor: crosshair; }
.court-wrap.tele.tool-move #court { cursor: default; }
.phase-badge {
  position: absolute; left: 12px; top: 10px; pointer-events: none;
  padding: 5px 10px; border-radius: 8px; font-size: 12px; font-weight: 700;
  background: rgba(0, 0, 0, .6); border: 1px solid rgba(255, 255, 255, .12);
}
.phase-text {
  min-height: 48px; padding: 10px 14px; border-radius: 10px;
  background: var(--surface); border-left: 3px solid var(--mode-color); color: var(--text);
}
.phase-text b { color: var(--accent-2); }

.controls { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.ctrl-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ctrl {
  min-width: 42px; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); font-size: 15px;
}
.ctrl:disabled { opacity: .4; cursor: not-allowed; }
.ctrl.primary { background: var(--accent); border-color: var(--accent); color: #1b0f02; font-weight: 800; min-width: 56px; }
.ctrl.wide { font-size: 13px; }
.ctrl[aria-pressed="true"] { background: rgba(242, 140, 40, .18); border-color: var(--accent); color: var(--accent-2); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg-btn { height: 38px; padding: 0 11px; border: 0; background: var(--surface); color: var(--text-2); font-size: 12.5px; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.active { background: var(--surface-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

.stepper { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; }
.step {
  flex: 1 0 120px; text-align: left; padding: 7px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 12px; line-height: 1.3;
}
.step b { display: block; color: var(--text); font-size: 12px; }
.step.done { border-color: color-mix(in srgb, var(--mode-color) 45%, var(--border)); }
.step.active { background: color-mix(in srgb, var(--mode-color) 20%, var(--surface)); border-color: var(--mode-color); color: var(--text); }

.tele-bar {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 8px;
  background: rgba(242, 140, 40, .07); border: 1px dashed rgba(242, 140, 40, .45); border-radius: 12px;
}
.tools { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.tool { height: 34px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; }
.tool.active { background: var(--accent); color: #1b0f02; border-color: var(--accent); font-weight: 700; }
.swatches { display: inline-flex; gap: 4px; margin-right: 4px; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
.swatch.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.6) inset; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--text-2); font-size: 12px; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend svg { width: 46px; height: 12px; overflow: visible; }
.lg-cut { stroke: #fff; stroke-width: 2; fill: none; }
.lg-pass { stroke: #fff; stroke-width: 2; fill: none; stroke-dasharray: 5 4; }
.lg-shot { stroke: var(--accent); stroke-width: 2; fill: none; stroke-dasharray: 1 4; stroke-linecap: round; }
.lg-head { fill: #fff; }
.lg-tokens i { display: inline-grid; place-items: center; font-style: normal; font-weight: 800; font-size: 10px; }
.tk-o { width: 20px; height: 20px; border-radius: 50%; background: var(--off); color: #fff; }
.tk-d { width: 24px; height: 20px; background: var(--def); color: #fff; clip-path: polygon(50% 100%, 0 0, 100% 0); padding-bottom: 6px; font-size: 8px !important; }
.tk-ball { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: inset -2px -2px 0 rgba(0,0,0,.25); }

/* Panel */
.panel {
  position: sticky; top: 122px;
  max-height: calc(100vh - 136px); overflow-y: auto; scrollbar-width: thin;
  display: flex; flex-direction: column; gap: 10px;
}
.panel-empty { padding: 30px 18px; color: var(--muted); text-align: center; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
#panelBody { display: flex; flex-direction: column; gap: 10px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.tag.cat { color: #fff; background: color-mix(in srgb, var(--mode-color) 30%, var(--surface)); border-color: transparent; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 14px; }
.card > summary {
  list-style: none; cursor: pointer; padding: 11px 0; font-weight: 700; font-size: 12.5px;
  text-transform: uppercase; letter-spacing: .6px; color: var(--accent-2);
  display: flex; justify-content: space-between; align-items: center;
}
.card > summary::-webkit-details-marker { display: none; }
.card > summary::after { content: "▾"; color: var(--muted); transition: transform .2s; }
.card:not([open]) > summary::after { transform: rotate(-90deg); }
.card p, .card ul, .card ol { margin: 0 0 12px; }
.card h4 { margin: 0 0 6px; font-size: 14px; }
.card ul { padding-left: 18px; }
.steps { padding-left: 0; list-style: none; counter-reset: s; }
.steps li {
  padding: 8px 10px; border-radius: 9px; margin-bottom: 4px; cursor: pointer;
  border: 1px solid transparent; color: var(--text-2);
}
.steps li b { display: block; color: var(--text); font-size: 12.5px; margin-bottom: 2px; }
.steps li:hover { background: var(--surface-2); }
.steps li.active { background: color-mix(in srgb, var(--mode-color) 16%, var(--surface)); border-color: var(--mode-color); color: var(--text); }
.reads { list-style: none; padding: 0 !important; }
.reads li { margin-bottom: 8px; padding: 8px 10px; border-radius: 9px; background: var(--surface-2); }
.reads .if { color: var(--warn); font-weight: 600; display: block; }
.reads .then { display: block; padding-left: 18px; position: relative; margin-top: 3px; }
.reads .then::before { content: "↳"; position: absolute; left: 2px; color: var(--ok); font-weight: 700; }
.keys li::marker { color: var(--ok); content: "✔ "; }
.errors li::marker { color: var(--def); content: "✖ "; }
textarea {
  width: 100%; resize: vertical; padding: 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-2); line-height: 1.45;
}
.saved { display: block; color: var(--muted); margin: 6px 0 12px; font-size: 11px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); opacity: 0;
  background: #0f1720; border: 1px solid var(--border); padding: 10px 16px; border-radius: 10px;
  box-shadow: var(--shadow); transition: .25s; pointer-events: none; z-index: 60; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- SVG cancha ---------- */
.court-line { fill: none; stroke: rgba(255, 255, 255, .92); stroke-width: .05; }
.court-line.dash { stroke-dasharray: .25 .2; }
.paint { fill: rgba(47, 90, 160, .30); }
.paint-def { fill: rgba(160, 47, 60, .26); }
.rim { fill: none; stroke: var(--accent); stroke-width: .06; }
.board { stroke: #fff; stroke-width: .1; }
.apron { fill: #0d1218; }

.act { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.act-o { stroke: #ffffff; stroke-width: .085; }
.act-d { stroke: var(--def-2); stroke-width: .06; opacity: .85; }
body[data-mode="defense"] .act-d { stroke-width: .085; opacity: 1; }
body[data-mode="defense"] .act-o { opacity: .8; }
.act-pass { stroke-dasharray: .32 .22; }
.act-shot { stroke: var(--accent-2); stroke-width: .07; stroke-dasharray: .04 .2; }
.act.preview { opacity: .35; }
.head-o { fill: #ffffff; }
.head-d { fill: var(--def-2); }
.head-shot { fill: var(--accent-2); }

.tok { cursor: default; }
.court-wrap.tele.tool-move .tok { cursor: grab; }
.court-wrap.tele.tool-move .tok.dragging { cursor: grabbing; }
.tok-o circle.body { fill: var(--off); stroke: #d7e8ff; stroke-width: .07; }
.tok-d path.body { fill: var(--def); stroke: #ffd6da; stroke-width: .06; }
.tok text { fill: #fff; font: 800 .52px var(--font); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.tok-d text { font-size: .36px; }
.tok .holder-ring { fill: none; stroke: var(--accent); stroke-width: .09; stroke-dasharray: .25 .12; }
.ball circle { fill: var(--accent); stroke: #5a2b05; stroke-width: .035; }
.ball path { fill: none; stroke: #5a2b05; stroke-width: .03; }
.ball.scored circle { filter: drop-shadow(0 0 .25px #ffcf8a); }

.draw-shape { cursor: pointer; }
.draw-zone { stroke-width: .06; stroke-dasharray: .2 .15; }

/* ---------- Responsive: tablets y móviles ---------- */
/* Evita cualquier desbordamiento horizontal: los hijos de grid pueden encogerse */
.layout > *, .stage > *, .topbar > *, .filters > * { min-width: 0; }

/* Portátil pequeño */
@media (max-width: 1360px) {
  .layout { grid-template-columns: 260px minmax(0, 1fr) 330px; }
}

/* Tablet horizontal (iPad 1180/1024) — ficha bajo la cancha, controles fijos abajo */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 260px minmax(0, 1fr); gap: 12px; padding: 12px; }
  .playlist { top: 118px; max-height: calc(100dvh - 130px); }
  #court { max-height: calc(100dvh - 250px); }
  .panel { grid-column: 1 / -1; position: static; max-height: none; overflow: visible; }
  #panelBody { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; align-items: start; }
  .meta-row { grid-column: 1 / -1; }
  .search { width: 220px; }
  .mode-btn { padding: 6px 12px; }
  .controls {
    position: sticky; bottom: 0; z-index: 20;
    margin: 0 -2px; padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    background: rgba(11, 15, 20, .94); backdrop-filter: blur(8px);
    border-top: 1px solid var(--border); border-radius: 12px 12px 0 0;
  }
}

/* Tablet vertical y móviles grandes — una columna, lista como cajón lateral */
@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr auto; gap: 8px; padding: 8px 12px;
    padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right));
  }
  .topbar { position: static; } /* en móvil la cabecera se desplaza: más espacio para la cancha */
  .stage { scroll-margin-top: 8px; }
  .mode-switch { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; }
  .mode-btn { flex: 1; align-items: center; padding: 6px 8px; }
  .top-actions { grid-column: 1 / -1; grid-row: 3; }
  .search { flex: 1; width: auto; height: 42px; }
  .search input { font-size: 16px; } /* evita el zoom automático de iOS */
  .only-mobile { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
  #btnDrawer { width: auto; padding: 0 12px; height: 40px; font-size: 16px; }
  .lbl-m { display: inline; font-size: 13px; font-weight: 600; }
  .filters { flex-direction: column; align-items: stretch; gap: 8px; padding: 8px 12px; }
  .chips { margin: 0 -12px; padding: 0 12px 2px; scroll-snap-type: x proximity; }
  .chip { scroll-snap-align: start; padding: 8px 13px; }
  .filter-extra select { flex: 1; height: 40px; font-size: 16px; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 10px 12px 0; }
  .playlist {
    position: fixed; z-index: 50; top: 0; left: 0; bottom: 0; width: min(88vw, 360px);
    max-height: none; border-radius: 0 var(--radius) var(--radius) 0;
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
    transform: translateX(-105%); transition: transform .25s ease;
  }
  .playlist.open { transform: none; box-shadow: var(--shadow); }
  .play-item { padding: 11px 9px; }
  .drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .55); }
  #court { max-height: calc(100dvh - 210px); min-height: 0; }
  .play-title h1 { font-size: 17px; }
  .phase-badge { font-size: 11px; left: 8px; top: 8px; padding: 4px 8px; }
  .phase-text { font-size: 14px; }
  .controls { justify-content: center; }
  .ctrl { min-width: 46px; height: 44px; }
  .seg-btn { height: 42px; }
  .tool { height: 40px; }
  .swatch { width: 30px; height: 30px; }
  .panel { padding-bottom: 16px; }
  .toast { bottom: calc(86px + env(safe-area-inset-bottom)); }
}

/* Móviles */
@media (max-width: 600px) {
  body { font-size: 14px; }
  .brand-text small { display: none; }
  .brand-logo { width: 28px; height: 28px; }
  .btn.ghost { padding: 0 11px; height: 42px; }
  .lbl { display: none; }
  .mode-btn .mode-sub { display: none; }
  .mode-btn .mode-title { font-size: 12.5px; }
  .layout { padding: 8px 8px 0; gap: 8px; }
  .court-wrap { border-radius: 10px; margin: 0 -4px; }
  #court { max-height: calc(100dvh - 150px); }
  .stage-head { padding: 0 2px; }
  .play-vs { font-size: 12.5px; }
  .phase-text { padding: 9px 11px; font-size: 13.5px; min-height: 0; }
  /* barra de control compacta fija abajo: navegación + velocidad/vista en dos filas */
  .controls { flex-direction: column; align-items: stretch; gap: 6px; margin: 0 -8px; border-radius: 14px 14px 0 0; }
  .ctrl-group { justify-content: center; flex-wrap: nowrap; gap: 5px; }
  .ctrl-group:first-child .ctrl { flex: 1; }
  .ctrl-group:last-child { justify-content: space-between; }
  .seg-btn { padding: 0 9px; font-size: 12px; }
  .ctrl.wide { min-width: 44px; padding: 0 10px; }
  .stepper { margin: 0 -8px; padding: 0 8px; scroll-snap-type: x mandatory; }
  .step { flex: 0 0 72%; scroll-snap-align: center; }
  .tele-bar { margin: 0 -4px; }
  .tools { gap: 4px; }
  .tool { padding: 0 9px; font-size: 12px; }
  .legend { font-size: 11px; gap: 4px 10px; }
  .legend svg { width: 34px; }
  #panelBody { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 0 12px; }
}

/* Móvil muy estrecho (320-360 px) */
@media (max-width: 360px) {
  .seg-btn { padding: 0 6px; font-size: 11px; }
  .ctrl { min-width: 40px; }
  .mode-btn .mode-title { font-size: 11.5px; letter-spacing: .3px; }
}

/* Móvil en horizontal (pantalla baja): prioridad absoluta a la cancha */
@media (max-height: 520px) and (orientation: landscape) {
  .topbar, .filters { position: static; }
  .topbar { grid-template-columns: auto 1fr auto; }
  .mode-switch { grid-column: auto; grid-row: auto; }
  .top-actions { grid-column: auto; grid-row: auto; }
  .mode-btn .mode-sub, .lbl, .brand-text { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .playlist {
    position: fixed; z-index: 50; top: 0; left: 0; bottom: 0; width: min(70vw, 360px); max-height: none;
    transform: translateX(-105%); transition: transform .25s ease;
  }
  .playlist.open { transform: none; }
  .only-mobile { display: inline-flex; }
  .drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .55); }
  #court { max-height: calc(100dvh - 155px); }
  .filters, .play-vs, .phase-badge { display: none; } /* la cancha primero; filtra con el buscador o el cajón */
  .stage-head { margin-top: -2px; }
  .play-title h1 { font-size: 15px; }
  .layout { padding-top: 6px; }
  .legend { display: none; }
}

/* Dispositivos táctiles: objetivos de toque más grandes y sin hover pegajoso */
@media (hover: none) and (pointer: coarse) {
  .play-item:hover, .steps li:hover { background: transparent; }
  .play-item.active { background: var(--surface-2); }
  .steps li { padding: 10px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
@media print {
  .topbar, .filters, .playlist, .controls, .tele-bar, .stepper { display: none !important; }
  .layout { grid-template-columns: 1fr; }
  .panel { position: static; max-height: none; }
  body { background: #fff; color: #000; }
}

/* Tendencias 2021-2026 */
.pi-new {
  font-size: 9.5px; font-weight: 700; padding: 1px 5px; border-radius: 6px; white-space: nowrap;
  color: #1b0f02; background: linear-gradient(135deg, var(--accent-2), var(--accent));
}
.card-trend { border-color: rgba(242, 140, 40, .45); background: linear-gradient(160deg, rgba(242, 140, 40, .10), var(--surface) 60%); }
.chip[data-rival="__modern"]:not(.active) { color: var(--accent-2); border-color: rgba(242, 140, 40, .45); }
