/* AirConsole: Prevenir selección y highlight táctil */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

/* Variables chalk + AirConsole safe areas - contenido dentro de la pizarra */
:root {
    --chalk-white: rgba(255, 255, 255, 0.92);
    --chalk-white-soft: rgba(255, 255, 255, 0.78);
    --chalk-border: 2px solid var(--chalk-white);
    /* AirConsole: respetar notch + barra AirConsole + margen (reglas .cursor) */
    --airconsole-safe-top: max(env(safe-area-inset-top, 0px), 50px, 12px);
    --airconsole-safe-bottom: max(env(safe-area-inset-bottom, 0px), 12px);
    --airconsole-safe-left: max(env(safe-area-inset-left, 0px), 12px);
    --airconsole-safe-right: max(env(safe-area-inset-right, 0px), 12px);
    /* AirConsole: botones mínimo 44px, óptimo 60px (accesibilidad táctil) */
    --btn-min-size: 44px;
    --btn-optimal-size: 60px;
    /* Margen pizarra: contenido nunca toca bordes marrones/negros */
    --pizarra-margin: clamp(4%, 5vw, 8%);
    --pizarra-margin-min: 14px;
    /* Contenedor máximo: fluido para PC/laptop/tablet/teléfono */
    --container-max: clamp(280px, 92vw, 420px);
}

/* Tipografía: Caveat Brush para cuerpo, Cabin Sketch para títulos */
.chalk-font,
.chalk-font *,
.chalk-font input,
.chalk-font button,
.chalk-font p,
.chalk-font span,
.chalk-font div,
.chalk-font label,
html,
body {
    font-family: 'Caveat Brush', cursive, sans-serif;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

.chalk-font h1,
.chalk-font h2,
.chalk-font h3,
.chalk-font .chalk-title,
h1, h2, h3, .chalk-title {
    font-family: 'Cabin Sketch', cursive, sans-serif;
}

.chalk-font .chalk-body,
.chalk-body {
    font-family: 'Caveat Brush', cursive, sans-serif;
}

/* Efecto tiza para texto */
.chalk-font .chalk-texture,
.chalk-font h1,
.chalk-font h2,
.chalk-font .font-black,
.chalk-font .font-bold {
    text-shadow: 
        0 1px 1px rgba(255, 255, 255, 0.12),
        0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Chalkboard safe area - TODO el contenido DENTRO de la pizarra, sin tocar bordes marrones/negros */
.chalkboard-safe-area {
    padding-top: max(var(--airconsole-safe-top), var(--pizarra-margin), var(--pizarra-margin-min));
    padding-bottom: max(var(--airconsole-safe-bottom), var(--pizarra-margin), var(--pizarra-margin-min));
    padding-left: max(var(--airconsole-safe-left), var(--pizarra-margin), var(--pizarra-margin-min));
    padding-right: max(var(--airconsole-safe-right), var(--pizarra-margin), var(--pizarra-margin-min));
    box-sizing: border-box;
    max-width: 100vw;
    overflow-x: hidden;
}

@media (max-height: 600px) {
    .chalkboard-safe-area {
        padding-top: max(var(--airconsole-safe-top), 3%, 14px);
        padding-bottom: max(var(--airconsole-safe-bottom), 3%, 14px);
    }
}

/* Pantallas muy cortas: mantener margen mínimo para bordes */
@media (max-height: 500px) {
    .chalkboard-safe-area {
        padding-top: max(var(--airconsole-safe-top), 2.5%, 12px);
        padding-bottom: max(var(--airconsole-safe-bottom), 2.5%, 12px);
        padding-left: max(var(--airconsole-safe-left), 3%, 12px);
        padding-right: max(var(--airconsole-safe-right), 3%, 12px);
    }
}

html, body {
    width: 100%;
    max-width: 100vw;
    height: 100%;
    overflow: hidden;
    overflow-x: hidden;
    background-color: #3d2318;
}

/* AirConsole: Contenedor fijo para evitar scroll/bounce en móvil */
body {
    position: fixed;
    top: 0;
    left: 0;
    touch-action: manipulation;
    overscroll-behavior: none;
    -webkit-font-smoothing: antialiased;
    background: url('assets/images/Pizarra%20.webp') center center / cover no-repeat fixed;
}

/* ========================================
   SCREENS - Mobile First, AirConsole compliant
   ======================================== */
.screen {
    display: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    padding: clamp(0.5rem, 2vw, 1rem);
    padding-top: max(clamp(0.5rem, 2vh, 1rem), env(safe-area-inset-top, 0px));
    padding-bottom: max(clamp(0.5rem, 2vh, 1rem), env(safe-area-inset-bottom, 0px));
    padding-left: max(clamp(0.5rem, 2vw, 1rem), env(safe-area-inset-left, 0px));
    padding-right: max(clamp(0.5rem, 2vw, 1rem), env(safe-area-inset-right, 0px));
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

/* Confetti */
@keyframes confettiFall {
    0% { transform: translateY(-10vh) rotateZ(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotateZ(360deg); opacity: 0; }
}
.confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 9999;
}
.confetti-piece {
    position: absolute;
    width: 10px;
    height: 18px;
    border-radius: 2px;
    opacity: 0.9;
    animation: confettiFall 2.6s ease-out forwards;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* Join: contenido dentro de pizarra */
#joinScreen {
    overflow: hidden;
    min-height: 0;
}

.join-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding-top: clamp(1.5rem, 5vh, 2.5rem); /* Espacio para no chocar con AirConsole */
}

.join-logo {
    width: clamp(3rem, min(12vw, 14vh), 5rem);
    height: clamp(3rem, min(12vw, 14vh), 5rem);
}

.join-title {
    line-height: 1;
    color: #FFFFFF !important;
    font-size: clamp(2rem, min(7vw, 8vh), 3.5rem);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.join-subtitle {
    color: #FFFFFF !important;
    font-size: clamp(1.05rem, min(4vw, 4vh), 1.5rem);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.join-rules {
    overflow: hidden;
    max-width: var(--container-max);
}

.join-footer {
    max-width: var(--container-max);
    padding-bottom: clamp(1rem, 4vh, 1.75rem); /* Separar botón del borde inferior */
}

/* Tarjetas de reglas - tipografía fluida */
.join-rule-card h3 {
    font-size: clamp(0.95rem, 3.8vw, 1.2rem);
}

.join-rule-card p {
    font-size: clamp(0.82rem, 3.1vw, 1.03rem);
}

#joinBtn {
    font-size: clamp(1rem, 4.2vw, 1.35rem);
    letter-spacing: 0.012em;
    line-height: 1.08;
}

/* Waiting screen: permitir scroll, ancho fluido */
#waitingScreen {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: clamp(0.5rem, 2vh, 1rem);
}

.waiting-content {
    max-width: var(--container-max);
}

#waitingScreen #playerAvatar {
    width: clamp(3rem, 15vw, 4rem);
    height: clamp(3rem, 15vw, 4rem);
    min-width: 3rem;
    min-height: 3rem;
}

#waitingScreen .bounce-anim {
    font-size: clamp(2rem, 8vw, 3rem);
}

