/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1177d1;
    --primary-hover: #0d5fa8;
    --primary-light: #e8f2fc;
    --danger: #d43f3a;
    --success: #398439;
    --warning: #f0ad4e;
    --info: #5bc0de;
    --bg: #f8f9fa;
    --surface: #ffffff;
    --surface-light: #e9ecef;
    --border: #dee2e6;
    --text: #373a3c;
    --text-muted: #6c757d;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
}

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

/* ===== Header ===== */
#app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    background: linear-gradient(135deg, var(--primary) 0%, #0d5fa8 100%);
    color: white;
    border-bottom: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

#header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

#header-icon {
    font-size: 1.6rem;
    line-height: 1;
    opacity: 0.9;
}

#app-header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: white;
    line-height: 1.2;
}

#header-subtitle {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#header-version {
    opacity: 0.5;
    font-size: 0.6rem;
    margin-left: 4px;
}

#header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

#room-code-badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.15em;
}

#mute-btn {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: background 0.2s;
}

#mute-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

#lang-select {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.82rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}

#lang-select option {
    background: var(--primary);
    color: white;
}

#lang-select:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ===== Main Layout ===== */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 16px;
    gap: 16px;
}

/* ===== Canvas ===== */
#canvas-container {
    width: 100%;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

#game-canvas {
    display: block;
    width: 100%;
}

/* ===== Quiz Panel ===== */
#quiz-panel {
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 24px;
    box-shadow: var(--shadow);
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

.hidden {
    display: none !important;
}

/* ===== Bank Selection ===== */
#bank-screen h2 {
    font-size: 1.15rem;
    margin-bottom: 16px;
    color: var(--text);
}

#bank-selector {
    margin-bottom: 16px;
}

#bank-dropdown {
    width: 100%;
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236c757d' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

#bank-dropdown:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Password */
#password-prompt {
    background: var(--bg);
    padding: 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
}

#password-prompt label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

#bank-password {
    flex: 1;
    min-width: 120px;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
    font-size: 0.95rem;
}

#password-submit {
    padding: 8px 18px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

#password-submit:hover {
    background: var(--primary-hover);
}

.error {
    color: var(--danger);
    font-size: 0.85rem;
    width: 100%;
}

/* Upload */
#upload-section {
    margin-bottom: 20px;
    padding: 16px;
    border: 2px dashed var(--border);
    border-radius: 6px;
    text-align: center;
}

#upload-section p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

#file-upload {
    display: none;
}

#upload-label {
    display: inline-block;
    padding: 8px 20px;
    background: var(--surface-light);
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
}

#upload-label:hover {
    background: var(--border);
}

#upload-filename {
    display: block;
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Settings */
#settings-panel {
    background: var(--bg);
    padding: 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

#settings-panel h3 {
    font-size: 0.95rem;
    margin-bottom: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.setting-row > label {
    font-size: 0.9rem;
    color: var(--text-muted);
    min-width: 140px;
}

.setting-row input[type="number"] {
    width: 70px;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
    font-size: 0.95rem;
    text-align: center;
}

.radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.radio-group label,
.setting-row > label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
}

input[type="radio"],
input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

/* Start button */
.primary-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    letter-spacing: 0.02em;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.primary-btn:active {
    transform: translateY(0);
}

/* ===== Question Screen ===== */
#progress-bar-container {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.progress-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: transparent;
    transition: background 0.3s, border-color 0.3s, transform 0.3s;
}

.progress-dot.current {
    border-color: var(--primary);
    transform: scale(1.25);
    box-shadow: 0 0 6px rgba(37, 99, 235, 0.5);
}

.progress-dot.clean {
    background: var(--success);
    border-color: var(--success);
}

.progress-dot.failed {
    background: var(--danger);
    border-color: var(--danger);
}

#progress-text {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

#fail-counter {
    font-size: 0.85rem;
    color: var(--danger);
    margin-bottom: 12px;
    font-weight: 500;
}

#question-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

#question-text {
    font-size: 1.15rem;
    line-height: 1.5;
    margin-bottom: 20px;
    color: var(--text);
}

#answers-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.answer-btn {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.answer-btn:hover:not(:disabled) {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: translateX(4px);
}

.answer-btn:disabled {
    cursor: default;
    opacity: 0.85;
}

.answer-btn.correct {
    background: rgba(57, 132, 57, 0.12);
    border-color: var(--success);
    animation: pulse-correct 0.5s ease;
}

.answer-btn.wrong {
    background: rgba(212, 63, 58, 0.12);
    border-color: var(--danger);
    animation: shake 0.4s ease;
}

@keyframes pulse-correct {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* Feedback Toast */
#feedback-toast {
    margin-top: 16px;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
    animation: fadeIn 0.3s ease;
}

#feedback-toast.correct {
    background: rgba(57, 132, 57, 0.08);
    border-left: 4px solid var(--success);
    color: var(--success);
}

#feedback-toast.wrong {
    background: rgba(212, 63, 58, 0.08);
    border-left: 4px solid var(--danger);
    color: var(--danger);
}

