* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-text-size-adjust: none !important;
    text-size-adjust: none !important;
}

body {
    font-family: 'Arial', sans-serif;
    color: #333;
    min-height: 100vh;
    overflow: hidden;
    user-select: none;
}

/* Темы */
body[data-theme="classic"] {
    background: linear-gradient(135deg, #591507 0%, #d23c1e 100%);
}

body[data-theme="wood"] {
    background: linear-gradient(135deg, #8B4513 0%, #DEB887 100%);
}

body[data-theme="metal"] {
    background: linear-gradient(135deg, #2F4F4F 0%, #708090 100%);
}

body[data-theme="space"] {
    background: linear-gradient(135deg, #0F0F23 0%, #1a1a2e 100%);
}

body[data-theme="ocean"] {
    background: linear-gradient(135deg, #0077be 0%, #00a8ff 100%);
}



/* Анимации для свайпов и перемещений */
.tile {
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: center;
}

.tile-active {
    background: linear-gradient(135deg, #ffd700, #ffa500) !important;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5) !important;
    z-index: 5;
}

/* Анимация перемещения */
.tile-moving {
    z-index: 10 !important;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

/* Эффект при наведении для десктопа */


/* Анимация "пульсации" для доступных плиток */
.tile.movable {
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
    }
    50% {
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
    }
    100% {
        box-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
    }
}

/* Улучшаем отзывчивость для мобильных */
@media (max-width: 768px) {
    .tile {
        -webkit-tap-highlight-color: transparent;
        touch-action: pan-x pan-y;
    }
    
    .tile:active {
        transform: scale(0.95);
        transition: transform 0.1s;
    }
}



@keyframes shuffleAppear {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes shuffleDisappear {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
}

.tile.shuffle-out {
    animation: shuffleDisappear 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.tile.shuffle-in {
    animation: shuffleAppear 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}



/* Уведомления */
.game-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 20px 30px;
    border-radius: 15px;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    z-index: 10000;
    animation: fadeInOut 3s ease-in-out;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border: 2px solid #ffd700;
    max-width: 80%;
    word-wrap: break-word;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, -40%); }
    20% { opacity: 1; transform: translate(-50%, -50%); }
    80% { opacity: 1; transform: translate(-50%, -50%); }
    100% { opacity: 0; transform: translate(-50%, -60%); }
}

/* Подсказка для кнопки перемешивания */
.compact-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
}
.shuffle-btn::before {
    content: '🎬';
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ffd700;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.shuffle-btn {
    position: relative;
    background: linear-gradient(135deg, #ff6b6b, #ee5a52) !important;
}
/* Анимации для перемешивания после рекламы */
@keyframes rewardShuffle {
    0% {
        transform: scale(0.8) rotate(90deg);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.1) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.tile.reward-shuffle {
    animation: rewardShuffle 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

/* Уведомления для рекламы */
.ad-notification {
    background: linear-gradient(135deg, #4CAF50, #45a049) !important;
    border: 2px solid #ffd700 !important;
}

.ad-error-notification {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52) !important;
    border: 2px solid #ffd700 !important;
}
.menu-btn.disabled {
    background: linear-gradient(135deg, #cccccc, #999999) !important;
    color: #666666 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

.menu-btn.disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Улучшаем визуальную обратную связь */
.menu-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.menu-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 500px;
    width: 90%;
    backdrop-filter: blur(10px);
}

body[data-theme="space"] .menu-container {
    background: rgba(15, 15, 35, 0.95);
    color: #ffffff;
}

body[data-theme="metal"] .menu-container {
    background: rgba(47, 79, 79, 0.95);
    color: #ffffff;
}

h1, h2 {
    margin-bottom: 30px;
    color: #2c3e50;
}

body[data-theme="space"] h1,
body[data-theme="space"] h2,
body[data-theme="metal"] h1,
body[data-theme="metal"] h2 {
    color: #ffffff;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.menu-btn, .level-btn, .control-btn {
    padding: 15px 30px;
    font-size: 18px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #af514c, #a05345);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: block;
    width: 100%;
}

.menu-btn:hover, .level-btn:hover, .control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(76, 175, 80, 0.3);
}

.back-btn {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    margin-top: 20px;
}


/* Стили для правильно расположенных плиток */
.tile.correct {
    background: linear-gradient(135deg, #4CAF50, #45a049) !important;
    color: white !important;
    box-shadow: inset 0 -3px 5px rgba(0,0,0,0.2), 0 0 10px rgba(76, 175, 80, 0.5);
}


/* Обновляем стиль перемещаемых плиток - убираем пульсацию */
.tile.movable {
    background: linear-gradient(135deg, #ffd700, #ffa500) !important;
    cursor: pointer;
    transition: all 0.2s ease;
}
.tile.empty.dark-empty {
    background-color: rgba(0, 0, 0, 0.3) !important;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5) !important;
}



.tile.movable:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.4);
}

.back-btn {
    background: linear-gradient(135deg, #fd746c, #ff9068);
    margin-top: 20px;
}

/* Игровой экран */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 400px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 15px;
}

body[data-theme="space"] .game-header,
body[data-theme="metal"] .game-header {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.game-info {
    font-size: 18px;
    font-weight: bold;
    color: #2c3e50;
}

body[data-theme="space"] .game-info,
body[data-theme="metal"] .game-info {
    color: #ffffff;
}

/* Компактные кнопки */
.compact-controls {
    display: flex !important;
    gap: 8px !important;
    background: rgba(255, 255, 255, 0.9) !important;
    padding: 8px !important;
    border-radius: 15px !important;
    backdrop-filter: blur(10px) !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1) !important;
}

body[data-theme="space"] .compact-controls,
body[data-theme="metal"] .compact-controls {
    background: rgba(255, 255, 255, 0.1) !important;
}

.compact-btn, .custom-btn {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    width: 60px !important;
    height: 50px !important;
    border: none !important;
    border-radius: 10px !important;
    color: white !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    padding: 6px !important;
    font-size: 12px !important;
    background: linear-gradient(135deg, #ea66661e, #a24b4b46) !important;
    user-select: none !important;
}

.compact-btn:hover, .custom-btn:hover {
    transform: translateY(-3px) scale(1.05) !important;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15) !important;
}

.btn-icon {
    font-size: 18px !important;
    margin-bottom: 3px !important;
}

.btn-text {
    font-size: 9px !important;
    font-weight: bold !important;
}

/* Игровое поле */
.board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    background-color: #8B4513;
    border: 3px solid #8B4513;
    border-radius: 10px;
    padding: 4px;
    max-width: 400px;
    width: 100%;
    aspect-ratio: 1;
}

body[data-theme="wood"] .board {
    background-color: #8B4513;
    border-color: #8B4513;
}

body[data-theme="metal"] .board {
    background-color: #708090;
    border-color: #708090;
}

body[data-theme="space"] .board {
    background-color: #1a1a2e;
    border-color: #4a4a8a;
}

body[data-theme="ocean"] .board {
    background-color: #0077be;
    border-color: #0077be;
}

.tile {
    background-color: #f8f9fa;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    aspect-ratio: 1;
    border-radius: 5px;
        transition: all 0.3s ease;

    box-shadow: inset 0 -3px 5px rgba(0,0,0,0.1);
}

body[data-theme="wood"] .tile {
    background: linear-gradient(135deg, #DEB887, #CD853F);
    color: #8B4513;
}

body[data-theme="metal"] .tile {
    background: linear-gradient(135deg, #C0C0C0, #A9A9A9);
    color: #2F4F4F;
}

body[data-theme="space"] .tile {
    background: linear-gradient(135deg, #4a4a8a, #2d2d5a);
    color: #ffffff;
}

body[data-theme="ocean"] .tile {
    background: linear-gradient(135deg, #00a8ff, #0097e6);
    color: #ffffff;
}

.tile:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.tile.empty {
    background-color: transparent !important;
    box-shadow: none !important;
    cursor: default;
}
body[data-theme="classic"] .tile.empty.dark-empty {
    background-color: rgba(139, 69, 19, 0.4) !important;
}
body[data-theme="wood"] .tile.empty.dark-empty {
    background-color: rgba(101, 67, 33, 0.5) !important;
}

body[data-theme="metal"] .tile.empty.dark-empty {
    background-color: rgba(47, 79, 79, 0.5) !important;
}

body[data-theme="space"] .tile.empty.dark-empty {
    background-color: rgba(0, 0, 0, 0.6) !important;
}

body[data-theme="ocean"] .tile.empty.dark-empty {
    background-color: rgba(0, 87, 146, 0.5) !important;
}


.tile.empty:hover {
    transform: none;
    box-shadow: none;
}
.tile.movable {
    background: linear-gradient(135deg, #ffd700, #ffa500) !important;
    cursor: pointer;
    transition: all 0.2s ease;
}


/* Обновляем структуру игрового экрана */
#gameScreen {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    gap: 20px;
}

/* Настройки */
.setting {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 15px 0;
    padding: 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
}

body[data-theme="space"] .setting,
body[data-theme="metal"] .setting {
    background: rgba(255, 255, 255, 0.1);
}

.toggle-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: #27ae60;
    color: white;
    cursor: pointer;
}

.toggle-btn.off {
    background: #e74c3c;
}

.language-switcher {
    display: flex;
    gap: 10px;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.lang-btn.active {
    background: rgba(255, 255, 255, 0.4);
    border-color: #fff;
    transform: scale(1.1);
}

/* Статистика */
.stats-content {
    text-align: left;
    margin: 20px 0;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    margin: 8px 0;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
}

body[data-theme="space"] .stat-item,
body[data-theme="metal"] .stat-item {
    background: rgba(255, 255, 255, 0.1);
}

/* Оверлей */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.overlay.active {
    display: flex;
}

.overlay-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: fadeIn 0.3s ease;
}

body[data-theme="space"] .overlay-content,
body[data-theme="metal"] .overlay-content {
    background: rgba(15, 15, 35, 0.95);
    color: #ffffff;
}

.win-content h2 {
    color: #27ae60;
    font-size: 28px;
}

.pause-stats, .win-stats {
    margin: 20px 0;
    text-align: left;
}

.pause-stat, .win-stat {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    margin: 8px 0;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
}

body[data-theme="space"] .pause-stat,
body[data-theme="space"] .win-stat,
body[data-theme="metal"] .pause-stat,
body[data-theme="metal"] .win-stat {
    background: rgba(255, 255, 255, 0.1);
}

.pause-buttons, .win-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

/* Адаптивность */
@media (max-width: 480px) {
    .menu-container {
        padding: 20px 15px;
    }
    
    .game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 15px;
    order: 1;
}

.board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    background-color: #8B4513;
    border: 3px solid #8B4513;
    border-radius: 10px;
    padding: 4px;
    max-width: 400px;
    width: 100%;
    aspect-ratio: 1;
    order: 2;
}
    .tile {
    -webkit-tap-highlight-color: transparent !important;
    -moz-tap-highlight-color: transparent !important;
    tap-highlight-color: transparent !important;
    touch-action: manipulation !important;
    cursor: pointer !important;
}

    .tile {
        font-size: 20px;
    }
    
    .compact-controls {
        gap: 5px !important;
    }
    
    .compact-btn, .custom-btn {
        width: 50px !important;
        height: 45px !important;
    }
    
    .btn-icon {
        font-size: 16px !important;
    }
}
.menu-btn, .compact-btn, .custom-btn {
    -webkit-tap-highlight-color: transparent !important;
    -moz-tap-highlight-color: transparent !important;
    tap-highlight-color: transparent !important;
    touch-action: manipulation !important;
    cursor: pointer !important;
}
* {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

/* Улучшаем отзывчивость плиток */
.tile:active {
    transform: scale(0.95);
    transition: transform 0.1s;
}

.tile.movable {
    cursor: pointer;
}

/* Адаптивность для маленьких экранов */
@media (max-width: 480px) {
    .tile {
        font-size: 18px !important;
    }
    
    .menu-btn, .compact-btn, .custom-btn {
        padding: 12px 20px !important;
        font-size: 16px !important;
    }
    
    .game-header {
        padding: 10px !important;
    }
    
    .compact-btn, .custom-btn {
        width: 50px !important;
        height: 45px !important;
    }
    
    .btn-icon {
        font-size: 16px !important;
    }
}


/* Анимации для перемещения плиток */
.tile.moving {
    z-index: 10 !important;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
    box-shadow: 0 5px 25px rgba(0,0,0,0.3) !important;
}



.tile.movable:active {
    transform: scale(0.95);
    transition: transform 0.1s;
}

/* Анимация появления новых плиток после перемещения */
.tile {
    animation: tileAppear 0.1s ease-out;
}


/* Эффект подсветки для доступных плиток */
.tile.movable {
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
    }
    50% {
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
    }
    100% {
        box-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
    }
}

/* Эффект волны при клике */
@keyframes clickWave {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 215, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0);
    }
}

.tile.movable.clicked {
    animation: clickWave 0.5s ease-out;
}

.menu-btn:active {
    transform: scale(0.98) !important;
}

/* Скрываем кнопки навигации в обучении */
.tutorial-nav {
    display: flex;
    gap: 1px;
    justify-content: center;
    flex-wrap: wrap;
}
.tutorial-content {
    text-align: left;
    margin: 20px 0;
    min-height: 200px;
}

.tutorial-step {
    display: none;
}

.tutorial-step.active {
    display: block;
}

.tutorial-step h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

body[data-theme="space"] .tutorial-step h3,
body[data-theme="metal"] .tutorial-step h3 {
    color: #ecf0f1;
}

.tutorial-step ul {
    margin: 10px 0 10px 20px;
}

.tutorial-step li {
    margin: 5px 0;
}

#prevTutorial, #nextTutorial {
    display: none !important;
}
/* Контейнер для игрового экрана */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 400px;
}/* ДОБАВЬТЕ В КОНЕЦ STYLE.CSS */

/* Улучшенные стили для мобильной анимации */
.tile.touch-active {
    background: linear-gradient(135deg, #ffa500, #ff8c00) !important;
    transform: scale(0.95) !important;
    transition: transform 0.1s ease !important;
}

.tile.moving {
    z-index: 10 !important;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
    box-shadow: 0 5px 25px rgba(0,0,0,0.3) !important;
}

/* Улучшаем отзывчивость для мобильных */
@media (max-width: 768px) {
    .tile {
        -webkit-tap-highlight-color: transparent !important;
        touch-action: manipulation !important;
        cursor: pointer !important;
    }
    
    .tile:active {
        transform: scale(0.95) !important;
        transition: transform 0.1s !important;
    }
    
    .tile.movable {
        animation: pulse-glow 2s infinite;
    }
}

/* Анимация для визуальной обратной связи при касании */
@keyframes mobileTap {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.tile.mobile-tap {
    animation: mobileTap 0.3s ease;
}

/* Улучшаем видимость перемещаемой плитки */
.tile.dragging {
    z-index: 100 !important;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4) !important;
    transform: scale(1.05) !important;
}

/* Шапка игры */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* Игровое поле */
.board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    background-color: #8B4513;
    border: 3px solid #8B4513;
    border-radius: 10px;
    padding: 4px;
    width: 100%;
    aspect-ratio: 1;
}

/* Адаптивность для мобильных */
@media (max-width: 480px) {
    .game-container {
        gap: 15px;
    }
    
    .game-header {
        gap: 10px;
        padding: 12px;
    }
    
    .compact-controls {
        gap: 8px !important;
    }
}


@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Простая CSS анимация */
@keyframes tileMove {
    0% { 
        transform: scale(1.1);
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    }
    100% { 
        transform: scale(1);
        box-shadow: none;
    }
}

.tile-move-animation {
    animation: tileMove 0.3s ease-in-out !important;
}