#waitingScreen #playerNameDisplay {
    font-size: clamp(1.05rem, 4.4vw, 1.4rem);
}

#waitingScreen .chalk-box p {
    font-size: clamp(1.02rem, 3.9vw, 1.28rem);
}

/* Waiting screen - compacto en landscape */
@media (max-height: 600px) {
    #waitingScreen .mb-6 { margin-bottom: clamp(0.5rem, 2vh, 0.75rem) !important; }
    #waitingScreen .mb-4 { margin-bottom: 0.4rem !important; }
    #waitingScreen #playerAvatar { width: 2.75rem !important; height: 2.75rem !important; }
    #waitingScreen .bounce-anim { font-size: 1.75rem !important; }
    #waitingScreen .my-4 { margin: clamp(0.35rem, 1.5vh, 0.5rem) 0 !important; }
    #waitingScreen .py-4, #waitingScreen .px-6 { padding: clamp(0.4rem, 1.5vh, 0.6rem) !important; }
    #waitingScreen .chalk-box p { font-size: 0.85rem !important; }
}
@media (max-height: 500px) {
    #waitingScreen .mb-6 { margin-bottom: 0.4rem !important; }
    #waitingScreen .bounce-anim { font-size: 1.5rem !important; }
}

@media (max-width: 360px) {
    .waiting-content { padding-left: 0.5rem; padding-right: 0.5rem; }
}

/* Icono de categoría seleccionada - mismo estilo chalk que el screen */
#selectedCategoryEmoji,
#selectedCategoryDisplay .category-icon-img {
    filter: brightness(0) invert(1) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

