:root {
    --bg-color: #1C1C19;
    --text-color: #FFFFFF;
    --primary-color: #493F91;
    --primary-hover: #5A4EAF;
    --secondary-color: #6F6F6A;
    --secondary-hover: #83837E;
    --accent-color: #BFC760;
    --accent-hover: #D4DC75;
    --card-bg: #262623;
    --error-color: #ef4444;
    --btn-shadow: 0 8px 24px rgba(73, 63, 145, 0.4);
    --btn-huge-shadow: 0 15px 40px rgba(191, 199, 96, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Maven Pro', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100dvh; /* Soporte para la barra de Safari iOS */
    padding: 2rem 1rem 4rem 1rem; /* Más padding inferior */
    overflow-y: auto;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 420px;
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transition: max-width 0.3s ease;
    min-height: 85vh;
}

.footer-credits {
    margin-top: auto;
    padding-top: 3rem;
    padding-bottom: 1rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.3);
    text-align: center;
    line-height: 1.5;
    width: 100%;
    font-weight: 500;
}

.app-logo {
    width: 180px;
    max-width: 80%;
    margin-bottom: 2rem;
    object-fit: contain;
    animation: fadeInDown 0.6s ease-out;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Pantallas */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    animation: fadeIn 0.4s ease-out forwards;
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tipografía */
h1, h2 {
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    letter-spacing: -0.5px;
}

h1 { font-size: 2.2rem; }
h2 { font-size: 1.8rem; }
p { color: var(--secondary-color); margin-bottom: 1.5rem; font-size: 1.1rem; }

/* Formularios */
form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

input {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--secondary-color);
    background: transparent;
    color: var(--text-color);
    font-size: 1.1rem;
    font-family: inherit;
    outline: none;
    transition: all 0.3s ease;
    text-align: center;
}

input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(191, 199, 96, 0.15);
}

/* Select de Equipos */
.team-select {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--secondary-color);
    background: transparent;
    color: var(--text-color);
    font-size: 1.1rem;
    font-family: inherit;
    outline: none;
    transition: all 0.3s ease;
    text-align: center;
    appearance: none;
    margin-bottom: 0.5rem;
}

.team-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(191, 199, 96, 0.15);
}

.team-select option {
    background-color: var(--bg-color);
    color: var(--text-color);
}

/* Botones */
.btn {
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.96);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    font-size: 1.1rem;
    box-shadow: var(--btn-shadow);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    box-shadow: 0 12px 28px rgba(73, 63, 145, 0.5);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--secondary-color);
    color: var(--text-color);
    padding: 0.8rem 1.5rem;
    font-size: 1.1rem;
}

.btn-secondary:hover {
    background-color: var(--secondary-color);
    color: #fff;
}

.btn-huge {
    background-color: var(--accent-color);
    color: var(--bg-color);
    width: 240px;
    height: 240px;
    border-radius: 50%;
    font-size: 2.2rem;
    font-weight: 800;
    box-shadow: var(--btn-huge-shadow);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.btn-huge:hover:not(:disabled) {
    transform: scale(1.05);
    background-color: var(--accent-hover);
    box-shadow: 0 20px 45px rgba(191, 199, 96, 0.5);
}

.btn-huge:active:not(:disabled) {
    transform: scale(0.95);
}

/* Sala de espera */
.participants-info {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 16px;
    width: 100%;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(255,255,255,0.05);
}

.participants-info p {
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: var(--secondary-color);
}

#participantCount {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

.participants-list {
    list-style: none;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.participants-list li {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 500;
    border-left: 4px solid var(--primary-color);
}

/* Resultados */
#resultScreen {
    position: relative;
    z-index: 1;
}

.ruleta-img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90%;
    max-height: 50vh;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
    z-index: 100;
    pointer-events: none;
    border: 4px solid var(--accent-color);
}

.ruleta-img.show-funny {
    animation: popInFunny 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.ruleta-img.hide-funny {
    animation: popOutFunny 0.6s cubic-bezier(0.6, -0.28, 0.735, 0.045) forwards;
}

@keyframes popInFunny {
    0% { transform: translate(-50%, -50%) scale(0) rotate(-180deg); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.1) rotate(10deg); }
    100% { transform: translate(-50%, -50%) scale(1) rotate(-5deg); opacity: 1; }
}

@keyframes popOutFunny {
    0% { transform: translate(-50%, -50%) scale(1) rotate(-5deg); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0) rotate(180deg); opacity: 0; }
}

.winner-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 20px;
    width: 100%;
    border: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 2rem;
}

#winnerName {
    font-size: 2.5rem;
    color: var(--accent-color);
    margin: 1rem 0 1.5rem 0;
}

.time-display {
    font-family: monospace;
    font-size: 1.1rem;
    background: var(--bg-color);
    padding: 0.8rem;
    border-radius: 8px;
    color: var(--secondary-color);
}

.mt-2 {
    margin-top: 1rem;
}

.result-actions {
    display: flex;
    gap: 1rem;
    width: 100%;
    justify-content: center;
}

.result-actions .btn {
    flex: 1;
}

