/* ================= Шрифт ================= */
@font-face {
    font-family: 'Baloo 2';
    src: url('../assets/fonts/Baloo2-Variable.ttf') format('truetype');
    font-weight: 400 800;
    font-display: swap;
}

/* ================= Дизайн-токены ================= */
:root {
    --bg-1: #f7e8cf;
    --bg-2: #eed7ae;
    --panel: #fffaf0;
    --panel-2: #fdf3df;
    --art-bg: #fcf2d5; /* фон сгенерированных иллюстраций */
    --ink: #4a3226;
    --ink-soft: #7a5c44;
    --accent: #e8863a;
    --accent-dark: #c96f2a;
    --green: #4f9d5d;
    --green-soft: #e2f2e5;
    --red: #d9534f;
    --amber: #e6a817;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 4px 14px rgba(74, 50, 38, 0.18);
    --shadow-sm: 0 2px 6px rgba(74, 50, 38, 0.14);
    --font: 'Baloo 2', 'Trebuchet MS', 'Comic Sans MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    overscroll-behavior: none;
    touch-action: manipulation;
}

body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background-color: var(--bg-1);
    background-image: url('../assets/tex-page-bg.webp');
    background-size: 480px;
    min-height: 100vh;
    overflow: hidden; /* экраны вписываются в вьюпорт целиком */
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

svg { vertical-align: middle; }
img { -webkit-user-drag: none; }

/* ================= Экран загрузки ================= */
#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: var(--bg-1) url('../assets/tex-page-bg.webp') 0 0 / 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    font-weight: 700;
    color: var(--ink-soft);
}
.loading-bar {
    width: min(60vw, 260px);
    height: 12px;
    border-radius: 999px;
    background: rgba(74, 50, 38, 0.12);
    overflow: hidden;
}
#loading-bar-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent-dark));
    transition: width 0.2s;
}

/* ================= Кнопки ================= */
.btn {
    font-family: inherit;
    font-weight: 700;
    font-size: 1rem;
    padding: 10px 20px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
    color: #fff;
    background: var(--ink-soft);
    min-height: 44px;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, var(--accent), var(--accent-dark)); }
.btn-secondary { background: #a98f77; }
.btn-accent { background: linear-gradient(180deg, #f0b429, #d99a12); }
.btn-danger { background: linear-gradient(180deg, #e05d59, #c74440); }
@media (hover: hover) {
    .btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow); filter: brightness(1.05); }
}
.btn:active:not(:disabled) { transform: translateY(1px); }

.icon-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 2.5px solid rgba(74, 50, 38, 0.2);
    background: var(--panel);
    color: var(--ink-soft);
    font-family: inherit;
    font-size: 1.35rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}
.icon-btn:active { transform: scale(0.92); }

/* ================= Шапка ================= */
.header {
    max-width: 1240px;
    margin: 0 auto;
    padding: 14px 16px 6px;
}
.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.header-btns { display: flex; align-items: center; gap: 8px; }
.game-title {
    margin: 0;
    font-size: clamp(1.3rem, 4vw, 2rem);
    letter-spacing: 0.3px;
    text-shadow: 0 2px 0 rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    gap: 10px;
}
.title-icon { display: inline-flex; filter: drop-shadow(0 2px 2px rgba(74, 50, 38, 0.25)); }

/* Индикатор опасности: сколько лису до норы */
.fox-danger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: 999px;
    background: var(--panel);
    border: 2.5px solid var(--green);
    font-weight: 700;
    font-size: 1rem;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.3s, background 0.3s;
}
.fox-danger .fox-danger-icon { display: inline-flex; }
.fox-danger .fox-danger-icon img { vertical-align: middle; }
.fox-danger b { font-size: 1.15em; }
.fox-danger.level-safe { border-color: var(--green); }
.fox-danger.level-warn { border-color: var(--amber); background: #fdf4dd; }
.fox-danger.level-danger {
    border-color: var(--red);
    background: #fbe9e8;
    animation: danger-pulse 1.2s ease-in-out infinite;
}
@keyframes danger-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(217, 83, 79, 0); }
    50% { box-shadow: 0 0 0 5px rgba(217, 83, 79, 0.3); }
}

