/* =========================================================
   tiktakpuck.css | TIK TAK PUCK
   Usa las variables de header.css (--neon-blue, --neon-pink…).
   ✕ = jugador 1 (azul) · ◯ = jugador 2 (rosa)
   ========================================================= */

:root {
    --p0: var(--neon-blue);
    --p0-soft: rgba(0, 242, 255, .14);
    --p1: var(--neon-pink);
    --p1-soft: rgba(255, 0, 85, .14);
    --lg: var(--neon-blue);           /* acento de la liga elegida (lo pone el JS) */
    --panel: #111723;
    --panel-2: #0d121c;
    --line: #232c3b;
}

.hidden { display: none !important; }

.ttp {
    max-width: 760px;
    margin: 0 auto;
    padding: 28px 16px 64px;
    box-sizing: border-box;
    min-height: 70vh;
}
.ttp *, .ttp *::before, .ttp *::after { box-sizing: border-box; }

/* ---------- Portada ---------- */
.ttp-hero { text-align: center; margin: 8px 0 26px; }
.ttp-badge {
    display: inline-block;
    font-size: .7rem; font-weight: 900; letter-spacing: .14em;
    color: var(--neon-yellow-green);
    border: 1px solid rgba(204, 255, 0, .35);
    background: rgba(204, 255, 0, .06);
    padding: 5px 12px; border-radius: 999px;
}
.ttp-title {
    font-size: clamp(2.4rem, 9vw, 3.8rem);
    font-weight: 900; letter-spacing: -2px;
    margin: 14px 0 8px; line-height: 1;
}
.ttp-title span { color: var(--neon-blue); text-shadow: 0 0 26px var(--neon-blue-glow); }
.ttp-sub { color: var(--text-secondary); max-width: 520px; margin: 0 auto; line-height: 1.55; }

.ttp-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
}
.ttp-card.center { text-align: center; max-width: 480px; margin: 20px auto; }

.ttp-label { display: block; font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary); margin: 4px 0 8px; text-align: left; }
.ttp-input {
    width: 100%;
    background: var(--panel-2);
    border: 1.5px solid var(--line);
    border-radius: 12px;
    color: #fff;
    font: 600 1rem 'Inter', sans-serif;
    padding: 13px 14px;
    margin-bottom: 18px;
    transition: border-color .2s, box-shadow .2s;
}
.ttp-input:focus { outline: none; border-color: var(--neon-blue); box-shadow: 0 0 0 3px rgba(0, 242, 255, .15); }

.league-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 20px; }
.lg-opt {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 12px 6px;
    background: var(--panel-2);
    border: 1.5px solid var(--line);
    border-radius: 12px;
    color: #fff; cursor: pointer;
    font: 800 .82rem 'Inter', sans-serif;
    transition: border-color .2s, background .2s, transform .15s;
}
.lg-opt:hover { border-color: color-mix(in srgb, var(--lg) 60%, transparent); }
.lg-opt:active { transform: scale(.97); }
.lg-opt.on { border-color: var(--lg); background: color-mix(in srgb, var(--lg) 14%, var(--panel-2)); box-shadow: 0 0 16px color-mix(in srgb, var(--lg) 30%, transparent); }
.lg-flag { font-size: 1.5rem; line-height: 1; }

