* {
    box-sizing: border-box !important;
    margin: 0;
    padding: 0;
    user-select: none;
}

:root {
    /* Фолбэк на случай если JS ещё не отработал / открыто вне Telegram */
    --app-height: 100vh;
}

html, body {
    width: 100%;
    height: var(--app-height);
    background-color: #121212;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
    /* Жёстко пришпиливаем документ к экрану: никакой resize/rubber-band
       не должен "просвечивать" контент чата под Web App попапом */
    position: fixed;
    inset: 0;
    overscroll-behavior: none;
}

.app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: var(--app-height);
    position: relative;
    overflow: hidden;
}

/* Навигация */
.top-nav {
    display: flex;
    height: 48px;
    background: #1e1e1e;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

.nav-btn {
    flex: 1;
    background: none;
    border: none;
    color: #888;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

.nav-btn.active {
    color: #ffca28;
    background: #2a2a2a;
    border-bottom: 3px solid #ffca28;
}

/* Разделы */
.content-section {
    display: none;
    flex: 1;
    min-height: 0; /* КЛЮЧЕВОЙ фикс: без этого flex-элемент не сжимается */
    position: relative;
    overflow: hidden;
}

.content-section.active {
    display: flex;
    flex-direction: column;
}

/* Карта */
.map-scroll-area {
    flex: 1;
    min-height: 0; /* тот же фикс: разрешаем блоку реально скроллиться,
                       а не распирать родителя своим содержимым */
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    position: relative;
    background: #000;
}

.map-viewport {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    overflow: hidden;
    touch-action: none;          /* жесты на карте обрабатываем сами (масштаб и сдвиг) */
    user-select: none;
    -webkit-user-select: none;
}

.map-container {
    position: relative;
    width: 100%;
    transform-origin: 0 0;
    will-change: transform;
}

.game-map {
    width: 100%;
    height: auto;
    display: block;
}

/* Фишки */
#chips-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
}

.chip {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #000;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 4px #000;
}

.chip-yellow { background: #ffd700; }
.chip-green  { background: #4caf50; }
.chip-purple { background: #7b2ff7; } /* чуть ближе к сине-фиолетовому */
.chip-red    { background: #f44336; }
.chip-pink   { background: #ff8fc7; } /* светло-розовый, чтобы отличался от красного */
.chip-blue   { background: #00bcd4; }

.chip.in-room {
    box-shadow: 0 0 0 3px rgba(255,202,40,0.6), 0 0 6px #000;
}

.chip.inactive { opacity: 0.55; }

/* Клетки, доступные для хода после броска */
#reachable-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
}

.reachable-dot {
    position: absolute;
    width: 11px;
    height: 11px;
    border-radius: 3px;
    background: rgba(255, 202, 40, 0.25);
    border: 1px solid rgba(255, 202, 40, 0.85);
    transform: translate(-50%, -50%);
    pointer-events: auto;
    cursor: pointer;
}

.reachable-dot:active { transform: translate(-50%, -50%) scale(1.3); }

/* Постоянные значки дверей — видно всегда, независимо от подсветки хода */
#doors-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
}

.door-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    font-size: 11px;
    opacity: 0.55;
    filter: drop-shadow(0 0 2px #000);
}

.room-actions-info {
    flex-basis: 100%;
    text-align: center;
    font-size: 12px;
    color: #aaa;
    margin-bottom: 4px;
}

/* Индикатор текущего хода */
.turn-bar {
    flex-shrink: 0;
    padding: 6px 12px;
    background: #1a1a1a;
    border-top: 1px solid #333;
    text-align: center;
    font-size: 13px;
    font-weight: bold;
    color: #ffca28;
}

/* Панель действий в комнате */
.room-actions {
    flex-shrink: 0;
    padding: 8px 12px;
    background: #1a1a1a;
    border-top: 1px solid #333;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.room-actions.hidden { display: none; }

.room-actions button {
    flex: 1 1 auto;
    min-width: 120px;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: #2a2a2a;
    color: #fff;
    font-weight: bold;
    cursor: pointer;
}

.room-actions button.teleport-btn {
    background: linear-gradient(135deg, #00bcd4, #0097a7);
    color: #000;
}

/* Панель кнопки */
.bottom-bar {
    height: 60px;
    flex-shrink: 0;
    background: #1a1a1a;
    border-top: 1px solid #333;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bottom-bar.hidden { display: none; }

.main-roll-btn {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ffca28, #f57c00);
    border: none;
    border-radius: 10px;
    color: #000;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(245, 124, 0, 0.4);
}

.main-roll-btn:active {
    opacity: 0.8;
    transform: scale(0.98);
}

/* Полноэкранный Оверлей для Модалки Кубиков */
.dice-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: var(--app-height);
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.dice-overlay.hidden {
    display: none !important;
}

.dice-card {
    background: #222;
    border: 2px solid #ffca28;
    border-radius: 16px;
    padding: 20px;
    width: 80%;
    max-width: 300px;
    text-align: center;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
}

.dice-title {
    color: #ffca28;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
}

.dice-row {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.die-box {
    width: 60px;
    height: 60px;
    background: #fff;
    color: #000;
    font-size: 32px;
    font-weight: bold;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #444;
}

.die-box.shake-anim {
    animation: pulse 0.1s infinite alternate;
}

@keyframes pulse {
    0% { transform: scale(0.95) rotate(-5deg); }
    100% { transform: scale(1.05) rotate(5deg); }
}

.dice-status {
    font-size: 15px;
    margin-bottom: 15px;
    min-height: 40px;
    color: #fff;
}

.close-btn {
    width: 100%;
    padding: 10px;
    background: #ffca28;
    border: none;
    border-radius: 8px;
    color: #000;
    font-weight: bold;
    cursor: pointer;
}

.close-btn.hidden {
    display: none;
}

/* Блокнот */
.notebook-inner {
    padding: 15px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    height: 100%;
}

h2 { color: #ffca28; font-size: 18px; margin-bottom: 5px; }
.hint { font-size: 12px; color: #aaa; margin-bottom: 15px; }

.notebook-category {
    background: #1e1e1e;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
}

.notebook-category h3 { color: #ffca28; font-size: 14px; margin-bottom: 8px; }

.notebook-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #2a2a2a;
}

.status-btn {
    padding: 4px 10px;
    background: #333;
    border: 1px solid #555;
    color: #fff;
    border-radius: 4px;
}

.status-btn.status-cross { background: #5c1d1d; color: #ff8888; }
.status-btn.status-query { background: #5c4d1d; color: #ffdd88; }
.status-btn.status-clue  { background: #1d5c2a; color: #88ff9e; }

/* Номер выхода из комнаты прямо на карте */
.exit-badge {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #ffca28;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    cursor: pointer;
    z-index: 3;
    animation: exitPulse 1s infinite alternate;
}

@keyframes exitPulse {
    from { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.5); }
    to   { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0); }
}

/* ===== v5: шапка со звуком ===== */
.nav-btn-icon { flex: 0 0 52px; font-size: 18px; }

/* Фишки, за которые никто не играет */
.chip.not-playing { opacity: 0.35; }

/* ===== Мои карты под полем ===== */
.hand-area {
    max-width: 600px;
    margin: 0 auto;
    padding: 12px 10px 16px;
}

.hand-title {
    color: #ffca28;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 8px;
}

.hand-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 8px;
}

.hand-card {
    border-radius: 8px;
    overflow: hidden;
    background: #1e1e1e;
    border: 1px solid #333;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.hand-card img { width: 100%; height: auto; display: block; }

.hand-card-fallback {
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 11px;
    padding: 4px;
    color: #ddd;
}

.card-zoom-img {
    max-width: 85%;
    max-height: 80%;
    border-radius: 14px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.9);
}

/* ===== Блокнот-таблица ===== */
.notebook-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 5px;
}

.small-btn {
    background: #2a2a2a;
    color: #fff;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
}

.notebook-table-wrap {
    background: #1b1813;
    border: 1px solid #4a3f2c;
    border-radius: 10px;
    overflow-x: auto;
}

.notebook-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.notebook-table th {
    position: sticky;
    top: 0;
    background: #2a241a;
    padding: 6px 2px;
    border-bottom: 1px solid #4a3f2c;
    font-weight: normal;
    z-index: 1;
}

.notebook-table th.nb-name-col { text-align: left; padding-left: 10px; color: #c9b88a; font-size: 12px; }

.nb-dot {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #000;
}

.nb-me { font-size: 9px; color: #ffca28; font-weight: bold; }

.nb-section td {
    background: #241f16;
    color: #ffca28;
    font-weight: bold;
    font-size: 12px;
    padding: 6px 10px;
}

.notebook-table td { border-bottom: 1px solid #2c261c; }

.nb-name {
    padding: 7px 6px 7px 10px;
    color: #eee;
    cursor: pointer;
    white-space: nowrap;
}

.nb-cell {
    width: 36px;
    height: 32px;
    text-align: center;
    border-left: 1px solid #2c261c;
    cursor: pointer;
    font-size: 14px;
}

.nb-cell.nb-cross { background: rgba(92, 29, 29, 0.55); }
.nb-cell.nb-query { background: rgba(92, 77, 29, 0.55); }
.nb-cell.nb-clue  { background: rgba(29, 92, 42, 0.55); }
.nb-cell.nb-fixed { cursor: default; opacity: 0.6; font-size: 11px; }

.nb-struck .nb-name {
    text-decoration: line-through;
    color: #777;
}

/* ===== Окно новой игры ===== */
.setup-card { max-width: 330px; }

.setup-label {
    text-align: left;
    font-size: 13px;
    color: #ccc;
    margin: 10px 0 6px;
}

.setup-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.setup-color {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid #000;
    opacity: 0.35;
    cursor: pointer;
}

.setup-color.selected {
    opacity: 1;
    box-shadow: 0 0 0 3px #fff;
}

.setup-info {
    font-size: 12px;
    color: #aaa;
    margin: 12px 0;
    min-height: 16px;
}

.close-btn:disabled { opacity: 0.4; cursor: default; }
.close-btn.secondary { background: #333; color: #fff; margin-top: 8px; }
.close-btn.secondary.hidden { display: none; }

/* ======================================================
   ТЕМА: зелёно-чёрная, как сукно игрового поля
   (блок переопределяет цвета выше; кнопка броска остаётся золотой)
   ====================================================== */
:root {
    --felt-bg:      #0b1510;   /* почти чёрный с зеленью — общий фон */
    --felt-surface: #12241a;   /* панели */
    --felt-raised:  #1a3324;   /* приподнятые элементы */
    --felt-cell:    #2a5a3a;   /* как клетки на карте */
    --felt-border:  #2f5a3e;
    --felt-text:    #e3efe6;
    --felt-muted:   #8fae98;
    --gold:         #ffca28;
}

html, body { background-color: var(--felt-bg); color: var(--felt-text); }

.top-nav {
    background: linear-gradient(180deg, #152b1e, var(--felt-surface));
    border-bottom: 1px solid var(--felt-border);
}
.nav-btn { color: var(--felt-muted); }
.nav-btn.active { background: var(--felt-raised); color: var(--gold); border-bottom-color: var(--gold); }

.map-scroll-area {
    background:
        radial-gradient(ellipse at top, rgba(42, 90, 58, 0.25), transparent 60%),
        var(--felt-bg);
}

.turn-bar, .room-actions, .bottom-bar {
    background: var(--felt-surface);
    border-top: 1px solid var(--felt-border);
}
.room-actions button { background: var(--felt-raised); border: 1px solid var(--felt-border); color: var(--felt-text); }
.room-actions-info { color: var(--felt-muted); }

/* Мои карты — как сукно стола */
.hand-area {
    background: linear-gradient(180deg, rgba(26, 51, 36, 0.6), rgba(11, 21, 16, 0));
    border-top: 1px solid var(--felt-border);
}
.hand-card { background: var(--felt-raised); border-color: var(--felt-border); }

/* Модалки */
.dice-overlay { background: rgba(4, 10, 6, 0.88); }
.dice-card { background: var(--felt-surface); border-color: var(--gold); }
.die-box { border-color: var(--felt-border); }
.close-btn.secondary { background: var(--felt-raised); }

/* Блокнот */
.notebook-inner { background: var(--felt-bg); }
.hint { color: var(--felt-muted); }
.small-btn { background: var(--felt-raised); border-color: var(--felt-border); color: var(--felt-text); }
.notebook-table-wrap { background: var(--felt-surface); border-color: var(--felt-border); }
.notebook-table th { background: var(--felt-raised); border-bottom-color: var(--felt-border); }
.notebook-table th.nb-name-col { color: var(--felt-muted); }
.nb-section td { background: #173022; }
.notebook-table td { border-bottom-color: #1c3526; }
.nb-cell { border-left-color: #1c3526; }
.nb-struck .nb-name { color: #5f7a67; }

/* ===== v7: онлайн-лобби ===== */
.turn-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.room-code-label { font-size: 11px; color: var(--felt-muted); font-weight: normal; white-space: nowrap; }

.room-code-big {
    background: var(--felt-raised);
    border: 1px dashed var(--gold);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 12px;
    font-size: 12px;
    color: var(--felt-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
}
.room-code-big b { font-size: 34px; letter-spacing: 6px; color: var(--gold); margin: 2px 0; }
.room-code-big span { font-size: 11px; }

.lobby-list { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.lobby-player {
    display: grid;
    grid-template-columns: 22px 1fr;
    align-items: center;
    column-gap: 8px;
    background: var(--felt-raised);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 14px;
}
.lobby-player small { grid-column: 2; color: var(--felt-muted); font-size: 11px; }
.lobby-player.offline { opacity: 0.5; }
.lobby-nocolor { background: transparent !important; border: 2px dashed #666 !important; }

.setup-color.taken { opacity: 0.12; cursor: not-allowed; }

.join-row { display: flex; gap: 8px; }
.join-row .close-btn { width: auto; padding: 10px 16px; }
.code-input {
    flex: 1;
    min-width: 0;
    background: var(--felt-bg);
    border: 1px solid var(--felt-border);
    border-radius: 8px;
    color: var(--gold);
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 4px;
    text-align: center;
    text-transform: uppercase;
    padding: 8px;
    user-select: text;
}

.main-roll-btn:disabled {
    background: var(--felt-raised);
    color: var(--felt-muted);
    box-shadow: none;
    cursor: default;
}

/* Всплывашка */
.toast {
    position: fixed;
    left: 50%;
    bottom: 90px;
    transform: translateX(-50%);
    background: rgba(18, 36, 26, 0.96);
    border: 1px solid var(--gold);
    color: var(--felt-text);
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 13px;
    z-index: 10001;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}
.toast.hidden { display: none; }

/* ===== v8: вопросы и обвинения ===== */
.action-card { max-height: calc(var(--app-height) - 40px); overflow-y: auto; }
.action-card .dice-title b { font-size: 18px; }

.suggest-banner {
    flex-shrink: 0;
    background: #10261a;
    border-top: 1px solid var(--gold);
    padding: 6px 12px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--felt-text);
}
.suggest-banner.hidden { display: none; }

.accuse-btn {
    background: #3a1d1d;
    border: 1px solid #a33;
    color: #ffb3b3;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
}
.accuse-btn.hidden { display: none; }

.pick-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}
.pick-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--felt-raised);
    border: 1px solid var(--felt-border);
    color: var(--felt-text);
    border-radius: 8px;
    padding: 8px;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}
.pick-item.selected { border-color: var(--gold); background: #2c4a1f; color: var(--gold); font-weight: bold; }
.nb-dot.small { width: 12px; height: 12px; flex-shrink: 0; }

.show-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 10px 0;
}
.show-grid.single { grid-template-columns: 1fr; max-width: 160px; margin: 10px auto; }
.card-caption { font-size: 11px; padding: 4px; text-align: center; color: var(--felt-text); }
.hand-card.big { cursor: default; }

.close-btn { margin-top: 8px; }
.close-btn.danger { background: #c62828; color: #fff; }

/* ===== v9: свои карты и блокнот в окне вопроса ===== */
.pick-item { flex-wrap: wrap; }
.pick-item small { width: 100%; font-size: 10px; color: var(--felt-muted); }
.pick-item.mine { opacity: 0.4; cursor: not-allowed; }
.pick-item.struck span { text-decoration: line-through; color: var(--felt-muted); }
.inline-nb { margin-top: 8px; max-height: 45vh; overflow-y: auto; text-align: left; }

/* ===== v10: лупы ===== */
.reveal-overlay { z-index: 10000; }

.mag-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: var(--felt-raised);
    border: 1px solid var(--gold);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 8px;
}
.mag-card img { max-width: 140px; max-height: 190px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.7); }
.mag-desc { font-size: 14px; font-weight: bold; color: var(--gold); text-align: center; }
.mag-result { color: var(--felt-text); font-size: 14px; }

.pick-grid.three { grid-template-columns: repeat(3, 1fr); }
.pick-grid.three .pick-item { justify-content: center; text-align: center; font-size: 12px; }
.hand-card.selected-card { outline: 3px solid var(--gold); }

.suggest-banner hr { border: none; border-top: 1px solid var(--felt-border); margin: 4px 0; }

/* ===== v11: окно вопроса — кому задаёшь, блокнот, блеф своими картами ===== */
.ask-chain {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 4px 0 8px;
    text-align: left;
}
.ask-row {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--felt-raised);
    border: 1px solid var(--felt-border);
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 12px;
    color: var(--felt-text);
}
.ask-num {
    width: 18px; height: 18px; flex-shrink: 0;
    border-radius: 50%;
    background: #0b1510;
    border: 1px solid var(--felt-border);
    font-size: 10px; font-weight: bold;
    display: flex; align-items: center; justify-content: center;
}
.ask-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ask-name small { color: var(--felt-muted); }
.ask-status { font-size: 11px; color: var(--felt-muted); white-space: nowrap; }
.ask-row.active { border-color: var(--gold); background: #243f1b; }
.ask-row.active .ask-status { color: var(--gold); font-weight: bold; }
.ask-row.shown { border-color: #4caf50; }
.ask-row.shown .ask-status { color: #8be08f; font-weight: bold; }
.ask-row.pass { opacity: 0.75; }
.ask-row.idle { opacity: 0.55; }

.nb-toggle { margin-top: 4px; }
.action-card .inline-nb { max-height: 38vh; }
.notebook-table tr.nb-hl td { background: rgba(255, 202, 40, 0.14); }
.notebook-table tr.nb-hl .nb-name { color: var(--gold); font-weight: bold; }
.notebook-table tr.nb-hl .nb-cell.nb-cross { background: rgba(120, 35, 35, 0.7); }

.pick-item.own { border-style: dashed; }
.pick-item.own small { color: #d9b86a; }
.pick-item.selected small { color: var(--gold); }

.suggest-summary {
    margin-top: 10px;
    padding: 8px;
    border-radius: 8px;
    background: #0e1d14;
    border: 1px solid var(--felt-border);
    font-size: 12px;
    line-height: 1.5;
    text-align: left;
    color: var(--felt-text);
}
.suggest-summary small { color: var(--felt-muted); }

/* ===== v12: карточка лупы — увеличение по тапу ===== */
.mag-card img { cursor: zoom-in; }
.mag-zoom-hint { font-size: 11px; color: var(--felt-muted); }
#card-zoom { z-index: 10002; }
#room-actions .close-btn { margin-top: 6px; }

/* ===== v13: масштаб карты ===== */
.map-viewport.zoomed { cursor: grab; }
.game-map { -webkit-user-drag: none; pointer-events: none; }
.zoom-controls {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.zoom-controls button {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--felt-border);
    background: rgba(18, 36, 26, 0.85);
    color: var(--gold);
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}
.zoom-controls button:active { transform: scale(0.92); }

/* Игра вдвоём: карты, лежащие в комнатах */
#table-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
}
.table-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    font-size: 9px;
    line-height: 1.2;
    padding: 1px 4px;
    border-radius: 4px;
    background: rgba(11, 21, 16, 0.85);
    border: 1px solid var(--felt-border);
    color: var(--felt-muted);
    white-space: nowrap;
}
.table-marker.seen { color: var(--gold); border-color: var(--gold); }
.table-marker.empty { opacity: 0.6; }
.nb-table-h { font-size: 13px; }
.nb-cell.nb-table-seen { opacity: 0.8; }

/* Блокнот поверх любого окна */
.nb-fab {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    right: 8px;
    z-index: 10004;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 2px solid var(--gold);
    background: var(--felt-raised);
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.7);
}
.nb-fab.hidden { display: none; }
.nb-overlay {
    position: fixed;
    inset: 0;
    z-index: 10005;
    background: rgba(4, 10, 6, 0.92);
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: calc(env(safe-area-inset-top, 0px) + 8px) 8px 8px;
}
.nb-overlay.hidden { display: none; }
.nb-panel {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    background: var(--felt-surface);
    border: 1px solid var(--gold);
    border-radius: 14px;
    padding: 10px;
    min-height: 0;
}
.nb-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--gold);
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 4px;
}
.nb-close {
    background: var(--felt-raised);
    border: 1px solid var(--felt-border);
    color: var(--felt-text);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
}
.nb-panel .hint { margin: 2px 0 6px; font-size: 11px; }
.nb-panel-table { flex: 1; min-height: 0; overflow-y: auto; }

/* ===== v14: выход из комнаты ===== */
.room-actions .exit-btn { background: var(--gold); color: #1a1a1a; border: none; font-weight: bold; }
.room-actions .close-btn { width: 100%; }
.room-actions .room-actions-info { flex-basis: 100%; }

/* ===== v15: мои карты по группам, мини-карточки в блокноте, итог вопроса вдвоём ===== */
.hand-grid {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.hand-group {
    flex-basis: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.hand-group + .hand-group {
    border-left: 1px dashed var(--felt-border);
    padding-left: 8px;
}
.hand-group-title {
    font-size: 11px;
    color: var(--felt-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hand-group-cards {
    display: grid;
    gap: 6px;
}
.hand-group-cards .hand-card-fallback { min-height: 70px; font-size: 10px; }

.nb-name-inner { display: flex; align-items: center; gap: 8px; }
.nb-name { padding-top: 3px; padding-bottom: 3px; }
.nb-thumb {
    width: 24px;
    height: 36px;
    object-fit: cover;
    border-radius: 3px;
    border: 1px solid var(--felt-border);
    flex-shrink: 0;
    cursor: zoom-in;
    background: var(--felt-raised);
}
.nb-thumb.nb-thumb-missing { visibility: hidden; }
.nb-struck .nb-thumb { opacity: 0.4; filter: grayscale(1); }
.nb-name-text { overflow: hidden; text-overflow: ellipsis; }
.nb-struck .nb-name { text-decoration: none; }
.nb-struck .nb-name-text { text-decoration: line-through; }

.table-warn {
    background: rgba(255, 138, 101, 0.12);
    border: 1px solid #ff8a65;
    border-radius: 8px;
    padding: 8px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--felt-text);
    margin: 6px 0;
    text-align: left;
}
.verdict-list { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; text-align: left; }
.verdict-row {
    background: var(--felt-raised);
    border: 1px solid var(--felt-border);
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 12px;
    color: var(--felt-text);
}
.verdict-row.sure { border-color: var(--gold); color: var(--gold); }
.hand-group { min-width: 78px; }

/* ===== v16: окно правил «📖» ===== */
.rules-overlay {
    position: fixed; inset: 0; z-index: 10010;
    background: rgba(4, 10, 6, 0.94);
    display: flex; justify-content: center; align-items: stretch;
    padding: calc(env(safe-area-inset-top, 0px) + 8px) 8px calc(env(safe-area-inset-bottom, 0px) + 8px);
}
.rules-overlay.hidden { display: none; }
.rules-panel {
    width: 100%; max-width: 620px; display: flex; flex-direction: column;
    background: var(--felt-surface); border: 1px solid var(--gold); border-radius: 14px; overflow: hidden;
}
.rules-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 12px; background: var(--felt-raised); border-bottom: 1px solid var(--felt-border);
    color: var(--gold); font-weight: bold; font-size: 16px;
}
.rules-close { background: none; border: 1px solid var(--felt-border); color: var(--felt-text); border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.rules-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px; font-size: 14px; line-height: 1.5; color: var(--felt-text); }
.rl-hero { border-left: 3px solid var(--gold); padding: 4px 0 4px 12px; margin-bottom: 14px; }
.rl-kicker { font-size: 11px; letter-spacing: 3px; color: var(--felt-muted); }
.rl-hero h2 { font-family: "Playfair Display", Georgia, serif; font-size: 26px; color: var(--gold); margin: 2px 0 6px; }
.rl-hero p { margin: 0; color: var(--felt-text); }
.rl-sec { background: var(--felt-bg); border: 1px solid var(--felt-border); border-radius: 10px; margin-bottom: 8px; }
.rl-sec[open] { border-color: var(--gold); }
.rl-sec summary { cursor: pointer; padding: 12px; font-weight: bold; font-size: 15px; list-style: none; position: relative; padding-right: 30px; }
.rl-sec summary::-webkit-details-marker { display: none; }
.rl-sec summary::after { content: '＋'; position: absolute; right: 12px; color: var(--gold); }
.rl-sec[open] summary::after { content: '－'; }
.rl-sec > *:not(summary) { margin: 0 12px 12px; }
.rl-sec h4 { color: var(--gold); font-size: 13px; margin-top: 12px; margin-bottom: 6px; }
.rl-sec p { margin-top: 0; }
.rl-steps, .rl-list { padding-left: 20px; }
.rl-steps li, .rl-list li { margin-bottom: 6px; }
.rl-steps li::marker { color: var(--gold); font-weight: bold; }
.rl-note { background: var(--felt-raised); border-radius: 8px; padding: 8px 10px; font-size: 13px; color: var(--felt-text); }
.rl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rl-card { margin: 0; text-align: center; }
.rl-card img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 6px; border: 1px solid var(--felt-border); background: #000; }
.rl-card figcaption { font-size: 11px; color: var(--felt-muted); margin-top: 2px; }
.rl-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.rl-chip { display: inline-block; background: var(--felt-raised); border: 1px solid var(--felt-border); border-radius: 6px; padding: 0 5px; font-size: 12px; }
.rl-sq { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: rgba(255, 202, 40, 0.25); border: 1px solid rgba(255, 202, 40, 0.85); vertical-align: middle; }
.rl-num { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--felt-surface); border: 2px solid var(--gold); color: var(--gold); font-size: 11px; font-weight: bold; }
.rl-tunnel { width: 34px; height: 34px; flex-shrink: 0; vertical-align: middle; }
.rl-row { display: flex; gap: 10px; align-items: center; }
.rl-row p { margin: 0; }
.rl-table { width: calc(100% - 24px); border-collapse: collapse; font-size: 13px; }
.rl-table td { padding: 6px; border-bottom: 1px solid var(--felt-border); vertical-align: middle; }
.rl-table td:first-child { width: 44px; text-align: center; font-size: 17px; }
.rl-loupes { display: flex; flex-direction: column; gap: 8px; }
.rl-loupe { display: flex; gap: 10px; align-items: center; background: var(--felt-raised); border-radius: 8px; padding: 6px; font-size: 13px; }
.rl-loupe img { width: 52px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 5px; flex-shrink: 0; background: #000; }
.lobby-rules-btn { margin-top: 10px; width: 100%; }

/* ===== v17: стиль «классический Cluedo» — чёрный, красный, слоновая кость. Поле остаётся зелёным ===== */
:root {
    --felt-bg:      #0e0b0b;   /* общий фон — почти чёрный */
    --felt-surface: #171212;   /* панели */
    --felt-raised:  #231a1a;   /* приподнятые элементы */
    --felt-border:  #3a2828;
    --felt-text:    #f2ebdd;   /* слоновая кость */
    --felt-muted:   #b2a493;
    --gold:         #f2e6c9;   /* акцент (раньше был жёлтый) — кремовый */
    --red:          #b3121b;
    --red-dark:     #6e0a10;
    --board-green:  #13301f;   /* зелёное сукно под полем */
}
html, body { background-color: var(--felt-bg); color: var(--felt-text); }

/* Шапка — чёрная, активная вкладка подчёркнута красным */
.top-nav { background: #0a0808; border-bottom: 2px solid var(--red); }
.nav-btn { color: var(--felt-muted); }
.nav-btn.active { background: #1a1111; color: var(--felt-text); border-bottom: 3px solid var(--red); }

/* Поле — на зелёном сукне, как настоящая доска */
.map-scroll-area {
    background: radial-gradient(ellipse at center, #1b4029 0%, var(--board-green) 55%, #0a1a10 100%);
}

/* Нижние панели — чёрные */
.turn-bar, .room-actions, .bottom-bar { background: #0f0c0c; border-top: 1px solid var(--felt-border); }
.turn-bar { color: var(--felt-text); }

/* Главная кнопка кубиков — красная с кремовой рамкой */
.main-roll-btn {
    background: linear-gradient(180deg, #c8161f, var(--red-dark));
    color: #fff;
    border: 2px solid var(--gold);
    letter-spacing: 2px;
    font-family: Georgia, "Times New Roman", serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    box-shadow: 0 4px 14px rgba(179, 18, 27, 0.35);
}
.main-roll-btn:disabled { background: #2a1f1f; color: var(--felt-muted); border-color: var(--felt-border); box-shadow: none; }

/* Обычные кнопки — красные, второстепенные — чёрные с кремовой рамкой */
.close-btn {
    background: linear-gradient(180deg, #c8161f, #8e0d14);
    color: #fff;
    border: 1px solid #e0404a;
    font-weight: bold;
}
.close-btn.secondary { background: #141010; color: var(--felt-text); border: 1px solid var(--gold); }
.close-btn.danger { background: #3a0508; color: #ffb3b8; border: 1px solid var(--red); }
.accuse-btn { background: #0a0808 !important; color: var(--felt-text) !important; border: 2px solid var(--red) !important; }
.room-actions button.teleport-btn { background: #141010; color: var(--felt-text); border: 1px solid var(--gold); }

/* Окна — чёрные карточки с красной рамкой, заголовки с засечками */
.dice-overlay { background: rgba(6, 3, 3, 0.9); }
.dice-card { background: var(--felt-surface); border: 2px solid var(--red); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), inset 0 0 0 1px rgba(242, 230, 201, 0.08); }
.dice-title, h2, .notebook-category h3 { font-family: "Playfair Display", Georgia, serif; color: var(--gold); letter-spacing: 1px; }
.room-code-big b { font-family: "Special Elite", monospace; letter-spacing: 8px; }
.verdict-row.sure { font-family: "Special Elite", monospace; }
.die-box { border-color: var(--red); background: #f2ebdd; color: #111; }

/* Выбор в списках — красное выделение вместо зелёного */
.pick-item.selected { border-color: var(--red); background: #3a0d10; color: #fff; }
.pick-item.selected small { color: var(--gold); }
.ask-row.active { border-color: var(--red); background: #2a0c0e; }
.ask-row.active .ask-status { color: #ff8a8f; }
.notebook-table tr.nb-hl .nb-name { color: #ff8a8f; }
.nb-me { color: var(--gold); }
.nb-fab { border-color: var(--red); background: #141010; }
.nb-panel, .rules-panel { border-color: var(--red); }
.hand-card.selected-card { outline-color: var(--red); }
.room-code-big b { color: var(--gold); }

/* Правила: главы */
.rules-head { background: #0a0808; border-bottom: 2px solid var(--red); color: var(--gold); font-family: "Playfair Display", Georgia, serif; }
.rl-hero { border-left-color: var(--red); }
.rl-sec[open] { border-color: var(--red); }
.rl-sec summary::after, .rl-steps li::marker { color: #ff5a62; }
.rl-flow {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px;
    background: #0a0808; border: 1px solid var(--felt-border); border-radius: 10px; padding: 8px; margin-bottom: 14px;
}
.rl-flow span { display: flex; flex-direction: column; align-items: center; font-size: 20px; min-width: 38px; }
.rl-flow small { font-size: 9px; color: var(--felt-muted); }
.rl-flow i { color: var(--red); font-style: normal; font-weight: bold; }
.rl-chapter { display: flex; align-items: center; gap: 10px; margin: 18px 0 8px; }
.rl-chapter-num {
    flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--red); color: #fff; font-family: "Special Elite", monospace; font-weight: bold; font-size: 14px;
}
.rl-chapter b { display: block; font-family: "Playfair Display", Georgia, serif; font-size: 17px; color: var(--gold); text-transform: uppercase; letter-spacing: 1px; }
.rl-chapter small { color: var(--felt-muted); font-size: 12px; }

/* ===== Игроки вокруг поля ===== */
.map-stage { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
