/* =================================================================
   МОДУЛЬ КАРТВОРД — стили
   ================================================================= */

.scanword-game {
    --sw-header-h: 64px;
    --sw-kb: 0px;
    --sw-cell-size: 80px;

    --sw-module-height: 85vh;
    --sw-module-height-mobile: 85vh;

    --sw-tool-icon-size: 22px;
    --sw-tool-btn-size: 40px;
    --sw-tool-gap: 4px;

    --sw-tool-icon-size-mobile: 22px;
    --sw-tool-btn-size-mobile: 38px;
    --sw-tool-gap-mobile: 3px;

    --sw-toolbar-justify: flex-end;
    --sw-toolbar-justify-mobile: flex-end;

    --sw-header-bg: #ffffff;

    --sw-tool-btn-bg: #ffffff;
    --sw-tool-btn-border-color: #e6e8ec;
    --sw-tool-btn-border-width: 1px;
    --sw-tool-btn-radius: 11px;
    --sw-tool-icon-color: #1e293b;

    --sw-scroll-hint-size: 18px;
    --sw-scroll-hint-offset: 2px;
    --sw-scroll-hint-bg: #2563eb;
    --sw-scroll-hint-color: #ffffff;

    /* ===== Дизайн сетки ===== */
    --sw-grid-line-color: #334155;
    --sw-grid-line-width: 1.5px;
    --sw-grid-outer-width: 1.5px;
    --sw-grid-outer-color: #334155;
    --sw-board-shadow: 0 1px 2px rgba(15,23,42,0.06), 0 8px 26px rgba(15,23,42,0.12);
    --sw-cell-radius: 0px;
    --sw-cell-hover-scale: 1.02;

    /* Переопределение фона клеток с буквами (по умолчанию — из темы) */
    --sw-cell-bg-override: initial;

    /* Буквы */
    --sw-letter-font: Georgia, "Times New Roman", serif;
    --sw-letter-fw: 700;
    --sw-letter-scale: 0.45;
    --sw-letter-fs: calc(var(--sw-cell-size) * var(--sw-letter-scale));
    --sw-letter-color-correct: #2563eb;
    --sw-letter-color-wrong: #dc2626;
    --sw-letter-color-hint: #16a34a;

    /* Текст вопросов */
    --sw-clue-font: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --sw-clue-fw: 500;
    --sw-clue-fs: 13px;
    --sw-clue-fs-mobile: 12px;
    --sw-clue-color: #000000;
    --sw-clue-lh: 1.12;
    --sw-clue-padding: 4px;

    /* Выделение */
    --sw-sel-bg: #c7ddfb;
    --sw-active-bg: #a3c4f7;
    --sw-active-ring: #2563eb;
    --sw-active-ring-width: 3px;

    /* Стрелки */
    --sw-arrow-color: #dc2626;

    /* Базовые переменные из темы */
    --sw-text: #1e293b;
    --sw-muted: #64748b;
    --sw-bar-bg: rgba(255, 255, 255, .92);
    --sw-border: rgba(15, 23, 42, .08);

    --sw-theme-bg: #f4f6ea;
    --sw-cell-bg: #fbfcfe;
    --sw-clue-bg: #ffffff;
    --sw-empty-cell-bg: #c9cfbc;
    --sw-cell-hover-bg: #ffffff;

    --sw-grid-line: var(--sw-grid-line-color);
    --sw-clue-fs-internal: var(--sw-clue-fs);

    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--sw-theme-bg);
    border-radius: 16px;
    overflow: hidden;
    overflow: clip;
    height: var(--sw-module-height, 85vh);
    min-height: 450px;
    max-height: 1400px;
    width: 100%;
    max-width: 100%;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--sw-text);
    box-sizing: border-box;
    box-shadow: 0 4px 20px rgba(15, 23, 42, .08);
}

.scanword-game *,
.scanword-game *::before,
.scanword-game *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

.scanword-game .scanword-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: var(--sw-theme-bg);
    pointer-events: none;
    transition: background .35s ease;
}

/* ================= HEADER + TOOLBAR ================= */
.scanword-game .scanword-header {
    position: relative;
    z-index: 4;
    flex: 0 0 auto;
    padding: 6px 10px;
    background: var(--sw-header-bg, var(--sw-bar-bg));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--sw-border);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: background .35s ease;
}

.scanword-game .scanword-title-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
    padding: 0 2px;
}
.scanword-game .scanword-title-row h1 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--sw-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.scanword-game .scanword-title-row p {
    margin: 0;
    font-size: 11px;
    color: var(--sw-muted);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1 1 auto;
}

.scanword-game .scanword-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-wrap: nowrap;
    position: relative;
}

.scanword-game .scanword-toolbar-stats {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    min-width: 0;
    overflow: hidden;
}

.scanword-game .scanword-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.045);
    border: 1px solid rgba(15, 23, 42, 0.06);
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
    color: var(--sw-text);
    line-height: 1;
    white-space: nowrap;
    height: 26px;
}
.scanword-game .scanword-chip-icon {
    width: 13px;
    height: 13px;
    color: var(--sw-muted);
    flex: 0 0 auto;
}
.scanword-game .scanword-chip-value {
    font-weight: 700;
    letter-spacing: 0.01em;
}
.scanword-game .scanword-chip-sep {
    color: var(--sw-muted);
    font-weight: 500;
    margin: 0 1px;
}

.scanword-game .scanword-toolbar-actions {
    display: flex;
    align-items: center;
    gap: var(--sw-tool-gap, 4px);
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 6px 2px;
    margin: -6px -2px;
    scroll-behavior: smooth;
}
.scanword-game .scanword-toolbar-actions::-webkit-scrollbar {
    display: none;
}