.ttp-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%;
    padding: 14px 18px;
    border-radius: 12px;
    border: 1.5px solid var(--line);
    background: var(--panel-2);
    color: #fff;
    font: 900 .95rem 'Inter', sans-serif;
    letter-spacing: .02em;
    cursor: pointer; text-decoration: none;
    transition: transform .15s, box-shadow .2s, border-color .2s, opacity .2s;
}
.ttp-btn:hover { border-color: var(--neon-blue); }
.ttp-btn:active { transform: scale(.98); }
.ttp-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.ttp-btn.primary { background: var(--neon-blue); border-color: var(--neon-blue); color: #041418; box-shadow: 0 0 22px rgba(0, 242, 255, .3); }
.ttp-btn.primary:hover { box-shadow: 0 0 30px rgba(0, 242, 255, .5); }
.ttp-btn.ghost { background: transparent; color: var(--text-secondary); margin-top: 10px; }
.ttp-btn.ghost:hover { color: #fff; }
.ttp-btn.small { width: auto; padding: 9px 14px; font-size: .8rem; margin: 0; }
.ttp-error { color: var(--neon-pink); font-weight: 700; font-size: .88rem; min-height: 1.2em; margin: 10px 0 0; }

.ttp-rules { margin-top: 26px; padding: 4px 6px; }
.ttp-rules h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: .08em; }
.ttp-rules ol { color: var(--text-secondary); line-height: 1.6; padding-left: 20px; }
.ttp-rules strong { color: #fff; }

/* ---------- Invitación / unirse ---------- */
.ttp-kicker { color: var(--lg); font-weight: 900; letter-spacing: .08em; text-transform: uppercase; font-size: .8rem; margin: 0; }
.ttp-h2 { font-size: 1.6rem; font-weight: 900; margin: 8px 0; }
.ttp-muted { color: var(--text-secondary); line-height: 1.5; margin: 0 0 18px; }
.invite-code {
    font: 900 2.4rem 'Inter', sans-serif; letter-spacing: .3em;
    color: var(--neon-blue); text-shadow: 0 0 20px var(--neon-blue-glow);
    margin: 4px 0 16px; padding-left: .3em;
}
.invite-row { display: flex; gap: 8px; }
.invite-row .ttp-input { margin-bottom: 12px; font-size: .85rem; }
.invite-row .ttp-btn { width: auto; height: 48px; }
.waiting { color: var(--text-secondary); font-weight: 700; margin: 18px 0 0; display: flex; align-items: center; justify-content: center; gap: 10px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--neon-blue); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* ---------- Marcador ---------- */
.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-bottom: 12px; }
.sb-player {
    display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto;
    column-gap: 10px; align-items: center;
    padding: 10px 12px;
    background: var(--panel);
    border: 1.5px solid var(--line);
    border-radius: 14px;
    min-width: 0;
    transition: border-color .25s, box-shadow .25s;
}
.sb-player.p1 { grid-template-columns: 1fr auto; text-align: right; }
.sb-player.p1 .sb-mark { grid-column: 2; grid-row: 1 / 3; }
.sb-player.p1 .sb-name, .sb-player.p1 .sb-wins { grid-column: 1; justify-content: flex-end; }
.sb-mark { grid-row: 1 / 3; font-size: 1.6rem; font-weight: 900; }
.p0 .sb-mark { color: var(--p0); }
.p1 .sb-mark { color: var(--p1); }
.sb-name { font-weight: 800; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-wins { display: flex; gap: 5px; margin-top: 4px; }
.sb-wins i { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--line); }
.p0 .sb-wins i.won { background: var(--p0); border-color: var(--p0); box-shadow: 0 0 8px var(--p0); }
.p1 .sb-wins i.won { background: var(--p1); border-color: var(--p1); box-shadow: 0 0 8px var(--p1); }
.sb-player.p0.active { border-color: var(--p0); box-shadow: 0 0 18px var(--p0-soft); }
.sb-player.p1.active { border-color: var(--p1); box-shadow: 0 0 18px var(--p1-soft); }
.sb-player.offline { opacity: .5; }
.sb-mid { text-align: center; display: flex; flex-direction: column; gap: 3px; }
.sb-grid { font-weight: 900; font-size: .9rem; letter-spacing: .06em; }
.sb-league { font-size: .72rem; color: var(--text-secondary); font-weight: 700; white-space: nowrap; }

/* ---------- Turno y reloj ---------- */
.turn-bar {
    display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
    margin-bottom: 14px;
}
.turn-text { margin: 0; font-weight: 800; font-size: .95rem; }
.turn-bar.mine .turn-text { color: var(--p0); }
.turn-bar.theirs .turn-text { color: var(--text-secondary); }
.timer { grid-column: 1 / -1; grid-row: 2; height: 6px; background: var(--panel); border-radius: 99px; overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: var(--neon-blue); border-radius: 99px; transition: width .2s linear, background .3s; }
.timer-num { grid-column: 2; grid-row: 1; font-weight: 900; font-variant-numeric: tabular-nums; font-size: 1.1rem; }
.turn-bar.hurry .timer-fill { background: var(--neon-pink); }
.turn-bar.hurry .timer-num { color: var(--neon-pink); }

/* ---------- Tablero ---------- */
.board {
    display: grid;
    grid-template-columns: minmax(62px, .8fr) repeat(3, 1fr);
    gap: 7px;
    max-width: 560px;
    margin: 0 auto;
}
.corner { display: flex; align-items: center; justify-content: center; font-size: 1.8rem; opacity: .6; }
.hdr {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
    text-align: center;
    padding: 8px 4px;
    min-height: 74px;
    min-width: 0;
    border-radius: 12px;
    background: color-mix(in srgb, var(--lg) 6%, var(--panel-2));
    border: 1px solid color-mix(in srgb, var(--lg) 22%, var(--line));
}
.hdr-img { width: 44px; height: 44px; object-fit: contain; }
.hdr-img.nat { width: 40px; height: 28px; object-fit: cover; border-radius: 4px; box-shadow: 0 0 0 1px rgba(255,255,255,.15); }
.hdr-big { font-size: 1.35rem; font-weight: 900; color: var(--lg); line-height: 1; }
.hdr-name { font-size: .68rem; font-weight: 800; color: var(--text-secondary); line-height: 1.2; text-transform: uppercase; letter-spacing: .02em; overflow-wrap: anywhere; }

.cell {
    position: relative;
    aspect-ratio: 1;
    min-width: 0;
    border-radius: 14px;
    border: 1.5px solid var(--line);
    background: var(--panel);
    color: #fff;
    font-family: inherit;
    padding: 0;
    cursor: default;
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    transition: border-color .2s, box-shadow .2s, transform .15s, background .2s;
}
.cell.open { cursor: pointer; border-style: dashed; border-color: color-mix(in srgb, var(--p0) 40%, var(--line)); }
.cell.open:hover, .cell.picking { border-style: solid; border-color: var(--p0); background: var(--p0-soft); }
.cell.open:active { transform: scale(.97); }
.cell-plus { font-size: 2rem; font-weight: 300; color: color-mix(in srgb, var(--p0) 70%, transparent); }
.cell img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; opacity: .9; }
.cell-name {
    position: absolute; left: 0; right: 0; bottom: 0;
    padding: 18px 5px 6px;
    font-size: .68rem; font-weight: 800; line-height: 1.15;
    background: linear-gradient(transparent, rgba(0,0,0,.9) 55%);
    overflow-wrap: anywhere;
}
.cell-mark { position: absolute; top: 4px; right: 7px; font-weight: 900; font-size: 1rem; text-shadow: 0 0 8px rgba(0,0,0,.9); }
.cell.by0 { border-color: var(--p0); box-shadow: inset 0 0 0 2px var(--p0), 0 0 14px var(--p0-soft); }
.cell.by0 .cell-mark { color: var(--p0); }
.cell.by1 { border-color: var(--p1); box-shadow: inset 0 0 0 2px var(--p1), 0 0 14px var(--p1-soft); }
.cell.by1 .cell-mark { color: var(--p1); }
.cell.win { animation: winpulse 1s ease-in-out infinite alternate; }
@keyframes winpulse { to { transform: scale(1.04); filter: brightness(1.25); } }
.cell.revealed { background: var(--panel-2); border-style: dashed; }
.cell.revealed .cell-name { position: static; background: none; padding: 4px; color: var(--text-secondary); font-style: italic; }
.cell.shake { animation: shake .45s; border-color: var(--neon-pink); }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.cell:disabled { cursor: default; }

