:root {
  --A: #1e88e5; --B: #e53935; --acento: #c8f13a;
  --fondo: #080b10; --panel: #111820; --panel2: #18212b; --linea: #243140; --texto: #e9eef3; --tenue: #7c8d9e;
  --peligro: #ff5c5c;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fondo); color: var(--texto); font-family: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif; font-size: 18px; }
body { min-height: 100vh; min-height: 100dvh; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; }
.oculto { display: none !important; }

.contenedor { max-width: 560px; margin: 0 auto; padding: 16px; }
.logo { display: flex; align-items: center; gap: 12px; margin: 8px 0 18px; }
.logo .bola { width: 34px; height: 34px; border-radius: 50%; background: var(--acento); box-shadow: 0 0 18px rgba(200,241,58,.45); flex: 0 0 auto; }
.logo h1 { margin: 0; font-size: 28px; letter-spacing: .5px; text-transform: uppercase; line-height: 1; }
.logo small { display: block; font-size: 15px; color: var(--tenue); letter-spacing: .3px; text-transform: none; margin-top: 3px; }

fieldset { border: 1px solid var(--linea); border-radius: 14px; padding: 14px; margin: 0 0 14px; background: var(--panel); min-width: 0; }
input[type=file] { max-width: 100%; color: var(--tenue); }
.segmento button { min-width: 0; }
legend { padding: 0 6px; color: var(--acento); text-transform: uppercase; letter-spacing: 1px; font-weight: 700; font-size: 15px; }
label.campo { display: block; color: var(--tenue); font-size: 15px; margin: 0 0 6px; }
.grupo { margin-bottom: 14px; }
.grupo:last-child { margin-bottom: 0; }
.ayuda { color: var(--tenue); font-size: 14px; margin: 8px 0 0; line-height: 1.3; }
input[type=text], input[type=password], input[type=tel] { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--linea); background: var(--panel2); color: var(--texto); font-size: 19px; }
input:focus { outline: 2px solid var(--acento); outline-offset: -1px; }
input[type=color] { width: 52px; height: 48px; padding: 2px; border-radius: 10px; border: 1px solid var(--linea); background: var(--panel2); flex: 0 0 auto; }
.fila { display: flex; gap: 8px; align-items: center; }
.pareja { display: grid; grid-template-columns: 6px 1fr; gap: 12px; margin-bottom: 12px; }
.pareja:last-child { margin-bottom: 0; }
.pareja .barra { border-radius: 4px; }
.pareja input + input { margin-top: 8px; }

