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

/* Скрываем элементы с v-cloak до инициализации Vue */
[v-cloak] {
    display: none !important;
}

/* Отключаем выделение текста и контекстное меню для соответствия требованиям Яндекс Игр (1.6.2.7) */
body, html {
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE10+/Edge */
    user-select: none; /* Standard */
    -webkit-touch-callout: none; /* iOS Safari */
    touch-action: manipulation; /* Отключаем зум на двойной тап и другие жесты */
    
    /* Отключаем браузерную прокрутку (требование 1.10.2) */
    overflow: hidden;
    height: 100%;
    width: 100%;
    position: fixed;
    overscroll-behavior: none; /* Отключаем pull-to-refresh */
}

/* Запрещаем перетаскивание изображений и canvas */
img, canvas {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    pointer-events: auto; /* Оставляем события для canvas */
}

/* Разрешаем выделение только для полей ввода и читаемого текста */
input, textarea, [contenteditable] {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

:root {
    /* Тёмная тема (единственная) */
    --bg: #0b0f19;
    --surface: #111827;
    --surface-2: #0f172a;
    --border: rgba(255, 255, 255, 0.08);
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #7c5cff;
    --accent-contrast: #ffffff;
}

/* ===== ПРЕЛОАДЕР ===== */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0b0f19 0%, #111827 50%, #0f172a 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
}

.preloader.fade-out {
    opacity: 0;
    visibility: hidden;
}

.preloader-content {
    text-align: center;
    color: var(--text);
    max-width: 400px;
    padding: 20px;
}

.bubble-animation {
    position: relative;
    width: 200px;
    height: 120px;
    margin: 0 auto 30px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    animation: bubble-float 2s ease-in-out infinite;
    box-shadow:
        inset 0 0 10px rgba(255, 255, 255, 0.3),
        0 0 20px rgba(124, 92, 255, 0.4);
}

.bubble-1 {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #ff6b6b, #ff8e8e);
    left: 20px;
    animation-delay: 0s;
}

.bubble-2 {
    width: 35px;
    height: 35px;
    background: linear-gradient(135deg, #4ecdc4, #6fffe9);
    right: 20px;
    animation-delay: 0.4s;
}

.bubble-3 {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #7c5cff, #a78bfa);
    top: 10px;
    animation-delay: 0.8s;
}

.bubble-4 {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, #ffd93d, #ffeb3b);
    left: 60px;
    bottom: 10px;
    animation-delay: 1.2s;
}

.bubble-5 {
    width: 25px;
    height: 25px;
    background: linear-gradient(135deg, #ff9800, #ffb74d);
    right: 80px;
    bottom: 20px;
    animation-delay: 1.6s;
}

@keyframes bubble-float {

    0%,
    100% {
        transform: translateY(0) scale(1);
        opacity: 0.8;
    }

    50% {
        transform: translateY(-15px) scale(1.1);
        opacity: 1;
    }
}

.game-title {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, #7c5cff, #a78bfa, #4ecdc4);
    background-size: 200% 200%;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradient-shift 3s ease-in-out infinite;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(124, 92, 255, 0.5);
}

@keyframes gradient-shift {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

.loading-text {
    font-size: 1.2rem;
    color: var(--muted);
    margin-bottom: 30px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

.progress-container {
    width: 100%;
    margin-top: 20px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    margin-bottom: 15px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #7c5cff, #a78bfa, #4ecdc4);
    background-size: 200% 100%;
    border-radius: 10px;
    width: 0%;
    transition: width 0.3s ease;
    animation: progress-glow 2s ease-in-out infinite;
    position: relative;
}

.progress-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: progress-shine 2s infinite;
}

@keyframes progress-glow {

    0%,
    100% {
        background-position: 0% 50%;
        box-shadow: 0 0 10px rgba(124, 92, 255, 0.4);
    }

    50% {
        background-position: 100% 50%;
        box-shadow: 0 0 20px rgba(124, 92, 255, 0.8);
    }
}

@keyframes progress-shine {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

/* Адаптивность для мобильных */
@media (max-width: 480px) {
    .preloader-content {
        padding: 15px;
        max-width: 300px;
    }

    .game-title {
        font-size: 2.2rem;
    }

    .bubble-animation {
        width: 150px;
        height: 90px;
        margin-bottom: 20px;
    }

    .bubble-1 {
        width: 30px;
        height: 30px;
    }

    .bubble-2 {
        width: 25px;
        height: 25px;
    }

    .bubble-3 {
        width: 35px;
        height: 35px;
    }

    .bubble-4 {
        width: 20px;
        height: 20px;
    }

    .bubble-5 {
        width: 18px;
        height: 18px;
    }
}

body {
    font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
    background-image: url(assets/bg_2.jpg);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: -1;
    pointer-events: none;
}

.game-container {
    text-align: center;

    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(6px);
    box-shadow: 0 10px 30px rgb(223 185 185 / 20%);
}

/* Game Stats Panel - новый дизайн */
.game-stats-panel {
    width: 100%;


    border-radius: 24px;


    margin-bottom: 16px;
}

.stats-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-radius: 16px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    white-space: nowrap;
}

.stat-card.stat-score {

    color: white;
}

.stat-card.stat-shots {

    color: white;
}

.stat-card.stat-balls {

    color: white;
}

.stat-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.4)); */
    pointer-events: none;
}