.game-actions { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }

/* ---------- Buscador ---------- */
.picker {
    position: fixed; inset: 0; z-index: 1500;
    background: rgba(3, 6, 12, .72);
    backdrop-filter: blur(3px);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 12vh 16px 16px;
}
.picker-box {
    width: 100%; max-width: 460px;
    background: var(--panel);
    border: 1.5px solid var(--p0);
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 24px 60px rgba(0,0,0,.7), 0 0 30px var(--p0-soft);
}
.picker-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.picker-title { flex: 1; margin: 0; font-weight: 800; font-size: .92rem; line-height: 1.4; }
.picker-title b { color: var(--p0); }
.picker-close { background: none; border: none; color: var(--text-secondary); font-size: 1.8rem; line-height: 1; cursor: pointer; padding: 0 4px; }
.picker-close:hover { color: #fff; }
.picker .ttp-input { margin-bottom: 8px; }
.picker-list { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; }
.picker-list li {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 10px; cursor: pointer;
}
.picker-list li:hover, .picker-list li.active { background: var(--p0-soft); }
.picker-list li.empty { color: var(--text-secondary); cursor: default; justify-content: center; }
.picker-list img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; object-position: top; background: var(--panel-2); flex-shrink: 0; }
.pl-name { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-team { font-size: .75rem; color: var(--text-secondary); white-space: nowrap; }
.picker-time { text-align: right; color: var(--text-secondary); font-size: .78rem; font-weight: 700; margin: 8px 0 0; }

/* ---------- Resultado ---------- */
.result {
    position: fixed; inset: 0; z-index: 1600;
    background: rgba(3, 6, 12, .78);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.result-box {
    width: 100%; max-width: 420px; text-align: center;
    background: var(--panel);
    border: 1.5px solid var(--lg);
    border-radius: 20px;
    padding: 26px 22px 18px;
    box-shadow: 0 0 40px color-mix(in srgb, var(--lg) 25%, transparent);
    animation: pop .35s cubic-bezier(.22,1,.36,1);
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
.result-kicker { margin: 0; color: var(--lg); font-weight: 900; letter-spacing: .12em; font-size: .75rem; }
.result-title { font-size: 1.7rem; font-weight: 900; margin: 8px 0; }
.result-sub { color: var(--text-secondary); font-weight: 700; margin: 0 0 14px; line-height: 1.6; }
.result-series { display: flex; justify-content: center; gap: 8px; margin-bottom: 18px; }
.result-series .dot {
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 900; font-size: .8rem;
    border: 1.5px solid var(--line); color: var(--text-secondary);
}
.result-series .dot.me { border-color: var(--neon-yellow-green); color: var(--neon-yellow-green); }
.result-series .dot.them { border-color: var(--neon-pink); color: var(--neon-pink); }
.result-series .dot.draw { border-style: dashed; }
.result-actions { display: flex; flex-direction: column; gap: 0; }

/* ---------- Avisos ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 1700; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: calc(100% - 32px); max-width: 420px; }
.toast {
    background: #0d121c; border: 1px solid var(--line); border-radius: 999px;
    padding: 10px 16px; font-weight: 700; font-size: .86rem; text-align: center;
    box-shadow: 0 12px 30px rgba(0,0,0,.6);
    opacity: 0; transform: translateY(12px); transition: opacity .25s, transform .3s;
}
.toast.in { opacity: 1; transform: none; }
.toast.good { border-color: var(--neon-yellow-green); color: var(--neon-yellow-green); }
.toast.bad { border-color: var(--neon-pink); color: #ff7aa2; }
.toast.info { border-color: var(--neon-blue); color: var(--neon-blue); }

/* ---------- Confeti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 1800; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: fall 2.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .6; } }

/* ---------- Móvil ---------- */
@media (max-width: 560px) {
    .ttp { padding-top: 18px; }
    .league-pick { grid-template-columns: repeat(2, 1fr); }
    .lg-opt { flex-direction: row; justify-content: flex-start; padding: 11px 12px; }
    .board { gap: 5px; grid-template-columns: minmax(54px, .75fr) repeat(3, 1fr); }
    .hdr { min-height: 62px; padding: 6px 2px; }
    .hdr-img { width: 34px; height: 34px; }
    .hdr-img.nat { width: 32px; height: 22px; }
    .hdr-big { font-size: 1.05rem; }
    .hdr-name { font-size: .58rem; }
    .cell-name { font-size: .6rem; }
    .sb-player { padding: 8px 9px; column-gap: 7px; }
    .sb-mark { font-size: 1.25rem; }
    .sb-name { font-size: .78rem; }
    .picker { padding-top: 8vh; }
}

@media (prefers-reduced-motion: reduce) {
    .cell.win, .dots i, .confetti i { animation: none; }
}
