/* ===== Базовые стили ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --success: #22c55e;
    --success-dark: #16a34a;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --secondary: #64748b;
    --secondary-dark: #475569;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===== Кнопки ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

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

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

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

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

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

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

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

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

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

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

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

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

.btn-large {
    padding: 16px 32px;
    font-size: 18px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.btn-icon:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-icon.btn-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
}

/* ===== Формы ===== */
input[type="text"],
textarea {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    transition: border-color 0.2s;
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
}

input[type="text"].error {
    border-color: var(--danger);
    animation: shake 0.3s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ===== Контейнеры ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.hidden {
    display: none !important;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 16px;
}

header h1 {
    font-size: 28px;
}

nav {
    display: flex;
    gap: 10px;
}

.empty-text {
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
}

.placeholder-text {
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
}

/* ===== Уведомления ===== */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--success);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius);
    font-weight: 600;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s, slideOut 0.3s 1.7s;
    z-index: 1000;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ===== Страница создания квиза ===== */
.create-section {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
}

@media (max-width: 900px) {
    .create-section {
        grid-template-columns: 1fr;
    }
}

.quiz-list-section {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius);
    height: fit-content;
}

.quiz-list-section h2 {
    margin-bottom: 16px;
    font-size: 18px;
}

.quiz-list-section .btn {
    width: 100%;
    margin-bottom: 16px;
}

.quiz-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quiz-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.quiz-item:hover {
    background: var(--bg-hover);
}

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

.quiz-item-count {
    color: var(--text-muted);
    font-size: 14px;
}

.editor-section {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius);
}

.editor-header {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.quiz-name-input {
    flex: 1;
    font-size: 20px;
    font-weight: 600;
}

.questions-container {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 20px;
}

@media (max-width: 700px) {
    .questions-container {
        grid-template-columns: 1fr;
    }
}

.questions-sidebar h3 {
    margin-bottom: 12px;
}

.questions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.question-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: var(--bg);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.question-item:hover {
    background: var(--bg-hover);
}

.question-item.active {
    border-color: var(--primary);
    background: var(--bg-hover);
}

.question-number {
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.question-preview {
    flex: 1;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.question-actions {
    display: flex;
    gap: 4px;
}

.question-editor {
    background: var(--bg);
    padding: 20px;
    border-radius: var(--radius);
    min-height: 300px;
}

.editor-field {
    margin-bottom: 20px;
}

.editor-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-muted);
}

.image-upload {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.preview-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    object-fit: contain;
}

.preview-image.blurred-preview {
    filter: blur(15px);
}

.video-preview {
    margin-top: 12px;
}

.video-preview video {
    width: 100%;
    max-width: 400px;
    max-height: 250px;
    border-radius: 8px;
    background: #000;
}

.checkbox-field {
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--bg-hover);
    border-radius: 8px;
}

.checkbox-field label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.checkbox-field input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.audio-preview {
    width: 100%;
    max-width: 400px;
    margin-top: 10px;
}

.video-options {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-hover);
    border-radius: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 14px;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.time-inputs {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.time-inputs label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.time-inputs input[type="number"] {
    width: 80px;
    padding: 6px 10px;
    font-size: 14px;
}

/* ===== Экран входа ===== */
.login-panel {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius);
    text-align: center;
    min-width: 320px;
}

.login-box h1 {
    margin-bottom: 24px;
}

.login-box input {
    width: 100%;
    padding: 14px;
    font-size: 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    margin-bottom: 16px;
    text-align: center;
}

.login-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.login-box .btn {
    width: 100%;
}

.login-box .error-text {
    color: var(--danger);
    margin-top: 12px;
}