.stat-icon {
    font-size: 24px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
    flex-shrink: 0;
}

.stat-content {
    position: relative;
    z-index: 1;
    flex: 1;
    min-width: 0;
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 2px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.025em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

#gameCanvas {
    border-radius: 12px;
    cursor: none;
    /* Убираем курсор в игровом поле */
    display: block;
    margin: 0 auto;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 4px;

    /* Touch оптимизация */
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.controls {
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 16px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    color: white;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    outline: none;
    min-width: 120px;
    background: unset;
}

/* Оверлей как у stat-card */
/* .reset-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.4));
    pointer-events: none;
    z-index: 1;
} */

.reset-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(47, 168, 255, 0.4), 0 5px 12px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.reset-btn:active {
    transform: scale(0.95);
}

.reset-btn:disabled,
.reset-btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
    transform: scale(1);
    pointer-events: none;
}

.reset-btn:disabled:hover,
.reset-btn.loading:hover {
    transform: scale(1);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.reset-btn.loading {
    animation: resetLoading 1s ease-in-out infinite;
}

@keyframes resetLoading {

    0%,
    100% {
        opacity: 0.7;
    }

    50% {
        opacity: 0.9;
    }
}

/* Стили для кулдауна кнопки */
.reset-btn.cooldown {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(1);
    pointer-events: none;
    background: linear-gradient(45deg, #666, #888);
    animation: cooldownPulse 1s ease-in-out infinite;
}

.reset-btn.cooldown:hover {
    transform: scale(1);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

@keyframes cooldownPulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 0.7;
    }
}

/* Текст с z-index для размещения поверх псевдоэлементов */
.reset-btn span,
.reset-btn {
    position: relative;
    z-index: 10;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.settings-btn {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    transform: translateY(-1px);
    background: rgba(124, 92, 255, 0.12);
    border-color: rgba(124, 92, 255, 0.4);
    color: var(--accent);
}


.next-bubble {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
}

.bubble-preview {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border);
    box-shadow: none;
}

/* Анимации */
@keyframes bubblePop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(0);
    }
}

.bubble-pop {
    animation: bubblePop 0.3s ease-out;
}

/* Модальное окно */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