/* Улики (3 в ряд) + «До норы» на одном уровне */
.info-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.clue-chips {
    display: grid;
    grid-template-columns: repeat(3, auto);
    justify-content: center;
    gap: 5px 6px;
}
.clue-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--panel);
    border: 2px solid rgba(74, 50, 38, 0.15);
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--ink-soft);
    box-shadow: var(--shadow-sm);
}
.clue-chip .chip-mark { font-size: 0.85em; min-width: 0.9em; text-align: center; }
.clue-chip { cursor: pointer; }

/* всплывающая подпись чипа улики */
#chip-tip {
    position: fixed;
    z-index: 250;
    background: var(--panel);
    border: 2px solid var(--accent);
    border-radius: 12px;
    padding: 7px 13px;
    font-weight: 700;
    font-size: 0.88rem;
    box-shadow: 0 6px 18px rgba(40, 25, 12, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    white-space: nowrap;
}
#chip-tip.visible { opacity: 1; }
.clue-chip.chip-yes { border-color: var(--green); background: var(--green-soft); color: #2f6b3b; }
.clue-chip.chip-no { border-color: #c9b8a4; background: #f1ece4; color: #9a8873; }
.clue-chip.chip-no svg,
.clue-chip.chip-no img { filter: grayscale(1); opacity: 0.55; }

/* ================= Нижняя навигация и экраны ================= */
.screen-tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: flex;
    gap: 8px;
    padding: 7px 10px calc(7px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 250, 240, 0.96);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 2px solid rgba(74, 50, 38, 0.12);
    box-shadow: 0 -4px 16px rgba(74, 50, 38, 0.1);
}
.tab {
    flex: 1;
    font-family: inherit;
    font-weight: 800;
    font-size: 1rem;
    padding: 9px 8px;
    border-radius: 14px;
    border: none;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.tab .tab-ico { display: inline-flex; }
.tab .tab-ico img { width: 26px; height: 26px; object-fit: contain; filter: grayscale(0.6) opacity(0.7); }
.tab.selected {
    background: #ffedd8;
    color: var(--ink);
    box-shadow: inset 0 0 0 2.5px var(--accent);
}
.tab.selected .tab-ico img { filter: none; }
.tab-badge {
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.tab.attention { animation: tab-pulse 1s ease-in-out infinite; }
@keyframes tab-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(232, 134, 58, 0); }
    50% { box-shadow: 0 0 0 5px rgba(232, 134, 58, 0.45); }
}

.screens { display: flex; justify-content: center; padding: 10px 8px 8px; }
.screen { display: flex; justify-content: center; align-items: flex-start; width: 100%; }
/* Режим ноутбука: поле и подозреваемые рядом */
.screens.split { gap: 22px; align-items: flex-start; }
.screens.split .screen { width: auto; }

/* Сетка подозреваемых 4×4 — целиком на экран */
.suspects-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    margin: 0 auto;
}