/* ===== Страница ведущего ===== */
.host-container {
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(135deg, var(--bg) 0%, #1a1a2e 100%);
}

.setup-panel {
    max-width: 1200px;
    margin: 0 auto;
}

.setup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.setup-title {
    display: flex;
    align-items: center;
    gap: 16px;
}

.setup-title .title-icon {
    font-size: 48px;
}

.setup-title h1 {
    font-size: 36px;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.setup-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
}

@media (max-width: 900px) {
    .setup-grid {
        grid-template-columns: 1fr;
    }
}

.setup-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.setup-sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.panel-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.player-count {
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
}

/* QR Card */
.qr-card {
    text-align: center;
}

.qr-wrapper {
    background: white;
    padding: 16px;
    border-radius: 12px;
    display: inline-block;
    margin-bottom: 16px;
}

.qr-image {
    width: 180px;
    height: 180px;
    display: block;
}

.qr-link-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.join-link {
    color: var(--primary);
    font-size: 14px;
    word-break: break-all;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s;
}

.join-link:hover {
    background: var(--bg-hover);
}

.btn-full {
    width: 100%;
}

/* Quiz Select */
.quiz-select-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quiz-select-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.quiz-select-item:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.quiz-select-item .quiz-name {
    flex: 1;
    font-weight: 600;
    font-size: 18px;
}

.quiz-select-item .quiz-questions {
    color: var(--text-muted);
    font-size: 14px;
}

/* Players Card */
.players-card {
    flex: 1;
    min-height: 200px;
}

.waiting-players-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.waiting-player {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--bg) 0%, var(--bg-hover) 100%);
    border-radius: 24px;
    font-weight: 500;
    border: 1px solid var(--border);
}

.waiting-player .remove-player {
    background: var(--danger);
    border: none;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s;
}

.waiting-player .remove-player:hover {
    background: var(--danger-dark);
    transform: scale(1.1);
}

/* ===== Панель игры ===== */
.game-panel {
    height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    position: relative;
}

.game-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 24px;
    flex: 1;
    min-height: 0;
}

@media (max-width: 1000px) {
    .game-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
}

/* Нижняя панель управления */
.game-controls-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--bg-card);
    border-radius: 16px;
    margin-top: 16px;
    border: 1px solid var(--border);
}

.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
}

.control-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.control-btn .control-icon {
    font-size: 20px;
}

.control-btn .control-label {
    font-weight: 500;
}

.control-btn.buzzer-btn {
    padding: 12px 32px;
    background: var(--primary);
    border-color: var(--primary);
}

.control-btn.buzzer-btn:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.control-btn.buzzer-btn.active {
    background: var(--warning);
    border-color: var(--warning);
}

.control-btn.buzzer-btn.active:hover {
    background: var(--warning-dark);
    border-color: var(--warning-dark);
}

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

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

.control-divider {
    width: 1px;
    height: 32px;
    background: var(--border);
    margin: 0 8px;
}

.question-display {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.header-buttons {
    display: flex;
    gap: 8px;
}

/* Оверлей с QR-кодом */
.join-info-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.join-info-overlay.hidden {
    display: none;
}

/* Анимации ответов */
.answer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    pointer-events: none;
}

.answer-overlay.hidden {
    display: none;
}

.answer-overlay.correct-overlay {
    background: rgba(34, 197, 94, 0.15);
    animation: overlayFadeIn 0.3s ease-out;
}

.answer-overlay.wrong-overlay {
    background: transparent;
    animation: none;
}

.answer-popup {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-radius: 24px;
    padding: 40px 60px;
    text-align: center;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 100px rgba(34, 197, 94, 0.4);
    animation: popupBounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.answer-popup.wrong {
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    animation: wrongPopupFloat 0.5s ease-out;
}

.wrong-content {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 48px;
}

.wrong-points {
    color: var(--danger);
    font-weight: bold;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
}

.wrong-emoji {
    animation: sadShake 0.4s ease-in-out;
}

@keyframes wrongPopupFloat {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 0;
    }
    30% {
        transform: translateY(-20px) scale(1.2);
        opacity: 1;
    }
    100% {
        transform: translateY(-30px) scale(1);
        opacity: 1;
    }
}

@keyframes sadShake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