.modal {
    background: #1e293b;
    border-radius: 16px;
    padding: 24px;
    max-width: 420px;
    width: 92%;
    max-height: 90vh;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.25s ease-out;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.modal-header {
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 20px;
    color: var(--text);
    margin: 0;
}

.modal-body {
    margin-bottom: 20px;
}

.final-score {
    margin-bottom: 20px;
}

.score-label {
    display: block;
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 6px;
}

.score-value {
    display: block;
    font-size: 32px;
    font-weight: 700;
    color: var(--accent);
    transition: transform 0.2s ease, color 0.2s ease;
}

/* Анимация увеличения очков */
.score-value.score-updated {
    transform: scale(1.06);
    color: #8a77ff;
}

.score-value.score-hardcore {
    color: #ef4444;
}

.win-message {
    font-size: 18px;
    color: #22c55e;
    font-weight: 700;
    animation: celebration 0.6s ease-in-out;
}

.gameover-message {
    font-size: 16px;
    color: rgba(229, 231, 235, 0.9);
    font-weight: 700;
}

.modal-footer {
    text-align: center;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 14px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    color: white;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    outline: none;
    min-width: 110px;
    background: unset;
    margin: 0 auto;
}

/* Псевдоэлемент закомментирован, как у reset-btn */
/* .modal-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.4));
    pointer-events: none;
    z-index: 1;
} */

.modal-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(47, 168, 255, 0.4), 0 5px 12px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.modal-btn:active {
    transform: scale(0.95);
}

/* Текст с z-index для размещения поверх псевдоэлементов (как у reset-btn) */
.modal-btn span,
.modal-btn {
    position: relative;
    z-index: 10;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Кнопка revival с наградой */
.modal-btn-revive {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    line-height: 1.3;
}

.modal-btn-revive:hover {
    box-shadow: 0 6px 12px rgba(16, 185, 129, 0.4), 0 5px 12px rgba(0, 0, 0, 0.2);
}

.modal-btn-revive small {
    font-size: 11px;
    opacity: 0.9;
    font-weight: 400;
}

/* Иконка видео для кнопки продолжения */
.video-icon {
    display: inline-block;
    font-size: 14px;
    opacity: 0.9;
    font-weight: 400;
    margin-top: 2px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    animation: pulse 2s infinite;
}

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

/* Анимации для модального окна */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes celebration {

    0%,
    100% {
        transform: scale(1);
    }

    25% {
        transform: scale(1.1) rotate(-2deg);
    }

    75% {
        transform: scale(1.1) rotate(2deg);
    }
}

/* Стили для модального окна настроек */
.settings-modal {
    max-width: min(520px, 90vw);
    max-height: 90%;
    padding: 16px;
    overflow-y: auto;
    /* Скрываем скроллбар для всех браузеров */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE и Edge */
}

/* Скрываем скроллбар для webkit браузеров (Chrome, Safari, Opera) */
.settings-modal::-webkit-scrollbar {
    display: none;
}

.setting-group {
    margin-bottom: 16px;
    text-align: left;
}

.setting-group h3 {
    color: var(--text);
    font-size: 15px;
    margin-bottom: 10px;
    text-align: center;
    font-weight: 700;
}

/* Настройка количества цветов */
.color-count-setting {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.color-count-slider {
    margin-bottom: 12px;
    position: relative;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.12);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: none;
    transition: transform 0.15s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.08);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    box-shadow: none;
    transition: transform 0.15s ease;
}

.slider::-moz-range-thumb:hover {
    transform: scale(1.08);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: var(--muted);
}

.color-count-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    margin-right: 8px;
}

.color-count-label {
    font-size: 13px;
    color: var(--muted);
}

.color-preview {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.color-bubble {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
    box-shadow: none;
    transition: transform 0.15s ease;
}

.color-bubble:hover {
    transform: scale(1.1);
}

.aim-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.aim-option {
    display: flex;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
    border: 1px solid var(--border);
}

.aim-option:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-1px);
}

.aim-option input[type="radio"] {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.aim-option input[type="radio"]:checked+.option-content {
    color: var(--accent);
}

.aim-option:has(input[type="radio"]:checked) {
    border-color: rgba(124, 92, 255, 0.4);
    background: rgba(124, 92, 255, 0.08);
}

.option-content {
    flex: 1;
}

.option-title {
    display: block;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 3px;
    color: var(--text);
}

.option-desc {
    display: block;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.3;
}

/* Hardcore mode styles */
.hardcore-option {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hardcore-checkbox {
    display: flex;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
    border: 1px solid var(--border);
}

.hardcore-checkbox:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-1px);
}

