:root {
    --pastel-green: #d4f6d4;
    --pastel-green-border: #a8e6a8;
    --pastel-yellow: #fff9c4;
    --pastel-yellow-border: #ffe082;
    --pastel-yellow-accent: #f5a623;
    --pastel-red: #ffcccb;
    --pastel-red-border: #ff9999;
    --pastel-red-accent: #e03e3e;
    --pastel-gray: #e8e8e8;
    --pastel-gray-border: #d0d0d0;
    --pastel-gray-hover: #ddd;
    --text-dark: #333;
    --text-muted: #666;
    --white: #ffffff;
    --shadow-soft: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --transition: all 0.15s ease;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #fafafa 0%, #f0f0f0 100%);
    min-height: 100vh;
    color: var(--text-dark);
    line-height: 1.6;
}

.section {
    padding: 2rem 1rem;
}

.title {
    font-weight: 700;
    color: var(--text-dark);
}

.subtitle {
    font-weight: 400;
}

/* ===== Шапка страницы: логотип, заголовок, подзаголовок ===== */
.page-header {
    margin-bottom: 1.75rem;
}

.page-header .site-logo {
    display: block;
    margin: 0 auto 0.9rem;
    max-width: min(280px, 70vw);
    max-height: 90px;
    height: auto;
    object-fit: contain;
}

.page-header .page-title {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-dark);
    margin: 0 0 0.7rem;
}

.page-header .page-subtitle {
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.55;
    color: var(--text-muted);
    margin: 0;
}

@media (max-width: 480px) {
    .page-header { margin-bottom: 1.4rem; }
    .page-header .page-title { font-size: 1.35rem; }
    .page-header .page-subtitle { font-size: 0.92rem; }
}

/* ===== Блок побуквенного ввода ===== */
.letter-input-block {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    padding: 1rem;
}

.btn-plus, .btn-minus {
    width: 52px;
    height: 52px;
    background: var(--pastel-gray);
    border: 2px solid var(--pastel-gray-border);
    border-radius: var(--radius-md);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex-shrink: 0;
}

.btn-plus:hover, .btn-minus:hover {
    background: var(--pastel-gray-hover);
    border-color: #c0c0c0;
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.btn-plus:active, .btn-minus:active {
    transform: translateY(0);
    box-shadow: var(--shadow-soft);
}

.btn-minus:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.letter-fields {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: center;
    min-width: 52px;
}

.letter-input {
    width: 52px;
    height: 52px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--pastel-green);
    border: 2px solid var(--pastel-green-border);
    border-radius: var(--radius-md);
    color: var(--text-dark);
    outline: none;
    transition: var(--transition);
}

.letter-input:focus {
    border-color: #7cc77c;
    box-shadow: 0 0 0 3px rgba(124, 199, 124, 0.3);
    background: #e8fce8;
}

.letter-input::placeholder {
    color: #999;
    font-weight: 400;
}

.letter-input.has-value {
    background: #c8f0c8;
    border-color: #8dd88d;
}

/* ===== Блоки клавиатур ===== */
.keyboard-block {
    background: var(--block-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--block-border);
}

.known-letters {
    --block-bg: var(--pastel-yellow);
    --block-border: var(--pastel-yellow-border);
}

.excluded-letters {
    --block-bg: var(--pastel-red);
    --block-border: var(--pastel-red-border);
}

.keyboard-title {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.keyboard {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 5px;
    justify-content: center;
    max-width: 100%;
}

/* Адаптивность для мобильных */
@media (max-width: 560px) {
    .keyboard {
        grid-template-columns: repeat(7, 1fr);
    }
}

@media (max-width: 420px) {
    .keyboard {
        grid-template-columns: repeat(6, 1fr);
    }
}

.key-btn {
    aspect-ratio: 1;
    min-height: 40px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.known-letters .key-btn {
    background: #fff3d0;
    color: var(--text-dark);
    border: 1px solid var(--pastel-yellow-border);
}

.known-letters .key-btn:hover:not(.disabled):not(.selected) {
    background: #ffe8a0;
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.excluded-letters .key-btn {
    background: #ffe0e0;
    color: var(--text-dark);
    border: 1px solid var(--pastel-red-border);
}

.excluded-letters .key-btn:hover:not(.disabled):not(.selected) {
    background: #ffc8c8;
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.key-btn.selected {
    color: var(--white) !important;
    font-weight: 700;
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
}

.known-letters .key-btn.selected {
    background: var(--pastel-yellow-accent);
    border-color: var(--pastel-yellow-accent);
}

.excluded-letters .key-btn.selected {
    background: var(--pastel-red-accent);
    border-color: var(--pastel-red-accent);
}

.key-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: #f5f5f5 !important;
    border-color: #eee !important;
    color: #aaa !important;
    transform: none !important;
    box-shadow: none !important;
}

.key-btn:focus-visible {
    outline: 2px solid #333;
    outline-offset: 2px;
}

/* ===== Кнопка поиска ===== */
#btnSearch {
    width: 100%;
    max-width: 320px;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: var(--radius-lg);
    transition: var(--transition);
    box-shadow: var(--shadow-soft);
}

#btnSearch:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

#btnSearch:active {
    transform: translateY(0);
}

#btnSearch:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ===== Результаты ===== */
.results {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    min-height: 60px;
    padding: 0.5rem;
}

.result-word {
    padding: 0.5rem 1rem;
    background: var(--white);
    border: 1px solid var(--pastel-gray-border);
    border-radius: 999px;
    font-family: 'SF Mono', 'Fira Code', 'Monospace', monospace;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-dark);
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
    white-space: nowrap;
}