@media (max-height: 500px) {
    .join-rules { overflow-y: auto; -webkit-overflow-scrolling: touch; }
}

/* Pantallas muy cortas (landscape): join screen compacto */
@media (max-height: 600px) {
    .join-logo { width: clamp(2.4rem, 9.5vw, 3.1rem); height: clamp(2.4rem, 9.5vw, 3.1rem); }
    .join-title { font-size: clamp(1.6rem, min(6vw, 7vh), 2.25rem); }
    .join-subtitle { font-size: clamp(0.95rem, min(3.5vw, 4vh), 1.2rem); }
    .join-rules { gap: clamp(0.25rem, 1vh, 0.4rem); }
    .join-rule-card { padding: clamp(0.35rem, 1.5vw, 0.5rem) !important; }
    .join-rule-card h3 { font-size: clamp(0.76rem, 2.9vw, 0.92rem) !important; }
    .join-rule-card p { font-size: clamp(0.66rem, 2.5vw, 0.82rem) !important; }
    #joinBtn { 
        min-height: var(--btn-min-size) !important; 
        padding: clamp(0.5rem, 2vh, 0.75rem) 1rem !important; 
        font-size: clamp(0.95rem, 3.9vw, 1.06rem) !important; 
    }
}

/* Teléfonos muy estrechos (320px típico) */
@media (max-width: 360px) {
    :root { --container-max: 100%; }
    .join-header { gap: 0.15rem; }
    .join-rules, .join-footer { padding: 0 0.25rem; }
    .join-title { font-size: clamp(1.85rem, 8vw, 2.5rem); }
    .join-subtitle { font-size: clamp(1rem, 4.5vw, 1.25rem); }
}

/* Tablets (600px+) */
@media (min-width: 600px) {
    :root { --container-max: min(90vw, 480px); }
    .join-rules, .join-footer { max-width: var(--container-max); }
    .join-logo { width: clamp(3.25rem, 6.4vw, 4.3rem); height: clamp(3.25rem, 6.4vw, 4.3rem); }
    .join-title { font-size: clamp(2.5rem, 5vw, 3.5rem); }
    .join-subtitle { font-size: clamp(1.2rem, 3vw, 1.5rem); }
    .join-rule-card { padding: clamp(0.5rem, 1.5vw, 0.75rem) !important; }
    .join-rule-card h3 { font-size: clamp(1rem, 2vw, 1.18rem) !important; }
    .join-rule-card p { font-size: clamp(0.82rem, 1.7vw, 0.98rem) !important; }
    #joinBtn { padding: clamp(0.65rem, 2vh, 0.9rem) 1.5rem !important; font-size: clamp(1.05rem, 2.1vw, 1.2rem) !important; }
}

/* Laptops (1024px+) */
@media (min-width: 1024px) {
    :root { --container-max: min(85vw, 560px); }
    .chalkboard-safe-area { padding: clamp(1.5rem, 3vw, 2.5rem); }
    .screen { padding: clamp(1rem, 2vw, 1.5rem); }
    .join-logo { width: clamp(4rem, 5.4vw, 5.6rem); height: clamp(4rem, 5.4vw, 5.6rem); }
    .join-title { font-size: clamp(2.75rem, 4.5vw, 4rem); }
    .join-subtitle { font-size: clamp(1.25rem, 2vw, 1.6rem); }
    .join-rule-card h3 { font-size: clamp(1.08rem, 1.65vw, 1.26rem) !important; }
    .join-rule-card p { font-size: clamp(0.92rem, 1.35vw, 1.06rem) !important; }
    #joinBtn { padding: 0.9rem 2rem !important; font-size: 1.24rem !important; }
    .answer-btn { font-size: clamp(1.5rem, 2.5vw, 2.25rem); }
    .answer-grid { gap: 0.75rem; min-height: clamp(140px, 35vh, 260px); }
    .chalk-readable { font-size: clamp(1.25rem, 2vw, 1.5rem); }
    .chalk-subtitle { font-size: clamp(1rem, 1.6vw, 1.2rem); }
    .chalk-player-card-mini { padding: 0.6rem 1rem; font-size: clamp(0.9rem, 1.2vw, 1rem); }
    .wizard-content { max-width: min(90vw, 640px); }
    .waiting-content { max-width: var(--container-max); }
}