.scanword-toolbar.sw-justify-desktop-right .scanword-toolbar-actions > .scanword-tool-btn:first-of-type {
    margin-left: auto;
}
.scanword-toolbar.sw-justify-desktop-center .scanword-toolbar-actions > .scanword-tool-btn:first-of-type {
    margin-left: auto;
}
.scanword-toolbar.sw-justify-desktop-center .scanword-toolbar-actions > .scanword-tool-btn:last-of-type {
    margin-right: auto;
}

@media (max-width: 720px) {
    .scanword-toolbar.sw-justify-desktop-right .scanword-toolbar-actions > .scanword-tool-btn:first-of-type,
    .scanword-toolbar.sw-justify-desktop-center .scanword-toolbar-actions > .scanword-tool-btn:first-of-type,
    .scanword-toolbar.sw-justify-desktop-center .scanword-toolbar-actions > .scanword-tool-btn:last-of-type {
        margin-left: 0;
        margin-right: 0;
    }

    .scanword-toolbar.sw-justify-mobile-right .scanword-toolbar-actions > .scanword-tool-btn:first-of-type {
        margin-left: auto;
    }
    .scanword-toolbar.sw-justify-mobile-center .scanword-toolbar-actions > .scanword-tool-btn:first-of-type {
        margin-left: auto;
    }
    .scanword-toolbar.sw-justify-mobile-center .scanword-toolbar-actions > .scanword-tool-btn:last-of-type {
        margin-right: auto;
    }
}

.scanword-toolbar.sw-toolbar-scroll-right .scanword-toolbar-actions {
    -webkit-mask-image: linear-gradient(to right,
        #000 0,
        #000 calc(100% - 26px),
        transparent 100%);
    mask-image: linear-gradient(to right,
        #000 0,
        #000 calc(100% - 26px),
        transparent 100%);
}
.scanword-toolbar.sw-toolbar-scroll-left .scanword-toolbar-actions {
    -webkit-mask-image: linear-gradient(to right,
        transparent 0,
        #000 26px,
        #000 100%);
    mask-image: linear-gradient(to right,
        transparent 0,
        #000 26px,
        #000 100%);
}
.scanword-toolbar.sw-toolbar-scroll-left.sw-toolbar-scroll-right .scanword-toolbar-actions {
    -webkit-mask-image: linear-gradient(to right,
        transparent 0,
        #000 26px,
        #000 calc(100% - 26px),
        transparent 100%);
    mask-image: linear-gradient(to right,
        transparent 0,
        #000 26px,
        #000 calc(100% - 26px),
        transparent 100%);
}

.scanword-toolbar-hint {
    position: absolute;
    right: var(--sw-scroll-hint-offset, 2px);
    top: 50%;
    transform: translateY(-50%);
    width: var(--sw-scroll-hint-size, 18px);
    height: var(--sw-scroll-hint-size, 18px);
    border-radius: 50%;
    background: var(--sw-scroll-hint-bg, #2563eb);
    color: var(--sw-scroll-hint-color, #ffffff);
    display: none;
    align-items: center;
    justify-content: center;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: max(9px, calc(var(--sw-scroll-hint-size, 18px) * 0.83));
    font-weight: 700;
    line-height: 1;
    padding: 0 0 2px 1px;
    pointer-events: auto;
    cursor: pointer;
    z-index: 4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
    user-select: none;
    -webkit-user-select: none;
    outline: none;
    transition: box-shadow .2s ease;
}
.scanword-toolbar-hint:focus-visible {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .35);
}
.scanword-toolbar.sw-toolbar-scroll-right .scanword-toolbar-hint {
    display: inline-flex;
    animation: swToolbarHintPulse 2.2s ease-in-out infinite;
}

@keyframes swToolbarHintPulse {
    0%, 100% {
        transform: translateY(-50%) translateX(0);
        opacity: .85;
        box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
    }
    50% {
        transform: translateY(-50%) translateX(-2px);
        opacity: 1;
        box-shadow: 0 2px 12px rgba(0, 0, 0, .45);
    }
}

.scanword-toolbar-hint.has-img {
    background: transparent;
    border-radius: 0;
    padding: 0;
    font-size: 0;
    box-shadow: none;
    overflow: hidden;
}
.scanword-toolbar-hint.has-img .scanword-toolbar-hint__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    flex: 0 0 auto;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-user-select: none;
}
.scanword-toolbar.sw-toolbar-scroll-right .scanword-toolbar-hint.has-img {
    animation-name: swToolbarHintImgPulse;
}
@keyframes swToolbarHintImgPulse {
    0%, 100% {
        transform: translateY(-50%) translateX(0);
        opacity: .85;
    }
    50% {
        transform: translateY(-50%) translateX(-2px);
        opacity: 1;
    }
}

.scanword-game .scanword-tool-btn {
    position: relative;
    flex: 0 0 auto;
    width: var(--sw-tool-btn-size, 40px);
    height: var(--sw-tool-btn-size, 40px);
    border-radius: var(--sw-tool-btn-radius, 11px);
    border: var(--sw-tool-btn-border-width, 1px) solid var(--sw-tool-btn-border-color, #e6e8ec);
    background: var(--sw-tool-btn-bg, #ffffff);
    color: var(--sw-tool-icon-color, var(--sw-text));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
    touch-action: manipulation;
    font-family: inherit;
    font-size: 16px;
    overflow: visible;
}

.scanword-game .scanword-tool-btn svg {
    width: var(--sw-tool-icon-size, 22px);
    height: var(--sw-tool-icon-size, 22px);
    max-width: calc(100% - 4px);
    max-height: calc(100% - 4px);
    flex: 0 0 auto;
    color: inherit;
    stroke: currentColor;
}

.scanword-game .scanword-tool-btn__img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: var(--sw-tool-icon-size, 22px);
    height: var(--sw-tool-icon-size, 22px);
    max-width: calc(100% - 4px);
    max-height: calc(100% - 4px);
    object-fit: cover;
    display: block;
    border-radius: 4px;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-user-select: none;
}

@media (hover: hover) and (pointer: fine) {
    .scanword-game .scanword-tool-btn:hover {
        background: #f1f5f9;
        border-color: rgba(15, 23, 42, 0.18);
    }
}
.scanword-game .scanword-tool-btn:active {
    transform: scale(.94);
}
.scanword-game .scanword-tool-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
}

.scanword-game.no-btn-bg .scanword-tool-btn:not(.is-active):not(.was-hint-active) {
    background: transparent;
    box-shadow: none;
}
.scanword-game.no-btn-bg .scanword-tool-btn:not(.is-active):not(.was-hint-active):hover {
    background: rgba(15, 23, 42, 0.08);
}
.scanword-game.no-btn-bg .scanword-tool-btn-theme {
    background: transparent;
    box-shadow: none;
}
.scanword-game.no-btn-bg .scanword-tool-btn.is-active {
    background: #2563eb;
    box-shadow: 0 2px 8px rgba(37, 99, 235, .35);
}
.scanword-game.no-btn-bg .scanword-tool-btn.is-active:hover {
    background: #1d4ed8;
}
.scanword-game.no-btn-bg .scanword-tool-btn.was-hint-active {
    background: #fef3c7;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .18);
}

.scanword-game.no-btn-border .scanword-tool-btn {
    border: none;
}

.scanword-game .scanword-tool-btn.has-img::before {
    content: none;
    display: none;
}

.scanword-game .scanword-tool-btn.is-active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, .35);
}
.scanword-game .scanword-tool-btn.is-active:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.scanword-game .scanword-tool-btn.was-hint-active {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #b45309;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .18);
}