.hardcore-checkbox input[type="checkbox"] {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.hardcore-checkbox input[type="checkbox"]:checked+.checkbox-content {
    color: #ef4444;
}

.hardcore-checkbox:has(input[type="checkbox"]:checked) {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.4);
}

/* Audio settings styles */
.audio-option {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.audio-checkbox {
    display: flex;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
    border: 1px solid var(--border);
}

.audio-checkbox:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-1px);
}

.audio-checkbox input[type="checkbox"] {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.audio-checkbox input[type="checkbox"]:checked+.checkbox-content {
    color: var(--accent);
}

.audio-checkbox:has(input[type="checkbox"]:checked) {
    background: rgba(124, 92, 255, 0.08);
    border-color: rgba(124, 92, 255, 0.4);
}

.checkbox-content {
    display: flex;
    flex-direction: column;
}

/* Умная адаптивная система */

/* Переменные для адаптивности */
:root {
    --game-scale: 1;
    --canvas-width: 782px;
    --canvas-height: 680px;
}

/* Контейнер игры с системой скейлинга */
.game-container {
    position: relative;
    transform-origin: center center;
    transform: scale(var(--game-scale));
    transition: transform 0.3s ease;
}



/* Canvas базовые размеры */
#gameCanvas {
    width: 782px;
    height: 680px;
}

/* Десктопная адаптивность - скейлинг при сжатии по высоте */
@media (min-width: 901px) and (max-height: 900px) {
    :root {
        /* Общая высота контейнера ~750px (680 canvas + 70 интерфейс) */
        /* Общая ширина контейнера ~822px (782 canvas + 40 отступы) */
        --game-scale: calc(min(85vh / 750px, 90vw / 822px));
    }

    body {
        min-height: 100vh;
        padding: 10px;
        overflow: hidden;
        /* Предотвращаем скроллы при скейлинге */
        /* Прижимаем к верху при скейлинге */
        align-items: flex-start !important;
        justify-content: center !important;
        padding-top: 20px !important;
    }

    .game-container {
        transform: scale(var(--game-scale));
        transform-origin: center top;
        /* Изменяем точку масштабирования */
        position: relative;
    }


}

/* Еще более компактный режим для очень низких экранов */
@media (min-width: 901px) and (max-height: 650px) {
    :root {
        /* Для очень низких экранов используем более агрессивный скейлинг */
        --game-scale: calc(min(80vh / 750px, 85vw / 822px));
    }

    body {
        padding: 5px !important;
        overflow: hidden !important;
        /* При очень низкой высоте прижимаем к верху */
        align-items: flex-start !important;
        justify-content: center !important;
        padding-top: 15px !important;
        min-height: auto !important;
    }

    .game-container {
        transform-origin: center top !important;
        /* Масштабирование от верха */
        position: relative !important;
        margin: 0 auto !important;
        margin-top: 0 !important;
        top: 0 !important;
    }

    .game-stats-panel {
        padding: 6px 0px;
        margin-bottom: 6px;
    }

    .controls {
        margin-top: 6px;
    }

    /* Обновляем индикатор для очень низких экранов */
    .game-container::before {
        content: 'Компактный режим (высота < 650px)';
        font-size: 10px;
        top: -25px;
    }
}

