/* Локальные правила не выходят за DOM-границы модуля. */
@scope (.hex-module-scope) {
/* ============================================================
   HEX — Уничтожение блоков
   ============================================================ */

.hex-app {
    max-width: 480px;
    margin: 0 auto;
    padding: 0;
    position: relative;
}

/* ===== SCREENS ===== */
.hex-screen {
    display: flex;
    flex-direction: column;
}
.hex-hidden { display: none !important; }

/* ===== TOOLBAR ===== */
.hex-toolbar {
    margin-bottom: 16px;
}
.hex-toolbar .tool-toolbar-heading {
    font-size: clamp(1rem, 2.2vw, 1.35rem);
}
.hex-toolbar-back {
    display: none;
}
.hex-app:has(#hexGameScreen:not(.hex-hidden)) ~ .hex-toolbar .hex-toolbar-back,
.tool-wrap:has(#hexGameScreen:not(.hex-hidden)) .hex-toolbar-back {
    display: inline-flex;
}

/* ===== EDITOR CONTROLS ===== */
.hex-editor-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 1rem 1.25rem;
}

.hex-dim-row { display: flex; gap: 10px; }

.hex-dim-group {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg);
    border: 1px solid var(--line);
    border-left: 3px solid var(--brass);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    min-width: 0;
    gap: 8px;
}

.hex-dim-group label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--ink-dim);
    white-space: nowrap;
}

.hex-stepper {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.hex-stepper button {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.hex-stepper button:hover {
    background: var(--brass);
    color: var(--bg);
    border-color: var(--brass);
}
.hex-stepper span {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 700;
    min-width: 22px;
    text-align: center;
    color: var(--ink);
}

.hex-goal-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-left: 3px solid var(--brass);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
}

.hex-goal-row label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--ink-dim);
    white-space: nowrap;
    flex-shrink: 0;
}

.hex-goal-row input {
    width: 80px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 700;
    padding: 6px 10px;
    text-align: center;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.hex-goal-row input:focus {
    border-color: var(--brass);
    box-shadow: 0 0 0 2px rgba(198, 162, 89, 0.2);
}

/* ===== BOARD ===== */
.hex-board-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    padding: 20px 0;
    overflow: hidden;
}
.hex-board {
    position: relative;
    margin: 0 auto;
}

/* Ячейка — контрастный фон + чёткая латунная обводка */
.hex-cell {
    position: absolute;
    width: var(--hw);
    height: var(--hh);
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: linear-gradient(160deg,
        var(--panel-raised) 0%,
        var(--panel-alt) 50%,
        var(--panel) 100%);
    box-shadow:
        inset 0 0 0 2px var(--line-brass),
        inset 0 -8px 10px rgba(0, 0, 0, 0.45),
        inset 0 3px 6px rgba(255, 255, 255, 0.06),
        0 4px 6px rgba(0, 0, 0, 0.35);
    transition: filter 0.15s ease;
    cursor: pointer;
    z-index: 1;
}
:root[data-theme="light"] .hex-cell {
    background: linear-gradient(160deg,
        #ffffff 0%,
        #f3eedf 50%,
        #e4dece 100%);
    box-shadow:
        inset 0 0 0 2px rgba(135, 100, 35, 0.35),
        inset 0 -8px 10px rgba(80, 60, 20, 0.15),
        inset 0 3px 6px rgba(255, 255, 255, 0.6),
        0 4px 6px rgba(80, 60, 20, 0.12);
}
.hex-cell:hover { filter: brightness(1.12); }
.hex-cell.drop-hover { filter: brightness(1.3); }

.hex-cell.ai-target {
    filter: brightness(1.2);
    box-shadow:
        0 0 30px rgba(198, 162, 89, 0.6),
        inset 0 0 0 2px var(--brass),
        inset 0 0 30px rgba(198, 162, 89, 0.3);
    animation: hexAiTargetPulse 1s ease-in-out infinite;
}
@keyframes hexAiTargetPulse {
    0%, 100% {
        filter: brightness(1.2);
        box-shadow:
            0 0 30px rgba(198, 162, 89, 0.6),
            inset 0 0 0 2px var(--brass),
            inset 0 0 30px rgba(198, 162, 89, 0.3);
    }
    50% {
        filter: brightness(1.4);
        box-shadow:
            0 0 50px rgba(198, 162, 89, 0.9),
            inset 0 0 0 2px var(--brass-light),
            inset 0 0 50px rgba(198, 162, 89, 0.5);
    }
}
}

