:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --marked: #bbf7d0;
    --free-space: #fef3c7;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

header {
    text-align: center;
    padding: 2rem 0;
}

    header h1 {
        font-size: 2.5rem;
        color: var(--primary);
        margin-bottom: 0.5rem;
    }

    header p {
        color: var(--text-muted);
    }

.card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

    .card h2 {
        margin-bottom: 1rem;
        color: var(--text);
        font-size: 1.25rem;
    }

.form-group {
    margin-bottom: 1rem;
}

    .form-group label {
        display: block;
        margin-bottom: 0.5rem;
        font-weight: 500;
        color: var(--text);
    }

    .form-group input, .form-group textarea, .form-group select {
        width: 100%;
        padding: 0.75rem;
        border: 2px solid var(--border);
        border-radius: 8px;
        font-size: 1rem;
        transition: border-color 0.2s;
    }

        .form-group input:focus, .form-group textarea:focus {
            outline: none;
            border-color: var(--primary);
        }

    .form-group textarea {
        resize: vertical;
        min-height: 150px;
    }

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

    .checkbox-group input[type="checkbox"] {
        width: auto;
    }

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

    .btn-primary:hover {
        background: var(--primary-dark);
    }

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

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

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-block {
    width: 100%;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.code-box {
    background: #1e293b;
    color: #f1f5f9;
    padding: 1rem;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 1.25rem;
    text-align: center;
    letter-spacing: 0.1em;
    user-select: all;
    margin: 0.5rem 0;
}

.share-link {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

    .share-link input {
        flex: 1;
    }

/* Bingo Grid */
.bingo-grid {
    display: grid;
    gap: 4px;
    margin: 1rem 0;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.bingo-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.25rem;
    background: white;
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 500;
    transition: all 0.2s;
    word-break: break-word;
    overflow: hidden;
    line-height: 1.2;
    min-height: 70px;
}

    .bingo-cell:hover:not(.free-space):not(.marked) {
        border-color: var(--primary);
        background: #eff6ff;
    }

    .bingo-cell.marked {
        background: var(--marked);
        border-color: var(--success);
    }

    .bingo-cell.free-space {
        background: var(--free-space);
        border-color: var(--warning);
        cursor: default;
        font-weight: 700;
    }

    .bingo-cell.winning {
        animation: pulse 0.5s infinite alternate;
    }

@keyframes pulse {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.05);
    }
}

@keyframes pulse {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.05);
    }
}

/* Phrase List */
.phrase-list {
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
}

.phrase-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

    .phrase-item:last-child {
        border-bottom: none;
    }

    .phrase-item button {
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
    }

/* Player List */
.player-list {
    list-style: none;
}

.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

    .player-item .status {
        padding: 0.25rem 0.5rem;
        border-radius: 4px;
        font-size: 0.75rem;
        font-weight: 600;
    }

        .player-item .status.winner {
            background: var(--success);
            color: white;
        }

        .player-item .status.playing {
            background: var(--primary);
            color: white;
        }

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

.tab {
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    border-radius: 8px 8px 0 0;
}

    .tab.active {
        color: var(--primary);
        background: #eff6ff;
        font-weight: 600;
    }

/* Views */
.view {
    display: none;
}

    .view.active {
        display: block;
    }

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat {
    text-align: center;
    padding: 1rem;
    background: #f1f5f9;
    border-radius: 8px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Winner Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.modal .confetti {
    font-size: 4rem;
    margin-bottom: 1rem;
}

/* Responsive */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.5rem;
    }

    header p {
        font-size: 0.9rem;
    }

    .container {
        padding: 0.5rem;
    }

    .card {
        padding: 0.75rem;
    }

    .bingo-grid {
        gap: 3px;
    }

    .bingo-cell {
        font-size: 0.50rem;
        padding: 0.2rem;
        min-height: 60px;
        border-radius: 4px;
        border-width: 1px;
    }

    .btn-group {
        flex-direction: column;
    }
}

/* Extra small phones */
@media (max-width: 380px) {
    .bingo-cell {
        font-size: 0.5rem;
        min-height: 55px;
        padding: 0.15rem;
    }
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-setup {
    background: #fef3c7;
    color: #92400e;
}

.badge-active {
    background: #dcfce7;
    color: #166534;
}

.badge-completed {
    background: #dbeafe;
    color: #1e40af;
}