/* =========================================================
   Rosco Pasapalabra - Estilos del juego para pantallas LED
   Resolución base: 1920x1080 (escalado por JS con transform)
   ========================================================= */

/* Viewport embebido: ocupa 100% del ancho del contenedor (página WP) y
   mantiene proporción 16:9 para que el rosco se vea completo sin cortarse. */
.rosco-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin: 0 auto;
    padding: 0;
    overflow: hidden;
    background: #000000;
    font-family: 'Poppins', sans-serif;
}

/* Fullscreen nativo via Fullscreen API */
.rosco-viewport:fullscreen {
    width: 100vw;
    height: 100vh;
    aspect-ratio: auto;
}
.rosco-viewport:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    aspect-ratio: auto;
}

/* Fallback cuando el navegador no permite Fullscreen API */
.rosco-viewport.is-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    aspect-ratio: auto;
    z-index: 999999;
}

.rosco-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 1920px;
    height: 1080px;
    background: radial-gradient(circle at center, #0a0a2e 0%, #000010 100%);
    color: #f0f0f0;
    overflow: hidden;
    box-sizing: border-box;
    transform-origin: top left;
}

.rosco-bg-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(0,0,20,0.35) 0%, rgba(0,0,0,0.85) 100%);
    pointer-events: none;
    z-index: 1;
}

/* =========================
   HEADER
   ========================= */
.rosco-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 110px;
    padding: 24px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    box-sizing: border-box;
}

/* Cuando no hay título, el botón de pantalla completa se queda a la derecha */
.rosco-header--no-title {
    justify-content: flex-end;
}

.rosco-title {
    font-size: 48px;
    font-weight: 800;
    color: #f0f0f0;
    margin: 0;
    letter-spacing: 2px;
    text-shadow: 0 0 24px rgba(255, 215, 0, 0.45), 0 0 6px rgba(240,240,240,0.25);
}

.rosco-fullscreen-btn {
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,0.08);
    color: #f0f0f0;
    border: 2px solid rgba(240,240,240,0.25);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.rosco-fullscreen-btn:hover {
    background: rgba(255, 215, 0, 0.15);
    border-color: #ffd700;
    color: #ffd700;
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.5);
}

/* =========================
   MAIN / ROSCO
   ========================= */
.rosco-main {
    position: absolute;
    top: 110px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
}

.rosco-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 900px;
    height: 900px;
    margin: -450px 0 0 -450px;
}

/* Cada letra */
.rosco-letter {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 72px;
    height: 72px;
    margin: -36px 0 0 -36px;
    border-radius: 50%;
    background: #1a1a2e;
    border: 2px solid rgba(240,240,240,0.25);
    color: #f0f0f0;
    font-size: 32px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: background 0.4s ease, color 0.4s ease, border-color 0.4s ease,
                box-shadow 0.4s ease, transform 0.3s ease;
    z-index: 3;
}

.rosco-letter:hover {
    transform: scale(1.08);
}

/* Estados */
.rosco-letter.state-pending {
    background: #1a1a2e;
    color: #f0f0f0;
    border-color: rgba(240,240,240,0.25);
}

.rosco-letter.state-correct {
    background: #00ff88;
    color: #001a0f;
    border-color: #00ff88;
    text-shadow: 0 0 20px #00ff88;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.75), inset 0 0 15px rgba(0,0,0,0.35);
}

.rosco-letter.state-incorrect {
    background: #ff3333;
    color: #f0f0f0;
    border-color: #ff3333;
    text-shadow: 0 0 20px #ff3333;
    box-shadow: 0 0 30px rgba(255, 51, 51, 0.75), inset 0 0 15px rgba(0,0,0,0.35);
}

.rosco-letter.state-pass {
    background: #ff9900;
    color: #1a0a00;
    border-color: #ff9900;
    text-shadow: 0 0 20px #ff9900;
    box-shadow: 0 0 30px rgba(255, 153, 0, 0.75), inset 0 0 15px rgba(0,0,0,0.35);
}

