
:root {
    --bg-dark: #0a0a0a;
    --bg-panel: #1a1a1a;
    --bg-header: #252525;
    --accent: #eab308;
    --text-main: #ffffff;
    --text-muted: #a0a0a0;
    --sidebar-w: 280px;
    --topbar-h: 80px;
}

/* Глобальные запреты согласно правилам Yandex Games */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    /* Отключаем выделение текста и подсветку тапов */
    user-select: none; 
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-tap-highlight-color: transparent; 
    /* Отключаем системные меню при долгом нажатии (iOS) */
    -webkit-touch-callout: none;
}

body {
    background: var(--bg-dark);
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-main);
    overflow: hidden;
    touch-action: none;
    width: 100vw;
    height: 100vh;
    /* Запрещаем "резиновый" скролл и обновление страницы потяжкой */
    overscroll-behavior: none;
}

/* Запрещаем стандартное перетаскивание всех изображений браузером */
img {
    -webkit-user-drag: none;
    user-drag: none;
}

#app-root {
    position: absolute;
    width: 1280px;
    height: 720px;
    background: var(--bg-dark);
    /* Точка трансформации в центре для корректного масштабирования */
    transform-origin: center center;
    overflow: hidden;
}

.view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
}

.hidden { display: none !important; }

/* Меню выбора уровней */
.menu-header { height: 100px; display: flex; align-items: center; justify-content: center; }
.levels-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 30px;
    padding: 0 100px;
    z-index: 10;
}

.level-card {
    background: #222;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid transparent;
    position: relative;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    touch-action: none;
}
.level-card:hover { transform: scale(1.05); border-color: var(--accent); }
.level-card.completed { border-color: #22c55e; }

.card-image-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
}
.card-image-wrap img { width: 100%; height: 100%; object-fit: cover; opacity: 0.8; transition: opacity 0.3s; }
.level-card:hover .card-image-wrap img { opacity: 1; }

.completion-check {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #22c55e;
    font-size: 60px;
    text-shadow: 0 4px 10px rgba(0,0,0,0.5);
    font-weight: bold;
    backdrop-filter: blur(2px);
}