/* Заблокированная ячейка */
.hex-cell.locked {
    background: linear-gradient(160deg, #3a3a3a 0%, #1f1f1f 55%, #101010 100%);
    filter: saturate(0.4);
    cursor: pointer;
    box-shadow:
        inset 0 0 0 2px rgba(176, 80, 31, 0.5),
        inset 0 -6px 8px rgba(0, 0, 0, 0.6),
        0 3px 3px rgba(0, 0, 0, 0.5);
}
:root[data-theme="light"] .hex-cell.locked {
    background: linear-gradient(160deg, #b8b0a0 0%, #8a8272 55%, #6a6355 100%);
    box-shadow:
        inset 0 0 0 2px rgba(153, 71, 29, 0.55),
        inset 0 -6px 8px rgba(0, 0, 0, 0.3),
        0 3px 3px rgba(80, 60, 20, 0.25);
}
.hex-cell.locked .hex-lock-info {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    filter: none;
    pointer-events: none;
    z-index: 2;
}
.hex-cell.locked .hex-lock-info .hex-lock-icon {
    font-size: 22px;
    line-height: 1;
}
.hex-cell.locked .hex-lock-info .hex-lock-score {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 800;
    color: var(--brass-light);
    background: rgba(0, 0, 0, 0.7);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-brass);
}

/* ===== TILES ===== */
.hex-tile {
    cursor: grab;
    touch-action: none;
    position: absolute;
    width: var(--hw);
    height: var(--hh);
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100 !important;
    transition: transform 0.12s ease;
    pointer-events: none;
    overflow: visible;
}

.hex-tile .hex-tile-layers {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.hex-tile .hex-tile-layer {
    position: absolute;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.hex-tile .hex-tile-layer svg {
    display: block;
    width: 100%;
    height: 100%;
}

.hex-tile.dragging {
    z-index: 9999 !important;
    transform: scale(1.08);
    cursor: grabbing;
    opacity: 0.95;
    pointer-events: none;
}
.hex-tile.pop { animation: hexPop 0.28s ease; }
@keyframes hexPop {
    0% { transform: scale(0.4); }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); }
}
.hex-tile.merge-burst { animation: hexBurst 0.35s ease; }
@keyframes hexBurst {
    0% { transform: scale(1); }
    40% { transform: scale(1.35); filter: brightness(1.5); }
    100% { transform: scale(1); }
}
.hex-tile.destroy-burst { animation: hexDestroyBurst 0.4s ease forwards; }
@keyframes hexDestroyBurst {
    0% { transform: scale(1); opacity: 1; }
    60% { transform: scale(1.4); opacity: 0.7; }
    100% { transform: scale(0.2); opacity: 0; }
}
.hex-tile.reveal { animation: hexReveal 0.25s ease; }
@keyframes hexReveal {
    0% { transform: scale(0.75); filter: brightness(1.6); }
    100% { transform: scale(1); }
}

.hex-tile.stack-locked {
    filter: brightness(0.7) saturate(0.8);
    opacity: 0.9;
    cursor: default !important;
    pointer-events: none !important;
    position: relative;
}

.hex-stack-lock-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 25;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.88);
    padding: 5px 9px 4px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--brass);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.9), 0 0 15px rgba(198, 162, 89, 0.3);
    min-width: 32px;
}
.hex-stack-lock-indicator .hex-lock-icon {
    font-size: 20px;
    line-height: 1.2;
}
.hex-stack-lock-indicator .hex-lock-score {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 800;
    color: var(--brass-light);
    background: rgba(0, 0, 0, 0.6);
    padding: 0 6px;
    border-radius: var(--radius-sm);
    margin-top: -2px;
}

/* ===== HINT — фиксированная высота, чтобы не дёргалось ===== */
.hex-hint {
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--ink-dim);
    padding: 10px 14px;
    min-height: 84px;
    height: 84px;
    box-sizing: border-box;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 3px solid var(--brass);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    overflow: hidden;
    transition: background 0.2s ease;
}

.hex-hint .hex-hint-text {
    text-align: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    line-height: 1.35;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.hex-hint .strategy-line {
    font-weight: 800;
    font-size: 13px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.hex-hint .strategy-merge { color: var(--status-ready); }
.hex-hint .strategy-onecell { color: var(--status-testing); }
.hex-hint .strategy-forced { color: var(--status-dev); }
.hex-hint .strategy-deadzone { color: var(--rust-light); }
.hex-hint .strategy-default { color: var(--ink); }

.hex-hint .details-line {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.hex-hint .hex-hint-stats {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--ink-faint);
    background: var(--bg);
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 6px;
    height: 20px;
    flex-shrink: 0;
}

.hex-hint .hex-stat-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.hex-hint .hex-stat-dot.good { background: var(--status-ready); }
.hex-hint .hex-stat-dot.medium { background: var(--brass); }
.hex-hint .hex-stat-dot.bad { background: var(--rust); }
.hex-hint .hex-stat-dot.unknown { background: var(--ink-faint); }

.hex-hint.hex-editor-hint {
    min-height: 32px;
    height: 32px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 6px 12px;
    background: var(--bg);
    border-color: var(--line-soft);
    border-left-width: 3px;
    text-align: center;
}

/* ===== AI ROBOT ===== */
.hex-ai-robot {
    position: absolute;
    z-index: 200;
    pointer-events: none;
    animation: hexAiRobotDance 0.8s ease-in-out infinite, hexAiRobotGlow 1.2s ease-in-out infinite;
    line-height: 1;
}

@keyframes hexAiRobotDance {
    0%, 100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
    25% { transform: translate(-50%, -60%) scale(1.1) rotate(-5deg); }
    50% { transform: translate(-50%, -40%) scale(1.15) rotate(5deg); }
    75% { transform: translate(-50%, -60%) scale(1.1) rotate(-3deg); }
}

@keyframes hexAiRobotGlow {
    0%, 100% {
        filter: drop-shadow(0 0 20px rgba(198, 162, 89, 0.8)) drop-shadow(0 0 40px rgba(198, 162, 89, 0.4));
    }
    50% {
        filter: drop-shadow(0 0 40px rgba(198, 162, 89, 1)) drop-shadow(0 0 80px rgba(198, 162, 89, 0.6));
    }
}

/* ===== AI BADGE ===== */
.hex-ai-badge {
    position: absolute;
    top: -32px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 800;
    color: var(--bg);
    background: linear-gradient(180deg, var(--brass-light), var(--brass));
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--brass);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6), 0 0 20px rgba(198, 162, 89, 0.3);
    white-space: nowrap;
    z-index: 100;
    display: none;
    animation: hexAiTagPulse 1.3s ease-in-out infinite;
    line-height: 1;
    pointer-events: none;
    min-width: 28px;
    text-align: center;
}