/* Desktop / PC (1280px+) */
@media (min-width: 1280px) {
    :root { --container-max: min(80vw, 600px); }
    .chalkboard-safe-area { padding: clamp(2rem, 4vw, 3rem); }
    .join-title { font-size: clamp(3rem, 4vw, 4.5rem); }
    .join-subtitle { font-size: clamp(1.35rem, 1.8vw, 1.75rem); }
}

/* Pantallas grandes (1536px+) */
@media (min-width: 1536px) {
    :root { --container-max: min(75vw, 680px); }
    .join-title { font-size: clamp(3.5rem, 4.5vw, 5rem); }
    .join-subtitle { font-size: clamp(1.5rem, 2vw, 1.9rem); }
}

/* Playing screen: margen superior para AirConsole (jugadores no-admin), inferior para tarjeta */
#playingScreen {
    padding-top: max(var(--airconsole-safe-top), 1rem, env(safe-area-inset-top, 0px));
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    padding-left: clamp(12px, 4vw, 18px);
    padding-right: clamp(12px, 4vw, 18px);
    overflow: hidden;
}

/* Playing header: SALIR (izq, solo admin) y Sonido (der) en una sola línea - mismo layout admin y no-admin */
.playing-header,
#playingHeader {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: clamp(0.75rem, 3vw, 1.25rem);
    width: 100%;
    max-width: 540px;
    padding: 0 clamp(8px, 4vw, 16px);
    margin: 0 auto;
}

@media (max-width: 360px) {
    #playingHeader {
        gap: 0.5rem;
        padding: 0 clamp(8px, 3vw, 14px);
    }
    #exitGameBtn {
        padding-inline: 10px;
    }
}

/* Espaciado entre elementos - responsivo */
.playing-screen-spaced {
    gap: clamp(0.5rem, 2vh, 1rem);
    align-items: center;
}

/* Cuando está activa: layout flex sin scroll - contenido adaptado al viewport */
#playingScreen.active {
    overflow: hidden;
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Header y footer fijos para que el grid de respuestas use el espacio restante */
#playingScreen > .text-left,
#playingScreen > .text-center {
    flex-shrink: 0;
}

#playingScreen .text-center.mb-3 {
    margin-bottom: clamp(0.5rem, 1.5vh, 0.75rem);
    padding-top: 0.15rem;
    min-height: 0;
}

#playingScreen .text-center,
#playingScreen .answer-grid,
#playingScreen .chalk-player-card-mini {
    width: 100%;
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
}

/* AirConsole: Botones táctiles mínimo 44px, óptimo 60px (reglas .cursor) */
.chalk-btn,
#joinBtn {
    min-height: var(--btn-min-size);
}

.chalk-answer-btn {
    min-height: var(--btn-min-size);
    min-width: var(--btn-min-size);
}

/* Botones de icono (sonido): mínimo 44px táctil */
#soundToggleBtn,
#soundToggleBtnPlaying {
    min-width: var(--btn-min-size) !important;
    min-height: var(--btn-min-size) !important;
    width: var(--btn-optimal-size);
    height: var(--btn-optimal-size);
}

.sound-toggle-btn {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.sound-icon-img {
    width: clamp(2.35rem, 10vw, 3.25rem);
    height: clamp(2.35rem, 10vw, 3.25rem);
    object-fit: contain;
}

/* Badge Admin */
.admin-badge {
    background: transparent !important;
    border: 2px solid rgba(255, 255, 255, 0.9) !important;
    color: rgba(255, 255, 255, 0.95);
    box-shadow: none !important;
}
.admin-crown-img {
    width: 1.35rem;
    height: 1.35rem;
    object-fit: contain;
}
.admin-label {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: rgba(255, 255, 255, 0.95);
}

.join-action-icon {
    width: clamp(1.55rem, 6vw, 2.3rem);
    height: clamp(1.55rem, 6vw, 2.3rem);
    object-fit: contain;
}

.waiting-avatar-icon {
    width: clamp(1.7rem, 7vw, 2.35rem);
    height: clamp(1.7rem, 7vw, 2.35rem);
    object-fit: contain;
}

.waiting-clock-icon {
    width: clamp(2.1rem, 9vw, 3rem);
    height: clamp(2.1rem, 9vw, 3rem);
    object-fit: contain;
}

/* ========================================
   WIZARD PROGRESS BAR
   ======================================== */
.step-label-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    opacity: 0.4;
    transition: all 0.3s ease;
}