/* Экстремально низкие экраны (например 1920x500) */
@media (min-width: 901px) and (max-height: 550px) {
    :root {
        /* Максимально агрессивный скейлинг для экстремально низких экранов */
        --game-scale: calc(min(75vh / 750px, 80vw / 822px));
    }

    body {
        padding: 2px !important;
        overflow: hidden !important;
        /* Принудительно убираем центрирование по вертикали */
        align-items: flex-start !important;
        justify-content: center !important;
        padding-top: 10px !important;
        min-height: auto !important;
    }

    .game-container {
        transform-origin: center top !important;
        /* Масштабирование от верха */
        position: relative !important;
        margin: 0 auto !important;
        margin-top: 0 !important;
        top: 0 !important;
    }

    .game-stats-panel {
        padding: 3px 0px;
        margin-bottom: 3px;
    }

    .controls {
        margin-top: 3px;
    }

    /* Индикатор для экстремально низких экранов */
    .game-container::before {
        content: 'Экстремально компактный режим (высота < 550px)';
        font-size: 9px;
        top: -20px;
        background: rgba(255, 0, 0, 0.8);
        color: #fff;
    }
}

@media(max-width:900px) {
    .stat-icon {
        display: none;
    }

    .game-stats-panel {
        padding: 4px;
    }
}

/* Планшетная адаптивность */
@media (max-width: 900px) and (min-width: 601px) {
    :root {
        --game-scale: 1;

        /* Отключаем скейлинг */
        .stat-card {
            padding: 8px 12px;
            gap: 8px;
        }

        .stat-overlay {
            width: 24px;
            height: 24px;
        }

        .stat-card.stat-score {
            padding: 8px 12px;
            gap: 8px;
        }

        .stat-card.stat-shots {
            padding: 8px 12px;
            gap: 8px;
        }

        .stat-card.stat-balls {
            padding: 8px 12px;
            gap: 8px;
        }

        .stat-overlay {
            width: 24px;
            height: 24px;
        }
    }

    #gameCanvas {
        width: min(85vw, 650px);
        height: auto;
        aspect-ratio: 782 / 680;
        max-width: 650px;
    }

    .game-container {
        padding: 15px;
        margin: 8px;
        transform: none;
        /* Отключаем скейлинг контейнера */
    }

    .game-stats-panel {
        padding: 4px;
    }

    .stats-container {
        gap: 14px;
    }

    .stat-card {
        padding: 12px 16px;
        gap: 10px;
    }

    .stat-icon {
        font-size: 22px;
    }

    .stat-value {
        font-size: 18px;
    }

    .controls {
        gap: 10px;
    }
}

/* Мобильная адаптивность - полноэкранный режим */
@media (max-width: 600px) {
    :root {
        --game-scale: 1;
        /* Отключаем скейлинг */
    }

    /* Полноэкранный режим для мобильных */
    body {
        margin: 0;
        padding: 0;
        min-height: 100vh;
        max-height: 100vh;
        overflow: hidden;
        align-items: stretch;
        justify-content: stretch;
        display: flex;
        flex-direction: column;
    }

    #app {
        height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .game-container {
        height: 100vh;
        display: flex;
        flex-direction: column;
        padding: 0;
        margin: 0;
        transform: none;
        border-radius: 0;
        backdrop-filter: none;
        box-shadow: none;
        background: rgba(0, 0, 0, 0.3);
    }

    /* Статистика сверху */
    .game-stats-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
        padding: 4px;
        margin-bottom: 0;
        border-radius: 0;

        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .stats-container {
        flex-direction: row;
        gap: 8px;
        justify-content: space-between;
        align-items: center;
        max-width: 100%;
    }

    .stat-card {
        padding: 6px 8px;
        gap: 6px;
        flex: 1;
        min-width: 0;
        border-radius: 8px;
    }

    .stat-icon {
        font-size: 16px;
    }

    .stat-value {
        font-size: 14px;
    }

    .stat-label {
        font-size: 10px;
    }

    /* Canvas на всю высоту между панелями */
    #gameCanvas {
        position: fixed;
        top: 70px;
        /* Высота верхней панели */
        bottom: 80px;
        /* Высота нижней панели */
        left: 0;
        right: 0;
        width: 100vw;
        height: calc(100vh - 150px);
        max-width: none;
        max-height: none;
        border-radius: 0;
        border: none;
        padding: 0;
        margin: 0;
        box-shadow: none;
    }

    /* Управление снизу */
    .controls {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        flex-direction: row;
        gap: 12px;
        margin-top: 0;
        padding: 12px 16px;

        border-top: 1px solid rgba(255, 255, 255, 0.1);
        justify-content: space-between;
        align-items: center;
    }

    .reset-btn {
        padding: 8px 16px;
        font-size: 13px;
        min-width: 80px;
        border-radius: 8px;
    }

    .settings-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
        border-radius: 8px;
    }

    .next-bubble {
        font-size: 12px;
        flex: 1;
        justify-content: center;
    }

    .bubble-preview {
        width: 18px;
        height: 18px;
    }

    /* Адаптивность модального окна */
    .modal {
        margin: 10px;
        padding: 16px;
        max-width: 95vw;
        max-height: 95vh;
    }

    /* Адаптивность настроек */
    .settings-modal {
        max-width: 95vw;
        max-height: 95vh;
    }

}

