/* ============================================
   НОВОГОДНИЙ ТРИ В РЯД — СТИЛИ (ИСПРАВЛЕННЫЕ)
   ============================================ */

:root {
    --bg-gradient: linear-gradient(135deg, #1a252f 0%, #2c3e50 50%, #34495e 100%);
    --board-bg: #ecf0f1;
    --ui-bg: #34495e;
    --text-color: #ffffff;
    --accent-color: #f1c40f;
    --glow-color: rgba(255, 255, 255, 0.6);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

body {
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    position: relative;
    padding: 0;
    margin: 0;
}

/* --- СНЕГ --- */
.snow-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.snowflake {
    position: absolute;
    top: -20px;
    color: white;
    font-size: 10px;
    text-shadow: 0 0 5px var(--glow-color);
    animation: fall linear infinite;
    opacity: 0.8;
}

@keyframes fall {
    0% { transform: translateY(-20px) translateX(0) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(100vh) translateX(20px) rotate(360deg); opacity: 0; }
}

/* --- ДЕКОРАЦИИ --- */
.holiday-decoration {
    position: fixed;
    font-size: 2.5rem;
    z-index: 1;
    pointer-events: none;
    text-shadow: 0 0 10px var(--glow-color);
    animation: decoration-sway 3s ease-in-out infinite;
}

.decoration-top-left { top: 10px; left: 10px; }
.decoration-top-right { top: 10px; right: 10px; animation-delay: 0.5s; }
.decoration-bottom-left { bottom: 10px; left: 10px; animation-delay: 1s; }
.decoration-bottom-right { bottom: 10px; right: 10px; animation-delay: 1.5s; }

@keyframes decoration-sway {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

/* --- EMBED РЕЖИМ --- */
body.embed-mode {
    height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body.embed-mode .game-wrapper {
    width: 100%;
    height: 100%;
    max-width: none;
    padding: 10px;
    justify-content: flex-start;
}

body.embed-mode .game-title,
body.embed-mode .holiday-decoration {
    display: none;
}

/* --- КОНТЕЙНЕР --- */
.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
    padding: 15px;
    position: relative;
    z-index: 10;
    gap: 12px;
    height: 100vh;
    overflow: hidden;
}

.game-title {
    text-shadow: 0 0 20px var(--glow-color), 2px 2px 4px rgba(0,0,0,0.5);
    font-size: 1.8rem;
    color: var(--accent-color);
    animation: title-glow 2s ease-in-out infinite;
    text-align: center;
    line-height: 1.2;
    margin: 0;
}

.game-title span {
    font-size: 0.9rem;
    color: #f1c40f;
    display: block;
}

@keyframes title-glow {
    0%, 100% { text-shadow: 0 0 20px var(--glow-color); }
    50% { text-shadow: 0 0 30px var(--accent-color); }
}

/* --- ПАНЕЛЬ СТАТИСТИКИ --- */
.game-ui {
    display: flex;
    justify-content: space-around;
    width: 100%;
    background: var(--ui-bg);
    padding: 10px 15px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.1);
}

.stat-box { display: flex; flex-direction: column; align-items: center; }
.stat-label { font-size: 0.75rem; color: #bdc3c7; text-transform: uppercase; }
.stat-value { font-size: 1.3rem; font-weight: bold; color: var(--accent-color); }

/* --- КОНТЕЙНЕР ИГРОВОГО ПОЛЯ --- */
.game-board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    flex: 1;
    min-height: 0;
}

/* --- ИГРОВОЕ ПОЛЕ (АДАПТИВНОЕ) --- */
.game-board {
    display: grid;
    gap: 5px;
    background: var(--board-bg);
    border-radius: 8px;
    padding: 5px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
    position: relative;
    touch-action: none;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.2);
    overflow: visible;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    max-width: min(70vh, 550px);
}

/* --- ЯЧЕЙКИ --- */
.cell {
    background-color: #bdc3c7;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.3s, opacity 0.3s, box-shadow 0.3s;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    border: 2px solid rgba(255,255,255,0.3);
    overflow: hidden;
    aspect-ratio: 1 / 1;
}

.cell:not(.selected):not(.matched):hover {
    filter: brightness(1.2);
    transform: scale(1.08);
}

.cell.selected {
    background-color: var(--accent-color);
    transform: scale(1.15);
    z-index: 10;
    box-shadow: 0 0 25px var(--accent-color);
    border: 3px solid white;
}

.cell.matched { transform: scale(0); opacity: 0; }
.cell.shake { animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both; background-color: #e74c3c; }

@keyframes shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-6px); }
    40%, 60% { transform: translateX(6px); }
}