/* Scoreboard */
.scoreboard {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.8rem;
    width: 100%;
    max-width: 100%;
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 16px;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.05);
}

.podium-1st {
    margin-bottom: 1rem;
}

.other-places {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 1rem;
}

.place-item {
    display: flex;
    justify-content: space-between;
    width: 100%;
    background: rgba(0,0,0,0.2);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    align-items: center;
}

.place-rank {
    font-weight: bold;
    color: var(--secondary-color);
    width: 30px;
    font-size: 1.1rem;
}
.place-name {
    flex: 1;
    text-align: left;
    margin-left: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.place-time {
    color: var(--accent-color);
    font-family: monospace;
    font-size: 0.85rem;
}

.team-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.25);
    padding: 0.6rem 0.8rem;
    border-radius: 12px;
    min-width: 85px;
    flex: 1 1 calc(33.33% - 0.8rem);
    max-width: 130px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.team-score:hover {
    transform: translateY(-2px);
    background: rgba(0, 0, 0, 0.35);
    border-color: rgba(255, 255, 255, 0.08);
}

.team-label {
    font-size: 0.75rem;
    color: var(--secondary-color);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
}

.score-value {
    font-size: 1.6rem;
    font-weight: 800;
}

/* Admin Controls Premium */
.admin-controls {
    background: linear-gradient(145deg, var(--card-bg) 0%, rgba(28,28,25, 0.9) 100%);
    padding: 1.5rem;
    border-radius: 20px;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.admin-controls::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(191,199,96,0.03) 0%, transparent 70%);
    pointer-events: none;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 1rem;
}

.admin-header h3 {
    font-size: 1.2rem;
    margin: 0;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(90deg, #fff, #aaa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.admin-icon {
    font-size: 1.3rem;
}

.admin-teams {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    width: 100%;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 4px;
}

.admin-team {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0,0,0,0.25);
    padding: 0.8rem 1rem;
    border-radius: 12px;
    border-left: 4px solid var(--primary-color);
    width: 100%;
    transition: all 0.3s ease;
}

.admin-team:hover {
    background: rgba(255, 255, 255, 0.02);
    transform: translateX(2px);
}

.admin-team-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex: 1;
    text-align: left;
}

.admin-team-name {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.admin-team-score {
    font-size: 0.85rem;
    color: var(--accent-color);
    font-weight: 600;
    margin-top: 2px;
}

.admin-btn-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.btn-score {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    font-size: 1.3rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #fff;
    -webkit-tap-highlight-color: transparent;
}

.btn-minus {
    background: rgba(255, 255, 255, 0.1);
}
.btn-minus:hover {
    background: rgba(255, 255, 255, 0.2);
}

.team-red .btn-plus { background: rgba(239, 68, 68, 0.8); }
.team-red .btn-plus:hover { background: rgba(239, 68, 68, 1); box-shadow: 0 0 10px rgba(239,68,68,0.5); }

.team-blue .btn-plus { background: rgba(59, 130, 246, 0.8); }
.team-blue .btn-plus:hover { background: rgba(59, 130, 246, 1); box-shadow: 0 0 10px rgba(59,130,246,0.5); }

.team-green .btn-plus { background: rgba(34, 197, 94, 0.8); }
.team-green .btn-plus:hover { background: rgba(34, 197, 94, 1); box-shadow: 0 0 10px rgba(34,197,94,0.5); }

.btn-score:active {
    transform: scale(0.9);
}

.btn-reset-scores {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
    color: #ef4444;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-reset-scores:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.6);
}

body.admin-mode #adminResetScoresBtn,
body.admin-mode #adminResetScoresBtnSpectator {
    display: flex !important;
}


/* Errores y Toast */
.error-msg {
    color: var(--error-color);
    margin-top: 1rem;
    font-size: 0.95rem;
    font-weight: 500;
}

.hidden {
    display: none !important;
}

.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: white;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: 600;
    box-shadow: var(--btn-shadow);
    z-index: 1000;
    animation: toastSlideDown 0.3s ease-out;
}

@keyframes toastSlideDown {
    from { top: -50px; opacity: 0; }
    to { top: 20px; opacity: 1; }
}

/* Animaciones de Espectador */
.spectator-loader {
    width: 60px;
    height: 60px;
    position: relative;
    margin: 0 auto;
}