.level-info { padding: 12px; background: #2a2a2a; border-top: 1px solid #333; }
.level-title { font-size: 16px; font-weight: bold; color: white; text-transform: uppercase; letter-spacing: 1px; }
.level-difficulty { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Навигация в меню */
.side-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 32px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 50;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    touch-action: none;
}

.side-nav-btn:hover {
    background: var(--accent);
    color: black;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 0 20px var(--accent);
    border-color: transparent;
}

.side-nav-btn.prev { left: 20px; }
.side-nav-btn.next { right: 20px; }

.pagination-footer { 
    height: 60px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding-bottom: 20px;
}
.page-dots { display: flex; gap: 10px; }
.dot { width: 10px; height: 10px; background: #333; border-radius: 50%; transition: all 0.3s; }
.dot.active { background: var(--accent); width: 30px; border-radius: 5px; box-shadow: 0 0 10px var(--accent); }

/* Игровой экран */
.top-bar { height: var(--topbar-h); background: var(--bg-header); display: flex; align-items: center; padding: 0 20px; border-bottom: 1px solid #333; }
.top-left, .top-right, .top-center { flex: 1; display: flex; align-items: center; }
.top-left { justify-content: flex-start; gap: 15px; }
.top-center { justify-content: center; }
.top-right { justify-content: flex-end; gap: 15px; }

.icon-btn { background: none; border: none; color: white; cursor: pointer; font-size: 18px; display: flex; align-items: center; gap: 5px; opacity: 0.8; transition: opacity 0.2s; touch-action: none;}
.icon-btn:hover { opacity: 1; }

.hint-btn { background: var(--accent); border: none; padding: 8px 30px; border-radius: 8px; color: black; font-weight: bold; cursor: pointer; height: 54px; transition: all 0.2s; min-width: 140px; touch-action: none; }
.hint-btn:active { transform: scale(0.95); }
.hint-btn span { display: block; font-size: 16px; }
.hint-btn small { display: block; font-size: 11px; opacity: 0.8; margin-top: 2px; }

.hint-btn.waiting {
    background: #22c55e;
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.6);
    animation: hint-pulse 1.5s infinite ease-in-out;
}

@keyframes hint-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

.clear-btn { background: #4b5563; border: none; padding: 8px 15px; border-radius: 8px; color: white; font-weight: bold; cursor: pointer; height: 48px; transition: background 0.2s, transform 0.2s; font-size: 14px; touch-action: none; }
.clear-btn:hover { background: #374151; }
.clear-btn:active { transform: scale(0.95); }

.main-layout { flex: 1; display: flex; overflow: hidden; }
.board-container { flex: 1; background: #151515; position: relative; display: flex; align-items: center; justify-content: center; touch-action: none; }
#game-canvas { touch-action: none; }

.sidebar { width: var(--sidebar-w); background: #1f1f1f; display: flex; flex-direction: column; border-left: 1px solid #333; }
.sidebar-header { padding: 15px; text-align: center; color: var(--text-muted); text-transform: uppercase; font-size: 12px; border-bottom: 1px solid #333; }

/* Контейнеры со скроллом: скрываем визуальную полосу прокрутки */
.pieces-container, .sidebar-scroll { 
    flex: 1; 
    overflow-y: auto; 
    padding: 15px; 
    display: flex; 
    flex-direction: column; 
    gap: 20px; 
    align-items: center;
    touch-action: pan-y;
    
    /* Скрытие полосы для Firefox и IE */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Скрытие полосы для Webkit (Chrome, Safari, Yandex) */
.pieces-container::-webkit-scrollbar, 
.sidebar-scroll::-webkit-scrollbar { 
    display: none; 
}

.sidebar-piece { 
    width: 220px; aspect-ratio: 16/9; background-color: black; border: 1px solid #444; 
    cursor: grab; flex-shrink: 0; background-repeat: no-repeat;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    transition: transform 0.2s;
    touch-action: none;
}
.sidebar-piece:hover { transform: scale(1.02); border-color: #666; }

#dragging-piece-visual {
    position: absolute;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    border: 2px solid white;
    display: none;
    background-repeat: no-repeat;
    box-sizing: border-box;
}

.reference-thumb {
    position: absolute; 
    display: flex;
    flex-direction: column;
    width: 200px; 
    height: auto; 
    background: rgba(0,0,0,0.8); 
    padding: 4px; 
    border-radius: 6px; 
    border: 2px solid rgba(255,255,255,0.3); 
    cursor: move;
    z-index: 50;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: center center;
    touch-action: none;
}
.reference-thumb img { 
    width: 100%; 
    height: auto; 
    display: block; 
    border-radius: 2px;
}
.reference-thumb div { 
    font-size: 10px; 
    text-align: center; 
    margin-top: 4px; 
    color: #eee; 
    font-weight: bold;
    text-transform: uppercase;
}

.reference-thumb.zoomed {
    transform: scale(2);
    z-index: 500;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    border-color: var(--accent);
}

/* Модалки */
.modal { position: absolute; inset: 0; background: rgba(0,0,0,0.85); display: flex; align-items: center; justify-content: center; z-index: 1000; backdrop-filter: blur(5px); }
.modal-content { background: var(--bg-panel); padding: 40px; border-radius: 20px; text-align: center; min-width: 400px; border: 2px solid #444; box-shadow: 0 20px 50px rgba(0,0,0,0.5); }
.victory { border-color: var(--accent); }

/* Пауза */
.pause-icon { font-size: 64px; font-weight: bold; color: var(--accent); margin-bottom: 10px; }
.modal-content.pause { border-color: var(--accent); }

.primary-btn { background: var(--accent); border: none; padding: 15px 40px; border-radius: 10px; font-weight: bold; font-size: 18px; cursor: pointer; transition: transform 0.2s; touch-action: none; }
.primary-btn:hover { transform: scale(1.05); }
.secondary-btn { background: #444; color: white; border: none; padding: 15px 40px; border-radius: 10px; cursor: pointer; touch-action: none; }
.modal-buttons { display: flex; gap: 15px; margin-top: 30px; justify-content: center; }

/* Оверлей отсчета рекламы */
.ad-countdown-content { text-align: center; }
.ad-label { font-size: 24px; font-weight: bold; color: white; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 20px; }
.ad-timer-value { font-size: 120px; font-weight: 900; color: var(--accent); animation: pulse-timer 1s infinite; }

@keyframes pulse-timer {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* Ошибка ориентации */
.orientation-warning { position: fixed; inset: 0; background: #121212; z-index: 50000; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; text-align: center; }
.rotate-icon { font-size: 80px; margin-bottom: 20px; animation: rotate 2s infinite ease-in-out; }
@keyframes rotate { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(90deg); } }

/* Лоадер */
.loader { border: 4px solid #333; border-top: 4px solid var(--accent); border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin-bottom: 20px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.mute-btn-fixed { position: absolute; top: 20px; right: 20px; width: 48px; height: 48px; background: rgba(255,255,255,0.1); border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 100; transition: background 0.2s; touch-action: none; }
.mute-btn-fixed:hover { background: rgba(255,255,255,0.2); }
.mute-btn-fixed::after { content: '🔊'; font-size: 24px; }
.mute-btn-fixed.muted::after { content: '🔇'; }
.icon-btn-mute { background: none; border: none; cursor: pointer; font-size: 24px; touch-action: none; }
.icon-btn-mute::after { content: '🔊'; }
.icon-btn-mute.muted::after { content: '🔇'; }

/*     ---------------*/

/* 1. Увеличиваем кнопку подсказки (Hint Button) */
.hint-btn {
    min-width: 220px;       /* Было 140px — теперь кнопка шире */
    padding: 8px 40px;      /* Увеличили боковые отступы */
    height: 60px;           /* Немного увеличили высоту для солидности */
}

/* 2. Увеличиваем окно победы (Victory Modal) */
.modal-content.victory {
    min-width: 600px;       /* Было 400px — само окно стало намного больше */
    padding: 60px;          /* Увеличили внутренние отступы */
}

/* Увеличиваем текст заголовка в окне победы */
.modal-content.victory h2 {
    font-size: 48px;        /* Крупный заголовок */
    margin-bottom: 20px;
}

/* Увеличиваем основной текст в окне победы */
.modal-content.victory p {
    font-size: 24px;        /* Крупный текст подзаголовка */
    margin-bottom: 40px;
}

/* 3. Увеличиваем кнопку в окне победы (Menu button) */
.modal-content.victory .primary-btn {
    padding: 20px 60px;     /* Делаем кнопку массивнее */
    font-size: 24px;        /* Увеличиваем шрифт на кнопке */
    border-radius: 12px;
}