.cell.spawn { animation: dropIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

@keyframes dropIn {
    0% { transform: translateY(-50px) scale(0.5); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

.cell.empty {
    background-image: none !important;
    background-color: transparent;
    box-shadow: none;
    border: none;
}

/* --- БОНУСЫ --- */
.cell.bonus-line-h {
    background-image: url('assets/bonus-line-h.webp') !important;
    border: 2px solid #f1c40f;
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.5);
}

.cell.bonus-line-v {
    background-image: url('assets/bonus-line-v.webp') !important;
    border: 2px solid #f1c40f;
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.5);
}

.cell.bonus-bomb {
    background-image: url('assets/bonus-bomb.webp') !important;
    border: 2px solid #e74c3c;
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.6);
}

.cell.bonus-color {
    background-image: url('assets/bonus-color.webp') !important;
    border: 2px solid #9b59b6;
    box-shadow: 0 0 20px rgba(155, 89, 182, 0.6);
}

.cell.bonus-active {
    z-index: 100;
    filter: brightness(2);
    transform: scale(1.3);
    box-shadow: 0 0 40px white;
    transition: all 0.2s;
}

/* Подсказка */
.cell.hint {
    animation: pulse-hint 1.5s infinite;
    box-shadow: 0 0 20px #f1c40f;
    z-index: 20;
    border: 3px solid #f1c40f !important;
    filter: brightness(1.2);
}

@keyframes pulse-hint {
    0% { 
        box-shadow: 0 0 10px #f1c40f;
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 30px #f1c40f;
        transform: scale(1.05);
    }
    100% { 
        box-shadow: 0 0 10px #f1c40f;
        transform: scale(1);
    }
}

/* --- КНОПКИ --- */
.buttons-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    flex-shrink: 0;
}

.hint-btn, .restart-btn, .reset-btn, .info-btn {
    padding: 8px 20px;
    font-size: 0.9rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s;
    color: white;
    font-weight: bold;
}

.hint-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.hint-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 15px #3498db;
}

