@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #161e31;
    --bg-card: #1f2a45;
    
    --color-text: #f3f4f6;
    --color-muted: #9ca3af;
    
    --accent-glow: rgba(99, 102, 241, 0.15);
    --accent-color: #6366f1;
    --accent-success: #10b981;
    --accent-success-glow: rgba(16, 185, 129, 0.25);
    --accent-danger: #ef4444;
    
    --border-color: #2d3b5e;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-primary);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    align-items: center;
    justify-content: flex-start;
}

.app-container {
    width: 100%;
    max-width: 600px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 12px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-color);
}

h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #a78bfa 0%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-muted);
    background-color: var(--bg-secondary);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-danger);
}

.status-dot.connected {
    background-color: var(--accent-success);
    box-shadow: 0 0 8px var(--accent-success);
}

.live-display {
    background: linear-gradient(145deg, var(--bg-secondary), var(--bg-card));
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    height: 25%;
    min-height: 120px;
}

.last-number-label {
    font-size: 0.8rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
}

.ball-preview-container {
    perspective: 800px;
}

.loto-ball {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: 
        radial-gradient(circle at 60% 30%, #fff59d 0%, #ffca28 20%, #ff8f00 50%, #ef6c00 75%, #d84315 100%);
    perspective: 800px;
    transform-style: preserve-3d;
    animation: rotate3D 4s infinite linear;
    box-shadow: inset -12px -12px 30px rgba(0,0,0,0.6),
                inset 4px 4px 15px rgba(255,255,255,0.4),
                0 12px 35px rgba(0,0,0,0.4),
                0 0 40px rgba(255, 143, 0, 0.3);
    border: none;
    overflow: hidden;
}

/* ==== Specular highlight principal ==== */
.loto-ball::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    width: calc(100% + 4px);
    height: calc(100% + 4px);
    border-radius: 50%;
    background:
        radial-gradient(ellipse at 30% 22%, rgba(255,255,255,0.7) 0%, rgba(255,255,255,0.15) 8%, transparent 30%),
        radial-gradient(ellipse at 70% 80%, rgba(255,255,255,0.05) 0%, transparent 50%);
    z-index: 3;
    pointer-events: none;
}

/* ==== Banda ecuatorial ==== */
.loto-ball::after {
    content: '';
    position: absolute;
    top: 14%;
    left: -5%;
    width: 110%;
    height: 72%;
    border-radius: 50%;
    background: linear-gradient(180deg,
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,0.06) 35%,
        rgba(255,255,255,0.06) 65%,
        rgba(255,255,255,0) 100%);
    pointer-events: none;
    z-index: 1;
    transform: rotateX(12deg);
}

