:root {
    --mex-red: #d32f2f;
    --mex-red-dark: #9a0007;
    --mex-green: #2e7d32;
    --mex-green-dark: #1b5e20;
    --mex-gold: #fbc02d;
    --mex-gold-bright: #ffeb3b;
    --mex-gold-dark: #c49000;
    --mex-card-border: #2c3e50;
    --mario-coin: #ffd700;
    --mario-coin-shadow: #c68a00;
}

* { 
    box-sizing: border-box; 
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

html, body { 
    height: 100%; 
    width: 100%;
    overflow: hidden; 
    background: radial-gradient(circle at center, #ffd54f 0%, #f57f17 40%, var(--mex-red) 100%);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: #222;
}

/* =================================================== */
/* 1. PANTALLA DE LOBBY / SELECCIÓN DE SALA            */
/* =================================================== */
.lobby-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100svh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 14px 16px;
    z-index: 100;
    background: radial-gradient(circle at center, #ffca28 0%, #e65100 55%, #b71c1c 100%);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* =================================================== */
/* BRAND / TITULO WEB: LoteriaFamiliar.com              */
/* =================================================== */
.lobby-brand-container {
    text-align: center;
    margin-top: auto;
    margin-bottom: 12px;
    flex-shrink: 0;
    z-index: 101;
}

.lobby-brand-title {
    position: relative;
    display: inline-flex;
    align-items: baseline;
    font-family: 'Fredoka', 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: clamp(1.75rem, 6.6vw, 2.45rem);
    font-weight: 900;
    letter-spacing: 0.5px;
    margin: 0;
    line-height: 1.15;
    white-space: nowrap;
    cursor: default;
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.55));
}

.brand-part-loteria {
    color: #00e676;
    -webkit-text-stroke: 2px #003300;
    paint-order: stroke fill;
    text-shadow: 0 3px 0 #004d40, 0 5px 0 #002200;
}

.brand-part-familiar {
    color: #ffffff;
    -webkit-text-stroke: 2px #222222;
    paint-order: stroke fill;
    text-shadow: 0 3px 0 #333333, 0 5px 0 #111111;
    margin-left: 1px;
}

.brand-part-com {
    color: #ff1744;
    -webkit-text-stroke: 2px #5c0000;
    paint-order: stroke fill;
    text-shadow: 0 3px 0 #8b0000, 0 5px 0 #3e0000;
    margin-left: 1px;
}

.lobby-brand-title::after {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        110deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0) 38%,
        rgba(255, 255, 255, 0.95) 50%,
        rgba(255, 255, 255, 0) 62%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 250% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    -webkit-text-stroke: 0px transparent;
    pointer-events: none;
    animation: textShineSweep 3s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes textShineSweep {
    0% {
        background-position: 150% 0;
    }
    38% {
        background-position: -50% 0;
    }
    100% {
        background-position: -50% 0;
    }
}

/* BOTON DE GUIA EN EL LOBBY CARD */
.btn-lobby-guide {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: linear-gradient(135deg, #fff9c4 0%, #ffe082 100%);
    border: 2px solid #ffb300;
    border-radius: 12px;
    color: #4e342e;
    font-size: 0.86rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    transition: all 0.2s ease;
    text-align: left;
    margin-top: 2px;
    margin-bottom: 2px;
    font-family: inherit;
}

.btn-lobby-guide:hover {
    background: linear-gradient(135deg, #fffde7 0%, #ffd54f 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0,0,0,0.14);
}

.btn-lobby-guide:active {
    transform: translateY(1px);
}

.guide-btn-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.guide-btn-text {
    flex: 1;
    line-height: 1.25;
    display: flex;
    flex-direction: column;
}

.guide-btn-text strong {
    color: #bf360c;
    font-size: 0.92rem;
    font-weight: 800;
}

.guide-btn-arrow {
    font-weight: 900;
    color: #e65100;
    font-size: 1rem;
}

.lobby-card {
    background: #ffffff;
    border-radius: 20px;
    width: 100%;
    max-width: 380px;
    max-height: 96vh;
    overflow-y: auto;
    padding: 20px 24px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.4);
    border: 4px solid var(--mex-gold);
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: auto;
    animation: scaleIn 0.3s ease;
}

.lobby-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lobby-logo {
    width: 135px;
    max-width: 65%;
    height: auto;
    aspect-ratio: 1024 / 999;
    object-fit: contain;
    display: block;
    margin: 0 auto 6px auto;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.18));
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    will-change: transform;
}