.hex-ai-badge.has-chain {
    background: linear-gradient(180deg, var(--rust-light), var(--rust));
    border-color: var(--rust);
    animation: hexAiChainTagPulse 0.8s ease-in-out infinite;
}

@keyframes hexAiTagPulse {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6), 0 0 20px rgba(198, 162, 89, 0.3);
    }
    50% {
        transform: translateX(-50%) translateY(-3px);
        box-shadow: 0 2px 15px rgba(0, 0, 0, 0.8), 0 0 30px rgba(198, 162, 89, 0.5);
    }
}

@keyframes hexAiChainTagPulse {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6), 0 0 20px rgba(176, 80, 31, 0.3);
    }
    50% {
        transform: translateX(-50%) translateY(-3px);
        box-shadow: 0 2px 15px rgba(0, 0, 0, 0.8), 0 0 30px rgba(176, 80, 31, 0.5);
    }
}

.hex-tray-slot.ai-pick .hex-ai-badge { display: block !important; }
.hex-tray-slot.ai-pick .hex-tray-tile {
    filter: drop-shadow(0 0 12px rgba(198, 162, 89, 0.5));
}

/* ===== EDITOR CELL ===== */
.hex-ed-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 700;
    color: var(--ink-faint);
    text-align: center;
    cursor: pointer !important;
    pointer-events: auto !important;
    z-index: 2;
}
.hex-ed-cell.st-hidden {
    background: repeating-linear-gradient(135deg, var(--panel-alt), var(--panel-alt) 6px, var(--panel) 6px, var(--panel) 12px);
    opacity: 0.55;
    color: var(--ink-faint);
}
.hex-ed-cell.st-locked {
    background: linear-gradient(160deg, var(--brass-light), var(--brass) 60%, var(--brass-dim));
    color: var(--bg);
}
.hex-ed-cell .hex-ed-lock-score {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 800;
    margin-top: 2px;
}

/* ===== EDITOR FOOTER ===== */
.hex-editor-footer {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 4px;
    margin-top: auto;
}
#hexCreateFieldBtn {
    width: 100%;
    padding: 14px 18px;
    font-size: 0.95rem;
    min-height: 48px;
}

/* ===== PROGRESS ROW — единая высота 44px для полосы и сундука ===== */
.hex-progress-row {
    display: flex;
    align-items: stretch;
    gap: 10px;
    height: 44px;
}

.hex-progress-track {
    flex: 1;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 1px solid var(--line);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
}
:root[data-theme="light"] .hex-progress-track {
    box-shadow: inset 0 2px 6px rgba(80, 60, 20, 0.15);
}

.hex-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(180deg,
        var(--brass-light) 0%,
        var(--brass) 50%,
        var(--brass-dim) 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        0 0 12px rgba(198, 162, 89, 0.35);
    transition: width 0.45s cubic-bezier(0.4, 1.4, 0.6, 1);
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.hex-progress-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--ink);
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.9),
        0 0 6px rgba(0, 0, 0, 0.6);
    letter-spacing: 1px;
}

/* Сундук — та же высота 44px, аккуратная пилюля */
.hex-chest {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 14px 0 10px;
    border-radius: var(--radius-sm);
    background: var(--panel);
    border: 1px solid var(--line-brass);
    border-top: 2px solid var(--brass);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    box-sizing: border-box;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.hex-chest:hover {
    border-color: var(--brass);
    background: var(--panel-raised);
    box-shadow: 0 0 15px rgba(198, 162, 89, 0.35);
    transform: translateY(-1px);
}
.hex-chest:active { transform: translateY(0) scale(0.98); }
.hex-chest span {
    font-size: 22px;
    line-height: 1;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.6));
}
.hex-chest b {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 800;
    color: var(--brass);
    letter-spacing: 0.5px;
    line-height: 1;
}