/* Поле-лужайка */
.board-wrap {
    position: relative;
    width: min(92vw, 780px);
    margin: 0 auto;
    border-radius: 26px;
    /* overflow visible — фигурки на верхних клетках выступают за поле, как в настолке */
    border: 5px solid rgba(125, 145, 90, 0.85);
    box-shadow: var(--shadow), inset 0 0 40px rgba(90, 110, 50, 0.14);
}
.board-grid {
    display: grid;
    /* minmax(0,1fr): контент клетки (нора, грибы) не должен растягивать ряд */
    grid-template-columns: repeat(16, minmax(0, 1fr));
    grid-template-rows: repeat(16, minmax(0, 1fr));
    width: 100%;
    aspect-ratio: 1;
    border-radius: 21px;
    overflow: hidden;
    /* верхний слой — арт поляны (если сгенерирован), нижний — травяная текстура */
    background:
        url('../assets/board-bg.webp?v=2') center / cover no-repeat,
        #dbe6ab url('../assets/tex-grass.webp') center / 560px repeat;
}
.board-cell {
    position: relative;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Тропа лиса (SVG-кривая) */
#trail-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Арты в клетках */
.cell-art { display: inline-flex; width: 100%; height: 100%; align-items: center; justify-content: center; pointer-events: none; position: relative; z-index: 2; }
.cell-art img { width: 78%; height: 78%; object-fit: contain; }
.cell-art.art-clue img { width: 92%; height: 92%; filter: drop-shadow(0 2px 2px rgba(74, 50, 38, 0.35)); }
.cell-art.art-burrow img { width: 120%; height: 120%; }
.cell-art.art-decor img { opacity: 0.55; width: 62%; height: 62%; }

/* отклик на тап по нарисованному: подпрыгивание */
@keyframes poke-jump {
    0% { transform: scale(1); }
    35% { transform: scale(1.28) rotate(-5deg); }
    65% { transform: scale(0.94) rotate(4deg); }
    100% { transform: scale(1); }
}
.poke { animation: poke-jump 0.45s ease; }

/* «сюда нельзя»: покачивание клетки */
@keyframes shake-no-anim {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    50% { transform: translateX(4px); }
    75% { transform: translateX(-3px); }
}
.board-cell.shake-no { animation: shake-no-anim 0.3s ease; }

.board-cell.reachable { cursor: pointer; z-index: 2; /* подсветка поверх тропы — кружки не срезаются */ }
.board-cell.reachable::after {
    content: '';
    position: absolute;
    inset: 8%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 205, 100, 0.85) 0%, rgba(255, 180, 80, 0.45) 55%, transparent 78%);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55);
    animation: cell-pulse 1.2s ease-in-out infinite;
    pointer-events: none;
    z-index: 3;
}
@keyframes cell-pulse {
    0%, 100% { transform: scale(0.92); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
}
@media (hover: hover) {
    .board-cell.reachable:hover::after { transform: scale(1.1); opacity: 1; animation: none; }
}

/* Фигурки сыщиков */
.pawn-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.pawn-figure {
    position: absolute;
    top: 0;
    left: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.3, 0.64, 1);
    filter: drop-shadow(0 3px 3px rgba(74, 50, 38, 0.35));
}
.pawn-figure img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.pawn-figure .pawn-base {
    position: absolute;
    left: 18%;
    right: 18%;
    bottom: 2%;
    height: 13%;
    border-radius: 50%;
    opacity: 0.85;
    border: 2px solid rgba(255, 255, 255, 0.8);
}
.pawn-figure.active-pawn { animation: pawn-bounce 1.6s ease-in-out infinite; }
/* мгновенная первичная расстановка фигурок */
#pawn-layer.no-anim .pawn-figure,
#pawn-layer.no-anim .fox-token { transition: none; }
@keyframes pawn-bounce {
    0%, 100% { margin-top: 0; }
    50% { margin-top: -4px; }
}

/* Лис с пирогом на тропе */
.fox-token {
    position: absolute;
    top: 0;
    left: 0;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 3px 3px rgba(74, 50, 38, 0.35));
}
.fox-token img { width: 100%; height: 100%; object-fit: contain; }
/* во время пробежки вдоль тропы позицией управляет JS-анимация */
.fox-token.trail-anim { transition: none; }
.fox-token.in-burrow { opacity: 0; transform: scale(0.4); transition: transform 0.6s, opacity 0.6s; }

/* ================= Карты подозреваемых ================= */
.fox-card {
    width: 100%;
    height: 100%;
    min-height: 0;
    perspective: 700px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s;
}
.fox-card.revealed .card-inner { transform: rotateY(180deg); }
.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    overflow: hidden;
}
.card-back {
    background: url('../assets/tile-mystery.webp') center / cover no-repeat;
    border: 3px solid #a05a24;
}
.card-front {
    transform: rotateY(180deg);
    background: var(--art-bg);
    border: 3px solid #e3cba4;
    gap: 3px;
}
.card-front .portrait-img {
    width: auto;
    max-width: 100%;
    flex: 1;
    min-height: 0;
    object-fit: contain;
}
.portrait-img {
    display: block;
    margin: 0 auto;
}
.card-name { font-weight: 700; font-size: 0.95rem; }
.card-attrs { display: inline-flex; gap: 4px; align-items: center; min-height: 16px; }
.card-attrs .no-attrs { font-size: 0.72rem; color: var(--ink-soft); font-weight: 700; }