.retry-btn {
    display: block;
    margin-top: 12px;
    padding: 10px 24px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.retry-btn:hover {
    background: #b91c1c;
    transform: translateY(-1px);
}

.retry-btn:active {
    transform: translateY(0);
}

.continue-btn {
    display: block;
    margin-top: 12px;
    padding: 10px 24px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.continue-btn:hover {
    background: #15803d;
    transform: translateY(-1px);
}

.continue-btn:active {
    transform: translateY(0);
}

/* Reflection card */
#feedback-toast.reflection {
    border-left: 4px solid var(--info);
}

.reflection-block {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.reflection-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--primary);
}

.reflection-content {
    font-size: 1rem;
    font-style: italic;
    line-height: 1.5;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.reflection-continue-btn {
    max-width: 200px;
    margin: 0 auto;
    padding: 10px 24px;
    font-size: 0.95rem;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Result Screen ===== */
#result-screen {
    text-align: center;
    padding: 40px 24px;
}

#result-title {
    font-size: 2rem;
    margin-bottom: 12px;
}

#result-message {
    font-size: 1.05rem;
    color: var(--text-muted);
    margin-bottom: 28px;
    line-height: 1.5;
}

#replay-btn {
    max-width: 300px;
    margin: 0 auto;
}

/* ===== Back Button ===== */
.back-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 4px 0;
    margin-bottom: 8px;
    transition: color 0.2s;
    display: inline-block;
}

.back-btn:hover {
    color: var(--text);
}

/* ===== Mode Selection ===== */
.mode-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 20px;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 24px 32px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
    min-width: 160px;
}

.mode-btn:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(17, 119, 209, 0.15);
    transform: translateY(-2px);
}

.mode-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.mode-label {
    font-size: 1.1rem;
    font-weight: 700;
}

.mode-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

/* ===== Team Lobby ===== */

.ably-key-section {
    margin-bottom: 16px;
}

.ably-key-section label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.ably-key-section input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--surface-light);
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.02em;
}

.help-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-style: italic;
}




.room-code-display {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 0.3em;
    text-align: center;
    color: var(--primary);
    padding: 16px;
    background: var(--primary-light);
    border-radius: var(--radius);
    margin: 12px 0;
    font-family: 'Courier New', monospace;
    border: 1px solid var(--border);
}

#teacher-qr-container {
    display: flex;
    justify-content: center;
    margin: 12px 0;
}

#teacher-qr-container svg {
    border-radius: 8px;
    background: white;
    padding: 8px;
}

#teacher-link-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 16px;
}

.secondary-btn {
    padding: 8px 18px;
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.secondary-btn:hover {
    background: var(--surface-light);
}

#copy-link-feedback {
    font-size: 0.85rem;
    color: var(--success);
    font-weight: 600;
}

#teacher-close-room-btn {
    width: 100%;
    margin-top: 10px;
}

.player-count {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 8px;
}

.player-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-bottom: 16px;
}

.player-tag {
    display: inline-block;
    padding: 4px 10px;
    background: var(--primary-light);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--primary);
    border: 1px solid var(--border);
}

#teacher-bank-selector,
#teacher-settings {
    margin-top: 20px;
    margin-bottom: 16px;
}

#teacher-bank-selector h3 {
    font-size: 0.95rem;
    margin-bottom: 8px;
    color: var(--text-muted);
}

#teacher-bank-dropdown {
    width: 100%;
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 10px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236c757d' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

#teacher-bank-password-prompt {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

#teacher-bank-password {
    flex: 1;
    min-width: 120px;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--surface-light);
    background: white;
    color: var(--text);
}

#teacher-upload-section {
    margin: 10px 0;
}

#teacher-upload-label {
    display: inline-block;
    padding: 8px 16px;
    background: var(--surface-light);
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

#teacher-file-upload {
    display: none;
}

#teacher-upload-filename {
    display: inline-block;
    margin-left: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

#teacher-settings {
    background: var(--bg);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

/* ===== Student Join ===== */
.join-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 320px;
    margin: 20px auto 0;
}

.join-form label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.join-form input {
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--surface-light);
    background: var(--bg);
    color: var(--text);
    font-size: 1.1rem;
    text-align: center;
}

#student-room-code {
    font-size: 1.5rem;
    letter-spacing: 0.2em;
    font-weight: 700;
}

/* ===== Wait Screen ===== */
.wait-container {
    text-align: center;
    padding: 40px 20px;
}

.wait-container h2 {
    margin-bottom: 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Team Timer ===== */
#team-timer-bar {
    width: 100%;
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    margin-bottom: 10px;
    overflow: hidden;
}

#team-timer-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    width: 100%;
}

/* ===== Team Question ===== */
#team-progress-container {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

#team-progress-text {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

#team-answer-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 14px;
    text-align: center;
}

#team-question-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    margin-top: 8px;
    font-weight: 500;
}

#team-question-text {
    font-size: 1.15rem;
    line-height: 1.5;
    margin-bottom: 20px;
    color: var(--text);
}