/* ===== TRAY ===== */
#hexTray {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    padding: 6px 0;
    min-height: 70px;
}

.hex-tray-slot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    width: var(--hw);
    height: var(--hh);
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 2px dashed var(--line);
    transition: all 0.25s ease;
    overflow: visible;
}

.hex-tray-slot:hover {
    border-color: var(--brass);
    background: var(--panel);
}

.hex-tray-slot.has-stack {
    background: var(--panel);
    border-style: solid;
    border-color: var(--line-brass);
}

.hex-tray-slot.active-edit {
    border-color: var(--brass);
    box-shadow: 0 0 30px rgba(198, 162, 89, 0.2), inset 0 0 30px rgba(198, 162, 89, 0.08);
}

.hex-tray-slot.empty .hex-empty-plus {
    position: absolute;
    font-family: var(--font-display);
    font-size: 32px;
    color: var(--ink-faint);
    z-index: 2;
    pointer-events: none;
    transition: all 0.3s ease;
}
.hex-tray-slot.empty:hover .hex-empty-plus {
    color: var(--brass);
    transform: scale(1.1);
}

.hex-tray-slot .hex-tray-tile {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
    font-weight: 800;
    color: var(--ink);
    overflow: visible;
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    pointer-events: auto;
    z-index: 2;
}
.hex-tray-slot .hex-tray-tile .hex-tile-layers {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: visible;
}
.hex-tray-slot .hex-tray-tile .hex-tile-layer {
    position: absolute;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.hex-tray-slot .hex-tray-tile .hex-tile-layer svg {
    display: block;
    width: 100%;
    height: 100%;
}
.hex-tray-slot.dragging-out .hex-tray-tile { visibility: hidden; }

/* ===== GAME BUTTONS ===== */
.hex-button-container {
    display: flex;
    gap: 8px;
    align-items: stretch;
    min-height: 50px;
    flex-wrap: nowrap;
}

#hexStartTurnBtn {
    flex: 1 1 auto;
    min-width: 0;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
}
#hexStartTurnBtn:hover:not(:disabled) {
    border-color: var(--brass);
    background: var(--panel-raised);
    color: var(--brass);
}
#hexStartTurnBtn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
#hexStartTurnBtn.ready {
    border-color: var(--status-ready);
    color: var(--status-ready);
    background: var(--status-ready-bg);
    animation: hexBtnReadyPulse 1.5s ease-in-out infinite;
}
@keyframes hexBtnReadyPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(134, 160, 106, 0); }
    50% { box-shadow: 0 0 20px 0 rgba(134, 160, 106, 0.5); }
}
#hexStartTurnBtn.stop-turn {
    border-color: var(--rust);
    color: var(--rust-light);
    background: rgba(176, 80, 31, 0.12);
    animation: hexStopTurnPulse 1.5s ease-in-out infinite;
}
#hexStartTurnBtn.stop-turn:disabled {
    animation: none;
}
@keyframes hexStopTurnPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(176, 80, 31, 0); }
    50% { box-shadow: 0 0 20px 0 rgba(176, 80, 31, 0.5); }
}

.hex-button-container .tool-btn {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    min-width: 48px;
}

#hexSimulationBtn.sim-stop {
    border-color: var(--rust);
    color: var(--rust-light);
    background: var(--panel-raised);
    animation: hexStopBtnPulse 1.5s ease-in-out infinite;
}
#hexSimulationBtn.sim-stop:hover {
    background: var(--rust);
    color: var(--ink);
    border-color: var(--rust);
}
@keyframes hexStopBtnPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(176, 80, 31, 0); }
    50% { box-shadow: 0 0 15px 0 rgba(176, 80, 31, 0.5); }
}

/* ===== WIN ===== */
#hexWin {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(3, 8, 5, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 500;
    flex-direction: column;
    gap: 12px;
    text-align: center;
    padding: 20px;
}
#hexWin.show { display: flex; }
#hexWin h2 {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--brass);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 0 20px rgba(198, 162, 89, 0.5);
}
#hexWin p {
    color: var(--ink-dim);
    margin: 0;
    font-size: 0.95rem;
}
#hexWin button {
    margin-top: 8px;
    padding: 12px 28px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--brass);
    background: var(--panel-raised);
    color: var(--brass);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.25s ease;
}
#hexWin button:hover {
    background: var(--brass);
    color: var(--bg);
}

/* ===== MODALS ===== */
.hex-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(3, 8, 5, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 16px;
    overflow-y: auto;
}
.hex-modal-overlay.show { display: flex; }

.hex-modal {
    width: 100%;
    max-width: 340px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-top: 2px solid var(--brass);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
}

.hex-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

.hex-modal-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 1;
    line-height: 1.25;
    word-break: normal;
    overflow-wrap: break-word;
}