.fox-card.pulse .card-back {
    animation: card-glow 1.1s ease-in-out infinite;
}
@keyframes card-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(232, 134, 58, 0); }
    50% { box-shadow: 0 0 0 5px rgba(232, 134, 58, 0.55); }
}
@media (hover: hover) {
    .fox-card:hover .card-inner { transform: translateY(-3px); }
    .fox-card.revealed:hover .card-inner { transform: rotateY(180deg) translateY(-3px); }
}

.fox-card.released .card-front { filter: grayscale(0.7); opacity: 0.75; }

.stamp {
    position: absolute;
    top: 44%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-16deg);
    border: 3px solid;
    border-radius: 6px;
    padding: 1px 7px;
    font-weight: 800;
    font-size: 0.8rem;
    letter-spacing: 1px;
    background: rgba(255, 250, 240, 0.82);
    white-space: nowrap;
    pointer-events: none;
}
.stamp-released { color: #8a8a8a; border-color: #8a8a8a; }

/* ================= Панель действий (в шапке, всегда на виду) ================= */
.action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 16px;
    background: rgba(255, 250, 240, 0.85);
    border: 2px solid rgba(74, 50, 38, 0.12);
    box-shadow: var(--shadow-sm);
    min-height: 62px;
}
.players-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.player-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    background: var(--panel-2);
    border: 2px solid transparent;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--ink-soft);
    transition: border-color 0.2s, background 0.2s;
}
.player-chip .chip-avatar {
    display: inline-flex;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid;
    background: var(--art-bg);
    overflow: hidden;
    flex-shrink: 0;
}
.player-chip.active {
    border-color: var(--accent);
    background: #ffedd8;
    color: var(--ink);
}
.head-crop {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
}
.head-crop img {
    position: absolute;
    width: 185%;
    height: 185%;
    left: -42.5%;
    top: -6%;
    object-fit: cover;
}
.status {
    flex: 1;
    text-align: center;
    font-weight: 700;
    font-size: clamp(0.85rem, 2.5vw, 1.05rem);
    min-height: 1.3em;
}
.status.flash { animation: status-in 0.35s ease-out; }
@keyframes status-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}
.status.st-good { color: var(--green); }
.status.st-bad { color: var(--red); }
.status.st-warn { color: #b07a00; }
.action-buttons { display: flex; align-items: center; gap: 8px; }
.steps-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 1.05rem;
    background: var(--panel-2);
    border: 2px solid rgba(74, 50, 38, 0.15);
    border-radius: 999px;
    padding: 6px 14px;
}
.steps-icon { display: inline-flex; }

/* ================= Модальные окна ================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(60, 40, 20, 0.5);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal {
    background: var(--art-bg);
    border-radius: 20px;
    padding: 22px 24px;
    width: min(94vw, 440px);
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(40, 25, 12, 0.35);
    animation: modal-pop 0.25s cubic-bezier(0.34, 1.3, 0.64, 1);
    text-align: center;
}
@keyframes modal-pop {
    from { opacity: 0; transform: scale(0.92) translateY(10px); }
    to { opacity: 1; transform: none; }
}
.modal h2 {
    margin: 0 0 8px;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.modal-icon { display: inline-flex; }
.modal-icon-img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.modal-sub { margin: 0 0 16px; color: var(--ink-soft); font-weight: 600; }
.modal-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
}

/* Настройка игры */
.count-picker { display: flex; justify-content: center; gap: 10px; margin-bottom: 16px; }
.count-picker button {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    border: 3px solid #e3cba4;
    background: var(--panel-2);
    font-family: inherit;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--ink-soft);
    cursor: pointer;
    transition: all 0.15s;
}
.count-picker button.selected {
    border-color: var(--accent);
    background: #ffedd8;
    color: var(--ink);
    transform: scale(1.08);
}
.player-names { display: flex; flex-direction: column; gap: 14px; }
.player-setup-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border-radius: var(--radius);
    background: rgba(253, 243, 223, 0.6);
    border: 2px solid #eeddbd;
}
.player-name-row { display: flex; align-items: center; gap: 8px; }
.player-name-row input {
    flex: 1;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
    padding: 9px 14px;
    border-radius: 999px;
    border: 2px solid #e3cba4;
    background: var(--panel);
    outline: none;
    min-width: 0;
}
.player-name-row input:focus { border-color: var(--accent); }

