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

:root {
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-dark: #4338ca;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text: #1f2937;
    --text-light: #6b7280;
    --bg: #f9fafb;
    --border: #e5e7eb;
}

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 2em;
    color: var(--primary);
}

.status {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
    background-color: var(--border);
    color: var(--text-light);
}

.status.connected {
    background-color: #dbeafe;
    color: #1e40af;
}

.status.joined {
    background-color: #dcfce7;
    color: #15803d;
}

.status.disconnected {
    background-color: #fee2e2;
    color: #b91c1c;
}

main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

section {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

section h2 {
    margin-bottom: 20px;
    color: var(--primary);
    font-size: 1.5em;
}

section h3 {
    margin-bottom: 15px;
    color: var(--text);
    font-size: 1.1em;
}

.form-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-direction: column;
}

.form-group input,
.form-group textarea,
.form-group button {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1em;
    font-family: inherit;
}

.form-group input,
.form-group textarea {
    background: white;
    color: var(--text);
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group button {
    background: var(--primary);
    color: white;
    cursor: pointer;
    font-weight: 600;
    border: none;
    transition: background 0.2s;
}

.form-group button:hover {
    background: var(--primary-dark);
}

.form-group button.btn-danger {
    background: var(--danger);
}

.form-group button.btn-danger:hover {
    background: #dc2626;
}

textarea {
    min-height: 150px !important;
    resize: vertical;
    font-family: "Courier New", monospace;
    font-size: 0.9em;
}

/* Team and quiz specific styles */
.teams-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.team-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--bg);
    border-radius: 6px;
    border-left: 4px solid var(--primary);
}

.team-info h3 {
    margin: 0 0 5px 0;
    color: var(--text);
}

.team-info p {
    margin: 0;
    color: var(--text-light);
    font-size: 0.9em;
}

.team-score {
    font-size: 1.8em;
    font-weight: bold;
    color: var(--primary);
}

.question-display {
    background: var(--bg);
    padding: 20px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.question-card {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.question-number {
    font-size: 0.85em;
    color: var(--text-light);
    font-weight: 600;
}

.question-text {
    font-size: 1.3em;
    color: var(--text);
    font-weight: 600;
}

.question-answer {
    padding: 12px;
    background: #dcfce7;
    border-left: 4px solid var(--success);
    border-radius: 4px;
    color: #15803d;
}

.responses-section {
    margin-bottom: 25px;
}

.responses-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.response-item {
    padding: 12px;
    background: var(--bg);
    border-radius: 4px;
    font-size: 0.9em;
    border-left: 4px solid var(--primary);
    display: flex;
    gap: 10px;
    align-items: center;
    transition: all 0.2s;
}

.response-item.first-answer {
    background: #fef3c7;
    border-left-color: var(--warning);
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.response-rank {
    font-weight: 700;
    color: var(--primary);
    min-width: 30px;
    font-size: 1.1em;
}

.response-item.first-answer .response-rank {
    color: var(--warning);
    font-size: 1.2em;
}

.response-team {
    font-weight: 600;
    color: var(--text);
    min-width: 120px;
}

.response-answer {
    color: var(--text);
    flex: 1;
    word-break: break-word;
}

.response-time {
    font-weight: 600;
    color: var(--success);
    min-width: 60px;
    text-align: right;
    font-size: 0.95em;
}

.response-item.first-answer .response-time {
    color: var(--warning);
    font-weight: 700;
}

.no-responses {
    padding: 20px;
    text-align: center;
    color: var(--text-light);
    font-style: italic;
}

.team-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
    max-height: 200px;
    overflow-y: auto;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.checkbox-label:hover {
    background: #f3f4f6;
}

.checkbox-label input {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.leaderboard {
    background: var(--bg);
    padding: 20px;
    border-radius: 6px;
}

.leaderboard h3 {
    margin-top: 0;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: white;
    border-radius: 4px;
    margin-bottom: 8px;
    border-left: 4px solid var(--primary);
}

.leaderboard-item:last-child {
    margin-bottom: 0;
}

.position {
    font-weight: 600;
    color: var(--primary);
    min-width: 30px;
    font-size: 1.2em;
}

.leaderboard-item .name {
    flex: 1;
    font-weight: 500;
}

.leaderboard-item .score {
    font-size: 1.3em;
    font-weight: bold;
    color: var(--success);
}

.score-item {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg);
    border-radius: 6px;
    margin-bottom: 8px;
}

.score-item.current {
    background: #dbeafe;
    border-left: 4px solid var(--primary);
    padding-left: calc(12px - 4px);
}

.team-name {
    font-weight: 600;
}

.team-score {
    color: var(--primary);
    font-weight: bold;
}

.waiting {
    text-align: center;
    padding: 40px 20px;
}

.playing {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.answer-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.answer-option {
    padding: 15px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.answer-option:hover {
    border-color: var(--primary);
    background: #dbeafe;
}

#answerStatus {
    padding: 12px;
    border-radius: 6px;
    text-align: center;
    font-weight: 600;
}

#answerStatus.success {
    background: #dcfce7;
    color: #15803d;
}

#answerStatus.error {
    background: #fee2e2;
    color: #b91c1c;
}

.letter-answer-grid {
    padding: 20px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 20px;
}

.letter-prompt {
    text-align: center;
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text);
}

.letter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(45px, 1fr));
    gap: 8px;
    max-width: 600px;
    margin: 0 auto;
}

.letter-btn {
    padding: 12px;
    border: 2px solid var(--primary);
    background: white;
    color: var(--primary);
    border-radius: 6px;
    font-weight: 600;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s;
}

.letter-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

.letter-btn.selected {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.3);
}

.number-answer-grid {
    padding: 20px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 20px;
}

.number-prompt {
    text-align: center;
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text);
}

.number-display {
    background: white;
    border: 2px solid var(--primary);
    border-radius: 6px;
    padding: 20px;
    text-align: center;
    font-size: 2em;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 20px;
    min-height: 50px;
}

.number-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    max-width: 300px;
    margin: 0 auto 20px;
}

.number-btn {
    padding: 15px;
    border: 2px solid var(--primary);
    background: white;
    color: var(--primary);
    border-radius: 6px;
    font-weight: 700;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.2s;
}

.number-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

.number-btn.selected {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.3);
}

.number-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-secondary {
    padding: 12px 16px;
    border: 2px solid var(--text-light);
    background: white;
    color: var(--text-light);
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--text-light);
    color: white;
}

.btn-primary {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.ranking-points-config {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.ranking-points-config label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-weight: 600;
    font-size: 0.9em;
    color: var(--text);
}

.ranking-points-config input {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1em;
}

.ranking-preview {
    background: white;
    border: 2px solid var(--primary);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.ranking-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ranking-row {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: var(--bg);
    border-radius: 6px;
    border-left: 4px solid var(--primary);
}

.ranking-medal {
    font-size: 1.5em;
    min-width: 30px;
}

.ranking-team {
    flex: 1;
    font-weight: 600;
    color: var(--text);
}

.ranking-points {
    background: var(--success);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.95em;
}

.btn-award {
    background: var(--success);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-award:hover {
    background: #059669;
}

.end-screen {
    text-align: center;
    padding: 40px 20px;
}

.end-screen h2 {
    margin-bottom: 30px;
    color: var(--primary);
}

#finalScores {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.reset-section {
    grid-column: 1 / -1;
    text-align: center;
}

@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
    }

    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    header h1 {
        font-size: 1.5em;
    }

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

    .team-card {
        flex-direction: column;
        text-align: center;
    }

    section {
        padding: 15px;
    }
}