.answer-emoji {
    font-size: 80px;
    margin-bottom: 16px;
    animation: emojiPulse 0.6s ease-in-out infinite alternate;
}

.answer-player-name {
    font-size: 42px;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 8px;
}

.answer-message {
    font-size: 24px;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 16px;
}

.answer-points {
    font-size: 48px;
    font-weight: bold;
    color: white;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.4);
    animation: pointsGlow 0.8s ease-in-out infinite alternate;
}

@keyframes overlayFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes popupBounce {
    0% {
        transform: scale(0) rotate(-10deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotate(2deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes emojiPulse {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.15);
    }
}

@keyframes pointsGlow {
    from {
        text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.4);
    }
    to {
        text-shadow: 0 0 20px rgba(255, 255, 255, 0.8), 3px 3px 6px rgba(0, 0, 0, 0.4);
    }
}

/* Анимация выхода */
.answer-overlay.fade-out {
    animation: overlayFadeOut 0.4s ease-out forwards;
}

.answer-overlay.fade-out .answer-popup {
    animation: popupExit 0.4s ease-out forwards;
}

@keyframes overlayFadeOut {
    to {
        opacity: 0;
    }
}

@keyframes popupExit {
    to {
        transform: scale(0.5) translateY(-50px);
        opacity: 0;
    }
}

.join-info-content {
    text-align: center;
    padding: 40px;
}

.join-info-content h2 {
    margin-bottom: 24px;
    font-size: 32px;
}

.game-qr {
    width: 250px;
    height: 250px;
    margin-bottom: 20px;
    border-radius: var(--radius);
    background: white;
    padding: 10px;
}

.game-join-link {
    display: block;
    font-size: 24px;
    color: var(--primary);
    margin-bottom: 24px;
    word-break: break-all;
}

#questionCounter {
    font-size: 18px;
    color: var(--text-muted);
    flex: 1;
}

.question-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.question-text {
    font-size: 28px;
    line-height: 1.4;
    margin-bottom: 16px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    background: var(--bg-card);
    padding: 8px 16px;
    border-radius: var(--radius);
}

.question-image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0;
    max-height: calc(100vh - 280px);
    margin-bottom: 16px;
    overflow: hidden;
}

.question-image-container img {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius);
    object-fit: contain;
}

.question-image-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
}

.question-image-wrapper img {
    max-width: 100%;
    max-height: calc(100vh - 280px);
    border-radius: var(--radius);
    object-fit: contain;
    display: block;
    transition: filter 0.5s ease;
}

.question-image-wrapper img.image-blurred {
    filter: blur(30px);
}

.question-image-wrapper .question-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--radius);
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.question-image-container .question-video {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius);
    background: #000;
    transition: filter 0.5s ease;
}

.question-image-container .question-video.video-blurred {
    filter: blur(30px);
}