#team-answers-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#team-close-answers-btn {
    margin-top: 20px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    padding: 10px 32px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

#team-close-answers-btn:hover {
    background: #b53430;
}

.answer-btn.teacher-answer {
    cursor: default;
    opacity: 0.9;
}

.answer-btn.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.teacher-controls {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.teacher-controls .primary-btn {
    flex: 1;
    min-width: 140px;
}

.teacher-controls .secondary-btn {
    flex: 0;
    white-space: nowrap;
}

#team-wait-message {
    text-align: center;
    color: var(--text-muted);
    margin-top: 16px;
    font-size: 0.95rem;
    font-style: italic;
}

#team-feedback-toast {
    margin-top: 16px;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
    animation: fadeIn 0.3s ease;
}

#team-feedback-toast.correct {
    background: rgba(57, 132, 57, 0.08);
    border-left: 4px solid var(--success);
    color: var(--success);
}

#team-feedback-toast.wrong {
    background: rgba(212, 63, 58, 0.08);
    border-left: 4px solid var(--danger);
    color: var(--danger);
}

/* ===== Stats Screen ===== */
#team-stats-screen {
    text-align: center;
}

#team-stats-screen h2 {
    margin-bottom: 24px;
}

#stats-bars {
    max-width: 400px;
    margin: 0 auto 20px;
}









.answer-pct-badge {
    float: right;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    opacity: 0.8;
}

.feedback-section {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
}

.feedback-section:last-child {
    margin-bottom: 0;
}

.feedback-section.section-correct {
    border-left: 4px solid var(--success);
}

.feedback-section.section-wrong {
    border-left: 4px solid var(--danger);
}

.feedback-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.team-reveal-stats {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.team-reveal-correct {
    margin-top: 6px;
    color: var(--success);
    font-style: italic;
}


#stats-detail {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* ===== Team Result ===== */
#team-result-screen {
    text-align: center;
    padding: 40px 24px;
}

#team-result-title {
    font-size: 2rem;
    margin-bottom: 12px;
}

#team-result-message {
    color: var(--text-muted);
    margin-bottom: 8px;
}

#team-result-stats {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

#team-result-screen .primary-btn {
    max-width: 300px;
    margin: 12px auto;
}

/* ===== Reconnection Overlay ===== */
#reconnection-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.overlay-content {
    text-align: center;
    color: var(--text);
}

.overlay-content .spinner {
    width: 50px;
    height: 50px;
    margin-bottom: 16px;
}

/* ===== Footer ===== */
#app-footer {
    text-align: center;
    padding: 20px 24px;
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.8;
    border-top: 1px solid var(--border);
    margin-top: 16px;
}

#app-footer strong {
    color: var(--text);
    font-weight: 600;
}

.footer-sep {
    margin: 0 6px;
    opacity: 0.4;
}

.footer-links {
    margin-top: 2px;
}

.footer-links a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.footer-links a:hover {
    text-decoration: underline;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    main {
        padding: 8px;
        gap: 10px;
    }

    #app-header {
        padding: 10px 16px;
    }

    #app-header h1 {
        font-size: 1.1rem;
    }

    #quiz-panel {
        padding: 16px;
    }

    .setting-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .radio-group {
        flex-direction: column;
        gap: 8px;
    }

    #result-title,
    #team-result-title {
        font-size: 1.5rem;
    }

    .mode-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .mode-btn {
        min-width: 0;
        padding: 16px 20px;
    }

    .room-code-display {
        font-size: 2.2rem;
    }

    .join-form {
        max-width: 100%;
    }
}

/* ===== Bank load status (loaded / skipped / error) ===== */
.bank-status {
    margin: 12px 0;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-left: 3px solid var(--success);
    background: var(--bg);
    font-size: 0.9rem;
    color: var(--text);
}

.bank-status.error {
    border-left-color: var(--danger);
    color: var(--danger);
}

.bank-skipped {
    margin: 8px 0 0;
    padding-left: 1.1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.5;
}

.bank-skipped li {
    margin-top: 3px;
}

/* ===== Accessibility ===== */

/* There was exactly one :focus rule in this stylesheet, on #bank-dropdown.
   Everything else relied on the browser default ring, which survived only
   because every control is a real <button>. Make it a decision. */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Screens receive focus when they appear; that should not draw a box. */
.screen h2:focus,
.screen h3:focus,
.screen:focus {
    outline: none;
}

#motion-btn[aria-pressed="true"] {
    opacity: 0.65;
}

/* The canvas animation is driven from JS (see GameRenderer.reducedMotion).
   This covers the CSS side: timer bars, pulses and toasts. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* The teacher's screen is usually projected in class, so the key is masked
   by default and this row holds the reveal toggle beside it. */
.key-input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.key-input-row input {
    flex: 1;
    min-width: 0;
}

#ably-key-reveal {
    flex: 0 0 auto;
    padding: 0 12px;
    background: var(--bg);
    border: 1px solid var(--surface-light);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

#ably-key-reveal:hover {
    background: var(--surface-light);
}