.hex-modal-close {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--panel-alt);
    color: var(--ink-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.hex-modal-close:hover {
    background: var(--brass);
    color: var(--bg);
    border-color: var(--brass);
}

.hex-modal-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.hex-modal-footer {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    flex-shrink: 0;
}

.hex-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 11px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.hex-btn-ghost {
    background: var(--panel-alt);
    color: var(--ink-dim);
    border-color: var(--line);
}
.hex-btn-ghost:hover {
    border-color: var(--brass);
    color: var(--ink);
    background: var(--panel-raised);
}
.hex-btn-primary {
    background: var(--panel-raised);
    color: var(--brass-light);
    border-color: var(--brass);
}
.hex-btn-primary:hover {
    background: var(--brass);
    color: var(--bg);
}
.hex-btn-success {
    background: var(--panel-raised);
    color: var(--status-ready);
    border-color: var(--status-ready);
}
.hex-btn-success:hover {
    background: var(--status-ready);
    color: var(--bg);
}
.hex-btn-info {
    background: var(--panel-raised);
    color: var(--status-testing);
    border-color: var(--status-testing);
}
.hex-btn-info:hover {
    background: var(--status-testing);
    color: var(--bg);
}
.hex-btn-danger {
    background: var(--panel-raised);
    color: var(--rust-light);
    border-color: var(--rust);
}
.hex-btn-danger:hover {
    background: var(--rust);
    color: var(--ink);
}

/* ===== CELL TYPE OPTIONS ===== */
.hex-cell-type-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.hex-cell-type-options button {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--ink-dim);
    font-family: var(--font-body);
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}
.hex-cell-type-options button:hover {
    border-color: var(--brass);
    color: var(--ink);
}
.hex-cell-type-options button.selected {
    background: var(--panel-raised);
    border-color: var(--brass);
    color: var(--brass-light);
    font-weight: 600;
}

/* ===== UNLOCK ROW ===== */
#hexUnlockScoreRow,
.hex-unlock-row {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-left: 3px solid var(--brass);
    border-radius: var(--radius-sm);
}
#hexUnlockScoreRow label,
.hex-unlock-row label {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--ink-dim);
}
#hexUnlockScoreRow input,
.hex-unlock-row input {
    width: 80px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 700;
    padding: 6px 10px;
    text-align: center;
    outline: none;
}
#hexUnlockScoreRow input:focus,
.hex-unlock-row input:focus {
    border-color: var(--brass);
    box-shadow: 0 0 0 2px rgba(198, 162, 89, 0.2);
}

/* ===== EDIT ROW ===== */
.hex-edit-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.hex-edit-row label {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--ink-dim);
    min-width: 90px;
    flex-shrink: 0;
}
.hex-edit-row input {
    flex: 1;
    min-width: 0;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 700;
    padding: 8px 10px;
    text-align: center;
    outline: none;
}
.hex-edit-row input:focus {
    border-color: var(--brass);
    box-shadow: 0 0 0 2px rgba(198, 162, 89, 0.2);
}
.hex-edit-row-lock label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
    font-family: var(--font-body);
    font-size: 0.85rem;
    min-width: 0;
}
.hex-edit-row-lock input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brass);
    flex: 0 0 auto;
    padding: 0;
}
.hex-edit-row-top { margin-top: 6px; }

/* ===== CURRENT INFO ===== */
.hex-current-info {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--ink-dim);
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    text-align: center;
    letter-spacing: 0.5px;
    word-break: break-word;
}

/* ===== PRESETS — сетка ===== */
.hex-presets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
    gap: 6px;
}
.hex-goal-preset,
.hex-progress-preset {
    width: 100%;
    padding: 9px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--ink-dim);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}
.hex-goal-preset:hover,
.hex-progress-preset:hover {
    border-color: var(--brass);
    color: var(--ink);
    background: var(--panel-raised);
}
.hex-goal-preset.active {
    background: var(--brass);
    border-color: var(--brass);
    color: var(--bg);
    box-shadow: 0 0 12px rgba(198, 162, 89, 0.4);
}
.hex-progress-preset.active {
    background: var(--status-testing);
    border-color: var(--status-testing);
    color: var(--bg);
    box-shadow: 0 0 12px rgba(127, 163, 184, 0.4);
}

/* ===== COUNT BUTTONS — сетка 5 колонок ===== */
.hex-count-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    justify-content: center;
    width: 100%;
}
.hex-count-btn {
    width: 100%;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--ink-dim);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    padding: 0;
    line-height: 1;
    min-width: 0;
}
.hex-count-btn:hover {
    border-color: var(--brass);
    color: var(--ink);
    background: var(--panel-raised);
}
.hex-count-btn.active {
    background: var(--brass);
    border-color: var(--brass);
    color: var(--bg);
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(198, 162, 89, 0.4);
}
.hex-count-hint {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.6px;
    color: var(--ink-faint);
    text-align: center;
    text-transform: uppercase;
    line-height: 1.4;
}