/* ==== Color variants - esferas 3D premium ==== */
.loto-ball.emerald {
    background: 
        radial-gradient(circle at 30% 25%, #ffffff 0%, #e8ffe8 4%, #6fda8f 14%, #00854a 38%, #005a35 68%, #003d22 88%, #001a0e 100%);
    box-shadow:
        inset -12px -12px 30px rgba(0,0,0,0.7),
        inset 4px 4px 15px rgba(255,255,255,0.15),
        0 12px 35px rgba(0,0,0,0.5),
        0 0 50px rgba(16,185,129,0.25);
}
.loto-ball.ruby {
    background: 
        radial-gradient(circle at 30% 25%, #ffffff 0%, #ffe8e8 4%, #ff6b6b 14%, #cc2222 38%, #991111 68%, #660000 88%, #330000 100%);
    box-shadow:
        inset -12px -12px 30px rgba(0,0,0,0.7),
        inset 4px 4px 15px rgba(255,255,255,0.15),
        0 12px 35px rgba(0,0,0,0.5),
        0 0 50px rgba(239,68,68,0.25);
}
.loto-ball.sapphire {
    background: 
        radial-gradient(circle at 30% 25%, #ffffff 0%, #e8eeff 4%, #6b9ef0 14%, #2266cc 38%, #114499 68%, #002266 88%, #001133 100%);
    box-shadow:
        inset -12px -12px 30px rgba(0,0,0,0.7),
        inset 4px 4px 15px rgba(255,255,255,0.15),
        0 12px 35px rgba(0,0,0,0.5),
        0 0 50px rgba(59,130,246,0.25);
}
.loto-ball.gold {
    background: 
        radial-gradient(circle at 30% 25%, #ffffff 0%, #fffde8 4%, #f0d060 14%, #d4a017 38%, #b8860b 68%, #8b6914 88%, #5a4510 100%);
    box-shadow:
        inset -12px -12px 30px rgba(0,0,0,0.7),
        inset 4px 4px 15px rgba(255,255,255,0.15),
        0 12px 35px rgba(0,0,0,0.5),
        0 0 50px rgba(234,179,8,0.25);
}
.loto-ball.orange {
    background: 
        radial-gradient(circle at 30% 25%, #ffffff 0%, #ffe8d0 4%, #ff9f43 14%, #ff6b00 38%, #d35400 68%, #a04000 88%, #5e2600 100%);
    box-shadow:
        inset -12px -12px 30px rgba(0,0,0,0.7),
        inset 4px 4px 15px rgba(255,255,255,0.15),
        0 12px 35px rgba(0,0,0,0.5),
        0 0 50px rgba(255, 165, 0, 0.25);
}
.loto-ball.violet {
    background: 
        radial-gradient(circle at 30% 25%, #ffffff 0%, #f2e8ff 4%, #b266f0 14%, #8a2be2 38%, #6a0dad 68%, #4b0082 88%, #2e004f 100%);
    box-shadow:
        inset -12px -12px 30px rgba(0,0,0,0.7),
        inset 4px 4px 15px rgba(255,255,255,0.15),
        0 12px 35px rgba(0,0,0,0.5),
        0 0 50px rgba(138, 43, 226, 0.25);
}

@keyframes ball-spin-reveal {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(720deg); }
}

.loto-ball.spinning {
    animation: ball-spin-reveal 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.loto-ball .ball-number {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 2.8rem;
    font-weight: 900;
    color: #000000;
    font-family: 'Outfit', sans-serif;
    box-shadow:
        inset 0 -4px 10px rgba(0,0,0,0.2),
        inset 0 2px 6px rgba(255,255,255,0.8),
        0 3px 12px rgba(0,0,0,0.3);
    position: relative;
    z-index: 2;
    line-height: 1;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.loto-ball:not(.spinning) .ball-number {
    opacity: 1;
    transform: scale(1);
}


.ball-spot {
    position: absolute;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    color: #000;
    z-index: 2;
    pointer-events: none;
    background: radial-gradient(circle, #fff 20%, rgba(255,255,255,0.4) 50%, transparent 70%);
    box-shadow: inset 0 0 5px rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.loto-ball:not(.spinning) .ball-spot {
    opacity: 1;
}

.spot-1 { top: -2%; left: -2%; }
.spot-2 { top: -2%; right: -2%; }
.spot-3 { bottom: -2%; left: -2%; }
.spot-4 { bottom: -2%; right: -2%; }

@keyframes spinIn3D {
    0%   { transform: perspective(800px) rotateY(180deg) scale(0.3); opacity: 0; }
    50%  { transform: perspective(800px) rotateY(90deg) scale(1.15); opacity: 0.8; }
    75%  { transform: perspective(800px) rotateY(-10deg) scale(1); opacity: 1; }
    100% { transform: perspective(800px) rotateY(0deg) scale(1); opacity: 1; }
}

.no-numbers {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-muted);
    text-align: center;
    width: 100%;
}

.grid-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 10px;
}

.loto-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 4px;
    height: 100%;
    width: 100%;
}

.grid-cell {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-muted);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    position: relative;
    overflow: hidden;
}

@media (max-width: 480px) {
    body {
        overflow-y: auto;
    }
    .app-container {
        padding: 10px;
        gap: 10px;
        height: auto;
        min-height: 100dvh;
    }
    .live-display {
        height: auto;
        min-height: 62px;
        padding: 8px 16px;
        border-radius: 12px;
    }
    .last-number-label {
        font-size: 0.65rem;
        margin-bottom: 2px;
    }
    .loto-ball {
        width: 55px;
        height: 55px;
        border: none;
        box-shadow:
            inset -6px -6px 16px rgba(0,0,0,0.7),
            inset 2px 2px 8px rgba(255,255,255,0.15),
            0 6px 16px rgba(0,0,0,0.5),
            0 0 20px var(--accent-success-glow);
    }
    .loto-ball::before {
        top: -1px;
        left: -1px;
        width: calc(100% + 2px);
        height: calc(100% + 2px);
    }
    .loto-ball .ball-number {
        width: 38px;
        height: 38px;
        font-size: 1.8rem;
    }
    .ball-number::after {
        display: none;
    }
    .grid-wrapper {
        flex: none;
        height: auto;
        padding: 6px;
    }
    .loto-grid {
        grid-template-columns: repeat(10, 1fr);
        grid-template-rows: repeat(9, 70px);
        gap: 4px;
        height: auto;
    }
    .grid-cell {
        font-size: 0.95rem;
        border-radius: 6px;
        height: 70px;
        padding: 0;
    }
}

.grid-cell.marked {
    background: linear-gradient(135deg, #047857 0%, #10b981 100%);
    color: #ffffff;
    border-color: #34d399;
    box-shadow: 
        0 0 10px rgba(16, 185, 129, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.2);
    font-weight: 800;
    transform: scale(0.96);
    animation: markCell 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes markCell {
    0% { transform: scale(1.3); filter: brightness(1.5); }
    100% { transform: scale(0.96); filter: brightness(1); }
}

.grid-cell.latest {
    box-shadow: 0 0 15px #34d399, inset 0 2px 4px rgba(255, 255, 255, 0.4);
    border: 2px solid #ffffff;
    z-index: 10;
}

.admin-container {
    overflow-y: auto !important;
}

.admin-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 8px;
}

.btn {
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 10px 16px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--color-text);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #2b395d;
}

.btn-danger {
    background-color: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-danger:hover {
    background-color: var(--accent-danger);
    color: white;
}

.btn-success {
    background-color: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.btn-success:hover {
    background-color: var(--accent-success);
    color: white;
}

.admin-grid .grid-cell {
    cursor: pointer;
}

.admin-grid .grid-cell:hover:not(.marked) {
    background-color: var(--bg-card);
    color: #fff;
    border-color: var(--accent-color);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 320px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.modal-card h3 {
    margin-bottom: 12px;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--color-text);
}

.modal-card p {
    color: var(--color-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.btn-reset {
    background-color: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-reset:hover {
    background-color: var(--accent-danger);
    color: white;
}

.admin-header-controls {
    display: flex;
    gap: 6px;
    flex: 1;
    padding-right: 10px;
    align-items: center;
}

.admin-lota-name-input {
    width: 100%;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: #fff;
    outline: none;
    font-size: 1.1rem;
    font-weight: bold;
}

.admin-small-btn {
    padding: 4px 8px;
    font-size: 0.8rem;
}

.admin-prize-bar {
    margin-top: 10px;
    margin-bottom: 5px;
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-prize-label {
    font-size: 0.85rem;
    color: var(--color-muted);
    white-space: nowrap;
}

.admin-prize-input {
    flex: 1;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: #fff;
    outline: none;
    font-size: 0.9rem;
}

.auth-input {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: #fff;
    text-align: center;
    outline: none;
}

.auth-input-email {
    font-size: 1rem;
}

.auth-input-password {
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.full-width-btn {
    width: 100%;
    font-size: 1rem;
    padding: 12px;
}

.winner-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    z-index: 2000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    pointer-events: none;
}

.winner-title {
    font-size: 3.5rem;
    text-align: center;
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 50%, #f59e0b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: winnerPulse 1s infinite alternate;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.8), 0 0 40px rgba(251, 191, 36, 0.5);
}

.winner-subtitle {
    color: #fff;
    font-size: 1.5rem;
    font-weight: 800;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9), 0 0 20px rgba(0, 0, 0, 0.5);
}

.winner-info {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 500;
    text-align: center;
    margin-top: 16px;
    line-height: 1.6;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
    max-width: 90%;
}

.winner-messages {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
}

.winner-info--highlight {
    font-weight: 700;
    font-size: 1.25rem;
    color: #fff;
}

@keyframes winnerPulse {
    0% { transform: scale(1); text-shadow: 0 0 20px var(--accent-success-glow); }
    100% { transform: scale(1.1); text-shadow: 0 0 40px var(--accent-success); }
}

.live-history {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 4px;
    overflow-y: auto;
    max-height: 100px;
    padding-right: 10px;
}

.history-plain {
    font-size: 1rem;
    font-weight: 700;
    color: #e2e8f0;
    letter-spacing: 1px;
    line-height: 1.7;
    word-break: break-word;
}
.ball-preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    border-left: 1px solid var(--border-color);
    padding-left: 15px;
}
.display-prize {
    color: var(--accent-success);
    font-size: 1rem;
    font-weight: 600;
    display: none;
}

.header-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