.scanword-game .scanword-tool-btn-theme {
    background: var(--sw-tool-btn-bg, #b7cf4c);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .6);
}
.scanword-game .scanword-tool-btn-theme::before {
    content: '🎨';
    font-size: 18px;
    line-height: 1;
    filter: drop-shadow(0 1px 1px rgba(255, 255, 255, .9));
}
.scanword-game .scanword-tool-btn-theme svg { display: none; }

.scanword-game .scanword-tool-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: #f59e0b;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
    pointer-events: none;
    z-index: 2;
}
.scanword-game .scanword-tool-btn.is-active .scanword-tool-badge {
    background: #fff;
    color: #2563eb;
}

.scanword-game .scanword-zoom-indicator {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--sw-muted);
    min-width: 32px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    flex: 0 0 auto;
    line-height: 1;
    padding: 0 2px;
}

/* ================= BOARD ================= */
.scanword-game .scanword-board-viewport {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    overflow: auto;
    padding: 12px;
    -webkit-overflow-scrolling: touch;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    background: var(--sw-board-bg, transparent);
    touch-action: pan-x pan-y;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    min-height: 0;
}

.scanword-game .scanword-board-viewport::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}
@media (hover: hover) and (pointer: fine) {
    .scanword-game .scanword-board-viewport { cursor: grab; }
}
.scanword-game .scanword-board-viewport.is-dragging,
.scanword-game .scanword-board-viewport.is-dragging * { cursor: grabbing !important; }

.scanword-game .scanword-board-zoom {
    margin: 0 auto;
    position: relative;
    transition: width .22s ease, height .22s ease;
    flex: 0 0 auto;
}