.restart-btn { 
    background: linear-gradient(135deg, #e74c3c, #c0392b); 
}

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

.reset-btn { 
    background: linear-gradient(135deg, #7f8c8d, #95a5a6); 
}

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

.info-btn {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

.info-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(155, 89, 182, 0.5);
}

/* --- МОДАЛЬНОЕ ОКНО --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
    transition: opacity 0.3s;
}

.modal-overlay.hidden { opacity: 0; pointer-events: none; }

.modal-content {
    background: linear-gradient(135deg, #1a252f, #2c3e50);
    color: white;
    padding: 25px;
    border-radius: 20px;
    text-align: center;
    max-width: 90%;
    width: 350px;
    border: 3px solid var(--accent-color);
    transform: scale(0.8);
    transition: transform 0.3s;
}

.modal-overlay:not(.hidden) .modal-content { transform: scale(1); }
.modal-content h2 { font-size: 1.8rem; margin-bottom: 10px; }
.modal-content p { font-size: 1rem; margin-bottom: 20px; }
.modal-btn {
    padding: 10px 25px;
    font-size: 1rem;
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
}
.modal-btn.lose { background: linear-gradient(135deg, #c0392b, #e74c3c); }

/* ============================================
   АДАПТИВНОСТЬ
   ============================================ */

/* МОБИЛЬНЫЕ */
@media (max-width: 899px) {
    body {
        overflow: auto;
        height: auto;
        min-height: 100vh;
    }
    
    .game-wrapper {
        padding: 10px;
        gap: 8px;
        justify-content: center;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }
    
    .game-title {
        font-size: 1.2rem;
        margin-top: 5px;
    }
    
    .game-title span {
        font-size: 0.7rem;
    }
    
    .game-board-container {
        flex: 0 0 auto;
        min-height: auto;
        margin: 5px 0;
    }
    
    .game-board {
        width: 85vw;
        height: 85vw;
        max-width: 85vw;
        max-height: 85vw;
        gap: 3px;
        padding: 3px;
    }
    
    .game-ui {
        padding: 8px 12px;
        width: 95%;
        max-width: 400px;
    }
    
    .stat-label { font-size: 0.65rem; }
    .stat-value { font-size: 1.1rem; }
    
    .buttons-row {
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }
    
    .hint-btn, .restart-btn, .reset-btn, .info-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
        flex: 0 1 auto;
    }
    
    .right-sidebar {
        width: 100%;
        margin-top: 10px;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .studio-info {
        width: 95%;
        margin-top: 10px;
        padding: 8px 12px;
        text-align: center;
        font-size: 0.7rem;
    }
    
    .holiday-decoration {
        font-size: 1.5rem;
    }
}

/* ПК */
@media (min-width: 900px) {
    .game-wrapper {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        max-width: 1100px;
        gap: 20px;
        padding: 20px;
    }
    
    .game-title {
        position: absolute;
        top: 15px;
        left: 50%;
        transform: translateX(-50%);
        width: 100%;
        text-align: center;
        font-size: 1.6rem;
        margin: 0;
    }
    
    .game-title span {
        font-size: 0.8rem;
    }
    
    .game-ui {
        flex-direction: column;
        width: 160px;
        gap: 8px;
        padding: 15px;
        order: 1;
        margin: 0;
    }
    
    .stat-box {
        padding: 6px 0;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    
    .stat-box:last-child {
        border-bottom: none;
    }
    
    .stat-label { font-size: 0.7rem; }
    .stat-value { font-size: 1.3rem; }
    
    .game-board-container {
        order: 2;
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 0;
    }
    
    .game-board {
        width: 450px;
        max-width: 450px;
    }
    
    .buttons-row {
        flex-direction: column;
        width: 160px;
        order: 3;
        margin: 0;
        gap: 8px;
    }
    
    .buttons-row button {
        width: 100%;
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    .holiday-decoration {
        font-size: 2rem;
    }
}

/* Очень маленькие экраны (до 480px) */
@media (max-width: 480px) {
    .game-board {
        width: 92vw;
        height: 92vw;
        gap: 2px;
        padding: 2px;
    }
    
    .game-title {
        font-size: 1rem;
    }
    
    .stat-label { 
        font-size: 0.6rem; 
    }
    
    .stat-value { 
        font-size: 1rem; 
    }
    
    .buttons-row {
        gap: 6px;
    }
    
    .hint-btn, .restart-btn, .reset-btn, .info-btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
    
    .studio-info {
        font-size: 0.65rem;
        padding: 6px 10px;
    }
    
    .holiday-decoration {
        font-size: 1.2rem;
    }
}

/* Альбомная ориентация на мобильных */
@media (max-width: 899px) and (orientation: landscape) {
    .game-wrapper {
        gap: 5px;
    }
    
    .game-board {
        max-width: 60vh;
        max-height: 60vh;
    }
    
    .game-ui {
        flex-direction: row;
        width: 95%;
        padding: 5px 10px;
    }
    
    .stat-box {
        padding: 0 8px;
    }
    
    .buttons-row {
        flex-direction: row;
        width: 95%;
    }
    
    .holiday-decoration {
        font-size: 1.2rem;
    }
}

body.embed-mode .buttons-row { 
    display: flex; 
}

/* Для iOS исправление кликов */
.cell {
    -webkit-tap-highlight-color: transparent;
}

/* Анимация для кнопки подсказки */
.hint-btn:active {
    transform: scale(0.95);
}

/* ============================================
   ИНСТРУКЦИЯ
   ============================================ */

/* Модальное окно инструкции */
.info-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.info-modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.info-modal-content {
    background: linear-gradient(135deg, #1a252f, #2c3e50);
    color: white;
    border-radius: 20px;
    max-width: 90%;
    width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    border: 3px solid #f1c40f;
    box-shadow: 0 0 30px rgba(241, 196, 15, 0.3);
    animation: modalSlideIn 0.3s ease;
}

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

.info-modal-header {
    padding: 15px 20px;
    border-bottom: 2px solid rgba(241, 196, 15, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, #1a252f, #2c3e50);
    border-radius: 20px 20px 0 0;
    z-index: 10;
}

.info-modal-header h2 {
    margin: 0;
    color: #f1c40f;
    font-size: 1.5rem;
}

.close-info-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-info-btn:hover {
    background: rgba(231, 76, 60, 0.5);
    transform: rotate(90deg);
}

.info-modal-body {
    padding: 15px 20px;
}

.info-section {
    margin-bottom: 20px;
}

.info-section h3 {
    color: #f1c40f;
    margin-bottom: 10px;
    font-size: 1.2rem;
    border-left: 4px solid #f1c40f;
    padding-left: 10px;
}

.info-section p {
    line-height: 1.5;
    margin: 6px 0;
    color: #ecf0f1;
    font-size: 0.9rem;
}

/* Карточки бонусов */
.bonus-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(52, 73, 94, 0.5);
    padding: 10px;
    margin: 10px 0;
    border-radius: 12px;
    transition: transform 0.2s;
}

.bonus-card:hover {
    transform: translateX(5px);
    background: rgba(52, 73, 94, 0.8);
}

.bonus-preview {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 2px solid #f1c40f;
    flex-shrink: 0;
}

.bonus-preview.bonus-line-h {
    background-image: url('assets/bonus-line-h.webp') !important;
}

.bonus-preview.bonus-line-v {
    background-image: url('assets/bonus-line-v.webp') !important;
}

.bonus-preview.bonus-bomb {
    background-image: url('assets/bonus-bomb.webp') !important;
    border-color: #e74c3c;
}

.bonus-preview.bonus-color {
    background-image: url('assets/bonus-color.webp') !important;
    border-color: #9b59b6;
}

.bonus-desc {
    flex: 1;
}

.bonus-desc strong {
    color: #f1c40f;
    display: block;
    margin-bottom: 3px;
    font-size: 0.9rem;
}

.bonus-effect {
    font-size: 0.8rem;
    color: #bdc3c7;
}

/* Список комбинаций */
.combos-list {
    list-style: none;
    padding-left: 0;
}

.combos-list li {
    padding: 5px 0;
    padding-left: 22px;
    position: relative;
    color: #ecf0f1;
    font-size: 0.85rem;
}

.combos-list li:before {
    content: "✨";
    position: absolute;
    left: 0;
}

.info-modal-footer {
    padding: 15px 20px;
    border-top: 2px solid rgba(241, 196, 15, 0.3);
    text-align: center;
    position: sticky;
    bottom: 0;
    background: linear-gradient(135deg, #1a252f, #2c3e50);
    border-radius: 0 0 20px 20px;
}

.close-modal-btn {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    border: none;
    padding: 10px 25px;
    font-size: 1rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.close-modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(46, 204, 113, 0.3);
}

/* Адаптивность для инструкции */
@media (max-width: 768px) {
    .info-modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .bonus-card {
        flex-direction: column;
        text-align: center;
    }
    
    .bonus-preview {
        width: 60px;
        height: 60px;
    }
    
    .info-section h3 {
        font-size: 1rem;
    }
    
    .info-modal-header h2 {
        font-size: 1.2rem;
    }
}

/* Скрытый блок для SEO */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
/* Информация о студии — под кнопками */
.studio-info {
    text-align: center;
    margin-top: 15px;
    padding: 8px 12px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.6);
    background: rgba(52, 73, 94, 0.5);
    border-radius: 8px;
    backdrop-filter: blur(4px);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.studio-info a {
    color: #f1c40f;
    text-decoration: none;
    transition: color 0.3s;
}

.studio-info a:hover {
    color: #fff;
    text-decoration: underline;
}

.studio-credits {
    margin: 0;
    line-height: 1.4;
}
/* Правая колонка (для ПК) */
/* Правая колонка - общий контейнер для кнопок и информации о студии */
.right-sidebar {
    display: flex;
    flex-direction: column;
    gap: 15px;
    float: none; /* отключаем float, если он где-то есть */
    clear: both;
}

/* Порядок элементов внутри правой колонки */
.right-sidebar .buttons-row {
    order: 1;
    float: none;
}

.right-sidebar .studio-info {
    order: 2;
    float: none;
}

/* Мобильные устройства */
@media (max-width: 899px) {
    .right-sidebar {
        width: 100%;
        margin-top: 15px;
    }
    
    .right-sidebar .buttons-row {
        order: 0;
    }
    
    .right-sidebar .studio-info {
        order: 0;
    }
}

/* ПК - фиксированная ширина */
@media (min-width: 900px) {
    .right-sidebar {
        width: 180px;
        order: 3;
        margin: 0;
        float: none;
    }
    
    .buttons-row {
        flex-direction: column;
        width: 100%;
        gap: 10px;
        float: none;
    }
    
    .buttons-row button {
        width: 100%;
        padding: 8px 12px;
        font-size: 0.85rem;
        white-space: nowrap;
    }
    
    .studio-info {
        width: 100%;
        margin: 0;
        margin-top: 10px;
        padding: 8px 12px;
        text-align: center;
        background: rgba(52, 73, 94, 0.5);
        border-radius: 8px;
        backdrop-filter: blur(4px);
        float: none;
        clear: both;
    }
}