/* ===== COLOR PALETTE — сетка 8 колонок ===== */
.hex-edit-color-palette {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
    justify-content: center;
    padding: 8px 0;
    width: 100%;
}
.hex-color-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.15), 0 2px 4px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s, box-shadow 0.15s;
    min-width: 0;
    position: relative;
}
.hex-color-swatch:hover { transform: scale(1.08); }
.hex-color-swatch.selected {
    box-shadow: 0 0 0 2px var(--brass), inset 0 0 0 2px rgba(255, 255, 255, 0.5), 0 0 12px rgba(198, 162, 89, 0.5);
    transform: scale(1.12);
}

/* ===== EDIT LAYERS ===== */
.hex-edit-layers {
    max-height: 140px;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 8px;
}
.hex-edit-layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin-bottom: 4px;
    background: var(--panel-alt);
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-soft);
    min-width: 0;
}
.hex-edit-layer-item:last-child { margin-bottom: 0; }
.hex-edit-layer-item .hex-swatch-sm {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2);
}
.hex-edit-layer-item .hex-layer-info {
    flex: 1;
    min-width: 0;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.4px;
    color: var(--ink-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.hex-edit-layer-item .hex-layer-remove {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid var(--rust);
    background: transparent;
    color: var(--rust-light);
    cursor: pointer;
    font-size: 11px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.hex-edit-layer-item .hex-layer-remove:hover {
    background: var(--rust);
    color: var(--ink);
}

.hex-builder-empty {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--ink-faint);
    text-align: center;
    padding: 10px;
}

/* ===== LOG MODAL ===== */
.hex-modal-log {
    max-width: min(520px, calc(100vw - 32px)) !important;
    max-height: calc(100vh - 32px);
}
.hex-log-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.hex-log-controls .hex-btn {
    flex: 0 0 auto;
    padding: 8px 12px;
    font-size: 0.62rem;
    white-space: nowrap;
}
.hex-log-format {
    flex: 1;
    min-width: 90px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    padding: 8px 10px;
    cursor: pointer;
}
.hex-log-stats {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--ink-dim);
    padding: 8px 0;
    border-bottom: 1px solid var(--line-soft);
    letter-spacing: 0.5px;
    word-break: break-word;
}
.hex-log-textarea {
    width: 100%;
    min-height: 220px;
    max-height: 360px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    line-height: 1.6;
    padding: 10px;
    resize: vertical;
    outline: none;
    white-space: pre;
    overflow: auto;
    box-sizing: border-box;
}
.hex-log-textarea:focus { border-color: var(--brass); }
.hex-log-autoscroll {
    display: flex;
    gap: 16px;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--ink-dim);
    letter-spacing: 0.5px;
    flex-wrap: wrap;
}
.hex-log-autoscroll label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.hex-log-autoscroll input[type="checkbox"] {
    accent-color: var(--brass);
    cursor: pointer;
}

/* ===== INSTRUCTION MODAL ===== */
.hex-modal-instruction {
    max-width: min(520px, calc(100vw - 32px)) !important;
    max-height: calc(100vh - 32px);
}
.hex-instruction-content {
    overflow-y: auto;
    padding-right: 6px;
    min-height: 0;
}
.hex-instruction-content::-webkit-scrollbar { width: 4px; }
.hex-instruction-content::-webkit-scrollbar-track { background: var(--bg); border-radius: 4px; }
.hex-instruction-content::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.hex-instruction-section {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line-soft);
}
.hex-instruction-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.hex-instruction-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--brass);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.hex-instruction-section p {
    font-size: 0.85rem;
    color: var(--ink-dim);
    line-height: 1.6;
    margin: 4px 0 0 0;
}
.hex-instruction-section p strong {
    color: var(--ink);
}
.hex-instruction-section ul {
    list-style: none;
    padding: 0;
    margin: 8px 0 0 0;
}
.hex-instruction-section ul li {
    font-size: 0.82rem;
    color: var(--ink-dim);
    padding: 5px 0 5px 20px;
    position: relative;
    line-height: 1.5;
}
.hex-instruction-section ul li::before {
    content: '▸';
    position: absolute;
    left: 2px;
    color: var(--brass);
}
.hex-instruction-section ul li strong {
    color: var(--ink);
}

.hex-shortcuts {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}
.hex-shortcut {
    font-size: 0.82rem;
    color: var(--ink-dim);
    padding: 6px 10px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-soft);
    line-height: 1.5;
}
.hex-shortcut kbd {
    display: inline-block;
    background: var(--panel-alt);
    padding: 1px 8px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--brass-light);
    border: 1px solid var(--line);
    margin-right: 4px;
}