/* Выбор зверька */
.animal-picker { display: flex; justify-content: center; gap: 10px; }
.animal-btn {
    width: 66px;
    height: 82px;
    border-radius: 14px;
    border: 3px solid #e3cba4;
    background: var(--art-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    padding: 0;
    transition: all 0.15s;
}
.animal-btn .detective-img { width: 100%; height: 100%; object-fit: cover; }
.animal-btn.selected {
    border-color: var(--accent);
    background: #ffedd8;
    transform: scale(1.12);
    box-shadow: var(--shadow-sm);
}
@media (hover: hover) {
    .animal-btn:not(.selected):hover { border-color: var(--accent-dark); transform: scale(1.05); }
}

/* Выбор цвета */
.color-picker { display: flex; justify-content: center; gap: 12px; }
.color-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 2px 5px rgba(74, 50, 38, 0.3);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
.color-btn.selected {
    transform: scale(1.22);
    box-shadow: 0 0 0 3px var(--ink-soft), 0 2px 5px rgba(74, 50, 38, 0.3);
}

/* Кубики */
.target-picker { display: flex; gap: 10px; justify-content: center; margin-bottom: 18px; }
.target-btn {
    flex: 1;
    max-width: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 8px;
    border-radius: var(--radius);
    border: 3px solid #e3cba4;
    background: var(--panel-2);
    font-family: inherit;
    font-weight: 700;
    color: var(--ink);
    cursor: pointer;
    transition: all 0.15s;
}
.target-btn small { color: var(--ink-soft); font-weight: 600; }
.target-btn .target-icon { display: inline-flex; height: 30px; align-items: center; }
.target-btn.selected { border-color: var(--accent); background: #ffedd8; transform: scale(1.04); }
.target-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.target-btn.locked-choice { pointer-events: none; }
.target-btn.locked-choice:not(.selected) { opacity: 0.35; }

.dice-row { display: flex; justify-content: center; gap: 14px; margin: 6px 0 10px; }
.die {
    width: 64px;
    height: 64px;
    background: #fff;
    border: 3px solid #b09879;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.die .die-q { font-size: 30px; font-weight: 800; color: #c9b18d; }
.die.locked { border-color: var(--green); background: var(--green-soft); transform: scale(1.05); }
.die.rolling { animation: die-shake 0.45s ease-in-out; }
@keyframes die-shake {
    0% { transform: translateY(0) rotate(0); }
    25% { transform: translateY(-10px) rotate(-14deg); }
    50% { transform: translateY(2px) rotate(10deg); }
    75% { transform: translateY(-6px) rotate(-6deg); }
    100% { transform: translateY(0) rotate(0); }
}
.dice-hint { min-height: 1.4em; margin: 4px 0 0; font-weight: 700; color: var(--ink-soft); }
.dice-hint.st-good { color: var(--green); }
.dice-hint.st-bad { color: var(--red); }
.dice-hint.st-warn { color: #b07a00; }
.dice-actions { align-items: center; }
.rolls-left { font-weight: 700; font-size: 1.05rem; }

/* Дешифратор: сцена «лупа наводится на улику» */
.lens-scene {
    position: relative;
    width: 270px;
    height: 215px;
    margin: 0 auto;
    overflow: hidden;
}
.lens-item {
    position: absolute;
    left: 50%;
    top: 46%;
    width: 86px;
    height: 86px;
    transform: translate(-50%, -50%);
}
.lens-verdict {
    position: absolute;
    left: 50%;
    top: 46%;
    width: 104px;
    height: 104px;
    transform: translate(-50%, -50%) scale(0.55);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
}
.lens-verdict img {
    width: 58px;
    height: 58px;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(74, 50, 38, 0.35));
}
.lens-verdict span {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 800;
    box-shadow: 0 2px 5px rgba(74, 50, 38, 0.35);
}
.lens-verdict.show-yes {
    background: radial-gradient(circle, rgba(120, 205, 130, 0.55) 0%, rgba(120, 205, 130, 0.2) 62%, transparent 75%);
    box-shadow: inset 0 0 0 4px rgba(79, 157, 93, 0.55);
    color: #2f6b3b;
    animation: verdict-in 0.45s 1.15s forwards;
}
.lens-verdict.show-no {
    background: radial-gradient(circle, rgba(220, 120, 115, 0.5) 0%, rgba(220, 120, 115, 0.18) 62%, transparent 75%);
    box-shadow: inset 0 0 0 4px rgba(200, 80, 75, 0.55);
    color: #a33630;
    animation: verdict-in 0.45s 1.15s forwards;
}
@keyframes verdict-in {
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.lens-magnifier {
    position: absolute;
    width: 175px;
    height: 175px;
    /* линза арта — в точке ~62%/35% картинки: совмещаем её с уликой */
    left: calc(50% - 108px);
    top: calc(46% - 61px);
    animation: lens-scan 1.25s ease-out forwards;
    pointer-events: none;
    filter: drop-shadow(0 4px 5px rgba(74, 50, 38, 0.3));
}
@keyframes lens-scan {
    0% { transform: translate(190px, 130px) rotate(16deg); opacity: 0; }
    22% { opacity: 1; }
    55% { transform: translate(-28px, -16px) rotate(-7deg); }
    80% { transform: translate(15px, 9px) rotate(4deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}
.decoder-result.delayed {
    opacity: 0;
    animation: verdict-text-in 0.4s 1.25s forwards;
}
@keyframes verdict-text-in { to { opacity: 1; } }
.item-img { display: inline-block; vertical-align: middle; border-radius: 6px; }
.decoder-result {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 1.5em;
    margin: 6px 0 0;
    font-weight: 700;
    font-size: 1.15rem;
    animation: status-in 0.3s ease-out;
}
.decoder-result.res-yes { color: var(--green); }
.decoder-result.res-no { color: var(--ink-soft); }

/* Досье */
.dossier-portrait { display: flex; justify-content: center; margin: 0 auto; }
.dossier-portrait .portrait-img { width: auto; height: 200px; }
.dossier-name { font-size: 1.4rem; font-weight: 800; margin: 6px 0 2px; }
.dossier-attrs {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.dossier-attr {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--art-bg);
    border: 2px solid #e3cba4;
    font-weight: 700;
    font-size: 0.85rem;
}
.dossier-note { margin-top: 12px; font-weight: 700; }

/* Конец игры */
.endgame-art { display: flex; justify-content: center; margin-bottom: 4px; }
.endgame-title { font-size: 1.6rem; font-weight: 800; margin: 6px 0; }
.endgame-title.win { color: var(--green); }
.endgame-title.lose { color: var(--red); }
.endgame-thief { margin-top: 10px; }
.endgame-thief .portrait-img { width: auto; height: 150px; }

/* Настройки */
.settings-list { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-weight: 700;
    font-size: 1.05rem;
    padding: 4px 2px;
}
.settings-wide { width: 100%; }
.toggle {
    appearance: none;
    width: 52px;
    height: 30px;
    border-radius: 999px;
    background: #cbb9a2;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: left 0.2s;
}
.toggle:checked { background: var(--green); }
.toggle:checked::after { left: 25px; }
.lang-switch { display: inline-flex; gap: 6px; }
.lang-btn {
    font-family: inherit;
    font-weight: 800;
    padding: 6px 14px;
    border-radius: 999px;
    border: 2.5px solid #e3cba4;
    background: var(--panel);
    color: var(--ink-soft);
    cursor: pointer;
}
.lang-btn.selected { border-color: var(--accent); background: #ffedd8; color: var(--ink); }

/* Правила */
#rules-slide { min-height: 240px; }
.rules-art { display: flex; justify-content: center; margin: 8px 0; }
.rules-art img { max-height: 150px; width: auto; }
.rules-slide-title { font-size: 1.25rem; font-weight: 800; margin-bottom: 6px; }
.rules-text { font-weight: 600; color: var(--ink-soft); line-height: 1.45; margin: 0; }
#rules-dots { display: flex; justify-content: center; gap: 6px; margin-top: 14px; }
.dot-nav {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(74, 50, 38, 0.2);
}
.dot-nav.on { background: var(--accent); }

/* ================= Туториал ================= */
#tut-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    pointer-events: none;
    display: none;
}
#tut-overlay.visible { display: block; }
#tut-spot {
    position: absolute;
    border-radius: 18px;
    box-shadow: 0 0 0 9999px rgba(40, 25, 10, 0.45);
    border: 3px dashed rgba(255, 210, 130, 0.95);
    transition: all 0.35s ease;
}
#tut-bubble {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: min(92vw, 420px);
    background: var(--panel);
    border: 3px solid var(--accent);
    border-radius: 18px;
    padding: 14px 16px;
    box-shadow: 0 10px 30px rgba(40, 25, 12, 0.4);
    pointer-events: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
    /* позиция меняется мгновенно под коротким fade — без «поездок» по экрану */
    transition: opacity 0.13s ease;
}
#tut-bubble.switching { opacity: 0; }
#tut-bubble .tut-fox { flex-shrink: 0; }
#tut-bubble p {
    flex: 1;
    min-width: 200px;
    margin: 0;
    font-weight: 700;
    line-height: 1.4;
    text-align: left;
}
.tut-actions {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.tut-actions .btn { min-height: 38px; padding: 6px 16px; font-size: 0.9rem; }

/* ================= Компактная высота (карточки без примет) ================= */
@media (max-height: 760px) {
    .card-attrs { display: none; }
    .card-name { font-size: 0.82rem; }
}

/* ================= Мобильные ================= */
@media (max-width: 767px) {
    .header { padding: 8px 10px 0; }
    .header-row { justify-content: center; gap: 8px; }
    .game-title { font-size: 1.15rem; }
    .icon-btn { width: 40px; height: 40px; }
    .header-btns .btn { padding: 8px 14px; font-size: 0.85rem; min-height: 40px; }
    .fox-danger { padding: 4px 12px; font-size: 0.9rem; }

    .action-row { flex-wrap: wrap; justify-content: center; row-gap: 6px; margin-top: 6px; padding: 6px 8px; min-height: 0; }
    .players-strip { width: 100%; justify-content: center; }
    .status { flex-basis: 100%; order: -1; font-size: 0.85rem; }
    .action-buttons .btn { padding: 8px 14px; font-size: 0.9rem; min-height: 40px; }

    .tab { padding: 6px 14px; font-size: 0.88rem; }

    .card-front { padding: 4px 2px; }
    .card-name { font-size: 0.74rem; }
    .card-attrs { display: none; }
    .stamp { font-size: 0.6rem; }
    .suspects-grid { gap: 7px; }

    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal {
        width: 100%;
        max-width: none;
        border-radius: 22px 22px 0 0;
        padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
        animation: modal-slide-up 0.3s cubic-bezier(0.34, 1.2, 0.64, 1);
    }
    @keyframes modal-slide-up {
        from { opacity: 0.5; transform: translateY(60%); }
        to { opacity: 1; transform: none; }
    }

    .die { width: 56px; height: 56px; }
    .animal-btn { width: 54px; height: 70px; }
    .color-btn { width: 30px; height: 30px; }
}