/* Очень маленькие экраны (старые телефоны) */
@media (max-width: 360px) {
    .stat-card {
        padding: 6px 10px;
        gap: 6px;
    }

    .stat-icon {
        font-size: 16px;
    }

    .stat-value {
        font-size: 14px;
    }

    .stat-label {
        font-size: 10px;
    }

    .reset-btn {
        padding: 8px 12px;
        font-size: 13px;
        min-width: 80px;
    }

    .settings-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
}

/* Ландшафтная ориентация для мобильных - полноэкранный режим */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    :root {
        --game-scale: 1;
    }

    /* Уменьшаем высоту панелей в ландшафте */
    .game-stats-panel {
        padding: 4px 12px;
    }

    .stat-card {
        padding: 4px 6px;
        gap: 4px;
    }

    .stat-icon {
        font-size: 14px;
    }

    .stat-value {
        font-size: 12px;
    }

    .stat-label {
        font-size: 9px;
    }

    #gameCanvas {
        top: 50px;
        /* Уменьшенная высота верхней панели */
        bottom: 60px;
        /* Уменьшенная высота нижней панели */
        height: calc(100vh - 110px);
    }

    .controls {
        padding: 8px 12px;
        gap: 8px;
    }

    .reset-btn {
        padding: 6px 12px;
        font-size: 12px;
        min-width: 70px;
    }

    .settings-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .next-bubble {
        font-size: 11px;
    }

    .bubble-preview {
        width: 16px;
        height: 16px;
    }
}

/* Экстремально короткие экраны (очень низкая высота) */
@media (max-width: 900px) and (max-height: 400px) {
    .game-stats-panel {
        padding: 2px 8px;
    }

    .stat-card {
        padding: 2px 4px;
        gap: 2px;
        border-radius: 6px;
    }

    .stat-icon {
        font-size: 12px;
    }

    .stat-value {
        font-size: 10px;
    }

    .stat-label {
        font-size: 8px;
    }

    #gameCanvas {
        top: 35px;
        /* Максимально сжатая верхняя панель */
        bottom: 45px;
        /* Максимально сжатая нижняя панель */
        height: calc(100vh - 80px);
    }

    .controls {
        padding: 4px 8px;
        gap: 6px;
    }

    .reset-btn {
        padding: 4px 8px;
        font-size: 10px;
        min-width: 60px;
        border-radius: 6px;
    }

    .settings-btn {
        width: 28px;
        height: 28px;
        font-size: 10px;
        border-radius: 6px;
    }

    .next-bubble {
        font-size: 9px;
    }

    .bubble-preview {
        width: 14px;
        height: 14px;
    }
}

