/* Dalí: papel arena, tinta y naranja de atardecer. Tokens y componentes del diseño. */
:root {
  --papel: #F3E7CF;
  --papel-claro: #FBF4E4;
  --papel-oscuro: #E8D6B0;
  --tinta: #221B14;
  --naranja: #F0642B;
  --naranja-pres: #E5551F;
  --cielo: #2F5BD3;
  --apagado: #5E5144;
  --error: #B3261E;
  --ok: #1C6B3E;
  --linea: rgba(34, 27, 20, 0.25);
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--papel); color: var(--tinta); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; }
button, input { font-family: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--cielo); outline-offset: 3px; }
a { color: var(--cielo); }

.app { max-width: 480px; min-height: 100dvh; margin: 0 auto; display: flex; flex-direction: column; position: relative; overflow-x: hidden; }
.pant { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.cuerpo { flex: 1; min-height: 0; padding: 0 24px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.pie { flex: none; padding: 14px 24px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.cab { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 20px 24px 0; }
.eyebrow { font-size: 13px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.etiqueta { font-size: 14px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.muted { color: var(--apagado); }
.chico { font-size: 14px; }
.centro { text-align: center; }

/* Titulares */
.t1 { margin: 0; font-family: var(--serif); font-style: italic; font-weight: 900; font-size: 40px; line-height: 1; letter-spacing: -1px; }
.t2 { margin: 0; font-family: var(--serif); font-style: italic; font-weight: 900; font-size: 32px; line-height: 1; letter-spacing: -0.5px; }
.num { font-family: var(--serif); font-weight: 900; line-height: 1; }

/* Botones */
.btn { height: 58px; width: 100%; border: 2.5px solid var(--tinta); border-radius: 18px; font-size: 19px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; }
.btn-p { background: var(--naranja); color: var(--tinta); box-shadow: 0 4px 0 var(--tinta); }
.btn-p:active:not(:disabled) { background: var(--naranja-pres); transform: translateY(4px); box-shadow: none; }
.btn-s { background: transparent; color: var(--tinta); font-size: 18px; }
.btn-s:active:not(:disabled) { background: rgba(34, 27, 20, 0.08); }
.btn:disabled { background: rgba(34, 27, 20, 0.08); color: var(--apagado); border-color: rgba(34, 27, 20, 0.3); box-shadow: none; cursor: not-allowed; }
.btn-texto { height: 48px; border: 0; background: transparent; font-size: 16px; font-weight: 700; text-decoration: underline; color: var(--apagado); }
.btn-icono { width: 48px; height: 48px; flex: none; border: 2.5px solid var(--tinta); border-radius: 14px; background: transparent; display: flex; align-items: center; justify-content: center; }
.btn-icono:active { background: rgba(34, 27, 20, 0.08); }
.btn-icono[aria-pressed="true"] { background: var(--tinta); color: var(--papel); }
.btn-herr { width: 52px; height: 52px; flex: none; border: 2.5px solid var(--tinta); border-radius: 14px; background: var(--papel-claro); display: flex; align-items: center; justify-content: center; }
.btn-herr[aria-pressed="true"] { background: var(--tinta); color: var(--papel); }
.btn-herr:disabled { opacity: 0.4; }
.btn-back { width: 48px; height: 48px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; margin: 14px 0 0 12px; }
.btn-chico { height: 46px; padding: 0 22px; border: 2.5px solid var(--papel); border-radius: 14px; background: var(--naranja); color: var(--tinta); font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 8px; }

/* Campos */
.campo { width: 100%; height: 56px; border: 2.5px solid var(--tinta); border-radius: 14px; background: var(--papel-claro); padding: 0 56px 0 16px; font-size: 20px; font-weight: 700; }
.campo:focus { outline: none; box-shadow: 0 0 0 4px var(--naranja); }
.campo-grande { height: 72px; font-family: var(--serif); font-size: 32px; padding-right: 64px; }
.campo-wrap { position: relative; }
.campo-wrap .cuenta { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 14px; color: var(--apagado); pointer-events: none; }
.campo-int { height: 48px; border-radius: 12px; font-size: 18px; padding: 0 14px; }
.codigo { display: flex; gap: 10px; }
.codigo input { width: 100%; min-width: 0; height: 92px; text-align: center; border: 2.5px solid var(--tinta); border-radius: 16px; background: var(--papel-claro); font-family: var(--serif); font-size: 52px; font-weight: 900; padding: 0; text-transform: uppercase; }
.codigo input:focus { outline: none; box-shadow: 0 0 0 4px var(--naranja); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Selectores */
.tarjetas { display: flex; gap: 12px; }
.tarjeta { flex: 1; height: 104px; border: 2.5px solid var(--tinta); border-radius: 16px; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-size: 17px; font-weight: 800; }
.tarjeta[aria-pressed="true"] { background: var(--tinta); color: var(--papel); box-shadow: 0 4px 0 var(--naranja); }
.segmentado { display: flex; padding: 4px; border: 2.5px solid var(--tinta); border-radius: 16px; background: var(--papel-claro); }
.segmentado button { flex: 1; height: 44px; border: 0; border-radius: 11px; background: transparent; font-size: 16px; font-weight: 800; }
.segmentado button[aria-pressed="true"] { background: var(--tinta); color: var(--papel); }
.fila-metas { display: flex; gap: 8px; }
.fila-metas button { flex: 1; height: 52px; border: 2.5px solid var(--tinta); border-radius: 14px; background: transparent; font-family: var(--serif); font-size: 24px; font-weight: 900; }
.fila-metas button[aria-pressed="true"] { background: var(--tinta); color: var(--papel); }
.paso { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px 0; }
.paso .ctrl { display: flex; align-items: center; gap: 14px; }
.paso .n { min-width: 34px; text-align: center; font-size: 40px; }
.interruptor { flex: none; width: 60px; height: 34px; border: 2.5px solid var(--tinta); border-radius: 999px; background: transparent; position: relative; padding: 0; }
.interruptor::after { content: ''; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--tinta); transition: transform 0.12s; }
.interruptor[aria-checked="true"] { background: var(--naranja); }
.interruptor[aria-checked="true"]::after { transform: translateX(26px); }
.interruptor:disabled { border-color: rgba(34, 27, 20, 0.3); }
.interruptor:disabled::after { background: rgba(34, 27, 20, 0.3); }

/* Piezas */
.pill { padding: 6px 12px; border: 2px solid var(--tinta); border-radius: 999px; background: var(--papel-claro); font-size: 14px; font-weight: 700; }
.pill-sala { font-size: 13px; font-weight: 800; letter-spacing: 0.14em; }
.pill-tinta { padding: 7px 14px; background: var(--tinta); color: var(--papel); border-radius: 999px; font-size: 14px; font-weight: 700; }
.chip { flex: none; width: var(--t, 40px); height: var(--t, 40px); border-radius: 50%; background: var(--bg); color: var(--fg); border: 2.5px solid var(--tinta); display: inline-flex; align-items: center; justify-content: center; font-size: calc(var(--t, 40px) * 0.45); font-weight: 800; }
.fila-jug { min-height: 52px; display: flex; align-items: center; gap: 12px; }
.fila-jug .nombre { flex: 1; min-width: 0; font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ok { color: var(--ok); font-weight: 700; display: flex; align-items: center; gap: 6px; font-size: 15px; }
.espera { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--apagado); }
.puntos { display: inline-flex; gap: 3px; }
.puntos i { width: 6px; height: 6px; border-radius: 50%; background: var(--naranja); animation: latido 1.2s infinite; }
.puntos i:nth-child(2) { animation-delay: 0.2s; }
.puntos i:nth-child(3) { animation-delay: 0.4s; }
@keyframes latido { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
.tarjeta-oscura { border-radius: 22px; background: var(--tinta); color: var(--papel); padding: 18px 20px; box-shadow: 0 5px 0 var(--naranja); }
.caja { padding: 14px 16px; border: 2px solid var(--tinta); border-radius: 16px; background: var(--papel-claro); }
.caja-rayas { padding: 16px 18px; border: 2px dashed var(--tinta); border-radius: 18px; }
.pasos { display: flex; flex-direction: column; gap: 12px; }
.pasos .p { display: flex; gap: 12px; align-items: flex-start; font-size: 17px; line-height: 1.35; }
.pasos .p b { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--tinta); color: var(--papel); font-size: 15px; display: flex; align-items: center; justify-content: center; }
.barras { display: flex; gap: 6px; }
.barras i { flex: 1; height: 8px; border-radius: 4px; background: rgba(34, 27, 20, 0.18); }
.barras i.on { background: var(--naranja); }
.delta { min-width: 62px; height: 40px; padding: 0 12px; border: 2.5px solid rgba(34, 27, 20, 0.3); border-radius: 12px; font-family: var(--serif); font-weight: 900; font-size: 24px; color: var(--apagado); display: flex; align-items: center; justify-content: center; }
.delta.mas { border-color: var(--tinta); background: var(--naranja); color: var(--tinta); }
.delta.menos { border-color: var(--error); color: var(--error); }

/* Dibujos */
.marco { border: 3px solid var(--tinta); border-radius: 20px; background: #FFFDF7; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 6px var(--c, var(--tinta)); margin: 6px; overflow: hidden; }
.marco svg, .marco canvas { display: block; width: 100%; height: 100%; }
.marco-papel { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; color: var(--apagado); font-weight: 700; text-align: center; padding: 12px; }
.marco-mini { width: 92px; height: 92px; flex: none; border-radius: 14px; border-width: 3px; box-shadow: 0 0 0 4px var(--c, var(--tinta)); margin: 4px; }
#lienzo { touch-action: none; cursor: crosshair; }
.tarjeta-int { display: flex; gap: 12px; align-items: stretch; }
.tarjeta-int .lado { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 6px; min-width: 0; }
.tarjeta-int .quien { font-size: 14px; font-weight: 800; }
.pendiente { display: flex; gap: 12px; align-items: center; min-height: 100px; padding-right: 12px; }
.pendiente .vacio { flex: none; width: 92px; height: 92px; margin: 4px; border: 2.5px dashed rgba(34, 27, 20, 0.45); border-radius: 14px; display: flex; align-items: center; justify-content: center; color: var(--apagado); }
.fila-interp { min-height: 44px; display: flex; align-items: center; gap: 10px; }
.fila-interp .quien { width: 66px; font-size: 15px; font-weight: 700; }
.fila-interp .texto { flex: 1; font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.fila-interp .texto.vacio { font-size: 16px; font-weight: 400; font-style: italic; color: var(--apagado); }
.fila-valid { min-height: 56px; display: flex; align-items: center; gap: 10px; }
.fila-valid .col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fila-valid .col small { font-size: 13px; font-weight: 700; color: var(--apagado); }
.fila-valid .col span { font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.fila-valid .col span.vacio { font-size: 16px; font-weight: 400; font-style: italic; color: var(--apagado); }

/* Tablas */
.tabla-cab { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--apagado); padding: 0 2px 6px; }
.fila-punt { min-height: 62px; display: flex; align-items: center; gap: 10px; border-top: 1.5px solid var(--linea); }
.fila-punt:first-of-type { border-top: 2px solid var(--tinta); }
.fila-punt .pos { width: 28px; font-size: 24px; }
.fila-punt .cen { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.fila-punt .cen b { font-size: 17px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila-punt .cen i { display: block; height: 8px; min-width: 4px; border-radius: 4px; background: var(--naranja); }
.fila-punt .esta { width: 62px; text-align: right; font-size: 17px; font-weight: 700; }
.fila-punt .tot { width: 44px; text-align: right; font-size: 28px; }
.podio { display: flex; align-items: flex-end; justify-content: center; gap: 10px; height: 196px; }
.podio .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.podio .nombre { font-size: 14px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podio .base { width: 100%; border: 2.5px solid var(--tinta); border-radius: 12px 12px 0 0; background: var(--papel-claro); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.podio .primero .base { background: var(--naranja); }
.tabla-fin .f { min-height: 44px; display: flex; align-items: center; gap: 8px; border-bottom: 1.5px solid var(--linea); }
.tabla-fin .r { width: 34px; text-align: right; font-size: 16px; }
.tabla-fin .t { width: 52px; text-align: right; font-size: 22px; }

/* Avisos */
.aviso { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border: 2.5px solid var(--tinta); border-radius: 18px; background: var(--papel-claro); }
.aviso .ico { flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--error); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; }
.aviso h2 { margin: 0 0 3px; font-family: var(--serif); font-weight: 900; font-size: 22px; line-height: 1.1; }
.aviso p { margin: 0; font-size: 15px; line-height: 1.35; color: var(--apagado); }
.error-inline { padding: 12px 14px; border: 2px solid var(--error); border-radius: 12px; color: var(--error); font-size: 15px; font-weight: 700; background: var(--papel-claro); }
#toasts { position: fixed; left: 0; right: 0; top: calc(12px + env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 10; padding: 0 16px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 999px; background: var(--tinta); color: var(--papel); font-size: 15px; font-weight: 700; box-shadow: 0 6px 18px rgba(34, 27, 20, 0.3); animation: entra 0.18s ease-out; }
.toast.error { background: var(--error); color: #fff; }
.toast .gira { width: 18px; height: 18px; border-radius: 50%; border: 3px solid rgba(243, 231, 207, 0.35); border-top-color: var(--naranja); animation: gira 0.8s linear infinite; }
@keyframes entra { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes gira { to { transform: rotate(360deg); } }

/* Inicio */
.inicio-logo { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 48px 28px 0; }
.inicio-logo h1 { margin: 6px 0 0; font-family: var(--serif); font-style: italic; font-weight: 900; font-size: 116px; line-height: 0.9; letter-spacing: -3px; }
.inicio-ilus { flex: 1; min-height: 0; display: flex; align-items: flex-end; }
.inicio-ilus svg { display: block; width: 100%; height: auto; max-height: 100%; }

.codigo-sala { border-radius: 22px; background: var(--tinta); color: var(--papel); padding: 18px 20px 20px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.codigo-sala .big { font-family: var(--serif); font-style: italic; font-weight: 900; font-size: 84px; line-height: 1; letter-spacing: 0.1em; padding-left: 0.1em; }

@media (prefers-reduced-motion: reduce) { .puntos i, .toast, .toast .gira { animation: none; } .interruptor::after { transition: none; } }
@media (max-height: 700px) {
  .t1 { font-size: 34px; }
  .inicio-logo { padding-top: 24px; }
  .inicio-logo h1 { font-size: 88px; }
  .btn { height: 52px; }
}

/* Dibujo ampliado */
.marco-btn { display: block; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 20px; }
.marco-btn:active .marco { transform: scale(0.97); }
.zoom { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: calc(16px + env(safe-area-inset-top)) 18px calc(16px + env(safe-area-inset-bottom)); background: rgba(34, 27, 20, 0.94); }
.zoom[hidden] { display: none; }
.zoom-cab { width: min(100%, 560px); display: flex; align-items: center; gap: 10px; color: var(--papel); }
.zoom-nombre { flex: 1; min-width: 0; font-family: var(--serif); font-style: italic; font-weight: 900; font-size: 26px; line-height: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-zoom { flex: none; width: 48px; height: 48px; border: 2.5px solid var(--papel); border-radius: 14px; background: transparent; color: var(--papel); display: flex; align-items: center; justify-content: center; }
.btn-zoom:active { background: rgba(243, 231, 207, 0.15); }
.zoom-marco { width: min(100%, 560px, calc(100dvh - 250px)); aspect-ratio: 1; border: 3px solid var(--tinta); border-radius: 20px; background: #FFFDF7; box-shadow: 0 0 0 6px var(--c, var(--papel)); overflow: hidden; margin: 6px; }
.zoom-marco svg { display: block; width: 100%; height: 100%; }
.zoom-pie { width: min(100%, 560px); display: flex; flex-direction: column; gap: 12px; }
.zoom-nav { display: flex; align-items: center; justify-content: center; gap: 18px; color: var(--papel); }
.zoom-cuenta { min-width: 70px; text-align: center; font-weight: 700; font-size: 16px; }
@media (max-height: 560px) { .zoom-marco { width: min(100%, calc(100dvh - 190px)); } }

.cat-propia { display: flex; flex-direction: column; gap: 10px; }
