/* Основные стили */
.fillword-game {
    font-family: 'Segoe UI', Arial, sans-serif;
    max-width: 900px;
    margin: 0px auto;
    padding: 0px 20px 0px 20px;
    background: #ffffff;
    border-radius: 24px;
    position: relative;
    box-sizing: border-box;
    width: 100%;
}

.fillword-game h2 {
    text-align: center;
    color: #1e293b;
    margin-bottom: 12px;
    margin-top: 0;
    font-size: clamp(1.8rem, 5vw, 2.2rem);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.description {
    text-align: center;
    color: #64748b;
    margin-bottom: 30px;
    font-size: clamp(0.95rem, 2.5vw, 1.05rem);
}

/* Сообщения - стандартное (для завершения без промокода) */
.fillword-message {
    padding: 14px 18px;
    margin: 0 0 20px 0;
    border-radius: 16px;
    display: none;
    font-size: clamp(0.95rem, 2.5vw, 1rem);
    font-weight: 500;
    text-align: center;
    box-shadow: 0 6px 14px rgba(0,0,0,0.05);
    animation: slideIn 0.3s ease-out;
    position: relative;
    z-index: 100;
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    left: auto;
    top: auto;
    transform: none;
    box-sizing: border-box;
}

/* Специальный контейнер для центрированного завершающего сообщения без промокода */
.fillword-message.centered-horizontal {
    position: absolute !important;
    top: 20px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 90%;
    max-width: 600px;
    z-index: 1000;
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    color: #155724;
    border: 2px solid #28a745;
    padding: 20px;
    font-size: 1.2rem;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: slideInHorizontal 0.5s ease-out;
    backdrop-filter: blur(5px);
    margin: 0 !important;
}

@keyframes slideInHorizontal {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px) !important;
        scale: 0.95;
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) !important;
        scale: 1;
    }
}

/* Стили для центрированного сообщения с промокодом - относительно контейнера сетки */
.puzzle-container {
    position: relative;
}

.promo-message-container {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 90%;
    max-width: 600px;
    z-index: 1000;
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    color: #155724;
    border: 3px solid #28a745;
    padding: 30px;
    font-size: 1.3rem;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: slideInCenter 0.5s ease-out;
    backdrop-filter: blur(5px);
    pointer-events: auto !important;
}

.promo-message-container .promo-code-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin: 15px 0;
    width: 100%;
}

.promo-message-container.success {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    color: #155724;
    border: 3px solid #28a745;
    border-left: 10px solid #28a745;
}

.promo-message-container .promo-code {
    font-size: 1rem  !important;
    font-weight: bold;
    margin: 15px 0;
    padding: 5px 5px;
    background: white;
    border-radius: 10px;
    border: 3px dashed #28a745;
    color: #155724;
    letter-spacing: 2px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    user-select: all !important;
    cursor: text;
    min-width: 200px;
    text-align: center;
}

.promo-message-container .copy-promo-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
}

