/* =========================================================
   territory.css | PUCK TERRITORY
   Se carga después de tiktakpuck.css (portada, invitación,
   buscador, avisos y resultado son comunes).
   Jugador 1 = azul (--p0) · Jugador 2 = rosa (--p1)
   ========================================================= */

.terr { max-width: 820px; }

/* ---------- Marcador: hexágonos y reloj ---------- */
.terr .sb-player {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
}
.terr .sb-count {
    grid-row: 1 / 3;
    font-size: 1.9rem; font-weight: 900; line-height: 1;
    min-width: 1.6em; text-align: center;
    font-variant-numeric: tabular-nums;
}
.terr .p0 .sb-count { color: var(--p0); }
.terr .p1 .sb-count { color: var(--p1); }
.terr .sb-player.p1 { grid-template-columns: 1fr auto; }
.terr .sb-player.p1 .sb-count { grid-column: 2; grid-row: 1 / 3; }
.terr .sb-player.p1 .sb-name, .terr .sb-player.p1 .sb-clock { grid-column: 1; }
.sb-clock {
    font-weight: 900; font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    margin-top: 2px;
}
.sb-player.active .sb-clock { color: #fff; }
.sb-clock.low { color: var(--neon-pink) !important; }
.sb-player.flagged .sb-clock { color: var(--neon-pink); text-decoration: line-through; }

.terr-turn { text-align: center; margin: 4px 0 12px; font-weight: 800; }
.terr-turn.mine { color: var(--p0); }
.terr-turn.theirs { color: var(--text-secondary); }

/* ---------- Tablero ---------- */
.hexboard {
    position: relative;
    /* Cabe entero en la pantalla: el ancho se limita también por el alto disponible */
    width: min(100%, 540px, calc((100vh - 230px) * var(--ar, .79)));
    min-width: min(100%, 300px);
    margin: 0 auto;
}
.hex {
    position: absolute;
    padding: 0;
    border: 0;
    background: var(--line);                 /* hace de borde */
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
    cursor: default;
    font-family: inherit;
    color: #fff;
    transform: scale(.955);
    transition: background .25s, transform .15s, filter .2s;
}
.hex-in {
    position: absolute;
    inset: 2px;
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
    background: var(--panel);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    padding: 0 8%;
    text-align: center;
    overflow: hidden;
    transition: background .25s;
}
.hx-img { width: 58%; height: 42%; object-fit: contain; }
.hx-img.nat { width: 44%; height: 22%; object-fit: cover; border-radius: 3px; }
.hx-img.league { width: 44%; height: 30%; }
.hx-big { font-size: clamp(.8rem, 2.6vw, 1.15rem); font-weight: 900; color: var(--lg); line-height: 1; }
.hx-sub { font-size: clamp(.42rem, 1.3vw, .58rem); font-weight: 800; color: var(--text-secondary); text-transform: uppercase; line-height: 1.1; max-width: 100%; }
.hx-player {
    font-size: clamp(.42rem, 1.35vw, .6rem); font-weight: 900;
    line-height: 1.1; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: #fff;
}

/* Neutral y jugable */
.hex.open { cursor: pointer; background: color-mix(in srgb, var(--p0) 45%, var(--line)); }
.hex.open:hover, .hex.open:focus-visible, .hex.picking { transform: scale(1.02); z-index: 2; background: var(--p0); }
.hex.open:hover .hex-in, .hex.picking .hex-in { background: color-mix(in srgb, var(--p0) 18%, var(--panel)); }
.hex:focus-visible { outline: none; filter: brightness(1.3); }

/* Conquistados */
.hex.own0 { background: var(--p0); }
.hex.own0 .hex-in { background: color-mix(in srgb, var(--p0) 30%, var(--panel-2)); }
.hex.own1 { background: var(--p1); }
.hex.own1 .hex-in { background: color-mix(in srgb, var(--p1) 30%, var(--panel-2)); }
.hex.own0 .hx-big, .hex.own1 .hx-big { color: #fff; }
.hex.own0 .hx-sub, .hex.own1 .hx-sub { color: rgba(255,255,255,.75); }

/* Bloqueado: no quedan respuestas */
.hex.dead { background: #1a1f29; }
.hex.dead .hex-in { background: #0b0e14; opacity: .45; }

.hex.flash { animation: hexflash .8s ease-out; }
@keyframes hexflash {
    0% { transform: scale(.955); filter: brightness(2.2); }
    40% { transform: scale(1.08); }
    100% { transform: scale(.955); filter: none; }
}
.hex.shake { animation: hexshake .45s; background: var(--neon-pink); }
@keyframes hexshake { 20%, 60% { transform: scale(.955) translateX(-4px); } 40%, 80% { transform: scale(.955) translateX(4px); } }

.hex-info {
    text-align: center;
    color: var(--text-secondary);
    font-weight: 700; font-size: .88rem;
    min-height: 1.4em;
    margin: 12px 0 0;
}

/* ---------- Buscador ---------- */
.terr .picker-title { display: flex; align-items: center; gap: 10px; }
.pk-cat { display: inline-flex; width: 42px; height: 42px; align-items: center; justify-content: center; flex-shrink: 0; background: var(--panel-2); border-radius: 10px; }
.pk-cat .hx-img { width: 32px; height: 32px; }
.pk-cat .hx-img.nat { width: 30px; height: 20px; }
.pk-cat .hx-big { font-size: 1rem; }
.picker-neigh { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.pn-title { width: 100%; font-size: .72rem; font-weight: 800; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.pn { font-size: .74rem; font-weight: 700; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); }
.pn.free { color: #fff; }
.pn.steal { border-color: var(--p1); color: #ff7aa2; }

@media (max-width: 560px) {
    .terr .sb-count { font-size: 1.5rem; }
    .sb-clock { font-size: .92rem; }
    .hex-in { inset: 1.5px; }
}

@media (prefers-reduced-motion: reduce) {
    .hex.flash, .hex.shake { animation: none; }
}