.scanword-game .scanword-board {
    position: absolute;
    top: 0;
    left: 0;
    display: inline-grid;
    gap: var(--sw-grid-line-width, 1.5px);
    background: var(--sw-grid-line-color, #334155);
    border: var(--sw-grid-outer-width, 1.5px) solid var(--sw-grid-outer-color, #334155);
    box-shadow: var(--sw-board-shadow, 0 1px 2px rgba(15,23,42,0.06), 0 8px 26px rgba(15,23,42,0.12));
    transform-origin: top left;
    transition: transform .22s ease;
    will-change: transform;
}

/* ================= ЯЧЕЙКИ ================= */
.scanword-game .cell {
    width: var(--sw-cell-size);
    height: var(--sw-cell-size);
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    transition: background .35s ease;
    border-radius: var(--sw-cell-radius, 0);
    overflow: hidden;
}
.scanword-game .cell.empty { background: var(--sw-empty-cell-bg); }

.scanword-game .cell.letter {
    background: var(--sw-cell-bg-override, var(--sw-cell-bg));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--sw-letter-fs, 36px);
    font-weight: var(--sw-letter-fw, 700);
    font-family: var(--sw-letter-font, Georgia, serif);
    color: #0f172a;
    position: relative;
    transition: background .15s, transform .12s ease;
}
@media (hover: hover) and (pointer: fine) {
    .scanword-game .cell.letter:hover {
        background: var(--sw-cell-bg-override, var(--sw-cell-hover-bg));
        transform: scale(var(--sw-cell-hover-scale, 1.02));
    }
}

.scanword-game .cell.letter.sel { background: var(--sw-sel-bg, #c7ddfb); }
.scanword-game .cell.letter.active {
    background: var(--sw-active-bg, #a3c4f7);
    box-shadow: inset 0 0 0 var(--sw-active-ring-width, 3px) var(--sw-active-ring, #2563eb);
}
.scanword-game .cell.letter.filled-manual { color: var(--sw-letter-color-correct, #2563eb); }
.scanword-game .cell.letter.filled-wrong  { color: var(--sw-letter-color-wrong, #dc2626); }
.scanword-game .cell.letter.filled-hint   { color: var(--sw-letter-color-hint, #16a34a); }

.scanword-game .arrow-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}
.scanword-game .arrow-svg path:first-child {
    stroke: var(--sw-arrow-color, #dc2626);
}
.scanword-game .arrow-svg path:last-child {
    fill: var(--sw-arrow-color, #dc2626);
}
.scanword-game .letter-txt {
    position: relative;
    z-index: 1;
    line-height: 1;
}

.scanword-game .cell.clue {
    background: var(--sw-clue-bg, #fff);
    padding: var(--sw-clue-padding, 4px) calc(var(--sw-clue-padding, 4px) + 1px);
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    font-family: var(--sw-clue-font, -apple-system, "Segoe UI", Roboto, Arial, sans-serif);
    font-size: var(--sw-clue-fs, 13px);
    font-weight: var(--sw-clue-fw, 500);
    line-height: var(--sw-clue-lh, 1.12);
    letter-spacing: -0.01em;
    color: var(--sw-clue-color, #000000);
    text-shadow: 0 1px 0 rgba(255, 255, 255, .35);
    text-align: center;
    overflow-wrap: anywhere;
    word-break: normal;
    hyphens: auto;
    -webkit-hyphens: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: geometricPrecision;
    transition: background .15s;
}
.scanword-game .cell.clue .scanword-clue-txt {
    position: relative;
    z-index: 1;
    width: 100%;
    text-align: center;
}
.scanword-game .cell.clue.clue-image {
    padding: 2px;
    cursor: zoom-in;
}
@media (hover: hover) and (pointer: fine) {
    .scanword-game .cell.clue.clue-image:hover { background: #f1f5f9; }
}
.scanword-game .cell.clue .scanword-clue-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
    background: #fff;
}

.scanword-game .image-block {
    position: relative;
    overflow: hidden;
    background: #f0f0f0;
    border-radius: var(--sw-cell-radius, 4px);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
    z-index: 3;
    cursor: default;
    width: auto;
    height: auto;
}
.scanword-game .image-block.image-block--text {
    background: var(--sw-clue-bg, #fff);
}
.scanword-game.is-hint-mode .image-block {
    cursor: crosshair;
    box-shadow: inset 0 0 0 3px #f59e0b, 0 0 0 4px rgba(245, 158, 11, 0.2);
    animation: swPulseBlock 1.4s ease-in-out infinite;
}
@keyframes swPulseBlock {
    0%, 100% { box-shadow: inset 0 0 0 3px #f59e0b, 0 0 0 4px rgba(245, 158, 11, 0.2); }
    50%      { box-shadow: inset 0 0 0 4px #fbbf24, 0 0 0 8px rgba(245, 158, 11, 0.15); }
}
.scanword-game .image-block img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
    border-radius: var(--sw-cell-radius, 4px);
}
.scanword-game .image-block .block-text {
    position: absolute;
    inset: 0;
    padding: 8%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: var(--sw-clue-font, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: var(--sw-clue-color, #000);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
    overflow: auto;
    overflow-wrap: anywhere;
    word-break: normal;
    hyphens: auto;
    -webkit-hyphens: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.scanword-game .image-block .block-text::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.scanword-game.is-hint-mode .cell.clue {
    cursor: crosshair;
    animation: swPulseClue 1.4s ease-in-out infinite;
}
.scanword-game.is-hint-mode .cell.letter { cursor: crosshair; }
@keyframes swPulseClue {
    0%, 100% { box-shadow: inset 0 0 0 2px rgba(245, 158, 11, 0.35); }
    50%      { box-shadow: inset 0 0 0 3px rgba(245, 158, 11, 0.95); }
}

@keyframes swFlash {
    0%, 100% { box-shadow: inset 0 0 0 3px var(--sw-active-ring, #2563eb); }
    50%      { box-shadow: inset 0 0 0 3px rgba(37, 99, 235, .25); }
}
.scanword-game .cell.flash,
.scanword-game .image-block.flash {
    animation: swFlash 0.55s ease-in-out 3;
}

/* ================= БАННЕР В ПОЛЕ ================= */
.scanword-game .grid-ad-block {
    position: relative;
    overflow: hidden;
    background: #ffffff;
    border-radius: var(--sw-cell-radius, 4px);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
    z-index: 3;
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}
.scanword-game .grid-ad-block--image {
    cursor: pointer;
}
.scanword-game .grid-ad-block .grid-ad-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    line-height: 0;
}
.scanword-game .grid-ad-block img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    border-radius: var(--sw-cell-radius, 4px);
}
.scanword-game .grid-ad-block--code {
    padding: 4px;
    background: #fff;
    cursor: auto;
}
.scanword-game .grid-ad-block--code > * {
    max-width: 100% !important;
    max-height: 100% !important;
    box-sizing: border-box !important;
}
.scanword-game .grid-ad-block--code iframe,
.scanword-game .grid-ad-block--code img,
.scanword-game .grid-ad-block--code ins,
.scanword-game .grid-ad-block--code video,
.scanword-game .grid-ad-block--code object,
.scanword-game .grid-ad-block--code embed {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

/* ================= ЭКРАННАЯ КЛАВИАТУРА ================= */
.scanword-game .scanword-keyboard {
    position: relative;
    z-index: 5;
    flex: 0 0 auto;
    padding: 6px 6px 8px;
    background: var(--sw-bar-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--sw-border);
    display: none;
    flex-direction: column;
    gap: 5px;
}
.scanword-game .scanword-keyboard.is-open {
    display: flex;
}
.scanword-game .scanword-keyboard-row {
    display: flex;
    gap: 4px;
    justify-content: center;
    width: 100%;
}
.scanword-game .scanword-key {
    flex: 1 1 0;
    min-width: 0;
    height: 44px;
    border-radius: 7px;
    border: 1px solid rgba(15, 23, 42, 0.09);
    background: #fff;
    color: var(--sw-text);
    font-family: inherit;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Быстрый отклик на нажатие: очень короткие transition */
    transition: background .04s ease-out, transform .04s ease-out, border-color .04s ease-out;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}
@media (hover: hover) and (pointer: fine) {
    .scanword-game .scanword-key:hover {
        background: #f1f5f9;
        border-color: rgba(15, 23, 42, 0.2);
    }
}
.scanword-game .scanword-key:active {
    transform: scale(.94);
    background: #e2e8f0;
}

.scanword-game .scanword-key-backspace {
    flex: 0 0 60px;
    min-width: 60px;
    font-size: 21px;
    font-weight: 500;
    color: #b45309;
    background: #fef3c7;
    border-color: #fcd34d;
    padding: 0;
}
@media (hover: hover) and (pointer: fine) {
    .scanword-game .scanword-key-backspace:hover {
        background: #fde68a;
        border-color: #f59e0b;
    }
}

/* ================= МОДАЛКА СПИСКА ВОПРОСОВ ================= */
.scanword-questions-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483620;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity .22s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.scanword-questions-overlay.show { opacity: 1; }
.scanword-questions-panel {
    width: 100%;
    max-width: 640px;
    max-height: 82vh;
    background: #ffffff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    transform: translateY(30px);
    transition: transform .22s ease;
    overflow: hidden;
    color: #1e293b;
}
.scanword-questions-overlay.show .scanword-questions-panel { transform: translateY(0); }
.scanword-questions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #e2e8f0;
    flex: 0 0 auto;
}
.scanword-questions-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}
.scanword-questions-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .12s, color .12s;
    font-family: inherit;
    flex: 0 0 auto;
}
.scanword-questions-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}
.scanword-questions-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
    overflow-y: auto;
    flex: 1 1 auto;
    scrollbar-width: thin;
}
.scanword-questions-list::-webkit-scrollbar { width: 8px; }
.scanword-questions-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.scanword-questions-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    cursor: pointer;
    transition: background .12s;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    color: inherit;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.3;
}
.scanword-questions-item:hover { background: #f8fafc; }
.scanword-questions-item:active { background: #f1f5f9; }
.scanword-questions-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    overflow: hidden;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid #e2e8f0;
    position: relative;
}
.scanword-questions-item-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 7px;
}
.scanword-questions-item-icon .scanword-qii-tag {
    position: absolute;
    bottom: 1px;
    right: 1px;
    background: rgba(15, 23, 42, .75);
    color: #fff;
    font-size: 8px;
    padding: 1px 3px;
    border-radius: 3px;
    line-height: 1;
}
.scanword-questions-item-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.scanword-questions-item-text {
    color: #0f172a;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    word-break: break-word;
}
.scanword-questions-item-text.is-picture {
    font-style: italic;
    color: #64748b;
}
.scanword-questions-item-meta {
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    gap: 8px;
    align-items: center;
}
.scanword-questions-item-status {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
}
.scanword-questions-item.solved .scanword-questions-item-status { color: #16a34a; }
.scanword-questions-item.solved .scanword-questions-item-text {
    color: #94a3b8;
    text-decoration: line-through;
    text-decoration-color: #cbd5e1;
}
.scanword-questions-empty {
    padding: 40px 20px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

@media (min-width: 720px) {
    .scanword-questions-overlay {
        align-items: center;
        padding: 24px;
    }
    .scanword-questions-panel {
        border-radius: 16px;
        max-height: 82vh;
    }
}

/* =================================================================
   ЛАЙТБОКС + РЕКЛАМА
   ================================================================= */
.scanword-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2147483640;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity .25s ease;
    cursor: zoom-out;
    padding: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.scanword-lightbox.show { opacity: 1; }

.scanword-lightbox-body {
    flex: 0 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
}
.scanword-lightbox-body img {
    max-width: 100%;
    max-height: 70vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    background: #fff;
    pointer-events: none;
    transform: scale(.94);
    transition: transform .25s ease;
    user-select: none;
    -webkit-user-drag: none;
}
.scanword-lightbox.show .scanword-lightbox-body img {
    transform: scale(1);
}
.scanword-lightbox:not(.is-side-ads) .scanword-lightbox-body img {
    max-width: var(--sw-lightbox-img-width, 100%);
}

.scanword-lightbox-ad {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    cursor: auto;
    padding: 0;
    margin: 0;
}

.scanword-lightbox-ad a.scanword-ad-link {
    display: block;
    width: 100%;
    max-width: 100%;
    text-decoration: none;
    line-height: 0;
    overflow: hidden;
}
.scanword-lightbox-ad img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
    -webkit-user-drag: none;
    transform: none;
    transition: none;
}

.scanword-lightbox-ad > * {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}
.scanword-lightbox-ad iframe,
.scanword-lightbox-ad ins,
.scanword-lightbox-ad video,
.scanword-lightbox-ad img,
.scanword-lightbox-ad object,
.scanword-lightbox-ad embed {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
}

.scanword-lightbox-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 23, 42, 0.55);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, transform .12s;
    padding: 0 0 2px 0;
    font-family: inherit;
    z-index: 10;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.scanword-lightbox-close:hover { background: rgba(15, 23, 42, 0.8); }
.scanword-lightbox-close:active { transform: scale(.92); }

.scanword-lightbox.is-side-ads {
    flex-direction: row;
    padding: 12px;
    gap: 8px;
}
.scanword-lightbox.is-side-ads:not(.has-side-ads) .scanword-lightbox-body {
    flex: 1 1 auto;
    max-width: 100%;
}

.scanword-lightbox.is-side-ads.has-side-ads {
    display: grid;
    grid-template-columns: 1fr var(--sw-lightbox-width, 60%) 1fr;
    grid-template-rows: 1fr;
    gap: 8px;
    padding: 12px;
    align-items: center;
    justify-items: stretch;
}

.scanword-lightbox.is-side-ads.has-side-ads .scanword-lightbox-ad-left {
    grid-column: 1;
}
.scanword-lightbox.is-side-ads.has-side-ads .scanword-lightbox-body {
    grid-column: 2;
    width: 100%;
    max-width: 100%;
    padding: 0;
}
.scanword-lightbox.is-side-ads.has-side-ads .scanword-lightbox-ad-right {
    grid-column: 3;
}

.scanword-lightbox.is-side-ads.has-side-ads .scanword-lightbox-ad-left,
.scanword-lightbox.is-side-ads.has-side-ads .scanword-lightbox-ad-right {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: auto;
    padding: 0;
    margin: 0;
}

.scanword-lightbox.is-side-ads.has-side-ads .scanword-lightbox-ad-left a.scanword-ad-link,
.scanword-lightbox.is-side-ads.has-side-ads .scanword-lightbox-ad-right a.scanword-ad-link {
    display: inline-block;
    width: auto;
    max-width: 100%;
    max-height: 100%;
    line-height: 0;
}
.scanword-lightbox.is-side-ads.has-side-ads .scanword-lightbox-ad-left img,
.scanword-lightbox.is-side-ads.has-side-ads .scanword-lightbox-ad-right img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    background: #fff;
    pointer-events: auto;
    cursor: pointer;
}

.scanword-lightbox.is-side-ads.has-side-ads .scanword-lightbox-ad-left > *,
.scanword-lightbox.is-side-ads.has-side-ads .scanword-lightbox-ad-right > * {
    max-width: 100% !important;
    max-height: 100% !important;
    box-sizing: border-box !important;
}

@media (max-width: 720px) {
    .scanword-lightbox { gap: 4px; }
    .scanword-lightbox-body { padding: 0 8px; }
    .scanword-lightbox-body img { max-height: 65vh; }
    .scanword-lightbox-close { top: 8px; right: 8px; width: 40px; height: 40px; font-size: 26px; }
}

/* ================= HINT LABEL ================= */
.scanword-hint-label {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(.85);
    z-index: 2147483600;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    padding: 12px 24px;
    border-radius: 999px;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .02em;
    white-space: nowrap;
    text-align: center;
    box-shadow:
        0 10px 30px rgba(245, 158, 11, .45),
        0 0 0 4px rgba(255, 255, 255, .85);
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    opacity: 0;
    transition: opacity .3s ease, transform .3s ease;
    animation: swHintPulse 1.6s ease-in-out infinite;
    animation-play-state: paused;
    will-change: opacity, transform;
}
.scanword-hint-label.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    animation-play-state: running;
}
@keyframes swHintPulse {
    0%, 100% {
        box-shadow: 0 10px 30px rgba(245, 158, 11, .45), 0 0 0 4px rgba(255, 255, 255, .85);
    }
    50% {
        box-shadow: 0 10px 34px rgba(245, 158, 11, .65), 0 0 0 8px rgba(245, 158, 11, .18);
    }
}

/* ================= HIDDEN INPUT ================= */
.scanword-game .scanword-hidden-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: 0;
    opacity: 0;
    border: none;
    outline: none;
    background: transparent;
    color: transparent;
    font-size: 16px;
    z-index: 1;
    pointer-events: none;
    caret-color: transparent;
}

/* ================= TOAST ================= */
.scanword-game .scanword-toast {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(.9);
    background: rgba(15, 23, 42, .9);
    color: #fff;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s ease, transform .2s ease;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    max-width: 90%;
    text-align: center;
}
.scanword-game .scanword-toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ================= LOADING ================= */
.scanword-game .scanword-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    background: var(--sw-theme-bg);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .35s ease, visibility .35s ease, background .35s ease;
}
.scanword-game .scanword-loading-overlay.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
.scanword-game .scanword-loading-spinner {
    position: relative;
    width: 84px;
    height: 84px;
    flex: 0 0 auto;
}
.scanword-game .scanword-spinner-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: #2563eb;
    border-right-color: rgba(37, 99, 235, .25);
    animation: swSpinRing 1.05s cubic-bezier(.55, .15, .45, .85) infinite;
}
.scanword-game .scanword-spinner-ring:nth-child(2) {
    inset: 11px;
    border-top-color: #f59e0b;
    border-right-color: rgba(245, 158, 11, .25);
    animation-duration: .85s;
    animation-direction: reverse;
}
.scanword-game .scanword-spinner-ring:nth-child(3) {
    inset: 22px;
    border-top-color: #16a34a;
    border-right-color: rgba(22, 163, 74, .25);
    animation-duration: 1.35s;
}
@keyframes swSpinRing {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.scanword-game .scanword-loading-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--sw-text);
    letter-spacing: .01em;
    text-align: center;
    padding: 0 24px;
}
.scanword-game .scanword-loading-dots {
    display: flex;
    gap: 9px;
    margin-top: -6px;
}
.scanword-game .scanword-loading-dots span {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #2563eb;
    animation: swDotPulse 1.15s ease-in-out infinite;
}
.scanword-game .scanword-loading-dots span:nth-child(2) {
    animation-delay: .16s; background: #f59e0b;
}
.scanword-game .scanword-loading-dots span:nth-child(3) {
    animation-delay: .32s; background: #16a34a;
}
@keyframes swDotPulse {
    0%, 100% { transform: scale(.55); opacity: .3; }
    50%      { transform: scale(1.15); opacity: 1; }
}

/* ================= АДАПТИВ ================= */
@media (max-width: 900px) {
    .scanword-game {
        /* Размеры шрифтов вопросов и букв контролируются настройками */
    }
}

@media (max-width: 720px) {
    .scanword-game {
        --sw-cell-size: 72px;
        border-radius: 12px;
        min-height: 400px;
        height: var(--sw-module-height-mobile, var(--sw-module-height, 85vh));
    }

    .scanword-game .cell.clue {
        font-size: var(--sw-clue-fs-mobile, 12px);
        padding: var(--sw-clue-padding, 3px) calc(var(--sw-clue-padding, 3px) + 1px);
    }
    .scanword-game .image-block .block-text {
        font-size: var(--sw-clue-fs-mobile, 12px);
    }
    .scanword-game .cell.clue.clue-image { padding: 1px; }

    .scanword-game .scanword-header {
        padding: 5px 8px;
        gap: 3px;
    }
    .scanword-game .scanword-title-row { display: none; }

    .scanword-game .scanword-toolbar { gap: 6px; }
    .scanword-game .scanword-toolbar-stats { gap: 3px; }
    .scanword-game .scanword-chip {
        padding: 2px 6px;
        height: 24px;
        font-size: 11px;
    }
    .scanword-game .scanword-chip-icon { width: 12px; height: 12px; }

    .scanword-game .scanword-toolbar-actions {
        gap: var(--sw-tool-gap-mobile, 3px);
        padding: 6px 2px;
        margin: -6px -2px;
    }
    .scanword-game .scanword-tool-btn {
        width: var(--sw-tool-btn-size-mobile, 38px);
        height: var(--sw-tool-btn-size-mobile, 38px);
    }
    .scanword-game .scanword-tool-btn svg {
        width: var(--sw-tool-icon-size-mobile, 22px);
        height: var(--sw-tool-icon-size-mobile, 22px);
    }
    .scanword-game .scanword-tool-btn__img {
        width: var(--sw-tool-icon-size-mobile, 22px);
        height: var(--sw-tool-icon-size-mobile, 22px);
    }

    .scanword-toolbar-hint {
        width: max(12px, calc(var(--sw-scroll-hint-size, 18px) - 2px));
        height: max(12px, calc(var(--sw-scroll-hint-size, 18px) - 2px));
        font-size: max(9px, calc(var(--sw-scroll-hint-size, 18px) * 0.75));
        right: max(0px, calc(var(--sw-scroll-hint-offset, 2px) - 1px));
    }

    .scanword-game .scanword-tool-btn-theme::before { font-size: 16px; }
    .scanword-game .scanword-tool-badge {
        top: -4px; right: -4px;
        min-width: 16px; height: 16px;
        font-size: 9px; line-height: 16px;
    }
    .scanword-game .scanword-zoom-indicator { min-width: 28px; font-size: 10px; }

    .scanword-game .scanword-board-viewport { padding: 8px; }

    .scanword-game .scanword-keyboard {
        padding: 5px 5px 7px;
        gap: 4px;
    }
    .scanword-game .scanword-keyboard-row { gap: 3px; }
    .scanword-game .scanword-key {
        height: 40px;
        font-size: 19px;
        border-radius: 6px;
    }
    .scanword-game .scanword-key-backspace {
        flex: 0 0 52px;
        min-width: 52px;
        font-size: 20px;
    }

    .scanword-game .scanword-loading-spinner { width: 72px; height: 72px; }
    .scanword-game .scanword-loading-text { font-size: 14px; }
}

@media (max-width: 480px) {
    .scanword-game .scanword-chip {
        padding: 2px 5px;
        font-size: 10.5px;
    }
    .scanword-game .scanword-chip-value { font-size: 10.5px; }
}

@media (max-width: 400px) {
    .scanword-game {
        --sw-cell-size: 68px;
    }

    .scanword-game .scanword-tool-btn-theme::before { font-size: 15px; }
    .scanword-game .scanword-key {
        height: 38px;
        font-size: 18px;
    }
    .scanword-game .scanword-key-backspace { flex: 0 0 48px; min-width: 48px; font-size: 19px; }
}

/* ================= ДОСТУПНОСТЬ ================= */
@media (prefers-reduced-motion: reduce) {
    .scanword-game .scanword-spinner-ring { animation-duration: 2.4s; }
    .scanword-game .scanword-loading-dots span { animation-duration: 2s; }
    .scanword-game .scanword-board { transition: none; }
    .scanword-game .scanword-board-zoom { transition: none; }
    .scanword-hint-label { animation: none; }
    .scanword-game.is-hint-mode .cell.clue,
    .scanword-game.is-hint-mode .image-block { animation: none; }
    .scanword-lightbox,
    .scanword-lightbox-body img { transition: none; }
    .scanword-questions-overlay,
    .scanword-questions-panel { transition: none; }
    .scanword-game .cell.flash,
    .scanword-game .image-block.flash { animation: none; box-shadow: inset 0 0 0 3px var(--sw-active-ring, #2563eb); }
    .scanword-toolbar.sw-toolbar-scroll-right .scanword-toolbar-hint { animation: none; }
    .scanword-toolbar.sw-toolbar-scroll-right .scanword-toolbar-hint.has-img { animation: none; }
    .scanword-game .cell.letter:hover { transform: none; }
}

/* ================= ПЕЧАТЬ ================= */
@media print {
    .scanword-game .scanword-header,
    .scanword-game .scanword-keyboard,
    .scanword-game .scanword-loading-overlay,
    .scanword-game .scanword-toast { display: none !important; }
    .scanword-hint-label { display: none !important; }
    .scanword-lightbox { display: none !important; }
    .scanword-questions-overlay { display: none !important; }
    .scanword-toolbar-hint { display: none !important; }
    .scanword-game {
        height: auto !important;
        max-height: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }
    .scanword-game .scanword-board-viewport { overflow: visible !important; }
    .scanword-game .scanword-board { position: static !important; transform: none !important; }
}

/* =================================================================
   БОНУС-СЛОВО
   ================================================================= */

.scanword-game .cell.bonus-cell {
    position: relative;
}
.scanword-game .bonus-num {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 24px;
    height: 24px;
    padding: 0 5px;
    background: #ea580c;
    color: #ffffff;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    font-weight: 800;
    line-height: 21px;
    border-radius: 12px;
    border: 1.5px solid rgba(0, 0, 0, 0.22);
    text-align: center;
    z-index: 3;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.28);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
    letter-spacing: -0.01em;
}
@media (max-width: 720px) {
    .scanword-game .bonus-num {
        min-width: 20px;
        height: 20px;
        font-size: 12px;
        line-height: 17px;
        padding: 0 4px;
        border-radius: 10px;
        border-width: 1.5px;
        top: 1px;
        right: 1px;
        box-shadow: 0 1.5px 3px rgba(0, 0, 0, 0.3);
        text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
    }
}
@media (max-width: 400px) {
    .scanword-game .bonus-num {
        min-width: 18px;
        height: 18px;
        font-size: 11px;
        line-height: 15px;
        padding: 0 3px;
        border-radius: 9px;
    }
}

.scanword-game .scanword-tool-badge--bonus {
    background: #16a34a;
    color: #fff;
    font-size: 11px;
    padding: 0;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    top: -4px;
    right: -4px;
}
.scanword-game .scanword-tool-btn .scanword-tool-badge--bonus {
    z-index: 4;
}

.scanword-bonus-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483625;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity .22s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.scanword-bonus-overlay.show {
    opacity: 1;
}

.scanword-bonus-panel {
    width: 100%;
    max-width: 480px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #1e293b;
    transform: translateY(20px) scale(.98);
    transition: transform .22s ease;
    max-height: 88vh;
    overflow-y: auto;
}
.scanword-bonus-overlay.show .scanword-bonus-panel {
    transform: translateY(0) scale(1);
}

.scanword-bonus-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 16px 18px 12px;
    border-bottom: 1px solid #e2e8f0;
    flex: 0 0 auto;
    gap: 12px;
}
.scanword-bonus-header-content {
    flex: 1 1 auto;
    min-width: 0;
}
.scanword-bonus-header h2 {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    word-break: break-word;
}
.scanword-bonus-progress-text {
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
}
.scanword-bonus-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .12s, color .12s;
    font-family: inherit;
    flex: 0 0 auto;
}
.scanword-bonus-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.scanword-bonus-cells {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 26px 18px 22px;
    flex-wrap: wrap;
    flex: 0 0 auto;
}
.scanword-bonus-cell {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, border-color .2s, box-shadow .2s;
    flex: 0 0 auto;
}
.scanword-bonus-cell.is-revealed {
    background: #dcfce7;
    border-color: #16a34a;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.2);
}
.scanword-bonus-cell-num {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #f59e0b;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 16px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
    z-index: 2;
}
.scanword-bonus-cell-letter {
    font-size: 24px;
    font-weight: 700;
    color: #166534;
    font-family: "Georgia", serif;
    line-height: 1;
}

.scanword-bonus-description {
    padding: 0 18px 18px;
    font-size: 14px;
    line-height: 1.45;
    color: #334155;
    text-align: center;
    overflow-wrap: anywhere;
    flex: 0 0 auto;
    white-space: pre-wrap;
}

.scanword-bonus-ad {
    padding: 0 18px 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    flex: 0 0 auto;
    max-width: 100%;
}
.scanword-bonus-ad > * {
    max-width: 100%;
    box-sizing: border-box;
}
.scanword-bonus-ad a.scanword-ad-link {
    display: block;
    max-width: 100%;
    line-height: 0;
    text-decoration: none;
}
.scanword-bonus-ad img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    pointer-events: auto;
    user-select: none;
    -webkit-user-drag: none;
}
.scanword-bonus-ad iframe,
.scanword-bonus-ad ins,
.scanword-bonus-ad video,
.scanword-bonus-ad img,
.scanword-bonus-ad object,
.scanword-bonus-ad embed {
    display: block;
    max-width: 100%;
}

.scanword-bonus-solved-msg {
    margin: 0 18px 18px;
    padding: 10px 14px;
    background: #dcfce7;
    color: #166534;
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    flex: 0 0 auto;
}

@media (max-width: 480px) {
    .scanword-bonus-overlay { padding: 12px; }
    .scanword-bonus-cell { width: 38px; height: 38px; }
    .scanword-bonus-cell-letter { font-size: 20px; }
    .scanword-bonus-header h2 { font-size: 15px; }
    .scanword-bonus-cells { gap: 5px; padding: 22px 12px 18px; }
    .scanword-bonus-ad { padding: 0 12px 14px; }
}

/* =================================================================
   ДОПОЛНЕНИЯ ДЛЯ ПЕЧАТИ
   ================================================================= */
@media print {
    .scanword-game .scanword-board-zoom {
        width: auto !important;
        height: auto !important;
        margin: 0 !important;
    }
    .scanword-game .scanword-board {
        border-width: var(--sw-grid-outer-width, 1px) !important;
        box-shadow: none !important;
    }
}