.lobby-logo:hover {
    animation: logoPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lobby-logo:active,
.lobby-logo.logo-popping {
    animation: logoPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes logoPop {
    0% {
        transform: scale(1) translateZ(0);
    }
    45% {
        transform: scale(1.09) translateZ(0);
    }
    100% {
        transform: scale(1) translateZ(0);
    }
}

.lobby-subtitle {
    font-size: 0.85rem;
    color: #666;
    font-weight: 600;
}

.lobby-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lobby-form-group label {
    font-size: 0.8rem;
    font-weight: 800;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lobby-form-group input, .lobby-select {
    padding: 12px 14px;
    border: 2px solid #ccc;
    border-radius: 10px;
    font-size: 1.05rem;
    font-weight: bold;
    outline: none;
    transition: border-color 0.2s;
    background: #fafafa;
}

.lobby-form-group input:focus, .lobby-select:focus {
    border-color: var(--mex-red);
    background: #fff;
}

.pin-input {
    letter-spacing: 8px;
    text-align: center;
    font-size: 1.8rem !important;
    font-family: 'Courier New', Courier, monospace;
    font-weight: 900 !important;
    color: var(--mex-red-dark);
}

.lobby-tabs {
    display: flex;
    background: #f0f0f0;
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
}

.tab-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    font-weight: 800;
    font-size: 0.85rem;
    color: #666;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: #fff;
    color: var(--mex-red);
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}

.tab-panel {
    display: none;
    flex-direction: column;
    gap: 14px;
}

.tab-panel.active {
    display: flex;
}

.btn-lobby {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 1.05rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 4px rgba(0,0,0,0.25);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-lobby:active {
    transform: translateY(2px);
    box-shadow: 0 2px rgba(0,0,0,0.25);
}

.btn-primary { background: linear-gradient(180deg, #e53935 0%, #b71c1c 100%); }
.btn-success { background: linear-gradient(180deg, #43a047 0%, #1b5e20 100%); }
.btn-secondary { background: #555; }
.btn-danger { background: #d32f2f; }

/* =================================================== */
/* 2. PANTALLA PRINCIPAL DEL JUEGO                     */
/* =================================================== */
.game-wrapper { 
    display: flex;
    flex-direction: column;
    height: 100vh; 
    height: 100svh; 
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
    padding: 6px 8px;
    gap: 5px;
    overflow: hidden;
}

/* Cabecera del juego */
.game-header {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    padding: 4px 10px;
    border-radius: 14px;
    color: white;
    font-size: 0.78rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.room-pill {
    cursor: pointer;
    background: rgba(255, 255, 255, 0.15);
    padding: 2px 7px;
    border-radius: 8px;
    font-weight: 700;
    transition: background 0.15s;
}

.room-pill:hover {
    background: rgba(255, 255, 255, 0.3);
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
}

/* Moneda Mario Bros Estilizada */
.coin-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(251, 192, 45, 0.25);
    border: 1px solid var(--mex-gold);
    padding: 1px 7px;
    border-radius: 12px;
    font-weight: 900;
    color: #fff9c4;
}

.mario-coin-icon {
    display: inline-block;
    width: 14px;
    height: 17px;
    background: linear-gradient(135deg, #fff176 0%, #ffd700 40%, #ff8f00 100%);
    border-radius: 50%;
    border: 1px solid #795548;
    box-shadow: inset 1px 1px 0px #fff, 0 1px 2px rgba(0,0,0,0.4);
    position: relative;
}

.mario-coin-icon::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 4px;
    width: 4px;
    height: 9px;
    border: 1px solid #ff8f00;
    border-radius: 50%;
}

.header-actions {
    display: flex;
    gap: 4px;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.15s, transform 0.1s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.08);
}

.btn-icon:active {
    transform: scale(0.92);
}

/* Barra informativa de modo y ronda */
.game-info-bar {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.info-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.badge-mode {
    background: rgba(255, 255, 255, 0.9);
    color: #111;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 10px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    border: 1px solid #ddd;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-round {
    background: #1976d2;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 900;
    padding: 2px 8px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.banner-alert {
    background: #ffeb3b;
    color: #b71c1c;
    font-size: 0.8rem;
    font-weight: 900;
    text-align: center;
    padding: 4px 8px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    animation: pulseAlert 1s infinite alternate;
}

/* 1. SECCIÓN SUPERIOR: Carta cantada + Historial */
.deck-section { 
    flex: 0 0 auto; 
    background: rgba(255, 255, 255, 0.95); 
    padding: 6px 8px; 
    border-radius: 12px; 
    display: flex;
    flex-direction: row; 
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.3);
    border: 2px solid rgba(255,255,255,0.8);
}

.current-card-wrapper {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

#current-card { 
    height: 105px;
    width: auto;
    aspect-ratio: 2/3;
    object-fit: contain; 
    border: 3px solid var(--mex-card-border);
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#current-card.card-pulse {
    transform: scale(1.08);
}

.history-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 3px;
}

.history-label {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #555;
    text-transform: uppercase;
}

.history-container { 
    flex: 1;
    display: flex; 
    flex-wrap: nowrap; 
    overflow-x: auto;
    overflow-y: hidden;
    height: 56px;
    align-items: center;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 6px;
    padding: 3px;
    gap: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.2) transparent;
}

.history-container::-webkit-scrollbar {
    height: 3px;
}

.history-container::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.25);
    border-radius: 4px;
}

.history-card { 
    height: 50px;
    width: auto;
    aspect-ratio: 2/3;
    object-fit: contain;
    border: 1px solid #777;
    border-radius: 3px;
    background: #fff;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* 2. SECCIÓN MEDIA: Botones de administración */
.buttons-row {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
}

.btn-draw, .btn-reset-server, .btn-tiebreaker { 
    flex: 1;
    height: 38px;
    color: white; 
    border: none; 
    font-weight: 900; 
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 3px rgba(0,0,0,0.25);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    transition: transform 0.08s ease, filter 0.15s ease;
}

.btn-draw { 
    background: linear-gradient(180deg, #e53935 0%, #b71c1c 100%); 
}

.btn-reset-server { 
    background: linear-gradient(180deg, #43a047 0%, #1b5e20 100%); 
}

.btn-tiebreaker {
    background: linear-gradient(180deg, #ff9800 0%, #e65100 100%);
    animation: glowBtn 1s infinite alternate;
}

.btn-draw:hover:not(:disabled), .btn-reset-server:hover:not(:disabled), .btn-tiebreaker:hover:not(:disabled) { 
    filter: brightness(1.1); 
}

.btn-draw:active:not(:disabled), .btn-reset-server:active:not(:disabled), .btn-tiebreaker:active:not(:disabled) { 
    transform: translateY(2px); 
    box-shadow: 0 1px rgba(0,0,0,0.2); 
}

/* Barra del Administrador: Finalizar Sala */
.admin-bar {
    flex: 0 0 auto;
    width: 100%;
}

.btn-finish-room-direct {
    width: 100%;
    height: 32px;
    background: linear-gradient(180deg, #c62828 0%, #7f0000 100%);
    color: #fff;
    border: 1px solid #ef5350;
    font-weight: 900;
    font-size: 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: transform 0.08s ease, filter 0.15s ease;
}

.btn-finish-room-direct:hover {
    filter: brightness(1.15);
}

.btn-finish-room-direct:active {
    transform: translateY(1px);
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    filter: grayscale(0.85);
    box-shadow: none;
}

/* 3. SECCIÓN INFERIOR: Tablero 4x4 y Espectador */
.board-container {
    flex: 1;
    min-height: 0;
    position: relative;
    display: flex;
}

.loteria-grid { 
    width: 100%;
    height: 100%;
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    grid-template-rows: repeat(4, 1fr); 
    gap: 4px; 
    background: #fff; 
    padding: 5px; 
    border: 4px solid var(--mex-card-border);
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

.card-slot {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    border-radius: 4px;
    background: #fafafa;
}

.card-slot img { 
    width: 100%;
    height: 100%;
    object-fit: contain; 
    cursor: pointer;
    border-radius: 3px;
    transition: transform 0.12s ease;
}

.card-slot img:hover {
    transform: scale(1.02);
}

.card-slot img:active {
    transform: scale(0.96);
}

.card-slot img[data-marked="true"] {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Capa de Espectador */
.spectator-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.spectator-msg {
    background: #fff;
    padding: 16px 20px;
    border-radius: 14px;
    text-align: center;
    border: 3px solid var(--mex-gold);
    max-width: 85%;
}

.spectator-icon {
    font-size: 2rem;
}

.spectator-msg h3 {
    color: var(--mex-red);
    font-size: 1.2rem;
    margin: 4px 0;
}

.spectator-msg p {
    font-size: 0.85rem;
    color: #555;
    font-weight: 600;
}

/* =================================================== */
/* 3. MODALES Y ANIMACIONES                            */
/* =================================================== */
.modal-overlay {
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0;
    width: 100%; 
    height: 100%; 
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(6px);
    z-index: 9999; 
    justify-content: center; 
    align-items: center;
    padding: 16px;
    animation: fadeIn 0.2s ease-out;
}

.modal-content { 
    background: #fff; 
    padding: 22px 18px; 
    border-radius: 18px; 
    text-align: center; 
    width: 100%; 
    max-width: 370px;
    box-shadow: 0 12px 35px rgba(0,0,0,0.55);
    border: 4px solid var(--mex-gold);
    animation: scaleIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Animación Moneda Mario Gigante */
.coin-bounce-animation {
    display: flex;
    justify-content: center;
    margin-bottom: -5px;
}

.mario-coin-huge {
    width: 52px;
    height: 64px;
    background: linear-gradient(135deg, #fff9c4 0%, #ffd700 45%, #ff8f00 100%);
    border-radius: 50%;
    border: 3px solid #6d4c41;
    box-shadow: inset 3px 3px 0px #fff, 0 8px 18px rgba(0,0,0,0.4);
    position: relative;
    animation: marioCoinJump 0.8s ease-in-out infinite alternate;
}

.mario-coin-huge::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 14px;
    width: 18px;
    height: 38px;
    border: 3px solid #ff8f00;
    border-radius: 50%;
}

.win-title { 
    font-size: 2.6rem; 
    color: var(--mex-red); 
    font-weight: 900; 
    margin: 0;
    letter-spacing: -1px;
}

.win-coin-award {
    background: #fff8e1;
    color: #e65100;
    font-size: 1.15rem;
    font-weight: 900;
    padding: 6px 12px;
    border-radius: 10px;
    border: 2px dashed #fbc02d;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}

.btn-modal {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 0.95rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 4px rgba(0,0,0,0.25);
    text-transform: uppercase;
    background: linear-gradient(180deg, #43a047 0%, #1b5e20 100%);
}

.btn-modal:active {
    transform: translateY(2px);
    box-shadow: 0 2px rgba(0,0,0,0.25);
}

.btn-modal-sec {
    background: linear-gradient(180deg, #1976d2 0%, #0d47a1 100%);
}

.btn-modal-gold {
    background: linear-gradient(180deg, #ffb300 0%, #f57f17 100%);
    color: #fff;
    box-shadow: 0 4px rgba(230, 81, 0, 0.4);
}

/* Modal Ver Tabla Ganadora */
.winning-board-card {
    max-width: 390px;
}

.winning-board-title {
    color: var(--mex-red);
    font-size: 1.4rem;
    font-weight: 900;
}

.winning-board-sub {
    font-size: 0.85rem;
    color: #555;
    font-weight: 600;
}

.winning-grid {
    height: 280px !important;
    gap: 3px;
    background: #fffde7;
    border-color: var(--mex-gold);
}

.winning-grid .card-slot img.is-winning-card {
    outline: 3px solid var(--mex-gold);
    outline-offset: -2px;
    border-radius: 4px;
    animation: glowWinning 1.2s infinite alternate;
}

/* Modal Desempate */
.tie-title {
    font-size: 2rem;
    color: #e65100;
    font-weight: 900;
}

.tie-players-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin: 6px 0;
}

.tie-player-chip {
    background: #ffe0b2;
    color: #e65100;
    font-weight: 800;
    font-size: 0.9rem;
    padding: 5px 12px;
    border-radius: 16px;
    border: 1px solid #ffb74d;
}

.tie-rule {
    font-size: 0.82rem;
    color: #555;
    background: #fafafa;
    padding: 8px;
    border-radius: 8px;
    border-left: 4px solid #ff9800;
}

/* Modal de Configuración */
.config-title {
    color: var(--mex-red);
    font-size: 1.4rem;
    font-weight: 900;
}

.config-sub {
    font-size: 0.85rem;
    color: #666;
}

.config-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.config-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
}

.config-option:hover {
    border-color: var(--mex-gold);
    background: #fffde7;
}

.config-option input[type="radio"] {
    margin-top: 3px;
    accent-color: var(--mex-red);
}

.option-body strong {
    display: block;
    font-size: 0.9rem;
    color: #222;
}

.option-body span {
    display: block;
    font-size: 0.75rem;
    color: #666;
    margin-top: 2px;
}

/* Modal de Ranking */
.ranking-title {
    color: var(--mex-gold-dark);
    font-size: 1.6rem;
    font-weight: 900;
}

.ranking-sub {
    font-size: 0.8rem;
    color: #666;
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 250px;
    overflow-y: auto;
    padding: 2px;
}

.ranking-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #fafafa;
    border-radius: 10px;
    border: 1px solid #ddd;
    font-weight: bold;
}

.ranking-item.first-place {
    background: linear-gradient(135deg, #fff9c4 0%, #fff176 100%);
    border: 2px solid var(--mex-gold);
    box-shadow: 0 3px 8px rgba(251, 192, 45, 0.4);
    transform: scale(1.02);
}

.ranking-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ranking-pos {
    font-size: 1.1rem;
    min-width: 26px;
    text-align: center;
}

.trophy-icon {
    font-size: 1.4rem;
    animation: rotateTrophy 2s infinite ease-in-out alternate;
}

.ranking-name {
    font-size: 0.95rem;
    color: #111;
}

.ranking-coins {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.95rem;
    color: #e65100;
}

/* Ocultar elementos admin si no es admin */
.admin-hidden {
    display: none !important;
}

/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes marioCoinJump {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(-10px) scale(1.05); }
}

@keyframes rotateTrophy {
    0% { transform: rotate(-8deg); }
    100% { transform: rotate(8deg); }
}

@keyframes glowBtn {
    0% { box-shadow: 0 0 5px #ff9800; }
    100% { box-shadow: 0 0 15px #e65100; }
}

@keyframes glowWinning {
    0% { outline-color: #ffd54f; }
    100% { outline-color: #e65100; box-shadow: 0 0 8px #ffb300; }
}

@keyframes pulseAlert {
    0% { transform: scale(0.98); }
    100% { transform: scale(1.02); }
}

/* =================================================== */
/* 4. MODAL DE CÓDIGO QR Y ESTILOS DE INVITACIÓN       */
/* =================================================== */
.invite-banner {
    background: #e8f5e9;
    border: 2px dashed #2e7d32;
    color: #1b5e20;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 800;
    text-align: center;
    animation: fadeIn 0.25s ease-out;
}

.pin-locked {
    background-color: #eeeeee !important;
    color: #555555 !important;
    cursor: not-allowed !important;
    border: 2px dashed #999 !important;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.qr-card {
    max-width: 360px;
}

.qr-title {
    color: var(--mex-red);
    font-size: 1.4rem;
    font-weight: 900;
}

.qr-sub {
    font-size: 0.85rem;
    color: #555;
    font-weight: 600;
}

.qr-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 6px 0;
}

.qr-code-box {
    background: #ffffff;
    padding: 12px;
    border: 3px solid var(--mex-gold);
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.15);
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 210px;
    min-height: 210px;
}

.qr-code-box img, .qr-code-box canvas {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.qr-pin-highlight {
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--mex-red);
    background: #fff8e1;
    border: 1px solid var(--mex-gold);
    border-radius: 8px;
    padding: 5px;
    letter-spacing: 2px;
}

.qr-url-box {
    display: flex;
    gap: 6px;
}

.qr-url-box input {
    flex: 1;
    font-size: 0.72rem;
    padding: 7px 9px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #f7f7f7;
    color: #444;
    outline: none;
    font-family: monospace;
}

.btn-copy {
    padding: 7px 12px;
    background: #1976d2;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, transform 0.1s;
}

.btn-copy:active {
    transform: scale(0.95);
    background: #0d47a1;
}

/* =================================================== */
/* MODALES: BIENVENIDA Y GUÍA DE INFORMACIÓN           */
/* =================================================== */
.welcome-card, .info-guide-card {
    max-width: 440px;
    max-height: 88vh;
    overflow-y: auto;
    text-align: left;
    gap: 12px;
}

.welcome-header, .info-guide-header {
    text-align: center;
}

.welcome-badge-icon {
    font-size: 2.6rem;
    display: block;
    margin-bottom: 4px;
    animation: bounceIcon 1.5s infinite alternate ease-in-out;
}

@keyframes bounceIcon {
    from { transform: scale(1); }
    to { transform: scale(1.12); }
}

.welcome-title, .info-guide-title {
    font-size: 1.38rem;
    font-weight: 900;
    color: var(--mex-red);
    margin: 0 0 4px 0;
    text-align: center;
    line-height: 1.25;
}

.welcome-subtitle, .info-guide-sub {
    font-size: 0.85rem;
    color: #555;
    text-align: center;
    margin: 0;
    line-height: 1.35;
}

.welcome-cards-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin: 4px 0;
}

.welcome-card-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: #fafafa;
    border: 1px solid #ebebeb;
    border-radius: 12px;
    padding: 9px 11px;
}

.welcome-card-item .item-icon {
    font-size: 1.45rem;
    flex-shrink: 0;
    background: #fff8e1;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ffe082;
}

.welcome-card-item .item-text strong {
    display: block;
    font-size: 0.86rem;
    color: var(--mex-green);
    margin-bottom: 2px;
}

.welcome-card-item .item-text p {
    font-size: 0.79rem;
    color: #555;
    margin: 0;
    line-height: 1.3;
}

/* Pestañas y Pasos de la Guía */
.guide-tabs {
    display: flex;
    gap: 6px;
    border-bottom: 2px solid #eee;
    padding-bottom: 8px;
    margin-top: 4px;
}

.guide-tab-btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 0.78rem;
    font-weight: 800;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    background: #f9f9f9;
    color: #555;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.guide-tab-btn:hover {
    background: #fff3e0;
    border-color: #ffb74d;
}

.guide-tab-btn.active {
    background: var(--mex-red);
    color: #fff;
    border-color: var(--mex-red);
    box-shadow: 0 3px 8px rgba(183, 28, 28, 0.35);
}

.guide-panel {
    display: none;
    flex-direction: column;
    gap: 9px;
    margin: 4px 0;
    max-height: 48vh;
    overflow-y: auto;
    padding-right: 4px;
}

.guide-panel.active {
    display: flex;
}

.guide-step {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: #fffde7;
    border-left: 4px solid var(--mex-gold);
    padding: 8px 10px;
    border-radius: 0 8px 8px 0;
}

.guide-step-num {
    background: #f57f17;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    flex-shrink: 0;
}

.guide-step-text strong {
    font-size: 0.85rem;
    color: #3e2723;
    display: block;
}

.guide-step-text p {
    font-size: 0.78rem;
    color: #5d4037;
    margin: 2px 0 0 0;
    line-height: 1.35;
}

@media (max-height: 680px) {
    .lobby-brand-container {
        margin-top: 8px;
        margin-bottom: 6px;
    }
    .lobby-brand-title {
        font-size: 1.45rem;
        -webkit-text-stroke: 1.5px #3e0c00;
    }
    .lobby-card {
        padding: 14px 18px;
        gap: 8px;
    }
    .btn-lobby-guide {
        padding: 7px 10px;
    }
    .welcome-card, .info-guide-card {
        padding: 16px 14px;
        gap: 10px;
    }
}

/* =================================================== */
/* MODAL DE BIENVENIDA SIMPLIFICADO CON LOGO Y LETRAS GRANDES */
/* =================================================== */
.welcome-card-v2 {
    max-width: 460px;
    padding: 22px 20px;
    background: #ffffff;
    border: 4px solid var(--mex-green);
    border-radius: 24px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    text-align: center;
}

.welcome-header-v2 {
    margin-bottom: 8px;
}

.welcome-logo-v2 {
    width: 175px;
    max-width: 70%;
    height: auto;
    display: block;
    margin: 0 auto 10px auto;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
    transition: transform 0.3s ease;
}

.welcome-logo-v2:hover {
    transform: scale(1.04);
}

.welcome-body-v2 {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 8px 0 14px 0;
}

.welcome-main-text {
    font-size: 1.14rem;
    font-weight: 700;
    color: #1b5e20;
    line-height: 1.45;
    margin: 0;
}

.welcome-highlight-box {
    background: #fffde7;
    border: 2px dashed #fbc02d;
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: inset 0 2px 6px rgba(251, 192, 45, 0.15);
}

.welcome-highlight-text {
    font-size: 1.04rem;
    font-weight: 600;
    color: #3e2723;
    line-height: 1.45;
    margin: 0;
}

.btn-welcome-large {
    font-size: 1.15rem !important;
    padding: 14px 20px !important;
    font-weight: 800 !important;
    border-radius: 12px !important;
    box-shadow: 0 6px 18px rgba(46, 125, 50, 0.45) !important;
}

/* =================================================== */
/* MODAL QR: BANNER DE INVITACION Y BOTON CERRAR "X"   */
/* =================================================== */
.modal-close-x {
    position: absolute;
    top: 10px;
    right: 12px;
    background: #f0f0f0;
    border: none;
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    color: #444;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 20;
}

.modal-close-x:hover {
    background: #d50000;
    color: #ffffff;
    transform: scale(1.1);
}

.qr-admin-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    border: 2px solid #388e3c;
    border-radius: 12px;
    padding: 10px 14px;
    margin: 4px 0 10px 0;
    text-align: center;
    box-shadow: 0 4px 10px rgba(56, 142, 60, 0.2);
}

.qr-admin-icon {
    font-size: 1.5rem;
}

.qr-admin-title {
    font-size: 1.02rem;
    font-weight: 800;
    color: #1b5e20;
    line-height: 1.25;
}

/* =================================================== */
/* OVERLAY Y FLECHAS DE TUTORIAL GUIADO INTERACTIVO   */
/* =================================================== */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.68);
    z-index: 99999;
    cursor: pointer;
    overflow: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    animation: fadeInOverlay 0.25s ease-out forwards;
}

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tutorial-spotlight {
    position: absolute;
    pointer-events: none;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.65), 0 0 16px 4px #ffd600;
    border: 3px solid #ffd600;
    border-radius: 12px;
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 100000;
    animation: pulseSpotlight 1.8s infinite ease-in-out;
}

@keyframes pulseSpotlight {
    0%, 100% {
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.65), 0 0 12px 2px rgba(255, 214, 0, 0.8);
        border-color: #ffd600;
    }
    50% {
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.65), 0 0 24px 8px rgba(255, 214, 0, 1);
        border-color: #fff176;
    }
}

.tutorial-pointer-wrap {
    position: absolute;
    z-index: 100001;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.tutorial-pointer-wrap.point-up {
    flex-direction: column;
}

.tutorial-pointer-wrap.point-down {
    flex-direction: column-reverse;
}

.tutorial-arrow {
    position: relative;
    width: 44px;
    height: 44px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6));
    transition: left 0.25s ease;
}

.point-up .tutorial-arrow {
    margin-bottom: 4px;
    animation: bounceArrowUp 1s infinite alternate ease-in-out;
}

.point-down .tutorial-arrow {
    margin-top: 4px;
    transform: rotate(180deg);
    animation: bounceArrowDown 1s infinite alternate ease-in-out;
}

@keyframes bounceArrowUp {
    from { transform: translateY(0); }
    to { transform: translateY(-8px); }
}

@keyframes bounceArrowDown {
    from { transform: rotate(180deg) translateY(0); }
    to { transform: rotate(180deg) translateY(-8px); }
}

.tutorial-arrow-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.tutorial-card {
    background: #ffffff;
    border: 3px solid #ffd600;
    border-radius: 16px;
    padding: 14px 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 0 3px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: popInCard 0.25s ease-out;
    box-sizing: border-box;
}

@keyframes popInCard {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.tutorial-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tutorial-badge-num {
    background: linear-gradient(135deg, #d50000, #ff1744);
    color: #ffffff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    font-weight: 900;
    box-shadow: 0 4px 10px rgba(213, 0, 0, 0.5);
    flex-shrink: 0;
    border: 2px solid #ffffff;
}

.tutorial-card-body {
    flex: 1;
}

.tutorial-text {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 700;
    color: #212121;
    line-height: 1.35;
}

.tutorial-card-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    border-top: 1px dashed #e0e0e0;
    padding-top: 8px;
    font-size: 0.78rem;
    font-weight: 800;
    color: #f57f17;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tutorial-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d50000;
    display: inline-block;
    animation: pulseDot 1s infinite alternate;
}

@keyframes pulseDot {
    from { transform: scale(0.8); opacity: 0.6; }
    to { transform: scale(1.3); opacity: 1; }
}