/* La vuelta a Andalucía (18/10/2026). Se sirve tal cual, sin pasar por
   Tailwind: el juego es una pantalla cerrada con sus propios colores, los de
   una carrera ciclista en el sur: el verde y el blanco del maillot, el
   amarillo del líder, el asfalto y el cielo. */
.vuelta {
    --papel: #fbfaf5;
    --verde: #127a3c;
    --verde-claro: #3ee07a;
    --amarillo: #f5c518;
    --tinta: #1d2127;
    --rojo: #d8262a;
    --naranja: #f08a2c;
    --cielo: #5c9ad8;
    --sombra: rgba(29, 33, 39, .22);
}

/*
  DENTRO DEL PORTAL, NO A PANTALLA COMPLETA, como el patio y el cortador: un
  alto cómodo con la cabecera y el pie alrededor. Es un juego de pie.
*/
.vuelta.juego {
    height: min(calc(100vh - 175px), 900px);
    height: min(calc(100dvh - 175px), 900px);
    min-height: 480px;
    color: var(--tinta);
    font-family: 'Baloo 2', ui-rounded, system-ui, sans-serif;
    -webkit-user-select: none;
    user-select: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px;
    box-sizing: border-box;
    max-width: 760px;
    margin: 0 auto;
}

/* ------------------------------------------------------------ Marcador */
.vuelta .marcador { display: flex; align-items: center; gap: 6px; }

.vuelta .lugar,
.vuelta .energia,
.vuelta .calor {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--papel);
    border-radius: 999px;
    padding: 4px 12px;
    box-shadow: 0 2px 0 var(--sombra);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    min-width: 0;
    height: 34px;
    box-sizing: border-box;
}