/* Touch устройства - дополнительные улучшения */
@media (hover: none) and (pointer: coarse) {

    /* Увеличиваем кнопки для лучшего touch-взаимодействия */
    .reset-btn {
        min-height: 48px;
        padding: 12px 20px;
    }

    .settings-btn {
        min-width: 48px;
        min-height: 48px;
    }

    .modal-btn {
        min-height: 48px;
        padding: 14px 24px;
    }

    /* Увеличиваем интерактивные элементы в настройках */
    /* .aim-option,
    .hardcore-checkbox,
    .audio-checkbox {
        min-height: 48px;
        padding: 16px;
    } */

    .slider {
        height: 8px;
    }

    .slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }

    .slider::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }

    /* Улучшенные состояния нажатия */
    .reset-btn:active,
    .settings-btn:active,
    .modal-btn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }

    /* Убираем hover эффекты на touch устройствах */
    .reset-btn:hover,
    .settings-btn:hover,
    .modal-btn:hover,
    .aim-option:hover,
    .hardcore-checkbox:hover,
    .audio-checkbox:hover {
        transform: none;
    }

    /* Активные состояния вместо hover */
    .reset-btn:active {
        background: rgba(124, 92, 255, 0.2);
    }

    .settings-btn:active {
        background: rgba(124, 92, 255, 0.2);
    }
}


/* === ЭФФЕКТ САЛЮТОВ === */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #ff6b6b;
    border-radius: 50%;
    box-shadow: 0 0 6px currentColor;
    will-change: transform, opacity;
}

/* Салютные взрывы из центра */
.confetti-piece.firework {
    animation: firework-explosion 2s ease-out forwards;
}

.confetti-piece.sparkle {
    animation: sparkle-fall 3s ease-out forwards;
    box-shadow: 0 0 8px currentColor, 0 0 12px currentColor;
}

/* Различные цвета салютов */
.confetti-piece.gold {
    background: #ffd700;
    color: #ffd700;
}

.confetti-piece.silver {
    background: #c0c0c0;
    color: #c0c0c0;
}

.confetti-piece.red {
    background: #ff4757;
    color: #ff4757;
}

.confetti-piece.blue {
    background: #3742fa;
    color: #3742fa;
}

.confetti-piece.green {
    background: #2ed573;
    color: #2ed573;
}

.confetti-piece.purple {
    background: #a55eea;
    color: #a55eea;
}

.confetti-piece.pink {
    background: #ff3838;
    color: #ff3838;
}

/* Анимация салютного взрыва */
@keyframes firework-explosion {
    0% {
        transform: translate(0, 0) scale(0);
        opacity: 1;
    }

    15% {
        transform: translate(var(--dx), var(--dy)) scale(1.2);
        opacity: 0.9;
    }

    100% {
        transform: translate(calc(var(--dx) * 2), calc(var(--dy) * 2.5)) scale(0.3);
        opacity: 0;
    }
}

/* Анимация блесток */
@keyframes sparkle-fall {
    0% {
        transform: translate(0, -20px) rotate(0deg) scale(1);
        opacity: 1;
    }

    20% {
        opacity: 0.8;
    }

    100% {
        transform: translate(var(--drift), 100vh) rotate(720deg) scale(0.1);
        opacity: 0;
    }
}

/* ===== ЛИДЕРБОРД ===== */

/* Кнопка лидерборда */
.leaderboard-btn {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #000;
    border: none;
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
    margin-left: 8px;
}

.leaderboard-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

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