.result-word:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    border-color: var(--pastel-green-border);
    background: var(--pastel-green);
}

.result-word .match-known {
    background: var(--pastel-yellow);
    padding: 0 2px;
    border-radius: 2px;
}

.result-word .match-excluded {
    background: var(--pastel-red);
    padding: 0 2px;
    border-radius: 2px;
}

.result-word .match-position {
    background: var(--pastel-green);
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 700;
}

.results-empty {
    color: var(--text-muted);
    font-style: italic;
    padding: 1rem;
    width: 100%;
    text-align: center;
}

.results-count {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    width: 100%;
    text-align: center;
}

/* ===== Подсказка ===== */
.help-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ===== Анимации ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-word {
    animation: fadeInUp 0.3s ease forwards;
}

.result-word:nth-child(1) { animation-delay: 0ms; }
.result-word:nth-child(2) { animation-delay: 30ms; }
.result-word:nth-child(3) { animation-delay: 60ms; }
.result-word:nth-child(4) { animation-delay: 90ms; }
.result-word:nth-child(5) { animation-delay: 120ms; }
.result-word:nth-child(6) { animation-delay: 150ms; }
.result-word:nth-child(7) { animation-delay: 180ms; }
.result-word:nth-child(8) { animation-delay: 210ms; }
.result-word:nth-child(9) { animation-delay: 240ms; }
.result-word:nth-child(10) { animation-delay: 270ms; }

/* ===== Состояния загрузки ===== */
#btnSearch.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

#btnSearch.is-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    color: var(--white);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Скроллбар для результатов ===== */
.results::-webkit-scrollbar {
    height: 6px;
}

.results::-webkit-scrollbar-track {
    background: transparent;
}

.results::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.results::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

/* ===== Модальное окно (Bulma-based custom) ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    overflow: auto;
}

.modal.is-active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.25s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-card {
    position: relative;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    animation: modalSlideUp 0.3s ease;
    overflow: hidden;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--pastel-gray-border);
    background: #fafafa;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
}

.modal-card-title .icon {
    color: var(--pastel-yellow-accent);
}

.results-badge {
    background: var(--pastel-green);
    color: #2d7d2d;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 0.5rem;
}

.modal-close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--pastel-gray);
    color: var(--text-dark);
}

.modal-card-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    max-height: 65vh;
}

/* ===== Список результатов в модалке ===== */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.result-item {
    background: var(--white);
    border: 1px solid var(--pastel-gray-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow-soft);
    animation: fadeInUp 0.3s ease forwards;
}

.result-item:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--pastel-green-border);
}

.result-header {
    display: flex;
    align-items: center;
    padding: 0.85rem 1rem;
    cursor: pointer;
    user-select: none;
    gap: 0.75rem;
}

.result-word-main {
    flex: 1;
    font-family: 'SF Mono', 'Fira Code', 'Monospace', monospace;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-dark);
    text-align: left;
    letter-spacing: 0.5px;
}

.result-word-main .match-position {
    background: var(--pastel-green);
    color: #2d7d2d;
    padding: 0 4px;
    border-radius: 4px;
    font-weight: 700;
}

.result-word-main .match-known {
    background: var(--pastel-yellow);
    color: #8a6d00;
    padding: 0 4px;
    border-radius: 4px;
}

.result-word-main .match-excluded {
    background: var(--pastel-red);
    color: #a02020;
    padding: 0 4px;
    border-radius: 4px;
}

.result-expand-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--pastel-gray);
    border: none;
    color: var(--text-dark);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.75rem;
}

.result-expand-btn:hover {
    background: var(--pastel-gray-hover);
    transform: scale(1.05);
}

.result-expand-btn:focus-visible {
    outline: 2px solid var(--pastel-yellow-accent);
    outline-offset: 2px;
}

.result-expand-btn[aria-expanded="true"] {
    transform: rotate(180deg);
    background: var(--pastel-yellow);
    color: #8a6d00;
}