.answer-reveal {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    padding: 20px 40px;
    background: var(--success);
    border-radius: var(--radius);
    animation: answerFadeIn 0.3s;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

@keyframes answerFadeIn {
    from { opacity: 0; transform: translateX(-50%) scale(0.9); }
    to { opacity: 1; transform: translateX(-50%) scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.answer-label {
    display: block;
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.correct-answer {
    font-size: 24px;
    font-weight: 700;
}

.question-controls {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.buzzer-queue {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    flex: 1;
}

.buzzer-queue h3 {
    margin-bottom: 16px;
}

.queue-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    max-height: 200px;
    overflow-y: auto;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
}

.queue-item.first {
    background: var(--warning);
    color: #000;
}

.queue-item.wrong-answer {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid var(--danger);
    opacity: 0.7;
}

.queue-item.wrong-answer .queue-position {
    background: var(--danger);
    color: white;
}

.queue-item.wrong-answer .queue-name {
    text-decoration: line-through;
    color: var(--text-muted);
}

.wrong-badge {
    color: var(--danger);
    font-weight: bold;
    font-size: 16px;
}

.queue-item.active-answerer {
    position: relative;
}

.active-arrow {
    position: absolute;
    left: -24px;
    font-size: 20px;
    color: var(--warning);
    animation: arrowPulse 0.8s ease-in-out infinite;
}

@keyframes arrowPulse {
    0%, 100% {
        transform: translateX(0);
        opacity: 1;
    }
    50% {
        transform: translateX(4px);
        opacity: 0.6;
    }
}

.queue-position {
    width: 28px;
    height: 28px;
    background: rgba(0,0,0,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

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

.queue-actions {
    display: flex;
    gap: 6px;
}

.scoreboard {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    flex: 1;
}

.scoreboard h3 {
    margin-bottom: 16px;
}

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

.score-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 8px;
}

.score-item.top-1 {
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    color: #000;
}

.score-item.top-2 {
    background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
    color: #000;
}

.score-item.top-3 {
    background: linear-gradient(135deg, #cd7f32, #a0522d);
    color: #fff;
}

.score-position {
    width: 24px;
    height: 24px;
    background: rgba(0,0,0,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

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

.score-points {
    font-size: 20px;
    font-weight: 700;
}

/* ===== Страница участника ===== */
.player-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.join-screen,
.waiting-screen,
.game-screen,
.removed-screen {
    width: 100%;
    max-width: 400px;
}

.join-card,
.waiting-card,
.game-card,
.removed-card {
    background: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius);
    text-align: center;
}

.join-card h1 {
    font-size: 48px;
    margin-bottom: 16px;
}

.join-card p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.join-card input {
    text-align: center;
    font-size: 20px;
    margin-bottom: 16px;
}

.join-card .btn {
    width: 100%;
}

.player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.player-name {
    font-weight: 700;
    font-size: 18px;
}

.player-score {
    color: var(--primary);
    font-weight: 600;
}

.waiting-content {
    padding: 40px 0;
}

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

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

.waiting-content h2 {
    margin-bottom: 12px;
}

.waiting-content p {
    color: var(--text-muted);
}

/* ===== Кнопка Buzzer ===== */
.buzzer-section {
    padding: 20px 0;
}

.buzzer-status {
    margin-bottom: 24px;
}

.status-text {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 500;
    background: var(--bg);
}

.status-open {
    background: var(--success);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.status-buzzed {
    background: var(--primary);
}

.status-answer {
    background: var(--warning);
    color: #000;
}

.buzzer-button {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(145deg, #ef4444, #dc2626);
    color: white;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 auto;
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.4);
    transition: all 0.2s;
}

.buzzer-icon {
    font-size: 48px;
}

.buzzer-button.active {
    animation: glow 1s infinite alternate;
}

@keyframes glow {
    from { box-shadow: 0 10px 30px rgba(239, 68, 68, 0.4); }
    to { box-shadow: 0 10px 50px rgba(239, 68, 68, 0.8); }
}

.buzzer-button.active:hover {
    transform: scale(1.05);
}

.buzzer-button.active:active {
    transform: scale(0.95);
}

.buzzer-button.disabled {
    background: linear-gradient(145deg, #475569, #334155);
    cursor: not-allowed;
    box-shadow: none;
}

.buzzer-button.buzzed {
    background: linear-gradient(145deg, #22c55e, #16a34a);
    box-shadow: 0 10px 30px rgba(34, 197, 94, 0.4);
}

.buzzed-info {
    margin-top: 24px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius);
}

.buzzed-position {
    font-size: 18px;
}

.buzzed-position span {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.question-info {
    margin-top: 24px;
    color: var(--text-muted);
}

/* ===== Экран удаления ===== */
.removed-card h2 {
    margin-bottom: 24px;
}

/* ===== QR-код секция ===== */
.qr-section {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius);
    margin-top: 24px;
}

.qr-section h3 {
    margin-bottom: 20px;
    text-align: center;
}

.qr-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.qr-container img {
    width: 200px;
    height: 200px;
    border-radius: var(--radius);
    background: white;
    padding: 10px;
}

.qr-info {
    text-align: center;
}

.qr-info p {
    color: var(--text-muted);
    margin-bottom: 12px;
}

.join-link {
    display: block;
    word-break: break-all;
    font-size: 14px;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 12px;
    color: var(--primary);
}

/* ===== QR оверлей на экране игры ===== */
.qr-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.qr-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.qr-overlay-content {
    text-align: center;
}

.qr-overlay-content h2 {
    margin-bottom: 24px;
    font-size: 28px;
}

.qr-overlay-content img {
    width: 300px;
    height: 300px;
    border-radius: var(--radius);
    background: white;
    padding: 15px;
    margin-bottom: 20px;
}

.join-url-text {
    font-size: 18px;
    color: var(--primary);
    margin-bottom: 24px;
    word-break: break-all;
}

.question-display {
    position: relative;
}

/* ===== Экран доступа запрещен ===== */
.access-denied-screen {
    width: 100%;
    max-width: 400px;
}

.access-denied-card {
    background: var(--bg-card);
    padding: 60px 40px;
    border-radius: var(--radius);
    text-align: center;
}

.access-denied-card h1 {
    font-size: 72px;
    margin-bottom: 16px;
}

.access-denied-card h2 {
    margin-bottom: 16px;
    color: var(--danger);
}

.access-denied-card p {
    color: var(--text-muted);
    line-height: 1.6;
}

/* ===== Финальный экран ===== */
.final-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--bg) 0%, #1a1a2e 100%);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.final-screen.hidden {
    display: none;
}

#confettiCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.final-content {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
    animation: finalFadeIn 0.5s ease-out;
}

@keyframes finalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.final-title {
    font-size: 36px;
    margin-bottom: 24px;
    background: linear-gradient(135deg, #f59e0b, #ef4444, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titleGlow 2s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    from {
        filter: drop-shadow(0 0 20px rgba(245, 158, 11, 0.5));
    }
    to {
        filter: drop-shadow(0 0 40px rgba(236, 72, 153, 0.5));
    }
}

.final-leaderboard {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.final-leaderboard h2 {
    margin-bottom: 20px;
    font-size: 24px;
}

.final-scores {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.final-score-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg);
    border-radius: 12px;
    animation: slideInScore 0.4s ease-out backwards;
}

@keyframes slideInScore {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.final-score-item.top-1 {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #000;
    font-size: 20px;
    padding: 20px 24px;
}

.final-score-item.top-2 {
    background: linear-gradient(135deg, #cbd5e1, #94a3b8);
    color: #000;
    font-size: 18px;
}

.final-score-item.top-3 {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: white;
}

.final-position {
    font-size: 28px;
    min-width: 40px;
    text-align: center;
}

.final-name {
    flex: 1;
    font-weight: 600;
    text-align: left;
}

.final-points {
    font-weight: bold;
}

.btn-large {
    padding: 16px 48px;
    font-size: 18px;
}

/* ===== Редактор маски ===== */
.mask-editor-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mask-editor-modal.hidden {
    display: none;
}

.mask-editor-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
}

.mask-editor-header {
    margin-bottom: 16px;
}

.mask-editor-header h2 {
    margin-bottom: 12px;
}

.mask-tools {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.mask-tools input[type="range"] {
    width: 120px;
}

.mask-tools input[type="color"] {
    width: 40px;
    height: 30px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.mask-editor-canvas-container {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 16px;
}

#maskCanvas {
    cursor: crosshair;
    border-radius: 8px;
}

.mask-editor-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Превью картинки с маской */
.image-preview-container {
    position: relative;
    display: inline-block;
    margin-top: 12px;
}

.image-preview-container .preview-image {
    display: block;
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
}

.image-preview-container .preview-mask {
    position: absolute;
    top: 0;
    left: 0;
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    pointer-events: none;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    margin-top: 8px;
}

.btn-warning {
    background: var(--warning);
    color: #000;
}

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