/* Letra activa (parpadea en su propia posición, por encima del panel central).
   IMPORTANTE: la posición de cada letra se establece mediante un `transform`
   inline (rotate/translate). Por eso la animación de parpadeo NO puede tocar
   `transform`; solo modifica opacidad, brillo y sombra para no mover la
   letra del rosco. */
.rosco-letter.active {
    background: #ffd700;
    color: #1a0a00;
    border-color: #ffd700;
    text-shadow: 0 0 22px rgba(255, 215, 0, 0.9);
    box-shadow: 0 0 35px rgba(255, 215, 0, 0.95), 0 0 70px rgba(255, 215, 0, 0.6);
    animation: roscoBlink 0.85s infinite ease-in-out;
    /* El panel central tiene z-index 6; la letra activa debe quedar por encima. */
    z-index: 15;
}

@keyframes roscoBlink {
    0%, 100% {
        opacity: 1;
        filter: brightness(1);
        box-shadow: 0 0 35px rgba(255, 215, 0, 0.95), 0 0 70px rgba(255, 215, 0, 0.6);
    }
    50% {
        opacity: 0.45;
        filter: brightness(1.35);
        box-shadow: 0 0 55px rgba(255, 215, 0, 1), 0 0 120px rgba(255, 215, 0, 0.85);
    }
}


/* Pulso solo con transform, manteniendo color del estado base */
.rosco-letter.state-correct.active,
.rosco-letter.state-incorrect.active,
.rosco-letter.state-pass.active {
    border-color: #ffd700;
}

/* =========================
   TÍTULO EN EL CENTRO DEL ROSCO
   ========================= */
.rosco-center-title {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 640px;
    text-align: center;
    font-family: 'Poppins', sans-serif;
    font-size: 72px;
    font-weight: 800;
    letter-spacing: 3px;
    color: #f0f0f0;
    line-height: 1.1;
    text-shadow: 0 0 24px rgba(255, 215, 0, 0.55), 0 0 6px rgba(240,240,240,0.25);
    z-index: 4;
    pointer-events: none;
}

/* =========================
   PANEL CENTRAL (aparece al seleccionar una letra)
   ========================= */
.rosco-center-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 700px;
    height: 620px;
    margin: -310px 0 0 -350px;
    background: rgba(10, 10, 30, 0.88);
    border: 2px solid rgba(255, 215, 0, 0.35);
    border-radius: 24px;
    padding: 28px 36px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    box-shadow: 0 0 45px rgba(255, 215, 0, 0.25), inset 0 0 40px rgba(0,0,0,0.45);
    z-index: 6;
    animation: roscoFadeIn 0.5s ease;
    gap: 18px;
}

@keyframes roscoFadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    to   { opacity: 1; transform: translate(0,0) scale(1); }
}

.rosco-big-letter {
    font-size: 92px;
    font-weight: 800;
    line-height: 1;
    color: #ffd700;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.9);
    margin-top: -4px;
    flex: 0 0 auto;
}