.result-expand-btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.result-definition {
    max-height: 0;
    overflow: hidden;
    padding: 0 1rem;
    background: #fafafa;
    border-top: 1px solid var(--pastel-gray-border);
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.result-definition.expanded {
    max-height: 300px;
    padding: 1rem;
}

.definition-content {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-dark);
}

.definition-content .word-form {
    font-weight: 600;
    color: var(--pastel-yellow-accent);
}

.definition-content .word-meaning {
    margin-top: 0.5rem;
}

.definition-source {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--pastel-gray-border);
}

.results-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

/* ===== Баннеры рекламы в модалке ===== */
.modal-ad-banner {
    margin: 0 -1.5rem 1rem;
    padding: 0.75rem 1.5rem;
    text-align: center;
}

.modal-ad-banner:first-child {
    margin-top: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-ad-banner:last-child {
    margin-bottom: 0;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    border-top: 1px solid var(--pastel-gray-border);
}

.ad-placeholder {
    background: linear-gradient(135deg, #f5f5f5 0%, #eee 100%);
    border: 1px dashed var(--pastel-gray-border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.ad-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    background: var(--white);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.ad-content {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== Мобильная интерстишл-реклама ===== */
.mobile-interstitial {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    background: var(--white);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.mobile-interstitial.is-active {
    display: flex;
    animation: interstitialFadeIn 0.3s ease;
}

@keyframes interstitialFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.interstitial-content {
    text-align: center;
    max-width: 360px;
    width: 100%;
    animation: interstitialSlideIn 0.4s ease;
}

@keyframes interstitialSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.interstitial-ad {
    margin-bottom: 1.5rem;
}

.interstitial-ad .ad-placeholder {
    min-height: 200px;
    padding: 2rem;
    background: linear-gradient(135deg, #fff8e1 0%, #ffe0b2 100%);
    border-color: #ffcc80;
}

.interstitial-ad .ad-content {
    font-size: 1rem;
}

.interstitial-timer {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 1rem;
    font-variant-numeric: tabular-nums;
}

#timerSeconds {
    color: var(--pastel-red-accent);
    font-weight: 700;
}

.interstitial-close {
    display: none;
    padding: 0.75rem 2rem;
    background: var(--pastel-gray);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
    transition: var(--transition);
}

.interstitial-close.visible {
    display: inline-block;
    animation: fadeIn 0.3s ease;
}

.interstitial-close:hover {
    background: var(--pastel-gray-hover);
}

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

/* ===== Модалка-подсказка «Укажите длину слова» ===== */
.hint-card {
    position: relative;
    z-index: 1;
    width: min(420px, 92vw);
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    padding: 2rem 1.75rem;
    text-align: center;
    animation: modalSlideUp 0.3s ease;
}

.hint-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
    color: var(--text-dark);
}

.hint-text {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.7;
    margin: 0 0 1.5rem;
}

.key-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    background: var(--pastel-gray);
    border: 1px solid var(--pastel-gray-border);
    border-radius: 6px;
    font-weight: 700;
    color: var(--text-dark);
}

.hint-close-btn {
    background: #8fd694;
    border-color: #8fd694;
    border-radius: var(--radius-md);
}

.hint-close-btn:hover {
    background: #7cc77c;
    border-color: #7cc77c;
}

/* ===== Адаптивность для модалки ===== */
@media (max-width: 480px) {
    .modal-card {
        width: 95%;
        max-height: 95vh;
        border-radius: var(--radius-lg);
    }
    
    .modal-card-body {
        padding: 0.75rem 1rem;
    }
    
    .modal-ad-banner {
        margin-left: -1rem;
        margin-right: -1rem;
        padding: 0.5rem 1rem;
    }
    
    .result-header {
        padding: 0.75rem 0.75rem;
    }
    
    .result-word-main {
        font-size: 1rem;
    }
    
    .result-definition.expanded {
        padding: 0.75rem;
    }
}

/* ===== SEO-текстовый блок ===== */
.seo-content {
    padding-top: 0;
}

.seo-content .title.is-5 {
    color: var(--text-dark);
}

.how-it-steps {
    padding-left: 1.25rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.8;
}

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.faq-item {
    background: var(--white);
    border: 1px solid var(--pastel-gray-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

.faq-item summary {
    cursor: pointer;
    padding: 0.85rem 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-dark);
    user-select: none;
    list-style-position: inside;
}

.faq-item summary:hover {
    background: var(--pastel-green);
}

.faq-item[open] summary {
    background: var(--pastel-green);
    border-bottom: 1px solid var(--pastel-gray-border);
}

.faq-item p {
    padding: 0.85rem 1rem;
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.7;
    text-align: left;
}

.site-footer {
    background: transparent;
    padding: 1.5rem 1rem;