.step-label-item.active,
.step-label-item.completed {
    opacity: 1;
}

.step-dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.step-label-item.active .step-dot {
    background: #0595AE;
    box-shadow: 0 0 0 3px rgba(5, 149, 174, 0.3);
}

.step-label-item.completed .step-dot {
    background: #73A03F;
}

.step-text {
    font-size: clamp(0.85rem, 2.8vw, 1.15rem);
    color: rgba(255, 255, 255, 0.85);
    font-weight: 600;
    transition: all 0.3s ease;
}

/* Botones +/- preguntas: mínimo 44px táctil */
#decreaseQuestions,
#increaseQuestions {
    min-width: var(--btn-min-size);
    min-height: var(--btn-min-size);
    width: var(--btn-optimal-size);
    height: var(--btn-optimal-size);
}

.step-label-item.active .step-text {
    color: rgba(255, 255, 255, 0.98);
    font-weight: 700;
}

.step-label-item.completed .step-text {
    color: rgba(255, 255, 255, 0.9);
}

/* Chalk box, buttons - controller */
.chalk-box {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chalk-btn:disabled,
.chalk-answer-btn:disabled {
    opacity: 0.5;
}

/* Texto legible - Pregunta X de Y, Selecciona tu respuesta (font más legible para UI) */
.chalk-readable {
    font-family: 'Caveat Brush', cursive, sans-serif !important;
    font-size: clamp(1.45rem, min(5.6vw, 5vh), 2.05rem); /* +25% legibilidad */
    color: rgba(255, 255, 255, 0.98);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.02em;
}

.chalk-subtitle {
    font-family: 'Caveat Brush', cursive, sans-serif !important;
    font-size: clamp(1.2rem, min(4.8vw, 4.4vh), 1.65rem); /* +25% */
    color: rgba(255, 255, 255, 0.95);
}

/* Tarjeta jugador en playing - estilo chalk, margen inferior para no tocar bordes */
.chalk-player-card-mini {
    background: transparent !important;
    border: 2px solid rgba(255, 255, 255, 0.75);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: env(safe-area-inset-bottom, 0px);
    flex-wrap: nowrap;
    gap: 0.6rem;
}

.chalk-player-card-mini .flex-1 {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.chalk-player-card-mini #miniName,
.chalk-player-card-mini #miniRank,
.chalk-player-card-mini #miniScore {
    white-space: nowrap;
}

/* Playing screen: responsivo, botones 44px mínimo (AirConsole accesibilidad) */
@media (max-height: 600px) {
    #playingScreen .chalk-player-card-mini {
        padding: 0.5rem 0.75rem;
        margin-top: 0.5rem;
    }
    #playingScreen .answer-grid {
        min-height: clamp(88px, 20vh, 140px);
        grid-template-rows: repeat(2, minmax(44px, 1fr));
    }
    #playingScreen .answer-btn {
        min-height: 44px;
        font-size: clamp(1.55rem, 6vw, 2.5rem); /* +24% */
    }
    #playingScreen .text-center.mb-3 {
        margin-bottom: 0.35rem;
        padding-top: 0.15rem;
    }
    #playingScreen .chalk-readable, #playingScreen .chalk-subtitle {
        font-size: clamp(1.25rem, 4.4vw, 1.7rem); /* +25% */
    }
}
@media (max-height: 500px) {
    #playingScreen .answer-grid {
        min-height: 88px;
    }
    #playingScreen .answer-btn {
        min-height: 44px;
    }
}

.chalk-score-badge {
    background: rgba(235, 130, 37, 0.85) !important;
    border: 1px solid #EB8225;
    font-size: clamp(1rem, 3.5vw, 1.3rem); /* +25% */
}

/* ========================================
   STEP CONTENT
   ======================================== */
.step-content {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    position: relative;
    width: 100%;
}

.step-content.active {
    display: flex;
    flex-direction: column;
    opacity: 1;
}

.step-content:not(.active) {
    visibility: hidden;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

/* Step 1 específico - necesita flex para el scroll de categorías */
#step2.active {
    flex: 1;
}

#categoryScrollContainer {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Category Select Screen - wizard, contenido en pizarra (solo cuando .active) */
#categorySelectScreen.active {
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#categorySelectScreen > .relative,
.wizard-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 48px);
    max-width: var(--container-max);
    width: 100%;
}

