/* «Pong Score» de pwnzor.ak en FontStruct (CC0): los dígitos del marcador del Pong de Atari.
   Cada dígito mide 1em de alto y 0.5em de ancho, y deja 0.5em libres a su derecha. */
@font-face { font-family: 'Pong Score'; src: url('fonts/pong-score.otf') format('opentype'); font-display: block; }
/* Arimo: libre y con las mismas medidas que Helvetica; se usa donde Helvetica no está instalada. */
@font-face { font-family: 'Arimo'; font-weight: 400; src: local('Arimo'), url('fonts/arimo-latin-400-normal.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Arimo'; font-weight: 700; src: local('Arimo Bold'), url('fonts/arimo-latin-700-normal.woff2') format('woff2'); font-display: swap; }

:root {
  --bg: #07080b;
  --panel: #0f1218;
  --panel-2: #151a22;
  --line: #242b37;
  --text: #ece8dc;
  --muted: #8b919c;
  --left: #3be3c2;
  --right: #ff5d8f;
  --accent: #ffd23f;
  --danger: #ff6b5b;
  --sans: 'Helvetica Neue', Helvetica, Arimo, Arial, sans-serif;
  --score: 'Pong Score', var(--sans);
  --r: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #12161f 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  min-height: 100vh;
}
button, input { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-gap.end { justify-content: flex-end; }

.scanlines {
  pointer-events: none; position: fixed; inset: 0; z-index: 50;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,0.025) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

/* ---------- barra superior ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--sans); font-size: 14px; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: .5px; }
.brand span, .logo span { color: var(--accent); }
.topbar-right { display: flex; gap: 12px; align-items: center; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer;
}
.icon-btn.off { color: var(--muted); text-decoration: line-through; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.conn.ok i { background: var(--left); box-shadow: 0 0 8px var(--left); }
.conn.off i { background: var(--danger); }

main { max-width: 1240px; margin: 0 auto; padding: 24px 16px 48px; }

/* ---------- tarjetas y controles comunes ---------- */
.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--r); padding: 20px;
}
h3 { font-family: var(--sans); font-size: 12px; font-weight: 700; letter-spacing: 1.2px; margin: 0 0 12px; text-transform: uppercase; }
h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin: 18px 0 8px; font-weight: 500; }
.kicker { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }

.btn {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px;
  padding: 10px 16px; cursor: pointer; font-weight: 500; transition: transform .08s, border-color .15s, background .15s;
}
.btn:hover { border-color: #3a4352; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #17140a; border-color: var(--accent); font-weight: 700; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.wide { width: 100%; margin-top: 8px; padding: 14px; }

input {
  background: #0a0c10; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; outline: none; width: 100%;
}
input:focus { border-color: var(--accent); }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; letter-spacing: .5px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #0a0c10; }
.seg button { border: 0; background: transparent; padding: 8px 14px; cursor: pointer; font-size: 13px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--text); color: var(--bg); font-weight: 700; }
.seg button:disabled { cursor: default; }