.promo-message-container .copy-promo-btn:hover {
    background: linear-gradient(135deg, #2980b9, #1f6fa5);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

.promo-message-container .copy-promo-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.promo-message-container .copy-success {
    font-size: 0.9rem;
    color: #28a745;
    margin-top: 5px;
    opacity: 0;
    transition: opacity 0.3s;
    height: 20px;
}

.promo-message-container .promo-label {
    font-size: 1.1rem;
    color: #0c5460;
    margin-bottom: 5px;
    font-weight: 600;
}

.promo-message-container .emoji {
    font-size: 2.5rem;
    margin-bottom: 15px;
}

.promo-message-container .stats-info {
    font-size: 1.1rem;
    margin: 10px 0;
    color: #0c5460;
    font-weight: 600;
}

@keyframes slideInCenter {
    from {
        opacity: 0;
        transform: translate(-50%, -60%) !important;
        scale: 0.9;
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) !important;
        scale: 1;
    }
}

.fillword-message.success {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    color: #155724;
    border: 2px solid #28a745;
    border-left: 6px solid #28a745;
    display: block;
}

.fillword-message.info {
    background: linear-gradient(135deg, #d1ecf1, #bee5eb);
    color: #0c5460;
    border: 2px solid #17a2b8;
    border-left: 6px solid #17a2b8;
    display: block;
}

.fillword-message.error {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    color: #721c24;
    border: 2px solid #dc3545;
    border-left: 6px solid #dc3545;
    display: block;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Игровой контейнер — ТЕПЕРЬ ВСЕГДА ВЕРТИКАЛЬНЫЙ */
.game-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-top: 15px;
    box-sizing: border-box;
    position: relative;
}

.puzzle-section {
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

.control-section {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* Сетка */
.puzzle-container {
    position: relative;
    width: 100%;
    border-radius: 15px;
    background: #cbd5e1;
    border: 1px solid #cbd5e1;
    padding: 3px;
    box-sizing: border-box;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.puzzle-grid-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.2s ease-out;
    transform-origin: 0 0;
    will-change: transform;
    overflow: visible;
    border-radius: 16px;
    touch-action: none;
}

.puzzle-grid {
    display: grid;
    gap: 2px;
    width: 100%;
    height: 100%;
    background: #cbd5e1;
    box-sizing: border-box;
    margin: 0 auto;
    transform-origin: 0 0;
    border-radius: 12px;
    overflow: hidden;
}

.grid-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: none;
    cursor: pointer;
    user-select: none;
    box-sizing: border-box;
    aspect-ratio: 1 / 1;
    font-size: clamp(14px, 3vw, 18px);
    font-weight: 600;
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
    color: #4d5056;
}

.grid-cell:hover {
    background: #f8fafc;
    transform: scale(0.98);
}

.grid-cell.selected {
    background: #3b82f6;
    color: white;
    transform: scale(0.96);
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #3b82f6;
    z-index: 2;
}

/* Найденные ячейки - разные цвета для каждого слова */
.grid-cell.found {
    cursor: default;
    opacity: 1;
    color: white !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Цвета для найденных слов - набор 1 */
.grid-cell.found.word-color-1 { background: #FF6B6B; }
.grid-cell.found.word-color-2 { background: #4ECDC4; }
.grid-cell.found.word-color-3 { background: #FFD166; }
.grid-cell.found.word-color-4 { background: #06D6A0; }
.grid-cell.found.word-color-5 { background: #118AB2; }
.grid-cell.found.word-color-6 { background: #EF476F; }
.grid-cell.found.word-color-7 { background: #7209B7; }
.grid-cell.found.word-color-8 { background: #F15BB5; }
.grid-cell.found.word-color-9 { background: #00BBF9; }
.grid-cell.found.word-color-10 { background: #00F5D4; }

/* Второй набор цветов для анимации перехода */
.grid-cell.found.word-color-1-alt { background: #FF9E9E; }
.grid-cell.found.word-color-2-alt { background: #7EE0DC; }
.grid-cell.found.word-color-3-alt { background: #FFE28F; }
.grid-cell.found.word-color-4-alt { background: #4BE0B5; }
.grid-cell.found.word-color-5-alt { background: #5AAFD6; }
.grid-cell.found.word-color-6-alt { background: #F57A9C; }
.grid-cell.found.word-color-7-alt { background: #9D4EDD; }
.grid-cell.found.word-color-8-alt { background: #F891C8; }
.grid-cell.found.word-color-9-alt { background: #5AC8FA; }
.grid-cell.found.word-color-10-alt { background: #5AF9E8; }

.grid-cell[disabled] {
    cursor: default;
    opacity: 1;
}

.grid-cell[disabled]:hover {
    background: inherit;
    transform: none;
}

.grid-cell.hint {
    animation: pulse 1.5s infinite;
    background: #fde68a;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.5);
    z-index: 5;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Анимация смены цвета для найденных слов */
@keyframes colorTransition {
    0% { 
        transform: scale(1.05); 
        box-shadow: 0 0 10px rgba(255,255,255,0.5);
    }
    50% { 
        transform: scale(1.02); 
        box-shadow: 0 0 15px rgba(255,255,255,0.7);
    }
    100% { 
        transform: scale(1); 
        box-shadow: 0 0 5px rgba(255,255,255,0.3);
    }
}

.grid-cell.found.color-transition {
    animation: colorTransition 1s ease;
}

/* Панель управления - ВСЕГДА В СТОЛБИК */
.controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

button {
    padding: clamp(14px, 3vw, 16px) 20px;
    border: none;
    border-radius: 60px;
    font-size: clamp(15px, 3vw, 16px);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
    width: 100%;
    text-align: center;
    box-shadow: 0 4px 6px -2px rgba(0, 0, 0, 0.05), 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.3px;
}

.hint-btn {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border-radius: 10px;
}

.hint-btn:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(37, 99, 235, 0.4);
}

.hint-btn:disabled {
    background: #94a3b8;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.new-game-btn {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: white;
    border-radius: 10px;
}

.new-game-btn:hover {
    background: linear-gradient(135deg, #ea580c, #c2410c);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(234, 88, 12, 0.4);
}

.solve-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border-radius: 10px;
}

.solve-btn:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(5, 150, 105, 0.4);
}

/* Кнопки печати */
.print-buttons-container {
    display: flex;
    flex-direction: row;
    gap: 12px;
    margin-top: 5px;
    width: 100%;
}

.print-btn {
    background: linear-gradient(135deg, #64748b, #475569);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 15px !important;
    font-size: 15px !important;
    border-radius: 60px;
    flex: 1;
}

.print-btn:hover {
    background: linear-gradient(135deg, #475569, #334155);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(71, 85, 105, 0.4);
}

/* Статистика - НОВЫЙ ДИЗАЙН */
.stats {
    padding: 20px 20px;
    background: #f8fafc;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: 15px 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: clamp(14px, 3vw, 15px);
    min-width: 100px;
}

.stat-item span:first-child {
    color: #64748b;
    font-weight: 500;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.count-container {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 1.4em;
    color: #0f172a;
}

.count-separator {
    color: #94a3b8;
    font-weight: 500;
    font-size: 0.8em;
}

/* Список слов - НОВЫЙ ДИЗАЙН */
.words-section {
    padding: 20px;
    background: #ffffff;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    box-sizing: border-box;
    width: 100%;
    box-shadow: 0 4px 6px -2px rgba(0,0,0,0.02);
}

.words-section h4 {
    margin: 0 0 15px 0;
    color: #1e293b;
    text-align: left;
    font-size: clamp(1rem, 3vw, 1.1rem);
    font-weight: 600;
}

.words-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    max-height: 160px;
    overflow-y: auto;
    padding: 5px 0;
    background: transparent;
    border-radius: 0;
    box-sizing: border-box;
    justify-content: flex-start;
    flex-direction: row;
}

.word-item {
    padding: 8px 12px 8px 8px;
    background: #f1f5f9;
    border-radius: 40px;
    font-weight: 500;
    font-size: clamp(13px, 2.5vw, 14px);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #e2e8f0;
    color: #334155;
}

.word-item.found {
    background: #dcfce7;
    color: #166534;
    text-decoration: line-through;
    border-color: #86efac;
    opacity: 0.8;
}

/* Цветной кружок для слова */
.word-item .color-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 4px;
    flex-shrink: 0;
}

/* Инструкция */
.instructions-section {
    padding: 20px;
    background: #f8fafc;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    box-sizing: border-box;
}

.instructions-section h4 {
    margin: 0 0 10px 0;
    color: #1e293b;
    text-align: left;
    font-size: clamp(1rem, 3vw, 1.1rem);
    font-weight: 600;
}

.instructions-section p {
    margin: 0 0 8px 0;
    color: #475569;
    font-size: clamp(13px, 2.5vw, 14px);
    line-height: 1.5;
}

.instructions-section p:last-child {
    margin-bottom: 0;
}

/* Мобильный зум */
.mobile-zoom-controls {
    display: none;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    padding: 10px 10px;
    background: #f1f5f9;
    border-radius: 60px;
    border: 1px solid #e2e8f0;
    width: 100%;
    box-sizing: border-box;
}

.zoom-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    border: none;
    border-radius: 50%;
    background: #ffffff;
    color: #1e293b;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
    border: 1px solid #cbd5e1;
}

.zoom-btn.zoom-out {
    color: #b91c1c;
}

.zoom-btn.zoom-in {
    color: #166534;
}

.zoom-btn.zoom-out:hover {
    background: #fee2e2;
    border-color: #f87171;
}

.zoom-btn.zoom-in:hover {
    background: #dcfce7;
    border-color: #4ade80;
}

.zoom-hint {
    display: none;
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 41, 59, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 40px;
    font-size: 14px;
    font-weight: 500;
    z-index: 20;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
}

/* Уменьшение шрифта для крупных сеток */
.puzzle-grid.size-16 .grid-cell,
.puzzle-grid.size-18 .grid-cell,
.puzzle-grid.size-20 .grid-cell {
    font-size: clamp(10px, 2.2vw, 14px);
}

/* Для мобильных устройств */
@media (max-width: 767px) {
    .fillword-game {
        padding: 5px 5px;
        border-radius: 20px;
    }
    
    .mobile-zoom-controls {
        display: flex;
    }
    
    .puzzle-container {
        touch-action: pan-x pan-y;
    }
    
    .zoom-hint {
        display: block;
    }
    
    .grid-cell {
        font-size: clamp(14px, 4vw, 18px);
    }
    
    .puzzle-grid-wrapper.zoomed {
        overflow: visible;
    }
    
    .puzzle-grid-wrapper.zoomed .grid-cell {
        box-shadow: 0 0 1px rgba(0,0,0,0.2);
    }
    
    .promo-message-container {
        width: 95%;
        max-width: 95%;
        padding: 15px 12px;
        font-size: 1rem;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .promo-message-container .promo-code-container {
        flex-direction: column;
        gap: 8px;
        margin: 10px 0;
        width: 100%;
    }
    
    .promo-message-container .promo-code {
        font-size: 1.2rem;
        padding: 10px 15px;
        min-width: 120px;
        margin: 8px 0;
    }
    
    .promo-message-container .copy-promo-btn {
        width: 100%;
        max-width: 180px;
        padding: 8px 12px;
        font-size: 1rem;
        min-width: 40px;
    }
    
    .promo-message-container .emoji {
        font-size: 1.5rem;
        margin-bottom: 8px;
    }
    
    .promo-message-container .stats-info {
        font-size: 0.9rem;
        margin: 6px 0;
    }
    
    .promo-message-container .promo-label {
        font-size: 0.95rem;
        margin-bottom: 4px;
    }
    
    .promo-message-container .copy-success {
        font-size: 0.8rem;
        height: 16px;
    }
    
    .fillword-message.centered-horizontal {
        width: 95%;
        max-width: 95%;
        padding: 12px;
        font-size: 0.95rem;
        top: 10px !important;
    }
    
    .print-buttons-container {
        flex-direction: column;
        gap: 10px;
    }
    
    .stats {
        padding: 15px 10px;
    }
    
    .stat-item {
        min-width: 70px;
    }
    
    /* ========== ГОРИЗОНТАЛЬНАЯ ПРОКРУТКА В 3 СТРОКИ ДЛЯ СПИСКА СЛОВ ========== */
    .words-container {
        max-height: none;
        display: grid;
        grid-template-rows: repeat(3, auto);
        grid-auto-flow: column;
        grid-template-columns: repeat(auto-fill, minmax(min(100%, max(120px, auto)), auto));
        gap: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 5px 0 12px 0;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        width: 100%;
    }
    
    /* Стилизация скроллбара для WebKit браузеров */
    .words-container::-webkit-scrollbar {
        height: 4px;
    }
    
    .words-container::-webkit-scrollbar-track {
        background: #e2e8f0;
        border-radius: 10px;
    }
    
    .words-container::-webkit-scrollbar-thumb {
        background: #94a3b8;
        border-radius: 10px;
    }
    
    .words-container::-webkit-scrollbar-thumb:hover {
        background: #64748b;
    }
    
    /* Каждое слово - цельный блок, растягивается по содержимому */
    .word-item {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 6px 14px 6px 10px;
        background: #f1f5f9;
        border-radius: 40px;
        font-weight: 500;
        font-size: clamp(12px, 3vw, 14px);
        border: 1px solid #e2e8f0;
        color: #334155;
        white-space: nowrap;
        width: auto;
        min-width: fit-content;
        max-width: none;
        flex-shrink: 0;
        flex-grow: 0;
    }
    
    /* Цветной кружок - фиксированный размер, не сжимается */
    .word-item .color-indicator {
        display: inline-block;
        width: 12px;
        height: 12px;
        border-radius: 50%;
        margin-right: 0;
        flex-shrink: 0;
    }
    
    /* Текст слова - не переносится */
    .word-item .word-text {
        display: inline;
        white-space: nowrap;
    }
    
    /* Длина слова в скобках - не переносится */
    .word-item .word-length {
        display: inline;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    /* Для очень длинных слов, которые не влезают в экран */
    .word-item.long-word {
        white-space: nowrap;
        max-width: none;
    }
    
    /* Для экранов до 480px - всё ещё 3 строки */
    @media (max-width: 480px) {
        .words-container {
            grid-template-rows: repeat(3, auto);
        }
        
        .word-item {
            padding: 5px 12px 5px 8px;
            font-size: clamp(11px, 2.8vw, 13px);
        }
        
        .word-item .color-indicator {
            width: 10px;
            height: 10px;
        }
    }
    
    /* Для экранов до 360px - уменьшаем до 2 строк */
    @media (max-width: 360px) {
        .words-container {
            grid-template-rows: repeat(2, auto);
        }
    }
    
    /* Для экранов до 280px - 1 строка */
    @media (max-width: 280px) {
        .words-container {
            grid-template-rows: repeat(1, auto);
        }
    }
    
    /* Уменьшение шрифта для крупных сеток на мобильных */
    .puzzle-grid.size-16 .grid-cell,
    .puzzle-grid.size-18 .grid-cell,
    .puzzle-grid.size-20 .grid-cell {
        font-size: clamp(9px, 3vw, 12px);
    }
}

@media (max-width: 480px) {
    .print-buttons-container {
        flex-direction: column;
    }
    
    .stats {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .stat-item {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
        min-width: auto;
    }
    
    .stat-item span:first-child {
        font-size: 0.9em;
    }
    
    .count-container {
        font-size: 1.2em;
    }
    
    /* Еще меньше шрифт для крупных сеток на очень маленьких экранах */
    .puzzle-grid.size-16 .grid-cell,
    .puzzle-grid.size-18 .grid-cell,
    .puzzle-grid.size-20 .grid-cell {
        font-size: clamp(8px, 2.8vw, 11px);
    }
}

@media (max-width: 360px) {
    /* Дополнительные корректировки при необходимости */
}

/* Анимации */
@keyframes celebrate {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.game-complete .puzzle-grid {
    animation: celebrate 2s ease-in-out infinite;
    border-color: #10b981;
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.2);
}

/* Стили для увеличенной сетки */
.puzzle-grid-wrapper.zoomed {
    cursor: grab;
}

.puzzle-grid-wrapper.zoomed:active {
    cursor: grabbing;
}

/* Стили для всплывающих сообщений */
.fillword-popup-container {
    position: fixed;
    top: 20px;
    left: 0;
    width: 100%;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

.fillword-popup-message {
    padding: 14px 25px;
    margin: 8px 0;
    border-radius: 60px;
    font-size: clamp(0.95rem, 2.5vw, 1rem);
    font-weight: 600;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    animation: popupSlideIn 0.3s ease-out;
    max-width: 90%;
    min-width: 300px;
    box-sizing: border-box;
    pointer-events: auto;
    backdrop-filter: blur(4px);
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes popupSlideOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-15px);
    }
}

.fillword-popup-message.success {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    color: #155724;
    border: 1px solid #28a745;
}

.fillword-popup-message.info {
    background: linear-gradient(135deg, #d1ecf1, #bee5eb);
    color: #0c5460;
    border: 1px solid #17a2b8;
}

.fillword-popup-message.error {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    color: #721c24;
    border: 1px solid #dc3545;
}

/* Стили для печати */
@media print {
    body * {
        visibility: hidden;
    }
    
    .fillword-print-container,
    .fillword-print-container * {
        visibility: visible;
    }
    
    .fillword-print-container {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        font-family: Arial, sans-serif;
        page-break-inside: avoid;
        display: block !important;
    }
    
    .print-header {
        text-align: center;
        margin-bottom: 20px;
        border-bottom: 2px solid #333;
        padding-bottom: 10px;
        display: block !important;
        visibility: visible !important;
    }
    
    .print-header h1 {
        font-size: 24px;
        margin: 0 0 10px 0;
        color: #2c3e50;
        display: block !important;
        visibility: visible !important;
    }
    
    .print-header .print-info {
        font-size: 14px;
        color: #666;
        display: block !important;
        visibility: visible !important;
    }
    
    .print-grid-container {
        margin: 0 auto;
        page-break-inside: avoid;
        display: block !important;
        visibility: visible !important;
    }
    
    .print-grid {
        display: grid !important;
        gap: 1px;
        background: #000;
        margin: 0 auto;
        border: 2px solid #000;
        visibility: visible !important;
        page-break-inside: avoid;
    }
    
    .print-cell {
        background: white;
        border: 1px solid #000;
        display: flex !important;
        align-items: center;
        justify-content: center;
        aspect-ratio: 1 / 1;
        font-size: 18px;
        font-weight: bold;
        page-break-inside: avoid;
        visibility: visible !important;
    }
    
    .print-words-section {
        margin-top: 30px;
        page-break-inside: avoid;
        display: block !important;
        visibility: visible !important;
    }
    
    .print-words-section h3 {
        text-align: center;
        font-size: 18px;
        margin: 0 0 15px 0;
        border-bottom: 1px solid #ccc;
        padding-bottom: 5px;
        display: block !important;
        visibility: visible !important;
    }
    
    .print-words-grid {
        display: grid !important;
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 8px;
        visibility: visible !important;
    }
    
    .print-word-item {
        padding: 8px;
        border: 1px dashed #ccc;
        border-radius: 4px;
        font-size: 14px;
        page-break-inside: avoid;
        display: block !important;
        visibility: visible !important;
    }
    
    .print-footer {
        margin-top: 30px;
        text-align: center;
        font-size: 12px;
        color: #666;
        border-top: 1px solid #ccc;
        padding-top: 10px;
        display: block !important;
        visibility: visible !important;
    }
    
    @page {
        margin: 1.5cm;
    }
    
    .page-break {
        page-break-before: always;
    }
}

/* ========== ИСПРАВЛЕННЫЕ СТИЛИ ДЛЯ МЕНЮ ВЫБОРА НОВОГО ФИЛВОРДА ========== */
.new-game-menu {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 550px;
    max-height: 80vh;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 32px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.2);
    z-index: 10000;
    flex-direction: column;
    overflow: hidden;
    animation: menuFadeIn 0.25s ease-out;
}

@keyframes menuFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -48%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.new-game-menu .menu-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px 30px 20px 30px;
}

.new-game-menu h3 {
    margin-top: 0;
    margin-bottom: 25px;
    color: #1e293b;
    border-bottom: 3px solid #3b82f6;
    padding-bottom: 15px;
    font-size: 1.6rem;
    font-weight: 600;
}

.new-game-menu .menu-section {
    margin-bottom: 30px;
}

.new-game-menu .menu-section-title {
    font-weight: 600;
    margin-bottom: 15px;
    color: #475569;
    font-size: 1.1rem;
}

.new-game-menu .grid-sizes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.new-game-menu .size-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 12px;
    background: #f8fafc;
    border-radius: 60px;
    transition: all 0.2s;
    border: 1px solid #e2e8f0;
}

.new-game-menu .size-option:hover {
    background: #e0f2fe;
    border-color: #3b82f6;
}

.new-game-menu .size-option input[type="radio"] {
    margin: 0;
    width: 18px;
    height: 18px;
    accent-color: #3b82f6;
}

.new-game-menu .size-option span {
    font-size: 1rem;
    font-weight: 500;
}

.new-game-menu .placement-modes {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.new-game-menu .mode-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    padding: 14px 16px;
    background: #f8fafc;
    border-radius: 16px;
    transition: all 0.2s;
    border: 1px solid #e2e8f0;
}

.new-game-menu .mode-option:hover {
    background: #e0f2fe;
    border-color: #3b82f6;
}

.new-game-menu .mode-option input[type="radio"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    accent-color: #3b82f6;
}

.new-game-menu .mode-option span {
    font-size: 0.95rem;
    line-height: 1.4;
    flex: 1;
    color: #334155;
}

.new-game-menu .menu-buttons {
    flex-shrink: 0;
    display: flex;
    gap: 15px;
    justify-content: space-between;
    border-top: 1px solid #e2e8f0;
    padding: 20px 30px;
    background: white;
}

.new-game-menu .cancel-btn {
    padding: 14px 30px;
    background: #f1f5f9;
    border: none;
    border-radius: 60px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s;
    flex: 1;
    max-width: 130px;
    color: #475569;
}

.new-game-menu .cancel-btn:hover {
    background: #e2e8f0;
    transform: translateY(-2px);
}

.new-game-menu .confirm-btn {
    padding: 14px 35px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 60px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.2s;
    flex: 1;
    max-width: 130px;
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.new-game-menu .confirm-btn:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.4);
}

/* Затемнение фона */
.new-game-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    z-index: 9999;
    backdrop-filter: blur(6px);
}

/* Адаптация для мобильных устройств */
@media (max-width: 767px) {
    .new-game-menu {
        width: 95%;
        max-width: 95%;
        max-height: 85vh;
        border-radius: 24px;
    }
    
    .new-game-menu .menu-content {
        padding: 20px 15px;
    }
    
    .new-game-menu h3 {
        font-size: 1.4rem;
        margin-bottom: 20px;
    }
    
    .new-game-menu .grid-sizes {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .new-game-menu .size-option {
        padding: 10px;
    }
    
    .new-game-menu .size-option span {
        font-size: 0.9rem;
    }
    
    .new-game-menu .menu-buttons {
        padding: 15px;
        gap: 10px;
    }
    
    .new-game-menu .cancel-btn,
    .new-game-menu .confirm-btn {
        padding: 14px 20px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .new-game-menu .grid-sizes {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .new-game-menu h3 {
        font-size: 1.3rem;
    }
    
    .new-game-menu .menu-section-title {
        font-size: 1rem;
    }
}

@media (max-width: 360px) {
    .new-game-menu .grid-sizes {
        grid-template-columns: repeat(1, 1fr);
    }
    
    .new-game-menu .mode-option span {
        font-size: 0.85rem;
    }
}

/* Стили для режимов сложности в меню */
.difficulty-modes {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.difficulty-option {
    background: #f8fafc !important;
    border: 2px solid #e2e8f0 !important;
    transition: all 0.2s ease !important;
    padding: 12px 16px !important;
}

.difficulty-option:hover {
    background: #e0f2fe !important;
    border-color: #3b82f6 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.difficulty-option input[type="radio"]:checked + span {
    font-weight: 600;
}

.difficulty-option[data-difficulty="easy"] {
    border-left: 6px solid #10b981 !important;
}

.difficulty-option[data-difficulty="medium"] {
    border-left: 6px solid #f59e0b !important;
}

.difficulty-option[data-difficulty="hard"] {
    border-left: 6px solid #ef4444 !important;
}

.difficulty-option[data-difficulty="master"] {
    border-left: 6px solid #8b5cf6 !important;
}

/* Адаптация для мобильных */
@media (max-width: 767px) {
    .difficulty-option small {
        font-size: 0.8em !important;
    }
    
    .difficulty-option {
        padding: 10px 12px !important;
    }
}

@media (max-width: 480px) {
    .difficulty-option small {
        font-size: 0.75em !important;
    }
    
    .difficulty-option {
        padding: 8px 10px !important;
    }
}

body.modal-open {
    overflow: hidden;
}

/* ===== ДОБАВЛЕННЫЕ СТИЛИ ДЛЯ УСТРАНЕНИЯ КОНФЛИКТОВ ===== */
html, body {
    position: static !important;
    overflow: visible !important;
    width: auto !important;
    height: auto !important;
}

/* ===== РЕКЛАМНЫЕ БЛОКИ ===== */
.fillword-ad-block {
    text-align: center;
    margin: 15px 0;
    overflow: hidden;
    clear: both;
}

.fillword-ad-top {
    margin-top: 0;
    margin-bottom: 20px;
}

.fillword-ad-after-words {
    margin: 15px 0;
}

.fillword-ad-before-stats {
    margin: 15px 0;
}

/* Для адаптивности рекламных блоков */
.fillword-ad-block img {
    max-width: 100%;
    height: auto;
    display: inline-block;
}

/* Для рекламных кодов (Яндекс.РСЯ, Google AdSense и т.д.) */
.fillword-ad-block ins.adsbygoogle,
.fillword-ad-block div[id^="yandex_rtb"] {
    display: block;
    margin: 0 auto;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .fillword-ad-block {
        margin: 10px 0;
    }
}