/* =====================
   Reloj de turno / defensa: barra compacta fija arriba al centro.
   Siempre visible (también con ventanas abiertas), no recibe clics y no tapa el centro del tablero.
   Se carga al final para tener prioridad sobre las ubicaciones anteriores del reloj
   (duel-board.css y duel-battlefield-theme.css). La clase repetida sube la especificidad a
   propósito para ganar también a las reglas con :has(.modal-overlay) y .timer-decision.
   ===================== */
body.duel-playing .game-timer-hud.game-timer-hud.game-timer-hud {
    position: fixed !important;
    --timer-hud-y: 0px;
    top: max(6px, env(safe-area-inset-top)) !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, 0) !important;
    width: max-content !important;
    min-width: 0 !important;
    max-width: min(520px, calc(100vw - 24px)) !important;
    justify-self: auto !important;
    z-index: 160 !important;
    opacity: 1 !important;
    overflow: hidden;
    gap: 10px;
    padding: 6px 16px 10px !important;
    border-radius: 14px;
    pointer-events: none;
}
body.duel-playing .game-timer-hud.game-timer-hud.game-timer-hud .timer-value { font-size: 1.32rem; min-width: 66px; }
body.duel-playing .game-timer-hud.game-timer-hud.game-timer-hud small { max-width: 200px; }

/* Barra de tiempo restante. */
.game-timer-hud .timer-bar {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 4px;
    height: 3px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
}
.game-timer-hud .timer-bar > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #d8a845, #ffe6a3);
    transform-origin: left center;
    transition: transform .5s linear;
}
.game-timer-hud.timer-block .timer-bar > span { background: linear-gradient(90deg, #4aa3df, #a6dcff); }
.game-timer-hud.timer-paused .timer-bar > span { opacity: .45; }
.game-timer-hud.timer-urgent:not(.timer-paused) .timer-bar > span { background: linear-gradient(90deg, #d9483b, #ff9a7a); }

/* Pocos segundos: el número se pone rojo; en los últimos 10 s el borde late (sin mover el reloj). */
.game-timer-hud.timer-urgent:not(.timer-paused) .timer-value { color: #ffb4a6; text-shadow: 0 0 14px rgba(255, 90, 70, .5); }
.game-timer-hud.timer-critical:not(.timer-paused) { animation: timerCriticalGlow 1s ease-in-out infinite !important; }
@keyframes timerCriticalGlow {
    0%, 100% { box-shadow: 0 0 0 1px rgba(255, 95, 88, .35), 0 0 18px rgba(255, 68, 68, .25), 0 10px 28px rgba(0, 0, 0, .4); }
    50% { box-shadow: 0 0 0 2px rgba(255, 95, 88, .7), 0 0 30px rgba(255, 68, 68, .5), 0 10px 28px rgba(0, 0, 0, .4); }
}

@media (max-width: 760px) {
    body.duel-playing .game-timer-hud.game-timer-hud.game-timer-hud { padding: 5px 12px 9px !important; gap: 7px; }
    body.duel-playing .game-timer-hud.game-timer-hud.game-timer-hud .timer-value { font-size: 1.12rem; min-width: 56px; }
}
@media (prefers-reduced-motion: reduce) {
    .game-timer-hud.timer-critical:not(.timer-paused) { animation: none !important; }
    .game-timer-hud .timer-bar > span { transition: none; }
}

/* Fuera del duelo el reloj nunca se muestra (evita que quede congelado al volver al menú). */
body:not(.duel-playing) .game-timer-hud,
body:not(.duel-playing) #aiActionFeed,
body:not(.duel-playing) #canticoStatusPanel {
    display: none !important;
}