/* ---------- inicio ---------- */
.hero { text-align: center; padding: 28px 0 32px; }
.logo { font-family: var(--sans); font-weight: 700; font-size: clamp(72px, 17vw, 160px); line-height: .9; margin: 0; letter-spacing: -0.04em; }
.logo small { display: block; font-size: clamp(13px, 2.4vw, 20px); font-weight: 700; letter-spacing: .32em; color: var(--accent); margin-bottom: 14px; text-transform: uppercase; line-height: 1.2; }
.tagline { color: var(--muted); margin: 18px 0 0; }
.tagline em { color: var(--accent); font-style: normal; }
.demo-court { position: relative; height: 80px; max-width: 420px; margin: 28px auto 0; border-top: 2px solid var(--line); border-bottom: 2px solid var(--line); }
.demo-court .pl, .demo-court .pr { position: absolute; width: 6px; height: 28px; top: 26px; animation: pad 2.4s ease-in-out infinite; }
.demo-court .pl { left: 8px; background: #fff; }
.demo-court .pr { right: 8px; background: #fff; animation-delay: -1.2s; }
.demo-court .ball { position: absolute; width: 8px; height: 8px; background: var(--text); top: 36px; left: 14px; animation: ball 2.4s linear infinite; }
@keyframes pad { 0%,100% { transform: translateY(-18px); } 50% { transform: translateY(18px); } }
@keyframes ball {
  0% { left: 14px; top: 18px; } 25% { top: 64px; } 50% { left: calc(100% - 22px); top: 30px; } 75% { top: 66px; } 100% { left: 14px; top: 18px; }
}
.home-card { max-width: 860px; margin: 0 auto; }
.home-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.home-col { border: 1px dashed var(--line); border-radius: var(--r); padding: 16px; }
.home-col p { margin: 0 0 12px; font-size: 13px; }
.join-row { display: flex; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: 6px; font-weight: 700; font-size: 16px; text-align: center; }

/* 1 vs 1 rápido */
.quick h3 { margin-bottom: 10px; }
.quick-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quick-btn {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: left; cursor: pointer;
  padding: 16px 18px; border-radius: var(--r); border: 1px solid var(--line); background: #0b0e13; transition: border-color .15s, transform .08s;
}
.quick-btn b { font-size: 17px; line-height: 1.3; }
.quick-btn span { font-size: 13px; color: var(--muted); }
.quick-btn:hover { border-color: var(--accent); }
.quick-btn:active { transform: translateY(1px); }
#btn-quick-human b { color: var(--left); }
#btn-quick-bot b { color: var(--right); }
.divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 16px; color: var(--muted); font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.search-card { text-align: center; }
.search-court { position: relative; height: 60px; margin: 18px auto 4px; max-width: 260px; border-top: 2px solid var(--line); border-bottom: 2px solid var(--line); }
.search-court .pl, .search-court .pr { position: absolute; width: 5px; height: 20px; top: 20px; animation: pad 2.4s ease-in-out infinite; }
.search-court .pl { left: 6px; background: #fff; }
.search-court .pr { right: 6px; background: #fff; animation-delay: -1.2s; }
.search-court .ball { position: absolute; width: 6px; height: 6px; background: var(--text); top: 26px; animation: ball 2.4s linear infinite; }
.search-time { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); margin: 10px 0; }
.search-actions { justify-content: center; margin-top: 14px; }
.overlay .row-gap { justify-content: center; }

/* ---------- sala ---------- */
.lobby-grid { display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 16px; align-items: start; }
.room-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; }
.room-code { font-size: 40px; font-weight: 700; letter-spacing: 6px; line-height: 1.1; color: var(--accent); margin-top: 6px; }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.list-head h3 { margin: 0; }
.player-list { list-style: none; padding: 0; margin: 12px 0 16px; }
.player-list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: #0b0e13; }
.player-list li .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-list li .tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.player-list li .tag.host { color: var(--accent); border-color: rgba(255,210,63,.4); }
.player-list li .tag.me { color: var(--left); border-color: rgba(59,227,194,.4); }
.player-list li .x { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 4px; }
.player-list li .x:hover { color: var(--text); }
.player-list .team-label { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin: 12px 0 6px; padding: 0; border: 0; background: none; }
.format-info { border-left: 3px solid var(--accent); padding: 10px 12px; background: rgba(255,210,63,.06); border-radius: 0 8px 8px 0; font-size: 13px; margin: 4px 0 12px; }
.format-info b { color: var(--accent); }

/* ---------- controles ---------- */
.controls .ctl-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.controls .ctl-head h3 { margin: 0; }
#controls-slot-game .controls { margin-top: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.voice-box { margin-top: 10px; }
.voice-meter { display: flex; align-items: center; gap: 10px; }
.voice-meter .lbl { font-size: 11px; color: var(--muted); }
.voice-meter .track { flex: 1; height: 10px; border-radius: 6px; background: linear-gradient(90deg, #1a2130, #2b2131); position: relative; border: 1px solid var(--line); }
.voice-meter .track i { position: absolute; top: -5px; width: 6px; height: 18px; background: var(--accent); border-radius: 2px; left: 50%; transform: translateX(-3px); transition: left .05s linear, opacity .2s; box-shadow: 0 0 10px var(--accent); }
.voice-meter .track i.idle { opacity: .25; box-shadow: none; }
.voice-row { display: flex; justify-content: space-between; align-items: baseline; margin: 8px 0 10px; }
.voice-note { font-size: 14px; font-weight: 700; }

/* ---------- juego ---------- */
.game-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.scorebar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-bottom: 10px; }
.team { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-left { color: var(--left); }
.t-right { color: var(--right); text-align: right; }
.sb-mid { font-family: var(--score); font-size: 34px; line-height: 1; display: flex; gap: 34px; font-weight: normal; }
.sb-mid b, .overlay .score b { font-weight: normal; margin-right: -0.5em; } /* quita el espacio libre tras el último dígito */
.court-wrap { position: relative; border: 2px solid #2a3140; border-radius: 6px; overflow: hidden; background: #050608; box-shadow: 0 0 0 1px #000, 0 20px 60px rgba(0,0,0,.5); touch-action: none; }
#cv { display: block; width: 100%; aspect-ratio: 16 / 10; cursor: default; }
.court-wrap.mouse #cv { cursor: none; }
.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(5,6,8,.72); text-align: center; padding: 20px; backdrop-filter: blur(2px);
}
.overlay .big { font-weight: 700; font-size: clamp(24px, 4vw, 40px); line-height: 1.15; letter-spacing: -0.01em; }
.overlay .score { font-family: var(--score); font-size: clamp(34px, 6vw, 60px); line-height: 1; display: flex; gap: 1em; margin: 6px 0; }
.overlay .win { color: var(--accent); }
.overlay .lose { color: var(--danger); }
.under-court { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; font-size: 13px; }
#you-label { margin-left: auto; }

/* ---------- pantalla completa ---------- */
.stage { position: relative; }
.fs-exit { display: none; }
.stage.is-fs { background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; }
.stage.pseudo-fs { position: fixed; inset: 0; z-index: 80; }
.stage.is-fs .scorebar, .stage.is-fs .court-wrap { width: min(100%, calc((100vh - 120px) * 1.6)); }
.stage.is-fs .court-wrap { border-color: #1b1f27; box-shadow: none; }
.stage.is-fs .sb-mid { font-size: clamp(34px, 5vh, 56px); }
.stage.is-fs .team { font-size: 18px; }
.stage.is-fs .fs-exit {
  display: block; position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(15,18,24,.8); color: var(--text); cursor: pointer; font-size: 16px; z-index: 2;
}
#you-label.l { color: var(--left); }
#you-label.r { color: var(--right); }

.side h3 { margin: 0; }
.side-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.live-list { list-style: none; padding: 0; margin: 0; }
.live-list li { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; background: #0b0e13; font-size: 13px; }
.live-list li.viewing { border-color: var(--accent); }
.live-list li.mine { box-shadow: inset 3px 0 0 var(--left); }
.live-list .names { overflow: hidden; }
.live-list .names div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-list .names .w { color: var(--accent); }
.live-list .sc { font-family: var(--score); font-size: 13px; text-align: right; line-height: 1.45; margin-right: -0.5em; }
.live-list .st { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted); }
.live-list .st .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); margin-right: 6px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.live-list button { border: 1px solid var(--line); background: none; border-radius: 6px; padding: 2px 8px; cursor: pointer; font-size: 11px; }
.table { width: 100%; border-collapse: collapse; font-size: 12px; }
.table th, .table td { padding: 5px 4px; text-align: center; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 500; }
.table .l { text-align: left; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table tr.me td { color: var(--left); }
.table tr:first-child td:first-child { color: var(--accent); }
.results { list-style: none; padding: 0; margin: 8px 0 0; font-size: 12px; max-height: 180px; overflow: auto; }
.results li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
details summary { cursor: pointer; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; margin-top: 16px; }
.side-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.champion { margin-top: 14px; padding: 14px; border: 1px solid var(--accent); border-radius: 8px; text-align: center; background: rgba(255,210,63,.07); }
.champion .big { font-size: 20px; font-weight: 700; line-height: 1.4; color: var(--accent); }

/* ---------- 1 vs 1 local ---------- */
.local-player { margin: 16px 0; padding: 14px 14px 12px; border: 1px solid var(--line); border-radius: 8px; background: #0b0e13; }
.local-player.l { box-shadow: inset 3px 0 0 var(--left); }
.local-player.r { box-shadow: inset 3px 0 0 var(--right); }
.local-player .field { margin-bottom: 10px; }
.local-player.l .field > span { color: var(--left); }
.local-player.r .field > span { color: var(--right); }
#lp1-voice-slot .voice-box { margin-top: 12px; }
.field em { font-style: normal; font-size: 11px; }
.overlay .btn { margin-top: 6px; }

/* ---------- liga local ---------- */
.offline-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; max-width: 980px; margin: 0 auto; }
.ol-players { list-style: none; padding: 0; margin: 8px 0 14px; counter-reset: ol; }
.ol-players li { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; counter-increment: ol; }
.ol-players li::before { content: counter(ol); width: 22px; text-align: right; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.ol-players .x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; }
.ol-players .x:hover { color: var(--text); }
.ol-players .x:disabled { opacity: .3; cursor: default; }
.resume { border: 1px solid var(--accent); border-radius: 8px; padding: 12px 14px; margin: 12px 0; background: rgba(255,210,63,.06); font-size: 14px; }
.resume .row-gap { margin-top: 8px; }
.ll-progress { margin: 6px 0 0; font-size: 13px; color: var(--accent); font-weight: 700; }
.lp-fixed { display: none; font-size: 17px; }
#local-side.league-mode .lp-input, #local-side.league-mode .lp-cpu { display: none; }
#local-side.league-mode .lp-fixed { display: block; }
.local-player.l .lp-fixed { color: var(--left); }
.local-player.r .lp-fixed { color: var(--right); }
.overlay .matchup { font-size: clamp(18px, 3vw, 28px); font-weight: 700; line-height: 1.3; }
.overlay .matchup .vs { color: var(--muted); font-weight: 400; margin: 0 .4em; }
.overlay .sides { font-size: 13px; color: var(--muted); }
.overlay .final-table { margin-top: 6px; font-size: 13px; border-collapse: collapse; min-width: min(360px, 90%); }
.overlay .final-table td { padding: 3px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.overlay .final-table td.l { text-align: left; }

/* ---------- modal / toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.modal-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); padding: 24px; width: min(440px, 100%); }
.calib-step { min-height: 3em; }
.calib-live { font-size: 24px; font-weight: 700; text-align: center; padding: 18px 0; color: var(--accent); }
.progress { height: 6px; background: #0a0c10; border-radius: 4px; overflow: hidden; border: 1px solid var(--line); }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; z-index: 60; transition: .2s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: var(--danger); }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .lobby-grid { grid-template-columns: 1fr 1fr; }
  .home-actions { grid-template-columns: 1fr 1fr; }
  #controls-slot-lobby { grid-column: 1 / -1; }
  .game-grid { grid-template-columns: 1fr; }
  .offline-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  main { padding: 16px 16px 40px; }
  .brand { font-size: 12px; }
  .quick-btns { grid-template-columns: 1fr; }
  .lobby-grid, .home-actions, .offline-grid { grid-template-columns: 1fr; }
  .room-code { font-size: 32px; }
  .sb-mid { font-size: 26px; gap: 26px; }
  .fs-btn { width: 100%; }
  .team { font-size: 13px; }
}