.rosco-definition {
    font-size: 38px;
    font-weight: 400;
    text-align: center;
    color: #f0f0f0;
    line-height: 1.2;
    padding: 0 4px;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

/* Reducción automática cuando la definición es muy larga */
.rosco-definition.is-long { font-size: 32px; line-height: 1.18; }
.rosco-definition.is-xlong { font-size: 28px; line-height: 1.15; }

.rosco-answer {
    font-size: 48px;
    font-weight: 800;
    color: #00ff88;
    text-shadow: 0 0 22px #00ff88, 0 0 40px rgba(0, 255, 136, 0.55);
    text-align: center;
    display: none;
    animation: roscoFadeIn 0.4s ease;
    line-height: 1.1;
    flex: 0 0 auto;
}

.rosco-hint {
    font-size: 22px;
    font-weight: 400;
    color: rgba(240,240,240,0.65);
    font-style: italic;
    text-align: center;
}

/* Pista de teclas 1/2/3 debajo del panel central */
.rosco-keys-hint {
    font-size: 20px;
    color: rgba(240, 240, 240, 0.55);
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.rosco-keys-hint .key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 18px;
    color: #0a0a2e;
    background: #f0f0f0;
    box-shadow: 0 0 10px rgba(240, 240, 240, 0.3);
    margin-right: 4px;
}

.rosco-keys-hint .key-correct   { background: #00ff88; color: #001a0f; box-shadow: 0 0 10px rgba(0, 255, 136, 0.5); }
.rosco-keys-hint .key-incorrect { background: #ff3333; color: #f0f0f0; box-shadow: 0 0 10px rgba(255, 51, 51, 0.5); }
.rosco-keys-hint .key-pass      { background: #ff9900; color: #1a0a00; box-shadow: 0 0 10px rgba(255, 153, 0, 0.5); }

.rosco-keys-hint .sep { opacity: 0.5; }

/* Variante agrandada para la pantalla de inicio */
.rosco-keys-hint--start {
    font-size: 28px;
    margin-top: 20px;
    color: rgba(240, 240, 240, 0.75);
    gap: 12px;
}

.rosco-keys-hint--start .key {
    width: 44px;
    height: 44px;
    font-size: 24px;
}

/* =========================
   TEMPORIZADOR
   ========================= */
.rosco-timer {
    position: absolute;
    top: 40px;
    right: 40px;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 8;
    display: none; /* oculto por defecto, se activa via JS */
}

.rosco-timer.is-visible { display: flex; }

.rosco-timer-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 80px;
    height: 80px;
    transform: rotate(-90deg);
}

.rosco-timer-track {
    fill: none;
    stroke: rgba(240,240,240,0.15);
    stroke-width: 6;
}

.rosco-timer-progress {
    fill: none;
    stroke: #ffd700;
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 283;   /* 2*pi*r, r=45 */
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
    filter: drop-shadow(0 0 6px rgba(255,215,0,0.7));
}

.rosco-timer-progress.warning { stroke: #ff9900; filter: drop-shadow(0 0 8px rgba(255,153,0,0.8)); }
.rosco-timer-progress.danger  { stroke: #ff3333; filter: drop-shadow(0 0 10px rgba(255,51,51,0.9)); }

.rosco-timer-text {
    font-size: 40px;
    font-weight: 800;
    color: #ffd700;
    text-shadow: 0 0 12px rgba(255,215,0,0.7);
    line-height: 1;
    z-index: 1;
}

/* =========================
   OVERLAYS INICIO / FINAL
   ========================= */
.rosco-start-overlay,
.rosco-final-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(0,0,30,0.95) 0%, rgba(0,0,0,0.98) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
    z-index: 20;
}

.rosco-start-overlay h2,
.rosco-final-overlay h2 {
    font-size: 72px;
    font-weight: 800;
    color: #ffd700;
    text-shadow: 0 0 30px rgba(255,215,0,0.75);
    margin: 0;
    text-align: center;
}

.rosco-final-score {
    font-size: 56px;
    font-weight: 600;
    color: #00ff88;
    text-shadow: 0 0 25px rgba(0,255,136,0.75);
}

.rosco-start-btn,
.rosco-restart-btn {
    padding: 24px 80px;
    font-size: 36px;
    font-weight: 800;
    letter-spacing: 4px;
    background: transparent;
    color: #ffd700;
    border: 3px solid #ffd700;
    border-radius: 16px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
    text-shadow: 0 0 18px rgba(255,215,0,0.7);
    box-shadow: 0 0 30px rgba(255,215,0,0.35), inset 0 0 30px rgba(255,215,0,0.08);
}

.rosco-start-btn:hover,
.rosco-restart-btn:hover {
    background: rgba(255, 215, 0, 0.15);
    box-shadow: 0 0 50px rgba(255,215,0,0.8), inset 0 0 30px rgba(255,215,0,0.2);
    transform: scale(1.05);
}

/* Utilidades */
.rosco-hidden { display: none !important; }
.rosco-invisible { visibility: hidden; }

/* Plantilla fullscreen: elimina márgenes por defecto del body */
body.rosco-fullscreen-body {
    margin: 0;
    padding: 0;
    background: #000;
    overflow: hidden;
}

body.rosco-fullscreen-body .rosco-viewport {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    aspect-ratio: auto;
    z-index: 1;
}