/* Paso 3: espacio extra para que el botón no se corte en la parte inferior */
#step4 {
    padding-bottom: clamp(1.5rem, 7vh, 3.5rem);
}

.final-summary {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: clamp(0.5rem, 2vw, 1.25rem);
    width: 100%;
    min-width: 0;
}

.summary-icon {
    flex-shrink: 0;
}

.summary-icon img {
    width: clamp(3rem, 12vw, 4rem);
    height: clamp(3rem, 12vw, 4rem);
}

.summary-details {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(0.35rem, 1.5vw, 0.75rem);
}

/* Siempre horizontal: Categoría y Preguntas en una fila */
.summary-details-horizontal {
    flex: 1;
    min-width: 0;
    width: 100%;
}

.final-summary .summary-details > div {
    min-width: 0;
    padding: clamp(0.5rem, 2vw, 0.75rem) clamp(0.5rem, 2vw, 0.75rem);
}

.final-summary .summary-details span {
    font-size: clamp(0.7rem, 2.5vw, 0.875rem);
}

.final-summary .summary-details .font-bold {
    font-size: clamp(0.8rem, 3vw, 1rem);
}

/* Pantallas muy estrechas: icono arriba, cards abajo en una fila */
@media (max-width: 520px) {
    .final-summary {
        flex-direction: column;
    }
    .summary-icon {
        order: -1;
    }
    .summary-details-horizontal {
        width: 100%;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Móviles muy estrechos (< 360px): Categoría y Preguntas se apilan */
@media (max-width: 360px) {
    .summary-details-horizontal {
        grid-template-columns: 1fr;
    }
}

/* Atrás y Salir en una línea; ¡INICIAR JUEGO! debajo */
.final-actions {
    display: flex;
    flex-direction: column;
    gap: clamp(0.6rem, 2vw, 1rem);
    width: 100%;
}

.final-actions-row {
    width: 100%;
}

/* ========================================
   DIFFICULTY GRID
   ======================================== */
.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(0.4rem, 2vw, 0.75rem);
}

.difficulty-btn {
    border: var(--chalk-border);
    background: transparent;
    border-radius: 0.75rem;
    padding: clamp(0.65rem, 2vw, 0.9rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    min-height: max(72px, var(--btn-min-size));
    transition: all 0.2s ease;
    color: rgba(255,255,255,0.92);
}

.difficulty-btn .difficulty-title {
    font-size: clamp(1.05rem, 4vw, 1.35rem);
    font-weight: 700;
    line-height: 1.1;
}

.difficulty-btn .difficulty-sub {
    font-size: clamp(0.72rem, 2.7vw, 0.9rem);
    color: rgba(255,255,255,0.75);
}

.difficulty-btn.selected {
    border-color: #73A03F;
    box-shadow: 0 0 20px rgba(115, 160, 63, 0.25);
    transform: translateY(-1px);
}

.difficulty-btn.selected .difficulty-sub {
    color: rgba(255,255,255,0.9);
}

@media (max-width: 420px) {
    .difficulty-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   CATEGORY GRID - Responsive
   ======================================== */
#categoryGrid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(0.35rem, 2vw, 0.6rem);
    padding: clamp(0.4rem, 1.5vw, 0.6rem) 0;
}

@media (max-width: 360px) {
    #categoryGrid { gap: 0.3rem; padding: 0.35rem 0; }
}

@media (min-width: 768px) {
    #categoryGrid {
        grid-template-columns: repeat(4, 1fr);
        gap: clamp(0.4rem, 1vw, 0.75rem);
    }
}

@media (min-width: 1024px) {
    #categoryGrid {
        gap: 0.75rem;
        padding: 0.75rem 0;
    }
    .category-btn .category-icon-img {
        width: clamp(2.5rem, 4vw, 3.5rem);
        height: clamp(2.5rem, 4vw, 3.5rem);
    }
    .category-btn .category-name {
        font-size: clamp(1rem, 1.5vw, 1.2rem);
    }
}