.segmento { display: flex; background: var(--panel2); border: 1px solid var(--linea); border-radius: 10px; padding: 3px; gap: 3px; }
.segmento button { flex: 1; border: 0; background: transparent; padding: 10px 4px; border-radius: 8px; font-size: 17px; font-weight: 600; color: var(--tenue); }
.segmento button.on { background: var(--acento); color: #0b0f14; }

.elegir { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.elegir button { padding: 14px 8px; border-radius: 10px; border: 1px solid var(--linea); background: var(--panel2); font-size: 18px; font-weight: 700; text-align: left; display: flex; align-items: center; gap: 8px; min-width: 0; }
.elegir button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.elegir button i { width: 10px; height: 26px; border-radius: 3px; flex: 0 0 auto; }
.elegir button.on { border-color: var(--acento); box-shadow: inset 0 0 0 1px var(--acento); }

.btn-grande { width: 100%; padding: 16px; border: 0; border-radius: 14px; background: var(--acento); color: #0b0f14; font-size: 22px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }
.btn-grande:disabled { opacity: .4; }
.btn-sec { width: 100%; padding: 13px; border-radius: 12px; border: 1px solid var(--linea); background: transparent; font-size: 18px; margin-top: 10px; }
.btn-chico { padding: 8px 12px; border-radius: 9px; border: 1px solid var(--linea); background: var(--panel2); font-size: 16px; }
.btn-chico.peligro, .opcion.peligro { color: var(--peligro); }

.velo { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.hoja { width: 100%; max-width: 560px; background: var(--panel); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 90vh; overflow: auto; }
.hoja h2 { margin: 0 0 12px; font-size: 24px; text-transform: uppercase; letter-spacing: .5px; }
.opcion { display: block; width: 100%; text-align: left; padding: 14px; margin-bottom: 8px; border-radius: 12px; border: 1px solid var(--linea); background: var(--panel2); font-size: 19px; font-weight: 600; }
.opcion small { display: block; color: var(--tenue); font-size: 14px; font-weight: 400; }

.link { display: flex; gap: 8px; margin-bottom: 12px; }
.link input { font-size: 14px !important; }

.toast { position: fixed; left: 50%; top: 46%; transform: translateX(-50%); background: #fff; color: #111; padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 50; max-width: 90vw; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
/* Pestañas de los paneles */
.pestanas { display: flex; gap: 6px; overflow-x: auto; margin: 0 0 14px; padding-bottom: 2px; }
.pestanas button { flex: 0 0 auto; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--linea); background: var(--panel); font-size: 17px; font-weight: 700; color: var(--tenue); }
.pestanas button.on { background: var(--acento); color: #0b0f14; border-color: var(--acento); }

/* Interruptores sí/no */
.interruptor { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--linea); cursor: pointer; }
.interruptor:last-child { border-bottom: 0; }
.interruptor span { font-size: 18px; font-weight: 600; }
.interruptor small { display: block; color: var(--tenue); font-size: 14px; font-weight: 400; }
.interruptor input { appearance: none; -webkit-appearance: none; flex: 0 0 auto; width: 50px; height: 30px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--linea); position: relative; cursor: pointer; transition: background .15s; }
.interruptor input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--tenue); transition: transform .15s, background .15s; }
.interruptor input:checked { background: var(--acento); border-color: var(--acento); }
.interruptor input:checked::after { transform: translateX(20px); background: #0b0f14; }

/* Vista previa 16:9 de la TV (iframe escalado) */
.previa { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; border: 1px solid var(--linea); background: #000; }
.previa iframe { position: absolute; top: 0; left: 0; width: 1920px; height: 1080px; border: 0; transform-origin: 0 0; pointer-events: none; }

.aviso-caja { border: 1px solid var(--linea); background: var(--panel); border-radius: 14px; padding: 16px; margin-bottom: 14px; line-height: 1.4; }
.aviso-caja.amarillo { border-color: #ffb020; }
.aviso-caja.rojo { border-color: var(--peligro); }
.aviso-caja h3 { margin: 0 0 6px; font-size: 22px; text-transform: uppercase; }
a { color: var(--acento); }

/* Estadísticas (control y stats.html) */
.est-cab { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.est-pareja { font-weight: 800; text-transform: uppercase; font-size: 16px; line-height: 1.15; border-bottom: 3px solid; padding-bottom: 4px; }
.est-pareja.B { text-align: right; }
.est-vs { color: var(--acento); font-weight: 800; text-transform: uppercase; font-size: 14px; letter-spacing: .5px; }
.est-fila { display: grid; grid-template-columns: 1fr 1.4fr 1fr; align-items: center; gap: 6px; padding: 7px 0 0; }
.est-val { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.est-val.B { text-align: right; }
.est-tit { text-align: center; color: var(--tenue); font-size: 14px; line-height: 1.1; }
.est-barras { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding-bottom: 7px; border-bottom: 1px solid var(--linea); }
.est-barras span { height: 5px; background: var(--panel2); border-radius: 3px; overflow: hidden; display: flex; }
.est-barras span:first-child { justify-content: flex-end; }
.est-barras i { display: block; height: 100%; border-radius: 3px; }

.error { color: var(--peligro); min-height: 1.2em; margin: 8px 0 0; }