/* ===== LOCKED CELL MODAL ===== */
.hex-modal-locked {
    max-width: min(360px, calc(100vw - 32px));
}
.hex-locked-note {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--ink-dim);
    text-align: center;
    padding: 8px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-soft);
    letter-spacing: 0.5px;
}
.hex-locked-note b {
    color: var(--brass);
    font-size: 0.85rem;
}
.hex-locked-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.hex-locked-actions .hex-btn {
    flex: 0 0 auto;
    width: 100%;
    padding: 12px 14px;
    font-size: 0.7rem;
}

/* ===== GOAL HINT — контрастный блок ===== */
.hex-goal-hint {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--ink-dim);
    text-align: center;
    padding: 10px 12px;
    background: var(--panel-alt);
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    border-left: 3px solid var(--brass);
    letter-spacing: 0.5px;
    line-height: 1.55;
}

/* ===== GROUP INFO ===== */
.hex-modal-group-info {
    max-width: min(340px, calc(100vw - 32px));
}
.hex-gi-body {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 10px;
    padding: 10px 4px;
    min-height: 160px;
}
.hex-gi-ruler {
    position: relative;
    width: 28px;
    align-self: flex-end;
}
.hex-gi-tick {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    transform: translateY(50%);
}
.hex-gi-tick span {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--ink-faint);
    min-width: 14px;
    text-align: right;
}
.hex-gi-tick i {
    flex: 1;
    height: 1px;
    background: var(--line);
    display: block;
}
.hex-gi-tick.hex-gi-threshold i { background: var(--rust); }
.hex-gi-tick.hex-gi-threshold span {
    color: var(--rust-light);
    font-weight: 800;
}
.hex-gi-stack {
    width: 64px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg);
    display: flex;
    flex-direction: column-reverse;
}
.hex-gi-layer {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 800;
    color: var(--ink);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.hex-gi-empty {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    opacity: 0.6;
    padding: 20px 10px;
    text-align: center;
    color: var(--ink-faint);
}
.hex-gi-legend {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--ink-faint);
    text-align: center;
    letter-spacing: 0.5px;
}

