@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;600;700&family=Barlow+Condensed:wght@600;700&display=swap');

:root {
  --bg: #0f1720; --panel: #1a2430; --panel2: #253240; --line: #334252; --border: #5a6b7d;
  --fg: #f2f5f8; --muted: #a9b6c4; --accent: #f5a524; --blue: #5cc8ff; --danger: #e5484d; --ok: #46c37b;
  --court-att: #1d5c8a; --court-att-area: #164868; --court-def: #7d3327; --court-def-area: #5e241b;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: 'Barlow', system-ui, sans-serif; font-size: 16px; }
body { padding-bottom: var(--foot, 32px); min-height: var(--app-h, 100vh); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
/* Las opciones de los desplegables nativos se pintan sobre fondo claro: texto oscuro siempre legible */
select option { color: #0f172a; background: #fff; font-weight: 600; }
button { cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
a { color: inherit; }
.cond { font-family: 'Barlow Condensed', 'Barlow', sans-serif; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
/* Pantallas de entrada: ocultas hasta que lang.js las traduce al idioma del navegador */
.i18n-pending .auth { visibility: hidden; }

/* Botones */
.btn { height: 44px; padding: 0 16px; border: 2px solid var(--border); border-radius: 10px; background: var(--panel2); color: var(--fg); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { border-color: transparent; background: var(--accent); color: var(--bg); font-weight: 700; }
.btn.light { border-color: transparent; background: var(--fg); color: var(--bg); font-weight: 700; }
.btn.blue { border-color: transparent; background: var(--blue); color: var(--bg); font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn.big { height: 60px; padding: 0 22px; border-radius: 12px; font-size: 18px; }
.btn.sm { height: 36px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; color: var(--muted); }
.input { height: 44px; padding: 0 12px; border: 2px solid var(--border); border-radius: 10px; background: var(--panel2); color: var(--fg); min-width: 0; width: 100%; }
.input:focus { outline: none; border-color: var(--blue); }
select.input { appearance: none; }
input[type=date].input, input[type=time].input { color-scheme: dark; }

/* Layout */
.panel { background: var(--panel); border-radius: 12px; padding: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.grow { flex-grow: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.page { max-width: none; margin: 0 auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 12px; }
.topbar { display: flex; align-items: center; gap: 16px; min-height: 60px; }
/* Invitación a instalar la app: hoja inferior en móvil, tarjeta centrada en pantallas grandes */
.instBg { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: flex-end; justify-content: center; background: rgba(5,9,14,.62); animation: instFade .25s ease-out; }
.instBg.out { opacity: 0; transition: opacity .22s ease-in; }
.instSheet { position: relative; width: min(520px, 100%); max-height: 92vh; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding: 22px 20px calc(18px + env(safe-area-inset-bottom)); background: linear-gradient(180deg, #1f2c3a 0%, var(--panel) 55%); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; box-shadow: 0 -12px 40px rgba(0,0,0,.55); animation: instUp .38s cubic-bezier(.2,.8,.2,1); }
.instBg.out .instSheet { transform: translateY(30px); transition: transform .22s ease-in; }
.instX { position: absolute; top: 10px; right: 10px; }
.instHead { display: flex; align-items: center; gap: 14px; padding-right: 36px; }
.instHead h2 { margin: 0; font-size: 22px; }
.instLogo { flex-shrink: 0; width: 72px; height: 72px; border-radius: 18px; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 40%, #24425f, #0f1720 75%); box-shadow: 0 0 0 1px rgba(92,200,255,.35), 0 0 24px rgba(92,200,255,.25); }
.instLogo img { width: 60px; height: 60px; object-fit: contain; }
.instBenefits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.instBenefits li { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.instIco { flex-shrink: 0; width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--accent); background: rgba(245,165,36,.12); }
.instHow { padding: 12px 14px; border-radius: 12px; background: var(--panel2); }
.instHowTitle { font-weight: 700; margin-bottom: 6px; }
.instSteps { margin: 0; padding-left: 22px; line-height: 1.55; }
.instSteps b { color: var(--fg); }
.instActions { display: flex; flex-direction: column; gap: 8px; }
.instActions .btn { width: 100%; }
@media (min-width: 700px) and (min-height: 560px) { .instBg { align-items: center; } .instSheet { border-radius: 22px; border-bottom: 1px solid var(--line); padding-bottom: 20px; } }
@keyframes instFade { from { opacity: 0; } }
@keyframes instUp { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { .instBg, .instSheet { animation: none; } }
.appmark { display: flex; width: 64px; height: 64px; flex-shrink: 0; }
@media (min-width: 1200px) { .appmark { width: 84px; height: 84px; } }
.appmark img { width: 100%; height: 100%; object-fit: contain; }
.homeIco { display: block; }
@media (max-height: 480px) and (orientation: landscape) { .appmark { width: 30px; height: 30px; margin-right: -2px; } }
@media (max-width: 700px) and (max-height: 480px) and (orientation: landscape) { .appmark { display: none; } }
.title { font-size: 20px; font-weight: 700; }
.subtitle { font-size: 14px; color: var(--muted); }

/* Logo del club */
.applogo { display: block; width: 96px; height: 96px; margin: 0 auto 6px; object-fit: contain; }
.logo { width: 56px; height: 56px; border-radius: 50%; background: var(--fg); color: var(--bg); display: flex; align-items: center; justify-content: center; font-family: 'Barlow Condensed', sans-serif; font-size: 22px; font-weight: 700; flex-shrink: 0; overflow: hidden; }
.logo img { width: 100%; height: 100%; object-fit: contain; }
/* Con imagen, sin fondo blanco: el logo del club se ve tal cual (transparencias incluidas) */
/* Fondo del escudo propio: azul suave con volumen (luz arriba a la izquierda, sombra abajo) y el escudo con sombra proyectada */
.logo:has(img) { background: radial-gradient(circle at 35% 28%, #74a6cc 0%, #4d86b2 55%, #2f6494 100%); box-shadow: inset 0 -5px 10px rgba(0,0,0,.28), inset 0 3px 6px rgba(255,255,255,.18), 0 3px 8px rgba(0,0,0,.35); }
.logo:has(img) img { width: 88%; height: 88%; filter: drop-shadow(0 4px 6px rgba(0,0,0,.55)); }
.logo.lg { width: 96px; height: 96px; font-size: 36px; }

/* Listas y tablas */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 12px; border: 2px solid var(--border); border-radius: 12px; background: var(--panel2); }
.item.clickable { cursor: pointer; }
.item.selected { border-color: var(--accent); }
.num { font-family: 'Barlow Condensed', sans-serif; font-size: 28px; font-weight: 700; width: 44px; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.t td { padding: 8px; border-bottom: 1px solid var(--panel2); }
table.t td.r, table.t th.r { text-align: right; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--panel2); color: var(--muted); }
.tag.ok { background: #16432b; color: #8ff0b4; }
.tag.warn { background: #4a3a10; color: #ffd27a; }
.tag.off { background: #4a1d1f; color: #ff9a9e; }
.tag.live { background: #0f3b57; color: #9fdcff; }

/* Mensajes */
.msg { padding: 10px 14px; border-radius: 10px; font-size: 15px; }
.msg.error { background: #4a1d1f; color: #ffb3b6; }
.msg.ok { background: #16432b; color: #b6f3cf; }
.msg.info { background: #1b3a52; color: #bfe6ff; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; padding: 20px; width: min(560px, 100%); max-height: calc(var(--app-h, 100vh) - 24px); overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal h2 { margin: 0; font-size: 20px; }

/* Acceso */
.auth { min-height: calc(var(--app-h, 100vh) - var(--foot, 32px)); display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth .panel { width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px; }
.auth h1 { margin: 0; font-size: 24px; }

/* Toast */
#toast { position: fixed; left: 50%; bottom: calc(var(--foot, 32px) + 12px); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 12px 18px; border-radius: 10px; font-weight: 600; z-index: 100; box-shadow: 0 4px 20px rgba(0,0,0,.4); }

/* Campo (medio campo 20×20 m) */
.court { position: relative; border-radius: 12px; overflow: hidden; background: var(--court-att); touch-action: none; }
.court.defense { background: var(--court-def); }
.court svg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.court .area { fill: var(--court-att-area); }
.court.defense .area { fill: var(--court-def-area); }
.court .lines { fill: none; stroke: var(--fg); stroke-width: .12; }
.court .nine { stroke-dasharray: .45 .45; }
.court .goal { fill: var(--fg); }

/* Fichas de jugador: escalan con el campo (--cs = ancho del campo / 470) */
.chip { user-select: none; -webkit-user-select: none; position: absolute; width: calc(66px * var(--cs, 1)); height: calc(92px * var(--cs, 1)); border: max(2px, calc(3px * var(--cs, 1))) solid var(--fg); border-radius: calc(12px * var(--cs, 1)); background: var(--fg); color: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; line-height: 1.15; touch-action: none; }
.chip.slot { transform: translate(-50%, -50%); }
.chip > * { flex-shrink: 0; }
.chip .n { font-family: 'Barlow Condensed', sans-serif; font-size: max(15px, calc(26px * var(--cs, 1))); font-weight: 700; line-height: 1; }
.chip .nm { font-size: max(9px, calc(11.5px * var(--cs, 1))); font-weight: 600; line-height: 1.05; max-width: calc(60px * var(--cs, 1)); text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: break-word; }
.chip .ps { font-size: max(8px, calc(11px * var(--cs, 1))); white-space: nowrap; max-width: calc(60px * var(--cs, 1)); overflow: hidden; }
.chip .mn { margin-top: 2px; padding: 0 calc(6px * var(--cs, 1)); border-radius: 6px; background: var(--bg); color: var(--fg); font-family: 'Barlow Condensed', sans-serif; font-size: max(10px, calc(16px * var(--cs, 1))); font-weight: 600; }
/* Portero: ficha apaisada con fondo gris claro; número a la izquierda, nombre y tiempo a la derecha */
.chip.gk { width: calc(112px * var(--cs, 1)); height: calc(48px * var(--cs, 1)); background: #d9dee5; border-color: #d9dee5; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; column-gap: calc(7px * var(--cs, 1)); row-gap: 0; align-items: center; justify-items: start; align-content: center; padding: 0 calc(8px * var(--cs, 1)); text-align: left; }
.chip.gk .n { grid-row: 1 / 3; grid-column: 1; font-size: max(17px, calc(30px * var(--cs, 1))); }
.chip.gk .nm { grid-row: 1; grid-column: 2; max-width: 100%; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; -webkit-line-clamp: unset; text-align: left; }
.chip.gk .ps { display: none; }
.chip.gk.empty .ps { display: block; grid-row: 2; grid-column: 2; }
.chip.gk .mn { grid-row: 2; grid-column: 2; margin-top: 1px; }
.chip.gk.sel { background: var(--accent); border-color: var(--bg); }
.chip.gk.sel.def { background: var(--blue); }
.chip.sel { background: var(--accent); border-color: var(--bg); }
.chip.sel.def { background: var(--blue); }
.chip.dim { opacity: .45; }
.chip.empty { background: transparent; color: var(--fg); border-style: dashed; }
.chip.bench { position: relative; flex-shrink: 0; width: auto; min-width: 70px; max-width: 120px; padding: 0 6px; height: 92px; background: var(--panel2); color: var(--fg); border: 2px solid var(--border); }
.chip.bench .n { font-size: 28px; }
.chip.bench .nm { color: var(--fg); font-weight: 500; font-size: 12px; max-width: 106px; }
.chip.bench .ps { color: var(--muted); font-size: 11px; }
.chip.bench .mn { background: transparent; font-size: 16px; }
.chip.dragging { opacity: .3; }
.chip.over { outline: 4px solid var(--accent); }
#ghost { position: fixed; pointer-events: none; z-index: 200; opacity: .9; transform: translate(-50%, -50%); width: 66px; height: 92px; }
.marker { position: absolute; width: calc(36px * var(--cs, 1)); height: calc(36px * var(--cs, 1)); margin: calc(-18px * var(--cs, 1)) 0 0 calc(-18px * var(--cs, 1)); border: 4px solid var(--bg); border-radius: 50%; background: var(--accent); pointer-events: none; }
.court.defense .marker { background: var(--blue); }
.hint { position: absolute; font-size: max(10px, calc(12.5px * var(--cs, 1))); line-height: 1.25; color: #d9e6f0; pointer-events: none; z-index: 2; text-shadow: 0 1px 2px rgba(0,0,0,.6); }

/* Pantallas pequeñas */
@media (max-width: 900px) {
  .page { padding: 12px; gap: 10px; }
  .topbar { gap: 8px; }
  .title { font-size: 17px; }
  .btn.big { height: 48px; padding: 0 14px; font-size: 16px; }
  .logo { width: 40px; height: 40px; font-size: 15px; }
  .panel { padding: 12px; }
  .modal { padding: 16px; }
}
@media (max-width: 700px) { .topbar { flex-wrap: wrap; } }

/* Campo pequeño (móvil horizontal): fichas estrechas con dorsal, nombre y tiempo, dejando aire entre ellas */
/* Campo pequeño (móvil): fichas algo más anchas y nombre legible a dos líneas */
.court.small .chip { width: min(max(42px, calc(58px * var(--cs, 1))), calc(76px * var(--cs, 1))); height: min(max(56px, calc(76px * var(--cs, 1))), calc(100px * var(--cs, 1))); border-width: 1.5px; border-radius: 7px; line-height: 1; }
.court.small .chip.slot { height: min(max(56px, calc(76px * var(--cs, 1))), calc(100px * var(--cs, 1))); }
.court.small .chip .n { font-size: max(15px, calc(22px * var(--cs, 1))); }
.court.small .chip .nm { font-size: 10px; line-height: 1.05; max-width: 100%; padding: 0 1px; -webkit-line-clamp: 2; white-space: normal; display: -webkit-box; margin-top: 1px; overflow-wrap: anywhere; }
.court.small .chip .ps { display: none; }
.court.small .chip.gk { width: max(78px, calc(112px * var(--cs, 1))); height: max(38px, calc(48px * var(--cs, 1))); padding: 0 5px; column-gap: 5px; }
.court.small .chip.gk .n { font-size: max(16px, calc(26px * var(--cs, 1))); }
.court.small .chip.gk .nm { white-space: nowrap; display: block; -webkit-line-clamp: unset; }
.court.small .chip .mn { font-size: 10px; padding: 0 3px; margin-top: 1px; border-radius: 4px; }
.court.small .chip.empty .ps { display: block; font-size: 7px; }
.court.small .chip.sel { animation: chipPulseSm 1.1s ease-in-out infinite; }
@keyframes chipPulseSm { 0%, 100% { box-shadow: 0 0 0 0 rgba(245,165,36,0); } 50% { box-shadow: 0 0 0 4px rgba(245,165,36,.55); } }

/* Altura de la ventana: usa la visible real en móviles (barra del navegador) */
:root { --app-h: 100vh; --app-w: 100vw; }
@supports (height: 100dvh) { :root { --app-h: 100dvh; } }
/* Horizontal forzado: con el dispositivo en vertical, el <body> se gira 90° y ocupa la pantalla entera */
html.rot { overflow: hidden; height: 100%; }
html.rot body { position: fixed; top: 0; left: 0; margin: 0; width: var(--app-w); height: var(--app-h); min-height: 0; padding-bottom: 0; overflow: hidden; transform: rotate(90deg) translateY(-100%); transform-origin: top left; }

/* Pie de página fijo: "Desarrollado por AIFASTTRACK" en todas las pantallas */
:root { --foot: 32px; }
@media (max-height: 480px) { :root { --foot: 22px; } }
:root[data-eff="phone"] { --foot: 22px; }
.credit { position: fixed; left: 0; right: 0; bottom: 0; height: var(--foot); z-index: 500; display: flex; align-items: center; justify-content: center; background: #0b1219; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); user-select: none; -webkit-user-select: none; }
.credit-inner { display: inline-flex; align-items: center; gap: 6px; color: inherit; text-decoration: none; max-width: 100%; white-space: nowrap; overflow: hidden; }
a.credit-inner:hover .credit-url { color: var(--fg); }
.credit-logo { display: inline-flex; align-items: center; height: calc(var(--foot) - 8px); }
.credit-logo img { height: 100%; width: auto; max-width: 130px; object-fit: contain; display: block; }
.credit-word { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 13px; letter-spacing: 1px; color: var(--fg); }
.credit-url { color: var(--muted); }
@media (max-height: 480px) { .credit { font-size: 10px; } .credit-word { font-size: 11px; } .credit-logo { height: calc(var(--foot) - 4px); } }
@media (max-width: 380px) { .credit-label { display: none; } }

/* Selector de idioma (en el login, el perfil y las cabeceras) */
.langSel { height: 38px; width: auto; min-width: 0; padding: 0 30px 0 10px; font-weight: 600; font-size: 14px; cursor: pointer; background: var(--panel2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center / 14px; }

/* Aviso del plan (prueba, caducado, cancelación, cobro fallido) bajo la cabecera de Inicio */
.planBar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 10px 14px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); font-size: 15px; }
.planBar .txt { flex: 1 1 240px; min-width: 0; line-height: 1.3; }
.planBar .btn { flex: 0 0 auto; height: 38px; padding: 0 14px; font-size: 14px; border-radius: 8px; }
.planBar.trial { background: #1b3a52; border-color: #2b6f99; color: #dff1ff; }
.planBar.expired { background: #4a2f10; border-color: var(--accent); color: #ffe3b0; font-weight: 600; }
.planBar.warn { background: #4a1d1f; border-color: #a13a3f; color: #ffd3d5; }
.planBar.info { background: var(--panel2); color: var(--fg); }
@media (max-width: 600px) { .planBar .btn { flex: 1 1 100%; } }
/* Ventana de suscripción: ventajas, precios mensual/anual y pago en Stripe */
.subBenefits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.subBenefits li { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.subBenefits li::before { content: '✓'; flex: 0 0 24px; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: rgba(70,195,123,.18); color: var(--ok); font-size: 14px; }
.subPrices { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.subPrice { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 2px solid var(--border); border-radius: 12px; background: var(--panel2); color: var(--fg); text-align: left; cursor: pointer; font: inherit; }
.subPrice.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.subPrice .lbl { font-size: 14px; color: var(--muted); font-weight: 600; }
.subPrice .amt { font-family: 'Barlow Condensed', sans-serif; font-size: 28px; font-weight: 700; line-height: 1; }
.subPrice .sub { font-size: 13px; color: var(--muted); }
.subPrice .tag { position: absolute; top: -10px; right: 10px; background: var(--ok); color: var(--bg); }
.subActions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.subActions .btn { flex: 1 1 auto; }
.modal-bg.locked { z-index: 1200; background: rgba(5,9,14,.82); }
/* Perfil: estado de la suscripción */
.planBox { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); }
.planBox .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-weight: 700; font-size: 17px; }
.planBox .btn { height: 40px; font-size: 15px; }
.planBox .btns { display: flex; flex-direction: column; gap: 8px; }
/* Pantalla baja (móvil apaisado, o en vertical con el giro forzado de la pizarra): ventana de suscripción compacta */
@media (max-height: 480px) { .subBenefits { display: none; } .modal:has(.subPrices) { gap: 10px; padding: 12px 14px; } .subPrice { padding: 8px 12px; } .subPrice .amt { font-size: 22px; } }
html.rot .subBenefits { display: none; }
html.rot .modal:has(.subPrices) { gap: 10px; padding: 12px 14px; }
html.rot .subPrice { padding: 8px 12px; }
html.rot .subPrice .amt { font-size: 22px; }
