/* --- Modern Theme Variables --- */
:root {
    /* Primary Brand Colors (Indigo to Violet Gradient) */
    --primary-color: #6366f1; /* Indigo-500 */
    --primary-dark: #4f46e5;  /* Indigo-600 */
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    
    /* Accent Colors (Coral/Rose for highlights) */
    --accent-color: #f43f5e; /* Rose-500 */
    --accent-hover: #e11d48; /* Rose-600 */
    
    /* Functional Colors */
    --text-main: #1e293b; /* Slate-800 */
    --text-muted: #64748b; /* Slate-500 */
    --success-bg: #dcfce7; /* Green-100 */
    --success-text: #166534; /* Green-800 */
    --bg-gradient: linear-gradient(135deg, #e0e7ff 0%, #f3e8ff 100%); /* Soft Purple/Blue Bg */
    
    /* UI Elements */
    --container-bg: rgba(255, 255, 255, 0.95);
    --card-border: 1px solid rgba(255, 255, 255, 0.5);
    --radius-lg: 1rem;
    --radius-md: 0.75rem;
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* --- Global Reset & Body --- */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
    box-sizing: border-box;
    /* Prevent bouncing on mobile */
    overscroll-behavior: none; 
}

h1, h2, h3 {
    margin: 0 0 1rem 0;
    line-height: 1.2;
}

h1 {
    font-size: 2rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

/* --- Main Layout Container --- */
.container {
    background: var(--container-bg);
    backdrop-filter: blur(12px); /* Glass effect */
    border: var(--card-border);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    /* Smart height management for mobile */
    max-height: calc(100vh - 2rem);
    overflow-y: auto; 
}

/* Hide scrollbar */
.container::-webkit-scrollbar { display: none; }
.container { -ms-overflow-style: none; scrollbar-width: none; }

/* --- Typography & Instructions --- */
.instructions {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
    text-align: left;
    margin-bottom: 2rem;
    background: #f8fafc;
    padding: 1rem;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
}

.instructions strong {
    color: var(--primary-dark);
    font-weight: 700;
}

/* --- Buttons --- */
button {
    font-family: inherit;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    width: 100%;
    position: relative;
    overflow: hidden;
    /* Prevent touch highlight on mobile */
    -webkit-tap-highlight-color: transparent;
}

button:active { transform: scale(0.98); }

/* Primary Action Button */
.btn-primary, .btn-full-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover, .btn-full-primary:hover {
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

/* Secondary Action Button */
.btn-secondary {
    background: white;
    color: var(--text-main);
    border: 2px solid #e2e8f0;
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #f8fafc;
}

/* Back / Ghost Button */
.btn-back {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 0.5rem;
}

.btn-back:hover {
    color: var(--text-main);
    text-decoration: underline;
    background: transparent;
    transform: none;
    box-shadow: none;
}

/* Top Right Corner Button (Leave) */
.top-right-corner-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: auto !important;
    background: #f1f5f9;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.4rem 0.8rem;
    border-radius: 999px; /* Pill shape */
}

.top-right-corner-btn:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

/* --- Forms & Inputs --- */
.form-group {
    margin-bottom: 1.25rem;
    text-align: left;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input, textarea, select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.2s;
    background: #f8fafc;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Option Groups (Pills) */
.option-group {
    display: flex;
    gap: 0.5rem;
    background: #f1f5f9;
    padding: 0.25rem;
    border-radius: var(--radius-md);
}

.option-group button {
    background: transparent;
    color: var(--text-muted);
    padding: 0.5rem;
    font-size: 0.9rem;
    border-radius: 0.5rem;
    box-shadow: none;
}

.option-group button:hover {
    transform: none;
    background: rgba(255,255,255,0.5);
}

.option-group button.selected {
    background: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    font-weight: 700;
}

/* --- Game Board --- */
.game-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px dashed #e2e8f0;
}

#game-info {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.font-mono {
    font-family: 'SF Mono', 'Roboto Mono', Menlo, monospace;
    font-weight: 700;
    letter-spacing: 0.05em;
}

/* Grid Layout */
.bingo-grid {
    display: grid;
    gap: 8px;
    aspect-ratio: 1/1;
    margin-top: 1rem;
    padding: 8px;
    background: #eef2ff;
    border-radius: var(--radius-lg);
}

/* Individual Cells */
.bingo-cell {
    background: white;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    text-align: center;
    font-size: clamp(0.6rem, 2vw, 0.85rem);
    font-weight: 600;
    color: var(--text-main);
    box-shadow: 0 2px 0 #cbd5e1; /* Pseudo-3D effect */
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    line-height: 1.2;
    /* Prevent text selection on tap */
    -webkit-user-select: none;
}

.bingo-cell:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 0 #94a3b8;
}

.bingo-cell:active {
    transform: translateY(2px);
    box-shadow: none;
}

/* Marked State */
.bingo-cell.marked {
    background: var(--primary-gradient);
    color: white;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
    transform: scale(0.95);
    border: 2px solid transparent; 
}

/* --- Notifications & Utilities --- */
.hidden { display: none !important; }

.error {
    background: #fef2f2;
    color: #ef4444;
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid #fecaca;
    margin-top: 1rem;
    font-size: 0.9rem;
    font-weight: 600;
}

#winner-notification {
    background: #fffbeb;
    border: 2px solid #fcd34d;
    color: #92400e;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    animation: bounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#mark-notification {
    background: var(--text-main);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    font-size: 0.9rem;
    font-weight: 500;
    width: max-content;
    max-width: 90%;
}

/* Animations */
@keyframes pop-in {
    0% { transform: scale(0.5); opacity: 0; }
    80% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); opacity: 1; }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

/* --- Auth Specifics --- */
#auth-view .text-link {
    color: var(--primary-color);
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    width: auto;
    display: inline-block;
    font-size: 0.9rem;
}
#auth-view .text-link:hover {
    text-decoration: underline;
}

/* --- MOBILE RESPONSIVENESS START --- */
/* Target smartphones (screens less than 600px wide) */
@media (max-width: 600px) {
    body {
        padding: 0.5rem; /* Less padding around the edge */
        align-items: flex-start; /* Align top so scrolling works better */
    }

    .container {
        padding: 1rem; /* Less internal padding */
        max-height: calc(100vh - 1rem); /* Use almost full height */
        border-radius: 0.75rem;
    }

    h1 {
        font-size: 1.75rem; /* Slightly smaller title */
    }

    /* Make the Game Header more compact */
    .game-header {
        margin-bottom: 0.75rem;
        padding-bottom: 0.75rem;
    }

    /* Adjust the grid for touch targets */
    .bingo-grid {
        gap: 4px; /* Tighter gap */
        padding: 4px;
        margin-top: 0.5rem;
    }

    .bingo-cell {
        font-size: clamp(0.5rem, 3.5vw, 0.8rem); /* Scale font with width */
        padding: 2px;
        border-radius: 4px; /* Slightly sharper corners */
    }

    /* Position the 'Leave' button out of the way */
    .top-right-corner-btn {
        top: 0.75rem;
        right: 0.75rem;
        padding: 0.3rem 0.6rem;
        font-size: 0.7rem;
    }
    
    /* Ensure inputs are easy to tap */
    input, textarea, button {
        font-size: 16px; /* Prevents auto-zoom on iOS */
    }
}
/* --- MOBILE RESPONSIVENESS END --- */