.pulse-ring {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--accent-color);
    animation: pulseRing 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes pulseRing {
    0% { transform: scale(0.5); opacity: 0.8; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Animación del Ganador */
.winner-animate {
    display: inline-block;
    animation: winnerTada 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes winnerTada {
    0% { transform: scale3d(1, 1, 1); }
    10%, 20% { transform: scale3d(0.9, 0.9, 0.9) rotate3d(0, 0, 1, -3deg); }
    30%, 50%, 70%, 90% { transform: scale3d(1.2, 1.2, 1.2) rotate3d(0, 0, 1, 3deg); color: #fff; }
    40%, 60%, 80% { transform: scale3d(1.2, 1.2, 1.2) rotate3d(0, 0, 1, -3deg); color: var(--accent-hover); }
    100% { transform: scale3d(1, 1, 1); }
}

/* Dashboard layout para Admin en PC */
@media (min-width: 700px) {
    body.admin-mode {
        overflow: hidden;
        padding: 0;
        align-items: center;
    }
    
    body.admin-mode .container {
        max-width: 1000px;
        height: 100vh;
        padding: 1.5rem;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
    
    body.admin-mode .app-logo {
        width: 100px;
        margin-bottom: 0.5rem;
    }
    
    body.admin-mode .scoreboard {
        margin-bottom: 1.5rem;
        max-width: 600px;
        padding: 0.5rem;
    }
    
    body.admin-mode #resultScreen.active {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 2rem;
        align-items: stretch;
        width: 100%;
        flex: 1;
        overflow-y: auto;
    }

    body.admin-mode .winner-card {
        flex: 1;
        margin-bottom: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        overflow-y: auto;
    }
    
    body.admin-mode .admin-controls {
        flex: 1;
        margin-bottom: 0;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
    
    body.admin-mode .admin-teams {
        display: flex;
        flex-direction: column;
        gap: 0.8rem;
        margin-bottom: 1rem;
    }
    
    body.admin-mode .admin-team {
        flex-direction: row;
        justify-content: space-between;
        padding: 1rem 1.5rem;
    }
    
    body.admin-mode .admin-actions {
        margin-top: auto;
    }
    
    body.admin-mode .result-actions {
        width: 100% !important;
        display: flex;
        justify-content: center;
        margin-top: 0;
        padding-bottom: 1rem;
    }
    
    body.admin-mode .result-actions button {
        padding: 0.8rem 2rem;
        font-size: 1rem;
    }
}

/* Imagen Especial del Admin (Flotante y Premium) */
.admin-image-container {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 1000;
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

body.admin-mode .admin-image-container {
    display: flex !important;
}

.btn-toggle-img {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-color);
    padding: 0.6rem 1rem;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-toggle-img:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

.btn-toggle-img:active {
    transform: translateY(0);
}

.admin-image-wrapper {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px;
    border-radius: 16px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    max-width: 260px;
    animation: fadeInScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.admin-special-img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    display: block;
    object-fit: contain;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@media (max-width: 700px) {
    .admin-image-container {
        position: absolute;
        top: 12px;
        left: 12px;
        z-index: 1000;
        margin: 0;
        width: auto;
        align-items: flex-start;
        display: none;
    }
    body.admin-mode .admin-image-container {
        display: flex !important;
    }
    .btn-toggle-img {
        padding: 0.5rem 0.8rem;
        font-size: 0.8rem;
        border-radius: 10px;
    }
    .admin-image-wrapper {
        max-width: 200px;
    }
}

/* Compactación general para Teléfonos Celulares */
@media (max-width: 600px) {
    body {
        padding: 1rem 0.75rem 2rem 0.75rem;
    }
    
    .container {
        min-height: auto;
    }

    .app-logo {
        width: 105px;
        margin-bottom: 0.8rem;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }

    h2 {
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }

    p {
        font-size: 0.95rem;
        margin-bottom: 0.75rem;
    }

    .scoreboard {
        padding: 0.5rem;
        margin-bottom: 0.8rem;
        gap: 0.5rem;
    }

    .team-score {
        padding: 0.4rem 0.6rem;
        min-width: 75px;
        flex: 1 1 calc(33.33% - 0.5rem);
    }

    .score-value {
        font-size: 1.3rem;
    }

    .team-label {
        font-size: 0.7rem;
    }

    .participants-info {
        padding: 0.8rem;
        margin-bottom: 0.6rem;
    }

    #participantCount {
        font-size: 1.6rem;
    }

    .participants-list {
        gap: 0.4rem;
    }

    .participants-list li {
        padding: 0.6rem 0.8rem;
        font-size: 0.95rem;
        border-radius: 8px;
    }

    .btn {
        padding: 0.75rem 1rem;
        font-size: 1rem;
        border-radius: 10px;
    }

    .btn-huge {
        width: 185px;
        height: 185px;
        font-size: 1.7rem;
    }

    .winner-card {
        padding: 1.2rem;
        margin-bottom: 1rem;
        border-radius: 16px;
    }

    #winnerName {
        font-size: 1.8rem;
        margin: 0.4rem 0 0.6rem 0;
    }

    .time-display {
        font-size: 0.9rem;
        padding: 0.5rem;
    }

    .admin-controls {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 16px;
    }

    .admin-header {
        margin-bottom: 0.8rem;
        padding-bottom: 0.6rem;
    }

    .admin-teams {
        max-height: 180px;
        gap: 0.5rem;
        margin-bottom: 0.8rem;
    }

    .admin-team {
        padding: 0.5rem 0.75rem;
        border-radius: 10px;
    }

    .admin-team-name {
        font-size: 0.9rem;
        max-width: 120px;
    }

    .admin-team-score {
        font-size: 0.75rem;
    }

    .btn-score {
        width: 38px;
        height: 38px;
        font-size: 1.05rem;
    }

    .btn-reset-scores {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .footer-credits {
        padding-top: 1rem;
        font-size: 0.75rem;
    }
}