/* ===== COLOR CLASSES ===== */
.hex-t-gold { background: linear-gradient(160deg, #f5e870, #e4cd3f 55%, #c9b230); }
.hex-t-cyan { background: linear-gradient(160deg, #6ef0ef, #2be5e4 55%, #1fb8b7); }
.hex-t-blue { background: linear-gradient(160deg, #7aa5ff, #3b82fe 55%, #1a5fd4); }
.hex-t-green { background: linear-gradient(160deg, #b0fa80, #91f74d 55%, #6dd82a); }
.hex-t-red { background: linear-gradient(160deg, #f07070, #e53939 55%, #c42a2a); }
.hex-t-orange { background: linear-gradient(160deg, #ff9933, #ff6b00 55%, #e05500); }
.hex-t-purple { background: linear-gradient(160deg, #c080fd, #a548fb 55%, #8820e0); }
.hex-t-magenta { background: linear-gradient(160deg, #f080f8, #e73df6 55%, #cc20d8); }

.hex-border-gold { background: #b89a18; }
.hex-border-cyan { background: #1a9a99; }
.hex-border-blue { background: #1a5fd4; }
.hex-border-green { background: #55c020; }
.hex-border-red { background: #b82a2a; }
.hex-border-orange { background: #cc5500; }
.hex-border-purple { background: #7020b8; }
.hex-border-magenta { background: #b020b8; }

/* ===== ANIMATIONS ===== */
@keyframes hexGlowPulse {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}
.hex-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 130%;
    height: 130%;
    transform: translate(-50%, -50%);
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    pointer-events: none;
    z-index: -1;
    animation: hexGlowPulse 0.6s ease-out forwards;
}

@keyframes hexFloatScore {
    0% { transform: translateY(0) scale(0.5); opacity: 0; }
    30% { transform: translateY(-30px) scale(1.2); opacity: 1; }
    100% { transform: translateY(-70px) scale(1); opacity: 0; }
}
.hex-score-float {
    position: fixed;
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 900;
    color: var(--brass);
    text-shadow: 0 0 20px rgba(198, 162, 89, 0.6), 0 2px 10px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 10000;
    animation: hexFloatScore 1s ease-out forwards;
}

.hex-tile.destroy-burst::after {
    content: '💥';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 36px;
    z-index: 30;
    animation: hexDestroyEmoji 0.6s ease forwards;
}
@keyframes hexDestroyEmoji {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    40% { transform: translate(-50%, -50%) scale(1.5); opacity: 1; }
    100% { transform: translate(-50%, -100%) scale(1); opacity: 0; }
}
.hex-destroy-flash {
    pointer-events: none;
    z-index: 9998;
}

/* ===== NUMBER INPUT — прячем спиннеры ===== */
.hex-goal-row input[type="number"],
.hex-edit-row input[type="number"],
#hexUnlockScoreRow input[type="number"],
.hex-unlock-row input[type="number"] {
    -webkit-appearance: textfield;
    -moz-appearance: textfield;
    appearance: textfield;
}
.hex-goal-row input[type="number"]::-webkit-outer-spin-button,
.hex-goal-row input[type="number"]::-webkit-inner-spin-button,
.hex-edit-row input[type="number"]::-webkit-outer-spin-button,
.hex-edit-row input[type="number"]::-webkit-inner-spin-button,
#hexUnlockScoreRow input[type="number"]::-webkit-outer-spin-button,
#hexUnlockScoreRow input[type="number"]::-webkit-inner-spin-button,
.hex-unlock-row input[type="number"]::-webkit-outer-spin-button,
.hex-unlock-row input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
    .hex-hint {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .hex-editor-controls { padding: 0.75rem 1rem; gap: 8px; }
    .hex-dim-group { padding: 6px 10px; }
    .hex-dim-group label { font-size: 0.66rem; letter-spacing: 0.8px; }
    .hex-stepper button { width: 24px; height: 24px; font-size: 12px; }
    .hex-stepper span { font-size: 0.85rem; min-width: 18px; }
    .hex-goal-row { padding: 6px 10px; }
    .hex-goal-row label { font-size: 0.66rem; letter-spacing: 0.8px; }
    .hex-goal-row input { width: 64px; font-size: 0.85rem; padding: 5px 8px; }

    .hex-board-wrap { min-height: 220px; padding: 12px 0; }

    .hex-progress-row { height: 40px; gap: 8px; }
    .hex-progress-track { height: 40px; }
    .hex-progress-label { font-size: 0.8rem; }
    .hex-chest { height: 40px; padding: 0 10px 0 8px; gap: 6px; }
    .hex-chest span { font-size: 18px; }
    .hex-chest b { font-size: 0.9rem; }

    #hexTray { gap: 8px; min-height: 56px; }
    .hex-tray-slot { width: 72px !important; height: 72px !important; }
    .hex-tray-slot.empty .hex-empty-plus { font-size: 26px; }

    .hex-button-container { gap: 6px; min-height: 44px; }
    #hexStartTurnBtn { font-size: 0.66rem; padding: 10px 10px; min-height: 40px; }
    .hex-button-container .tool-btn { width: 40px; height: 40px; min-width: 40px; }

    .hex-modal { padding: 16px; max-width: calc(100vw - 24px); }
    .hex-modal-title { font-size: 0.95rem; }
    .hex-btn { font-size: 0.64rem; padding: 10px 8px; letter-spacing: 0.3px; }
    .hex-count-btn { height: 30px; font-size: 0.72rem; }

    .hex-ed-cell { font-size: 26px !important; }
    .hex-score-float { font-size: 20px; }
    .hex-tile.destroy-burst::after { font-size: 26px; }

    .hex-log-textarea { font-size: 0.62rem; min-height: 160px; max-height: 280px; }
    .hex-log-controls .hex-btn { font-size: 0.56rem; padding: 6px 8px; }

    .hex-instruction-title { font-size: 0.9rem; }
    .hex-instruction-section p { font-size: 0.8rem; }
    .hex-shortcut { font-size: 0.78rem; }
    .hex-shortcut kbd { font-size: 0.68rem; }
}

@media (max-width: 380px) {
    .hex-editor-controls { padding: 0.6rem 0.8rem; gap: 6px; }
    .hex-dim-group { padding: 5px 8px; }
    .hex-dim-group label { font-size: 0.6rem; }
    .hex-stepper button { width: 22px; height: 22px; font-size: 11px; }
    .hex-stepper span { font-size: 0.8rem; min-width: 16px; }
    .hex-goal-row { padding: 5px 8px; }
    .hex-goal-row label { font-size: 0.6rem; }
    .hex-goal-row input { width: 56px; font-size: 0.8rem; padding: 4px 6px; }

    #hexTray { gap: 6px; }
    .hex-tray-slot { width: 60px !important; height: 60px !important; }
    .hex-tray-slot.empty .hex-empty-plus { font-size: 22px; }

    .hex-ed-cell { font-size: 22px !important; }
    .hex-score-float { font-size: 16px; }

    .hex-modal { padding: 12px; }
    .hex-modal-title { font-size: 0.88rem; }
    .hex-btn { font-size: 0.6rem; padding: 9px 6px; letter-spacing: 0.2px; }
    .hex-count-btn { height: 28px; font-size: 0.68rem; }

    .hex-button-container .tool-btn { width: 36px; height: 36px; min-width: 36px; }
}

/* ===== PREFERS REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    .hex-cell,
    .hex-tile,
    .hex-progress
/* ===== PREFERS REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    .hex-cell,
    .hex-tile,
    .hex-progress-fill,
    .hex-ai-robot,
    .hex-ai-badge,
    .hex-tile.pop,
    .hex-tile.merge-burst,
    .hex-tile.destroy-burst,
    .hex-tile.reveal,
    .hex-score-float,
    .hex-tile.destroy-burst::after,
    #hexStartTurnBtn.ready,
    #hexStartTurnBtn.stop-turn,
    .hex-cell.ai-target {
        animation: none !important;
        transition: none !important;
    }
}