.vuelta .lugar { flex: 1; }
.vuelta .lugar b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* La energía: verde llena, ámbar a medias, roja casi vacía; parpadea si se recupera. */
.vuelta .energia { flex: none; padding: 4px 10px; color: var(--verde); }
.vuelta .energia svg { width: 10px; height: 14px; flex: none; }
.vuelta .energia .barra { position: relative; width: 60px; height: 9px; border-radius: 6px; background: #e3e1d9; overflow: hidden; }
.vuelta .energia .barra i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: var(--verde); border-radius: 6px; transition: width .12s linear; }
.vuelta .energia.sube .barra i { background: var(--verde-claro); }
.vuelta .energia.bajo { color: var(--rojo); }
.vuelta .energia.bajo .barra i { background: var(--naranja); }
.vuelta .energia.vacio { background: #ffd9d4; animation: latido .5s ease-in-out infinite alternate; }
.vuelta .energia.vacio .barra i { background: var(--rojo); }

/* El calor: el termómetro sube; al lado, los bidones que llevas. */
.vuelta .calor { flex: none; padding: 4px 10px; color: #8a6a3a; }
.vuelta .calor svg { width: 9px; height: 17px; flex: none; }
.vuelta .calor.caliente { color: var(--rojo); background: #ffe6d4; }
.vuelta .calor .bidones { display: flex; align-items: center; gap: 3px; font-size: 14px; color: var(--tinta); }
.vuelta .calor .bidones::before {
    content: '';
    display: block;
    width: 8px;
    height: 15px;
    border-radius: 3px 3px 2px 2px;
    background: linear-gradient(#f4f4f4 0 3px, #3aa0d8 3px);
}

@keyframes latido { to { transform: scale(1.05); } }

.vuelta .sonido {
    flex: none;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: var(--papel);
    color: var(--tinta);
    box-shadow: 0 2px 0 var(--sombra);
    cursor: pointer;
}

.vuelta .sonido svg { width: 24px; height: 24px; }
.vuelta .sonido .con { display: none; }
.vuelta .sonido[aria-pressed="true"] .con { display: inline; }
.vuelta .sonido[aria-pressed="true"] .sin { display: none; }
.vuelta .sonido:focus-visible { outline: 3px solid var(--verde); outline-offset: 2px; }

/* Lo que llevas de carrera: el tiempo con la cabeza, la rueda, la velocidad y los puntos. */
.vuelta .avance {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    min-width: 0;
    font-variant-numeric: tabular-nums;
}

.vuelta .avance .tiempo { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--verde); }
.vuelta .avance .tiempo.lejos { color: var(--rojo); animation: latido .5s ease-in-out infinite alternate; }
.vuelta .avance .rueda { white-space: nowrap; opacity: .85; }
.vuelta .avance .rueda.bien { color: var(--verde); opacity: 1; }
.vuelta .avance .rueda.mal { color: #9a5b16; opacity: 1; }
.vuelta .avance .velocidad { white-space: nowrap; opacity: .8; }
.vuelta .avance #puntos { white-space: nowrap; }

/* ------------------------------------------------------------ Campo */
.vuelta .campo {
    position: relative;
    flex: 1;
    min-height: 0;
    border-radius: 16px;
    overflow: hidden;
    background: #7aa7d6;
    box-shadow: 0 5px 0 rgba(29, 33, 39, .2), 0 14px 30px rgba(29, 33, 39, .24);
    /* El dedo lleva al corredor, no mueve la página. */
    touch-action: none;
}

.vuelta canvas { display: block; width: 100%; height: 100%; }

/* Los botones, abajo: el desarrollo a la izquierda, beber, frenar y atacar a la derecha. */
.vuelta .acciones {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 10px;
    display: flex;
    align-items: stretch;
    gap: 6px;
    pointer-events: none;
}

.vuelta .acciones[hidden] { display: none; }
.vuelta .acciones > * { pointer-events: auto; }

.vuelta .cambio {
    display: flex;
    align-items: stretch;
    gap: 3px;
    background: rgba(251, 250, 245, .9);
    border-radius: 14px;
    padding: 3px;
    box-shadow: 0 3px 0 rgba(29, 33, 39, .4);
}

.vuelta .cambio .boton.chico { box-shadow: none; padding: 6px 10px; font-size: 20px; background: #ffffff; }

.vuelta .marcha {
    display: grid;
    place-items: center;
    align-content: center;
    min-width: 34px;
    gap: 2px;
    font-weight: 800;
    font-size: 18px;
    line-height: 1;
}

.vuelta .marcha i {
    display: block;
    height: 5px;
    width: 50%;
    border-radius: 3px;
    background: var(--verde);
    justify-self: start;
    transition: width .12s linear;
}

.vuelta .marcha i.corta { background: var(--rojo); }
.vuelta .marcha i.larga { background: var(--naranja); }

.vuelta .boton {
    font: inherit;
    font-weight: 800;
    font-size: 19px;
    color: var(--tinta);
    background: var(--amarillo);
    border: 0;
    border-radius: 999px;
    padding: 11px 30px;
    cursor: pointer;
    box-shadow: 0 4px 0 #a98700;
}

.vuelta .boton:active { transform: translateY(3px); box-shadow: 0 1px 0 #a98700; }
.vuelta .boton:focus-visible { outline: 3px solid var(--papel); outline-offset: 3px; }
.vuelta .boton:disabled { opacity: .45; cursor: default; transform: none; }

.vuelta .boton.chico {
    font-size: 14px;
    line-height: 1.1;
    padding: 8px 8px;
    border-radius: 14px;
    background: var(--papel);
    box-shadow: 0 3px 0 rgba(29, 33, 39, .45);
    touch-action: none;
}

.vuelta .boton.chico.beber { flex: 1; background: #d9f0fb; white-space: nowrap; }
.vuelta .boton.chico.frenar { flex: 1; background: #ffffff; white-space: nowrap; }
.vuelta .boton.chico.frenar.activo { background: #ffd2c4; transform: translateY(2px); }
.vuelta .boton.chico.atacar { flex: 1.5; font-size: 17px; background: var(--amarillo); box-shadow: 0 3px 0 #a98700; }
.vuelta .boton.chico.atacar.activo { background: #ffe58a; transform: translateY(2px); box-shadow: 0 1px 0 #a98700; }

/* ------------------------------------------------------------ Carteles */
.vuelta .cartel {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 10px;
    text-align: center;
    padding: 18px;
    background: rgba(12, 52, 32, .78);
    color: var(--papel);
    overflow-y: auto;
}

.vuelta .cartel[hidden] { display: none; }

.vuelta .firma {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    background: rgba(251, 250, 245, .94);
    color: var(--tinta);
    border-radius: 999px;
    padding: 7px 15px;
    box-shadow: 0 3px 0 rgba(29, 33, 39, .25);
}

.vuelta .firma .de { font-weight: 600; opacity: .62; font-size: 13px; letter-spacing: .03em; }
.vuelta .firma .logo { display: block; height: 24px; width: auto; }

.vuelta .cartel h1 { margin: 0; color: var(--papel); font-size: clamp(28px, 8vw, 46px); line-height: 1.02; text-wrap: balance; }
.vuelta .cartel p { margin: 0; font-size: 15px; max-width: 38ch; font-weight: 600; line-height: 1.35; }
.vuelta .cartel .hoy { font-size: 12px; opacity: .78; font-style: italic; }
.vuelta .cartel .hoy[hidden] { display: none; }

/* Las cuentas de la etapa: una línea por cosa. */
.vuelta .cuentas {
    margin: 0;
    padding: 10px 16px;
    list-style: none;
    display: grid;
    gap: 4px;
    background: rgba(251, 250, 245, .14);
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    text-align: left;
}

.vuelta .cuentas[hidden] { display: none; }
.vuelta .cuentas .mal { color: #ffb4a3; }
.vuelta .cuentas .bien { color: #ffe27a; }

/* El juego de la provincia, en su portal: discreto, como una nota al pie. */
.vuelta .conoces {
    font-size: 14px;
    font-weight: 700;
    color: var(--papel);
    opacity: .9;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.vuelta .conoces[hidden] { display: none; }
.vuelta .conoces:hover { opacity: 1; }

.vuelta .cartel .marca {
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(251, 250, 245, .18);
    font-size: 14px;
}

.vuelta .cartel .marca[hidden] { display: none; }

.vuelta .boton.otro {
    background: transparent;
    color: var(--papel);
    box-shadow: inset 0 0 0 2px var(--papel);
    font-size: 16px;
    padding: 8px 22px;
}

.vuelta .boton.otro[hidden] { display: none; }

.vuelta .pie { margin: 0; text-align: center; font-size: 12px; font-weight: 600; opacity: .7; }

/* En el móvil estrecho, el marcador se aprieta. */
@media (max-width: 420px) {
    .vuelta.juego { padding: 6px 8px; }
    .vuelta .energia .barra { width: 44px; }
    .vuelta .lugar { padding: 4px 10px; }
    .vuelta .avance { gap: 6px; font-size: 12px; }
}

/*
  TUMBADO, SIN EL PORTAL ALREDEDOR, igual que el patio: la cabecera y la
  barra de abajo son fijas y en un móvil apaisado se comerían la carretera.
*/
@media (orientation: landscape) and (max-height: 560px) {
    body:has(.vuelta.juego) #cabecera-del-portal,
    body:has(.vuelta.juego) .barra-de-abajo,
    body:has(.vuelta.juego) #aviso-de-especial { display: none; }
    body:has(.vuelta.juego) #contenido { padding-block: 0; }
    body:has(.vuelta.juego) { padding-bottom: 0; }

    .vuelta.juego { height: 100vh; height: 100dvh; min-height: 280px; gap: 4px; padding: 4px 8px; }
    .vuelta .pie { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .vuelta .energia.vacio,
    .vuelta .avance .tiempo.lejos { animation: none; }
}
