/* Локальные правила не выходят за DOM-границы модуля. */
@scope (.trap-module-scope) {
/* ============================================================
   TRAP — Муравьи в ловушке
   Проектный CSS. Каркас .tool-* и .tool-wrap — в корневом styles.css.
   Здесь только специфика проекта (.game-* и .trap-*).
   Файл: /trap/trap.css
   ============================================================ */

/* ============================================================
   НАСТРОЙКИ РЕЖИМА
   ============================================================ */

.trap-control {
    display: grid;
    gap: 0.55rem;
}

.trap-control-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--ink-dim);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.trap-mode-switcher {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.25rem;
    padding: 0.25rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

.trap-mode-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-width: 0;
    min-height: 44px;
    padding: 0.6rem 0.65rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--ink-dim);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
    touch-action: manipulation;
}

.trap-mode-btn:hover {
    background: var(--panel-raised);
    color: var(--brass);
}

.trap-mode-btn.active {
    background: var(--panel-raised);
    border-color: var(--brass);
    color: var(--brass);
}

.trap-mode-btn:focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
}

.trap-mode-desc {
    margin-top: 0.8rem;
    padding: 0.75rem 0.85rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-left: 3px solid var(--brass);
    border-radius: var(--radius-sm);
    color: var(--ink-dim);
    font-size: 0.82rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.trap-mode-desc p { margin: 0 0 0.5rem; }
.trap-mode-desc p:last-child { margin-bottom: 0; }
.trap-mode-desc strong { color: var(--ink); font-weight: 600; }

/* ============================================================
   ИГРОВОЕ ПОЛЕ (game-*)
   ============================================================ */

.game-board-panel {
    padding: 1.5rem;
}

.game-board-wrap {
    display: flex;
    justify-content: center;
    overflow-x: auto;
    padding: 4px;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    max-width: 420px;
    width: 100%;
    background: var(--bg-soft);
    padding: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.4);
}

.game-cell {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    cursor: pointer;
    position: relative;
    min-height: 48px;
    perspective: 600px;
    user-select: none;
    background: transparent;
    border: none;
    padding: 0;
}

.game-cell:focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
}

.game-cell-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
    position: relative;
}

.game-cell-front,
.game-cell-back {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    border-radius: var(--radius-sm);
}

.game-cell-front {
    background: var(--panel-alt);
    transform: rotateY(0deg);
    border: 2px solid var(--line);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.game-cell-front img {
    width: 110%;
    height: 110%;
    object-fit: contain;
}

.game-cell-back {
    background: var(--panel-raised);
    transform: rotateY(180deg);
    border: 2px solid var(--line-brass);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.game-cell-back img {
    width: 65%;
    height: 65%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.game-cell.opened .game-cell-inner {
    transform: rotateY(180deg);
}

.game-cell:not(.opened) .game-cell-front:hover {
    border-color: var(--brass);
    transform: scale(1.03);
    box-shadow: 0 0 16px rgba(198, 162, 89, 0.2);
}

/* ============================================================
   AI-ПОДСКАЗКА — усиленная подсветка
   ============================================================ */

/* Внешняя пульсирующая рамка — видна всегда, поверх клетки */
.game-cell.ai-hint::after {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2px solid var(--rust);
    border-radius: calc(var(--radius-sm) + 4px);
    pointer-events: none;
    animation: gameAiRing 1.2s ease-in-out infinite;
    z-index: 10;
    box-shadow: 0 0 16px rgba(176, 80, 31, 0.6);
}

.mode-create .game-cell.ai-hint::after {
    border-color: var(--brass);
    box-shadow: 0 0 16px rgba(198, 162, 89, 0.6);
}

@keyframes gameAiRing {
    0%, 100% {
        opacity: 0.55;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.06);
    }
}

/* Свечение на самом фронте */
.mode-avoid .game-cell.ai-hint .game-cell-front {
    border-color: var(--rust) !important;
    border-width: 3px !important;
    box-shadow:
        0 0 0 1px var(--rust),
        0 0 24px rgba(176, 80, 31, 0.8) !important;
}

.mode-create .game-cell.ai-hint .game-cell-front {
    border-color: var(--brass) !important;
    border-width: 3px !important;
    box-shadow:
        0 0 0 1px var(--brass),
        0 0 24px rgba(198, 162, 89, 0.8) !important;
}

/* ============================================================
   ПОДСВЕТКА ЗАВЕРШЁННЫХ ЛИНИЙ
   ============================================================ */

.game-cell-back.line-horizontal {
    border-color: var(--brass) !important;
    box-shadow: 0 0 15px rgba(198, 162, 89, 0.5) !important;
}

.game-cell-back.line-vertical {
    border-color: var(--status-testing) !important;
    box-shadow: 0 0 15px rgba(127, 163, 184, 0.5) !important;
}

.game-cell-back.line-diagonal {
    border-color: var(--rust-light) !important;
    box-shadow: 0 0 15px rgba(217, 122, 69, 0.5) !important;
}

/* ============================================================
   СВЕТЛАЯ ТЕМА — специфика игрового поля
   ============================================================ */

:root[data-theme="light"] .game-board {
    background: var(--bg-soft);
    border-color: var(--line);
    box-shadow: inset 0 0 30px rgba(80, 60, 20, 0.08);
}

:root[data-theme="light"] .game-cell-front {
    background: var(--panel);
    border-color: var(--line);
}

:root[data-theme="light"] .game-cell-back {
    background: var(--panel-raised);
    border-color: var(--line-brass);
}

/* ============================================================
   АДАПТИВ ИГРОВОГО ПОЛЯ
   ============================================================ */

@media (max-width: 768px) {
    .game-cell {
        min-height: 40px;
    }

    .game-board {
        gap: 4px;
        padding: 8px;
    }

    .game-board-panel {
        padding: 1.25rem;
    }
}

@media (max-width: 576px) {
    .game-cell {
        min-height: 32px;
    }

    .game-board {
        gap: 3px;
        padding: 6px;
    }
}

@media (max-width: 400px) {
    .game-cell {
        min-height: 28px;
    }

    .game-board {
        gap: 2px;
        padding: 4px;
    }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .game-cell-inner,
    .game-cell-front,
    .game-cell-back {
        transition: none !important;
    }

    .game-cell.ai-hint::after {
        animation: none !important;
        opacity: 1;
    }

    .game-cell:not(.opened) .game-cell-front:hover {
        transform: none !important;
    }
}
}