.category-btn {
    position: relative;
    min-height: max(clamp(56px, 15vh, 80px), var(--btn-min-size));
    padding: clamp(0.35rem, 1.5vw, 0.5rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: var(--chalk-border);
    border-radius: 0.75rem;
    gap: 0.25rem;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.category-btn:active {
    transform: scale(0.95);
}

.category-btn:not(.selected):hover:active {
    transform: translateY(-2px) scale(0.95);
}

.category-btn .category-icon,
.category-btn .category-icon-img {
    transition: filter 0.2s ease;
}

.category-btn .category-icon-img {
    width: clamp(2.75rem, 9vw, 4.5rem);
    height: clamp(2.75rem, 9vw, 4.5rem);
    min-width: 2.5rem;
    min-height: 2.5rem;
    object-fit: contain;
}

/* Iconos estilo chalk sobre pizarra */
.category-btn:not(.selected) .category-icon-img {
    filter: brightness(0) invert(1) opacity(0.85) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.category-btn.selected .category-icon-img {
    filter: brightness(0) invert(1) drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
}

.category-btn .category-icon {
    font-size: 1.5rem;
    color: var(--chalk-white-soft);
}

.category-btn .category-name {
    font-size: clamp(1.15rem, 4.6vw, 1.6rem);
    line-height: 1.2;
    text-align: center;
    font-weight: 600;
    color: var(--chalk-white-soft);
}

/* Hover: igual que screen (translateY, scale icono) */
.category-btn:not(.selected):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.category-btn:not(.selected):hover .category-icon-img {
    transform: scale(1.08);
}

.category-btn .category-icon-img {
    transition: transform 0.2s ease;
}

.category-btn.selected {
    border-width: 3px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

.category-btn.selected .category-icon,
.category-btn.selected .category-name {
    color: var(--chalk-white);
}

/* Checkmark de selección - mismo estilo que screen */
.category-btn .selection-check {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: 2px solid;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.95);
    background: transparent;
}

.category-btn.selected .selection-check {
    display: flex;
}

/* ========================================
   ANSWER GRID - Responsive 2x2
   ======================================== */
.answer-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, minmax(var(--btn-min-size), 1fr));
    gap: clamp(0.4rem, 2vw, 0.8rem);
    flex: 1;
    min-height: clamp(120px, 30vh, 240px);
}

.answer-btn {
    font-family: 'Caveat Brush', cursive, sans-serif !important;
    font-size: clamp(1.7rem, min(6vw, 7.5vh), 3.1rem); /* +25% aprox */
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--btn-min-size);
}

.answer-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, transparent 100%);
    border-radius: 0.75rem 0.75rem 0 0;
    pointer-events: none;
}

.answer-btn.selected {
    transform: translateY(4px);
}

.answer-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========================================
   AVATARS - Responsive
   ======================================== */
.player-avatar-visual {
    width: clamp(3rem, min(15vw, 12vh), 5rem);
    height: clamp(3rem, min(15vw, 12vh), 5rem);
    border-radius: 0.75rem;
    position: relative;
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
}

.player-avatar-visual::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    height: 12px;
    background: rgba(255,255,255,0.35);
    border-radius: 9px 9px 0 0;
}

