/* ==========================================
   DESIGN SYSTEM - BINGO RASPADINHA
   ========================================== */

:root {
    /* Colors */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #f59e0b;
    --secondary-dark: #d97706;
    --success: #10b981;
    --danger: #ef4444;
    
    /* Background */
    --bg-dark: #0f0f23;
    --bg-card: #1a1a2e;
    --bg-surface: #16213e;
    
    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    /* Bingo Colors */
    --bingo-b: #3b82f6;
    --bingo-i: #ef4444;
    --bingo-n: #f59e0b;
    --bingo-g: #10b981;
    --bingo-o: #8b5cf6;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.3);
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 50%;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ==========================================
   RESET & BASE
   ========================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(ellipse at top, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at bottom, rgba(245, 158, 11, 0.1) 0%, transparent 50%);
}

/* ==========================================
   LAYOUT
   ========================================== */

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

.screen {
    display: none;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================
   HEADER
   ========================================== */

.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
}

.logo {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    text-shadow: 0 0 40px rgba(99, 102, 241, 0.5);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* ==========================================
   START SCREEN
   ========================================== */

.start-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 60px 40px;
    text-align: center;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border: 1px solid rgba(99, 102, 241, 0.2);
    max-width: 500px;
    margin: 60px auto;
}

.start-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.start-card h2 {
    font-size: 1.8rem;
    margin-bottom: 12px;
    font-weight: 700;
}

.start-card p {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

/* ==========================================
   BUTTONS
   ========================================== */

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 40px;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: inherit;
    color: white;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md), 0 0 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(99, 102, 241, 0.6);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

.btn-icon {
    font-size: 1.4rem;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-light);
}

/* ==========================================
   BINGO CARD
   ========================================== */

.bingo-card-container {
    margin-bottom: 40px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.card-id {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: monospace;
}

.bingo-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 2px solid rgba(99, 102, 241, 0.3);
}

.card-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
}

.header-row {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.card-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all var(--transition-normal);
}

.header-cell {
    font-size: 1.8rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.card-body {
    display: grid;
    grid-template-rows: repeat(5, 1fr);
}

.number-cell {
    background: var(--bg-surface);
    color: var(--text-primary);
    position: relative;
}

.number-cell.free {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-dark) 100%);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
}

.number-cell.marked {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
    animation: markPulse 0.5s ease;
}

@keyframes markPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.number-cell.marked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 70%;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.4);
}

/* ==========================================
   DRAW BALLS SECTION
   ========================================== */

.draw-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.draw-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    margin-bottom: 8px;
}

.draw-icon {
    font-size: 1.5rem;
}

.revealed-count {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 400;
}

.draw-subtitle {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.balls-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 8px;
}

/* ==========================================
   INDIVIDUAL BALLS
   ========================================== */

.ball {
    aspect-ratio: 1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

/* Covered ball (not revealed) */
.ball.covered {
    background: linear-gradient(145deg, #3a3a5a 0%, #2a2a4a 100%);
    color: transparent;
    box-shadow: 
        inset 0 2px 10px rgba(0, 0, 0, 0.5),
        0 2px 5px rgba(0, 0, 0, 0.3);
}

.ball.covered::before {
    content: '?';
    color: var(--text-muted);
    font-size: 1.2rem;
    position: absolute;
}

.ball.covered::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 3px,
            rgba(255, 255, 255, 0.03) 3px,
            rgba(255, 255, 255, 0.03) 6px
        );
    border-radius: 50%;
}

.ball.covered:hover {
    transform: scale(1.1);
    box-shadow: 
        inset 0 2px 10px rgba(0, 0, 0, 0.5),
        0 4px 15px rgba(99, 102, 241, 0.4);
}

.ball.covered:hover::before {
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

/* Revealed ball */
.ball.revealed {
    color: white;
    box-shadow: 
        inset 0 -3px 10px rgba(0, 0, 0, 0.3),
        0 3px 10px rgba(0, 0, 0, 0.3);
    animation: revealBall 0.5s ease;
    cursor: default;
}

@keyframes revealBall {
    0% { transform: rotateY(0deg) scale(0.8); }
    50% { transform: rotateY(180deg) scale(1.1); }
    100% { transform: rotateY(360deg) scale(1); }
}

/* Ball colors by column */
.ball.revealed.col-b { background: linear-gradient(145deg, var(--bingo-b), #2563eb); }
.ball.revealed.col-i { background: linear-gradient(145deg, var(--bingo-i), #dc2626); }
.ball.revealed.col-n { background: linear-gradient(145deg, var(--bingo-n), #d97706); }
.ball.revealed.col-g { background: linear-gradient(145deg, var(--bingo-g), #059669); }
.ball.revealed.col-o { background: linear-gradient(145deg, var(--bingo-o), #7c3aed); }

/* In card indicator */
.ball.revealed.in-card {
    box-shadow: 
        inset 0 -3px 10px rgba(0, 0, 0, 0.3),
        0 0 15px rgba(16, 185, 129, 0.6),
        0 3px 10px rgba(0, 0, 0, 0.3);
}

.ball.revealed.in-card::after {
    content: '✓';
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--success);
    color: white;
    font-size: 0.6rem;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* ==========================================
   LAST REVEALED POPUP
   ========================================== */

.last-revealed {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 15px 30px;
    box-shadow: var(--shadow-lg);
    border: 2px solid var(--primary);
    z-index: 100;
    animation: slideUp 0.3s ease;
}

.last-revealed.hidden {
    display: none;
}

@keyframes slideUp {
    from { transform: translateX(-50%) translateY(100px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.last-revealed-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.last-number {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.last-status {
    color: var(--text-secondary);
    font-size: 1rem;
}

.last-status.in-card {
    color: var(--success);
    font-weight: 600;
}

/* ==========================================
   CONFETTI
   ========================================== */

#confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-100px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 600px) {
    .container {
        padding: 15px;
    }
    
    .logo {
        font-size: 1.8rem;
    }
    
    .start-card {
        padding: 40px 25px;
        margin: 30px auto;
    }
    
    .start-icon {
        font-size: 3.5rem;
    }
    
    .card-cell {
        font-size: 1.2rem;
    }
    
    .header-cell {
        font-size: 1.4rem;
    }
    
    .balls-container {
        grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
        gap: 6px;
    }
    
    .ball {
        font-size: 0.8rem;
    }
    
    .btn-primary {
        padding: 14px 30px;
        font-size: 1.1rem;
    }
    
    .draw-section {
        padding: 20px 15px;
    }
}

/* ==========================================
   LOADING STATE
   ========================================== */

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.btn-primary.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
