:root {
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --primary: #f59e0b;
    /* Amber 500 */
    --primary-glow: rgba(245, 158, 11, 0.5);
    --secondary: #3b82f6;
    /* Blue 500 */
    --accent: #ec4899;
    /* Pink 500 */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
    --border: #334155;

    --font-main: 'Outfit', sans-serif;

    --glass: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

/* Light Theme */
body.theme-light {
    --bg-dark: #f0f9ff;
    --bg-card: #ffffff;
    --primary: #0284c7;
    --primary-glow: rgba(2, 132, 199, 0.4);
    --secondary: #f59e0b;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #cbd5e1;
    --glass: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.05);
}

/* Classic Theme (Red) */
body.theme-classic {
    --bg-dark: #7f1d1d;
    --bg-card: #991b1b;
    --primary: #fbbf24;
    --primary-glow: rgba(251, 191, 36, 0.4);
    --secondary: #ffffff;
    --text-main: #ffffff;
    --text-muted: #fecaca;
    --border: #b91c1c;
    --glass: rgba(153, 27, 27, 0.9);
    --glass-border: rgba(255, 255, 255, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-main);
    height: 100vh;
    overflow: hidden;
    /* Prevent scrolling on fullscreen app */
    background-image:
        radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(236, 72, 153, 0.15) 0%, transparent 40%);
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--glass);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    margin-bottom: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.controls-top {
    display: flex;
    align-items: center;
    gap: 15px;
}

.theme-select {
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
}

.theme-select option {
    background: var(--bg-card);
    color: var(--text-main);
}

.separator-v {
    width: 1px;
    height: 24px;
    background: var(--border);
}

h1 {
    font-weight: 900;
    font-size: 2rem;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.highlight {
    color: var(--primary);
    background: linear-gradient(135deg, var(--primary) 0%, #fbbf24 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 1.5rem;
    flex: 1;
    min-height: 0;
    /* Important for scroll within grid */
}

/* Left Side: Display */
.display-section {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--glass);
    border-radius: 24px;
    padding: 2rem;
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.display-section::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
    opacity: 0.1;
    pointer-events: none;
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.current-number-container {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
}

.number-display-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.current-letter {
    font-size: 8rem;
    font-weight: 900;
    color: var(--primary);
    text-shadow: 0 0 30px var(--primary-glow);
    line-height: 1;
}

.current-number {
    font-size: 12rem;
    font-weight: 900;
    line-height: 1;
    color: var(--text-main);
    text-shadow: 0 0 40px var(--primary-glow);
    font-variant-numeric: tabular-nums;
    transition: all 0.1s;
}

/* Animation for popping visual */
.pop-in {
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    70% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.current-number-label {
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 300px;
    z-index: 10;
}

.btn {
    border: none;
    border-radius: 12px;
    padding: 1.2rem 2rem;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #d97706 100%);
    color: #fff;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 10px var(--primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px var(--primary-glow);
    filter: brightness(1.1);
}

.btn-secondary {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text-muted);
}

.btn-secondary:hover {
    border-color: var(--text-main);
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

/* Prize Section */
.prize-section {
    margin-top: 1.5rem;
    width: 100%;
    max-width: 300px;
}

.prize-section label {
    display: block;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.prize-input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--primary);
    border-radius: 12px;
    padding: 0.5rem 1rem;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.1);
}

.currency-symbol {
    color: var(--primary);
    font-weight: 700;
    font-size: 1.2rem;
    margin-right: 0.5rem;
}

#prize-value {
    background: transparent;
    border: none;
    color: #fff;
    font-family: var(--font-main);
    font-size: 1.5rem;
    font-weight: 700;
    width: 100%;
    outline: none;
}

#prize-value::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

/* Auto Play Controls */
.auto-play-section {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    width: 100%;
    max-width: 300px;
    border: 1px solid var(--border);
}

.auto-play-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.timer-input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#auto-timer {
    width: 50px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 4px 8px;
    border-radius: 6px;
    text-align: center;
    font-family: var(--font-main);
}

.btn-auto {
    width: 100%;
    padding: 0.8rem;
    font-size: 0.9rem;
    background: transparent;
    border: 1px dashed var(--secondary);
    color: var(--secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    font-weight: 700;
}

.btn-auto:hover {
    background: rgba(59, 130, 246, 0.1);
}

.btn-auto.active {
    background: rgba(239, 68, 68, 0.1);
    /* Red tint */
    border-color: #ef4444;
    color: #ef4444;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* History */
.history-preview {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
}

.history-preview span:first-child {
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
}

#history-list {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    min-height: 85px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-dark) 100%);
    border: 4px solid var(--border);
    color: var(--text-main);
    font-weight: 800;
    font-size: 2.2rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.history-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 60%);
}