.player-avatar-visual-small {
    width: clamp(2rem, min(6vw, 5vh), 3rem);
    height: clamp(2rem, min(6vw, 5vh), 3rem);
    min-width: 2rem;
    min-height: 2rem;
    border-radius: 0.5rem;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.player-avatar-visual-small::before {
    content: '';
    position: absolute;
    height: 8px;
    top: 3px;
    left: 3px;
    right: 3px;
    border-radius: 5px 5px 0 0;
    background: rgba(255,255,255,0.35);
}

/* ========================================
   3D BUTTONS
   ======================================== */
.btn-3d {
    transition: all 0.08s ease;
}

.btn-3d:active:not(:disabled) {
    transform: translateY(4px);
}

.btn-verde { box-shadow: 0 4px 0 #5a8030; }
.btn-verde:active:not(:disabled) { box-shadow: 0 1px 0 #5a8030; }

.btn-morado { box-shadow: 0 4px 0 #8a3070; }
.btn-morado:active:not(:disabled) { box-shadow: 0 1px 0 #8a3070; }

.btn-turquesa { box-shadow: 0 4px 0 #047a91; }
.btn-turquesa:active:not(:disabled) { box-shadow: 0 1px 0 #047a91; }

.btn-naranja { box-shadow: 0 4px 0 #c46d1d; }
.btn-naranja:active:not(:disabled) { box-shadow: 0 1px 0 #c46d1d; }

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.correct-highlight { animation: correctPulse 0.4s ease infinite; }
.wrong-highlight { animation: wrongShake 0.4s ease; }

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.bounce-anim { 
    animation: bounce 1s ease infinite;
    display: inline-block;
}

@keyframes popIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.pop-in { 
    animation: popIn 0.25s ease forwards;
    display: block;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.02); }
}

.pulse {
    animation: pulse 2s ease infinite;
    display: inline-flex;
}

/* ========================================
   BACKGROUND PARTICLES
   ======================================== */
.bg-particles {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0.4;
    animation: floatParticle 15s infinite ease-in-out;
    will-change: transform;
}

@keyframes floatParticle {
    0%, 100% { transform: translate(0, 0) rotate(0deg); opacity: 0.4; }
    25% { transform: translate(30px, -30px) rotate(90deg); opacity: 0.6; }
    50% { transform: translate(0, -60px) rotate(180deg); opacity: 0.4; }
    75% { transform: translate(-30px, -30px) rotate(270deg); opacity: 0.6; }
}

/* ========================================
   RESULT OVERLAY - dentro de safe area
   ======================================== */
#resultOverlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-sizing: border-box;
}

#resultOverlay.hidden {
    pointer-events: none;
    visibility: hidden;
}

#resultContent {
    word-break: break-word;
    color: rgba(255, 255, 255, 0.95);
}

/* End screen - responsive para todos los dispositivos */
#endScreen #finalRank {
    font-size: clamp(3.25rem, min(15.5vw, 13vh), 5.85rem); /* +30% */
}

#endScreen #finalMessage {
    font-size: clamp(1.3rem, min(5.2vw, 4.6vh), 1.75rem); /* +30% */
}

#endScreen #finalScore {
    font-size: clamp(1.4rem, min(5.8vw, 5vh), 1.95rem); /* +30% */
}

#endScreen .result-prize {
    background: transparent;
    border: 2px solid rgba(255,255,255,0.35);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: clamp(4.6rem, 15vw, 7rem);
    height: clamp(4.6rem, 15vw, 7rem);
}

#endScreen .result-prize iconify-icon {
    font-size: 3.4rem !important; /* +30% sobre 2.6rem */
}

@media (max-height: 500px) {
    #endScreen { gap: clamp(0.5rem, 2vh, 1rem) !important; }
    #endScreen .result-prize { width: clamp(4.2rem, 16vw, 6.5rem); height: clamp(4.2rem, 16vw, 6.5rem); }
}

@media (min-width: 1024px) {
    #endScreen #finalRank { font-size: clamp(3.9rem, 5.2vw, 5.8rem); }
    #endScreen #finalMessage { font-size: clamp(1.5rem, 2vw, 1.9rem); }
    #endScreen #finalScore { font-size: clamp(1.55rem, 2.2vw, 2rem); }
    #endScreen .result-prize { width: clamp(6.5rem, 10vw, 8rem); height: clamp(6.5rem, 10vw, 8rem); }
}

/* Desktop: cursor pointer y hover para ratón */
@media (min-width: 1024px) {
    .chalk-btn, .answer-btn, .category-btn {
        cursor: pointer;
    }
    .chalk-btn:hover:not(:disabled), .answer-btn:hover:not(:disabled) {
        transform: translateY(-2px);
    }
}

/* Respetar preferencia de movimiento reducido (reglas .cursor) */
@media (prefers-reduced-motion: reduce) {
    .screen, .step-content, .chalk-btn, .answer-btn { transition-duration: 0.01ms; }
    .bounce-anim, .pulse, .pop-in { animation-duration: 0.01ms; }
}

/* ========================================
   SCROLLBAR - delgado para móvil
   ======================================== */
.overflow-y-auto,
#categoryScrollContainer {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.overflow-y-auto::-webkit-scrollbar,
#categoryScrollContainer::-webkit-scrollbar {
    width: 4px;
}

.overflow-y-auto::-webkit-scrollbar-track,
#categoryScrollContainer::-webkit-scrollbar-track {
    background: transparent;
}

.overflow-y-auto::-webkit-scrollbar-thumb,
#categoryScrollContainer::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
}


/* Accesibilidad: foco visible sin alterar layout */
button:focus-visible,
[role="button"]:focus-visible,
.sound-toggle-btn:focus-visible,
.difficulty-btn:focus-visible,
.answer-btn:focus-visible,
.category-btn:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.92);
    outline-offset: 2px;
}