/* Модальное окно лидерборда */
.leaderboard-modal {
    background: var(--surface);
    border-radius: 16px;
    padding: 0;
    max-width: min(600px, 90vw);
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.leaderboard-modal .modal-body {
    padding: 20px;
}

.leaderboard-modal .modal-header h2 {
    padding-top: 20px;
}

.leaderboard-modal .modal-btn {
    margin-bottom: 20px;
}


/* Секции лидерборда */
.player-stats-section,
.top-players-section {
    margin-bottom: 24px;
}

.player-stats-section h3,
.top-players-section h3,
.section-title {
    color: var(--accent);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Вкладки */
.tabs {
    display: flex;
    background: var(--surface-2);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.tab-button {
    flex: 1;
    background: transparent;
    color: var(--muted);
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.tab-button:hover {
    color: var(--text);
    background: rgba(124, 92, 255, 0.1);
}

.tab-button.active {
    color: var(--accent);
    background: var(--accent);
    color: var(--accent-contrast);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(124, 92, 255, 0.3);
}

.tab-content {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Статистика игрока */
.player-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-item {
    background: var(--surface-2);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-label {
    color: var(--muted);
    font-size: 14px;
}

.stat-value {
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
}

/* Список игроков */
.top-players-list {
    background: var(--surface-2);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.players-list {
    max-height: 600px; /* Достаточно для ~20 записей + игрок внизу */
    overflow-y: auto;
    overflow-x: hidden;
    /* Скрываем скроллбар для всех браузеров */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE и Edge */
}

/* Скрываем скроллбар для webkit браузеров (Chrome, Safari, Opera) */
.players-list::-webkit-scrollbar {
    display: none;
}

.player-item {
    display: grid;
    grid-template-columns: 40px 1fr 80px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s ease;
}

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

.player-item:hover {
    background: rgba(124, 92, 255, 0.05);
}

.player-item.current-player {
    background: rgba(124, 92, 255, 0.1);
    border-left: 3px solid var(--accent);
}

.player-item.divider-item {
    background: transparent;
    border: none;
    border-top: 2px dashed rgba(124, 92, 255, 0.3);
    padding: 8px 0;
    margin: 8px 16px;
    opacity: 0.6;
    pointer-events: none;
    text-align: center;
    color: var(--text-secondary);
    font-size: 18px;
    letter-spacing: 2px;
}

.player-item.divider-item:hover {
    background: transparent;
}

.player-rank {
    color: var(--accent);
    font-weight: 700;
    font-size: 16px;
    text-align: center;
    min-width: 30px;
}

.player-name {
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-score {
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    text-align: right;
}

/* Нет данных */
.no-data {
    padding: 24px;
    text-align: center;
    color: var(--muted);
    font-style: italic;
}

/* Кнопка обновления */
.refresh-btn {
    background: linear-gradient(135deg, var(--accent) 0%, #5b3dcc 100%);
}

.refresh-btn:hover {
    background: linear-gradient(135deg, #5b3dcc 0%, var(--accent) 100%);
}

.refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Прелоадер лидерборда */
.leaderboard-preloader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--muted);
}

.preloader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.preloader-text {
    font-size: 14px;
    color: var(--muted);
    text-align: center;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Стили для информационных элементов */
.player-item.info-item {
    background: rgba(124, 92, 255, 0.1);
    border: 1px solid var(--accent);
    color: var(--accent);
}

.player-item.info-item .player-name {
    font-style: italic;
}

/* Адаптивность для мобильных */
@media (max-width: 600px) {
    .leaderboard-modal {
        width: 95%;
        max-height: 90vh;
    }

    .leaderboard-modal .modal-body {
        padding: 16px;
    }

    .leaderboard-preloader {
        padding: 30px 16px;
    }

    .preloader-spinner {
        width: 32px;
        height: 32px;
        border-width: 2px;
    }

    .player-stats {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .stat-item {
        padding: 10px;
    }
    
    .players-list {
        max-height: 500px; /* Больше для топ-20 на мобильных */
    }

    .tab-button {
        padding: 10px 12px;
        font-size: 13px;
    }

    .player-item {
        grid-template-columns: 30px 1fr 60px;
        padding: 10px 12px;
    }

    .player-rank {
        font-size: 14px;
    }

    .player-name,
    .player-score {
        font-size: 13px;
    }
    .color-count-display{
        display: none;
    }
}

/* Адаптивность для маленьких высот экрана (горизонтальная ориентация мобильных) */
@media (max-height: 600px) {
    .leaderboard-modal {
        max-height: 95vh;
    }
    
    .players-list {
        max-height: 400px; /* Достаточно для топ-20 в горизонтальной ориентации */
    }
    
    .player-stats-section,
    .top-players-section {
        margin-bottom: 12px;
    }
}