/* General Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    margin: 0;
    padding: 20px 10%;
}

.container {
    width: 100%;
    max-width: none;
    margin: 0 auto;
}

header {
    background-color: #fff;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

header h1 {
    margin: 0;
    font-size: 1.5em;
    color: #1c1e21;
}

.nav-links a {
    margin-left: 15px;
    text-decoration: none;
    color: #0866ff;
    font-weight: 500;
}

.card {
    background-color: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    height: 100%;
}

h2 {
    margin-top: 0;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
    margin-bottom: 15px;
    font-size: 1.2em;
    color: #333;
}

h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1em;
    color: #606770;
}

button {
    padding: 8px 15px;
    border: none;
    border-radius: 6px;
    background-color: #e4e6eb;
    color: #050505;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #d8dade;
}

button:disabled {
    background-color: #f0f2f5;
    color: #bcc0c4;
    cursor: not-allowed;
}

button#reset-game-btn {
    background-color: #fad2d2;
    color: #d92b2b;
}
button#reset-game-btn:hover {
    background-color: #f8b6b6;
}

/* Main Grid Layout */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1fr;
    gap: 20px;
    align-items: start;
}

/* Game Control */
#game-control .control-group {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f2f5;
}
#game-control .control-group:last-child {
    border-bottom: none;
}

#qualifying-teams {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

#game-control button {
    width: 100%;
    margin-bottom: 5px;
}

#start-final-btn, #next-question-btn {
    background-color: #cceeff;
    color: #0077cc;
}
#start-final-btn:hover, #next-question-btn:hover {
    background-color: #b3e6ff;
}

#activate-buzzer-btn {
    background-color: #e6ffcc;
    color: #339900;
}
#activate-buzzer-btn:hover {
    background-color: #d9ffb3;
}


/* Current State */
#current-state p {
    margin: 5px 0 15px;
}
#current-state span {
    font-weight: 600;
    background-color: #f0f2f5;
    padding: 3px 8px;
    border-radius: 4px;
}
#question-content {
    background-color: #f7f7f7;
    border: 1px solid #ddd;
    padding: 15px;
    border-radius: 6px;
    min-height: 80px;
    margin-bottom: 15px;
    white-space: pre-wrap;
    font-size: 1.1em;
}

#question-options-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}

#question-options-container .option-btn {
    padding: 12px;
    font-size: 1em;
    text-align: left;
    width: 100%;
    height: 100%;
    min-height: 50px;
}

#question-options-container .option-btn.correct {
    background-color: #a7e8b7;
    color: #0f5132;
    border: 1px solid #0f5132;
}

#question-options-container .option-btn.incorrect {
    background-color: #f5c2c7;
    color: #842029;
    border: 1px solid #842029;
}

#question-options-container .option-btn.selected {
    background-color: #007bff;
    color: white;
    border: 2px solid #0056b3;
    transform: scale(1.02);
    box-shadow: 0 2px 4px rgba(0,123,255,0.3);
}

#question-options-container .option-btn.selected:hover {
    background-color: #0056b3;
    border-color: #004085;
}

/* 答案解析区域样式 */
#answer-explanation-container {
    font-size: 14px;
    line-height: 1.5;
}

#answer-explanation-container h4 {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 选项选择确认区域样式 */
#answer-selection-container {
    font-size: 14px;
}

#answer-selection-container h4 {
    display: flex;
    align-items: center;
    gap: 8px;
}

#selected-options-display {
    font-family: monospace;
    background: rgba(255,255,255,0.8);
    padding: 8px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
}

#judging-buttons {
    display: flex;
    gap: 10px;
}
#judging-buttons button {
    flex-grow: 1;
    padding: 12px;
    font-size: 1.1em;
}
#judge-correct-btn {
    background-color: #a7e8b7;
    color: #0f5132;
}
#judge-incorrect-btn {
    background-color: #f5c2c7;
    color: #842029;
}


/* Team Management */
#team-list .team-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 8px;
    background-color: #f0f2f5;
}
#team-list .team-name {
    font-weight: 600;
}
#team-list .team-score {
    width: 60px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 5px;
    font-size: 1em;
}
#team-list .team-actions {
    display: flex;
    gap: 5px;
}

.team-management-actions {
    margin-top: 10px;
    margin-bottom: 20px;
    border-top: 1px solid #f0f2f5;
    padding-top: 15px;
}

.team-management-actions button {
    width: 100%;
    background-color: #0866ff;
    color: #fff;
    padding: 10px;
}
.team-management-actions button:hover {
    background-color: #0052cc;
}

.add-team-form {
    margin-top: 20px;
    border-top: 1px solid #f0f2f5;
    padding-top: 15px;
}
#add-team-form {
    display: flex;
    gap: 10px;
}
#add-team-form input {
    flex-grow: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
#add-team-form button {
    white-space: nowrap;
}

/* 抢答器控制面板样式 */
#buzzer-control {
    grid-column: 4; /* 放在第4列 */
}

.connection-status {
    margin-bottom: 15px;
}

.status-indicator {
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-weight: bold;
    text-align: center;
}

.status-indicator.disconnected {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.status-indicator.connected {
    background-color: #e8f5e8;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.status-indicator.listening {
    background-color: #fff3e0;
    color: #f57c00;
    border: 1px solid #ffcc02;
}

.status-indicator.locked {
    background-color: #fce4ec;
    color: #c2185b;
    border: 1px solid #f8bbd9;
}

.port-info {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 10px;
}

.connection-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.port-select {
    min-width: 150px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.buzzer-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.buzzer-result {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 20px;
}

.result-label {
    font-weight: bold;
    margin-bottom: 8px;
    color: #495057;
}

.winner-display {
    font-size: 1.2em;
    font-weight: bold;
    text-align: center;
    padding: 10px;
    border-radius: 4px;
    background-color: #fff;
    border: 2px solid #28a745;
    color: #28a745;
}

.winner-display.empty {
    border-color: #6c757d;
    color: #6c757d;
}

.status-monitor {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.monitor-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.monitor-item label {
    font-weight: 500;
    color: #495057;
}

.status-value {
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.9em;
}

.status-value.disconnected {
    background-color: #f8d7da;
    color: #721c24;
}

.status-value.ready {
    background-color: #d4edda;
    color: #155724;
}

.status-value.listening {
    background-color: #fff3cd;
    color: #856404;
}

.status-value.locked {
    background-color: #f8d7da;
    color: #721c24;
}

.device-info {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 15px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.info-item:last-child {
    margin-bottom: 0;
}

.info-item label {
    font-weight: 500;
    color: #495057;
}

/* 按钮映射样式 */
.buzzer-mapping {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 15px;
}

.mapping-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}

.mapping-row label {
    min-width: 100px;
    font-weight: 500;
    color: #495057;
}

.mapping-select {
    flex-grow: 1;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1em;
    min-width: 150px;
}

/* 按钮状态 */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 题组标签样式 */
.group-tag {
    background-color: #e9ecef;
    border: 2px solid #dee2e6;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-tag:hover {
    background-color: #f8f9fa;
    border-color: #adb5bd;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.group-tag.selected {
    background-color: #007bff;
    border-color: #0056b3;
    color: white;
    font-weight: 600;
}

.group-tag .group-name {
    display: block;
    text-align: center;
}

.group-tag .group-count {
    font-size: 0.8em;
    opacity: 0.7;
}

/* 响应式布局 */
@media (max-width: 1200px) {
    .main-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    #buzzer-control {
        grid-column: 1 / -1; /* 占满整行 */
    }
}