.history-item:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 10px 25px var(--primary-glow);
}

/* Right Side: Board */
.board-section {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.2);
}

.board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.board-header h2 {
    font-size: 1.25rem;
    color: var(--text-main);
}

.stats {
    display: flex;
    gap: 1.5rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.bingo-header-row {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    /* Default 1-75 is 15x5 approx, usually BINGO is 5 cols. Let's do standard 1-75 layout */
    /* Wait, standard bingo is 1-15 B, 16-30 I, etc. So 5 rows, 15 numbers each? No, 5 cols (B-I-N-G-O) and 15 numbers per col. */
    /* To display nicely on screen, often a 15x5 grid or 5 rows of 15 is valid. Let's do 5 rows (letters) x 15 columns. */
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.col-header {
    display: none;
    /* We will use row-based layout mostly for BINGO */
}

/* We will actually use a grid that is 15 columns wide and 5 rows high */
/* Or B-I-N-G-O letters on the left (5 rows) */

.bingo-board {
    display: grid;
    grid-template-columns: auto repeat(15, 1fr);
    gap: 6px;
    flex: 1;
    overflow-y: auto;
}

.letter-col {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.5rem;
    color: var(--primary);
    text-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
    padding-right: 1rem;
}

.number-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    font-weight: 600;
    color: var(--text-muted);
    border: 1px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1rem;
}

.number-cell.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 15px var(--primary-glow);
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.5);
    z-index: 2;
    font-weight: 900;
}

.number-cell.recent {
    animation: flash 1s infinite alternate;
}

@keyframes flash {
    from {
        filter: brightness(1);
    }

    to {
        filter: brightness(1.3);
    }
}

.footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 1rem;
}

/* Responsive */
@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .current-number {
        font-size: 8rem;
    }

    .bingo-board {
        gap: 4px;
    }

    .number-cell {
        font-size: 0.8rem;
    }
}

@media (max-width: 600px) {
    body {
        overflow-y: auto;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .bingo-header-row {
        gap: 2px;
    }

    .current-number {
        font-size: 6rem;
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
    opacity: 1;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-main);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: #ef4444;
}

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    color: var(--text-muted);
    margin-bottom: 0.8rem;
}

#check-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 1rem;
    resize: none;
    margin-bottom: 1rem;
}

#check-input:focus {
    border-color: var(--primary);
    outline: none;
}

.check-result {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 8px;
    font-weight: 700;
    text-align: center;
    min-height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.check-result.success {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid #10b981;
    color: #10b981;
}

.check-result.fail {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid #ef4444;
    color: #ef4444;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

.btn-check {
    background: transparent;
    border: 2px dashed var(--success);
    color: var(--success);
    margin-top: 5px;
}

.btn-check:hover {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

/* Generator Styles */
.modal-large {
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    overflow: hidden;
}

.modal-large .modal-body {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.generator-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

#card-quantity {
    width: 70px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    color: var(--text-main);
    text-align: center;
}

.cards-preview-container {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.bingo-card {
    background: #fff;
    color: #000;
    padding: 1rem;
    border-radius: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    border: 2px solid #000;
}

.bingo-card-header {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    margin-bottom: 5px;
}

.bingo-card-header div {
    font-weight: 900;
    font-size: 2rem;
    text-align: center;
    color: #000;
}

.bingo-card-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    border-top: 2px solid #000;
    border-left: 2px solid #000;
}

.bingo-card-cell {
    aspect-ratio: 1;
    border-right: 2px solid #000;
    border-bottom: 2px solid #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.5rem;
}

.bingo-card-cell.free {
    font-size: 0.8rem;
    background: #eee;
    text-transform: uppercase;
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
        overflow: visible;
    }

    .app-container,
    .modal-overlay,
    .modal-header,
    .generator-controls,
    .close-btn {
        display: none !important;
    }

    #generator-modal {
        position: static;
        display: block !important;
        background: white;
        width: 100%;
        height: auto;
        opacity: 1;
    }

    .modal-content {
        box-shadow: none;
        border: none;
        width: 100%;
        max-width: none;
        background: white;
        animation: none;
    }

    .modal-body {
        padding: 0;
        overflow: visible;
    }

    .cards-preview-container {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
        background: white;
        overflow: visible;
    }

    .bingo-card {
        box-shadow: none;
        break-inside: avoid;
        border: 2px solid #000;
    }
}