        /* ---------------- БЕРЛОГА ---------------- */
        #screen-den { overflow: hidden; background: #102d53; }
        #den-room {
            position: absolute; inset: calc(96px + max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px))) 0 75px;
            display: flex; flex-direction: column; overflow: hidden;
            background: linear-gradient(180deg, #153d65, #0b2440);
        }
        .den-room-art { display: block; flex: 1 1 62%; width: 100%; min-height: 0; object-fit: contain; object-position: center; background: #123760; }
        .den-menu-grid {
            flex: 0 0 38%; min-height: 190px; display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 7px;
            padding: 8px 10px max(8px, env(safe-area-inset-bottom, 0px));
            border-top: 2px solid rgba(175,225,255,.7);
            background: linear-gradient(180deg, rgba(28,77,119,.96), rgba(9,35,64,.98));
            box-shadow: 0 -5px 18px rgba(5,18,35,.35);
        }
        .den-menu-button {
            position: relative; z-index: 20; min-width: 0; min-height: 0;
            display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
            padding: 5px 3px; border: 1px solid #9bdafa; border-radius: 13px;
            color: #f4fbff; background: linear-gradient(155deg, #4388bd, #24547f 65%, #163e65);
            box-shadow: 0 3px 0 #0c2c4c, 0 5px 9px rgba(0,0,0,.26), inset 0 1px 0 rgba(255,255,255,.3);
            font-family: inherit; font-size: clamp(10px, 3vw, 13px); font-weight: 900;
            line-height: 1.05; text-align: center; text-shadow: 0 1px 2px #102e4b;
            cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
        }
        .den-menu-button:active { transform: translateY(2px); box-shadow: 0 1px 0 #0c2c4c, inset 0 1px 0 rgba(255,255,255,.3); }
        .den-menu-button:focus-visible { outline: 3px solid #ffe18a; outline-offset: 2px; }
        .den-menu-icon { font-size: clamp(19px, 6vw, 27px); line-height: 1; }
        .den-menu-admin { grid-column: 1 / -1; flex-direction: row; gap: 9px; font-size: 14px; background: linear-gradient(100deg, #946434, #d39a4d 48%, #80552d); border-color: #ffe1a2; box-shadow: 0 3px 0 #50351e, 0 5px 9px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.34); }
        .den-menu-admin .den-menu-icon { font-size: 22px; }
        .den-clan-mark { width: 27px; height: 27px; display: grid; place-items: center; border: 2px solid #d9f4ff; border-radius: 6px 6px 12px 12px; color: #fff; background: linear-gradient(#75caff,#2267a7); font-size: 18px; }
        .den-clan-emblem { position: absolute; top: 5px; width: 27px; height: 27px; object-fit: contain; }
        .den-clan-emblem[hidden] { display: none; }
        @media (max-height: 680px) { .den-menu-grid { flex-basis: 43%; min-height: 174px; gap: 5px; padding: 6px 8px; } }
        .den-hotspot {
            position: absolute; z-index: 20; display: block; padding: 0;
            border: 0; border-radius: 12px; background: transparent; cursor: pointer;
            touch-action: manipulation; -webkit-tap-highlight-color: transparent;
        }
        .den-hotspot:hover { background: rgba(147,197,253,0.14); box-shadow: inset 0 0 0 2px rgba(191,219,254,0.65); }
        .den-hotspot:focus-visible { outline: 3px solid #fde68a; outline-offset: 2px; background: rgba(147,197,253,0.18); }
        .den-inventory { left: 1%; top: 44.75%; width: 24%; height: 14.25%; }
        .den-quests { left: 18%; top: 31.25%; width: 24%; height: 15%; }
        .den-achievements { left: 60%; top: 31.25%; width: 22%; height: 23.25%; }
        .den-promo { right: 0; top: 32%; width: 19%; height: 15%; }
        .den-mail { right: 0; top: 46.25%; width: 20%; height: 14.25%; }
        .den-stats { left: 38%; top: 69.5%; width: 30%; height: 9%; }
        .den-admin-entry { position: absolute; z-index: 50; left: 51%; top: 29%; width: 10%; height: 10%; min-width: 48px; min-height: 48px; padding: 2px; transform: translateX(-50%); border: 0; border-radius: 10px; background: transparent; cursor: pointer; pointer-events: auto; filter: drop-shadow(0 3px 4px rgba(0,0,0,.55)); transition: transform .16s ease, filter .16s ease; }
        .den-admin-entry img { display: block; width: 100%; height: 100%; object-fit: contain; }
        .den-admin-entry:hover { transform: translateX(-50%) scale(1.08); filter: drop-shadow(0 0 8px rgba(255,212,104,.9)); }
        .den-admin-entry:active { transform: translateX(-50%) scale(.95); }
        .den-admin-entry:focus-visible { outline: 3px solid #ffe4a1; outline-offset: 2px; }

        .den-modal {
            position: absolute; inset: 0; z-index: 680; display: none;
            justify-content: center; align-items: center; padding: 14px;
            background: rgba(3,14,32,0.72); backdrop-filter: blur(3px);
        }
        .den-modal.show { display: flex; }
        .den-modal-card {
            width: min(100%, 560px); max-height: min(86%, 720px); min-height: 180px;
            display: flex; flex-direction: column; gap: 10px; overflow: hidden;
            padding: clamp(12px, 3vw, 20px); color: #eff6ff;
            background: linear-gradient(155deg, rgba(18,48,82,0.98), rgba(10,28,51,0.98));
            border: 2px solid #f4bd64; border-radius: 20px;
            box-shadow: 0 5px 0 #7c4b22, 0 14px 34px rgba(0,0,0,0.55), inset 0 0 0 2px rgba(147,197,253,0.28);
        }
        .den-modal-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
        .den-modal-title { margin: 0; color: #ffdf9b; font-size: clamp(19px, 5vw, 25px); font-weight: 900; text-shadow: 0 2px 0 #6b421f; }
        .den-close {
            flex: none; width: 38px; height: 38px; border: 2px solid #f4bd64; border-radius: 12px;
            background: #234b73; color: #fff; font-family: inherit; font-weight: 900; font-size: 18px; cursor: pointer;
        }
        .den-tabs { flex: none; display: flex; gap: 7px; overflow-x: auto; padding: 1px 1px 5px; touch-action: pan-x; }
        .den-tabs:empty { display: none; }
        .den-tab {
            flex: none; max-width: 180px; border: 1px solid #6ea2d7; border-radius: 999px; padding: 7px 11px;
            color: #dbeafe; background: rgba(37,75,115,0.9); font-family: inherit; font-weight: 800; font-size: 12px; cursor: pointer;
        }
        .den-tab.active { color: #39220c; border-color: #ffe0a1; background: linear-gradient(#ffe5ae,#d99a4f); }
        .den-modal-body { min-height: 0; flex: 1 1 auto; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 1px 4px 3px 1px; touch-action: pan-y; overscroll-behavior: contain; }
        .den-modal-body::-webkit-scrollbar { width: 5px; }
        .den-modal-body::-webkit-scrollbar-thumb { border-radius: 9px; background: #6ea2d7; }
        .den-back { flex: none; width: 100%; border: 1px solid #83b5e8; border-radius: 12px; padding: 10px; color: #fff; background: #234b73; font-family: inherit; font-weight: 900; font-size: 14px; cursor: pointer; }
        .den-note { padding: 9px 11px; border: 1px solid rgba(147,197,253,0.45); border-radius: 12px; color: #c8ddf5; background: rgba(18,43,72,0.8); font-size: 12px; line-height: 1.4; }
        .den-list { display: flex; flex-direction: column; gap: 8px; }
        .den-card { padding: 11px; border: 1px solid #719bc2; border-radius: 14px; color: #eff6ff; background: linear-gradient(135deg,rgba(39,76,113,0.98),rgba(20,48,78,0.98)); }
        .den-card.is-done { border-color: #e9be72; background: linear-gradient(135deg,rgba(94,73,48,0.94),rgba(30,59,82,0.98)); }
        .den-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
        .den-card h3 { margin: 0 0 3px; color: #ffe2a8; font-size: 15px; font-weight: 900; }
        .den-card p { margin: 0; color: #d9e8f8; font-size: 12px; line-height: 1.35; }
        .den-status { flex: none; border-radius: 999px; padding: 4px 7px; background: rgba(11,26,45,0.7); color: #c5def6; font-size: 10px; font-weight: 900; }
        .den-card.is-done .den-status { color: #ffe2a8; }
        .den-progress-label { display: flex; justify-content: space-between; gap: 8px; margin: 10px 0 5px; font-size: 11px; color: #d6e8f9; }
        .den-progress-label b { text-align: right; color: #ffe2a8; }
        .den-progress { height: 8px; overflow: hidden; border: 1px solid rgba(191,219,254,0.6); border-radius: 99px; background: rgba(4,18,35,0.72); }
        .den-progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#43c8ff,#a9eeff); box-shadow: 0 0 10px #68d9ff; }
        .den-action { flex: none; border: 0; border-radius: 10px; margin-top: 9px; padding: 9px 12px; color: #2e220d; background: linear-gradient(#ffe6ab,#dfa14f); box-shadow: 0 3px 0 #825225; font-family: inherit; font-weight: 900; font-size: 13px; cursor: pointer; }
        .den-action:active, .den-back:active { transform: translateY(2px); }
        .den-summary { display: flex; align-items: baseline; gap: 8px; padding: 11px; border-radius: 13px; color: #d9eafb; background: rgba(33,72,110,0.9); }
        .den-summary b { color: #ffe2a8; font-size: 21px; }
        .den-stat-highlight { display: flex; justify-content: space-between; gap: 8px; padding: 13px; border: 1px solid #f0bd67; border-radius: 14px; background: linear-gradient(120deg,#75512d,#284e73); font-weight: 800; }
        .den-stat-highlight b { color: #fff0c5; }
        .den-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
        .den-stat { min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 9px; border: 1px solid rgba(126,169,210,0.55); border-radius: 11px; background: rgba(22,52,82,0.9); }
        .den-stat span { color: #bed6ed; font-size: 11px; line-height: 1.3; }
        .den-stat b { color: #fff; font-size: 13px; overflow-wrap: anywhere; }
        .den-modal-body.den-stats-body { overflow: hidden; gap: 0; touch-action: none; }
        .den-stats-body .den-stat-grid { flex: 1; min-height: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(7, minmax(0, 1fr)); align-content: stretch; }
        .den-stats-body .den-stat { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; }
        .den-stats-body .den-stat span { flex: 1; min-width: 0; }
        .den-stats-body .den-stat b { flex: none; text-align: right; }
        .den-stats-body .den-stat-total { border-color: #f0bd67; background: linear-gradient(120deg,rgba(117,81,45,.92),rgba(40,78,115,.96)); }
        .den-stats-body .den-stat-total b { color: #fff0c5; }
        @media (max-height: 620px) {
            .den-stats-body .den-stat { gap: 2px; padding: 4px 7px; }
            .den-stats-body .den-stat span { font-size: 10px; }
            .den-stats-body .den-stat b { font-size: 12px; }
        }
        .den-empty { min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 20px; text-align: center; color: #d6e8f9; }
        .den-empty b { color: #ffe2a8; font-size: 17px; }
        .den-empty p { max-width: 390px; margin: 0; color: #bed6ed; font-size: 13px; line-height: 1.5; }
        .den-empty-icon { font-size: 34px; }
        .den-label { color: #ffe2a8; font-weight: 900; }
        .den-promo-row { display: flex; gap: 7px; align-items: stretch; }
        .den-promo-row input { flex: 1; min-width: 0; border: 1px solid #83b5e8; border-radius: 10px; padding: 9px 10px; color: #122b45; background: #f3f8ff; font-family: inherit; font-weight: 800; font-size: 15px; text-transform: uppercase; touch-action: auto; user-select: text; }
        .den-promo-row .den-action { margin: 0; }
        .den-message { min-height: 20px; color: #ffe2a8; font-weight: 800; font-size: 13px; }
        .leaderboard-modal { z-index: 690; }
        .admin-modal { z-index: 700; }
        .admin-modal-card { gap: 12px; border-color: #f4bd64; }
        .admin-kicker { margin-bottom: 3px; color: #94d7ff; font-size: 9px; font-weight: 1000; letter-spacing: 1.5px; }
        .admin-preview-note { flex: none; display: flex; flex-direction: column; gap: 3px; padding: 9px 11px; border: 1px solid rgba(255,215,130,.55); border-radius: 12px; color: #f6e6c2; background: rgba(109,75,34,.42); font-size: 11px; line-height: 1.35; }
        .admin-preview-note b { color: #ffe3a6; font-size: 12px; }
        .admin-tabs { flex: none; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
        .admin-tab { flex: 1 0 auto; border: 1px solid #638bb1; border-radius: 11px; padding: 8px 10px; color: #cfe5f9; background: #183956; font-family: inherit; font-size: 12px; font-weight: 800; cursor: pointer; }
        .admin-tab.active { border-color: #ffe0a1; color: #412b10; background: linear-gradient(#ffe5ae,#d99a4f); }
        .admin-panel-content { min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; }
        .admin-panel { display: none; flex-direction: column; gap: 11px; }
        .admin-panel.active { display: flex; }
        .admin-welcome { display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid #6095bd; border-radius: 15px; background: linear-gradient(130deg,rgba(36,83,121,.95),rgba(25,54,85,.95)); }
        .admin-crown { width: 45px; height: 45px; display: grid; place-items: center; flex: none; border-radius: 14px; color: #69420e; background: linear-gradient(145deg,#fff0b4,#e7a849); font-size: 30px; box-shadow: 0 3px 0 #815522; }
        .admin-welcome div:last-child { display: flex; flex-direction: column; gap: 3px; }
        .admin-welcome b { color: #ffe2a8; font-size: 16px; }
        .admin-welcome span,.admin-activity span { color: #c7dcef; font-size: 11px; }
        .admin-stat-cards { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; }
        .admin-stat-cards article { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 10px 8px; border: 1px solid rgba(126,169,210,.55); border-radius: 12px; background: rgba(22,52,82,.9); }
        .admin-stat-cards article span { color: #bed6ed; font-size: 10px; }
        .admin-stat-cards article b { color: #ffe2a8; font-size: 21px; }
        .admin-stat-cards article small { color: #9fb9d1; font-size: 9px; line-height: 1.2; }
        .admin-section-title { color: #ffe2a8; font-size: 14px; font-weight: 900; }
        .admin-shortcuts { display: flex; flex-direction: column; gap: 7px; }
        .admin-shortcuts button { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid #5985ac; border-radius: 12px; color: #e6f3ff; background: rgba(34,70,105,.9); font-family: inherit; font-size: 12px; font-weight: 800; text-align: left; cursor: pointer; }
        .admin-shortcuts button span { width: 28px; text-align: center; font-size: 21px; }
        .admin-activity,.admin-message-preview { display: flex; flex-direction: column; gap: 5px; padding: 11px; border: 1px dashed rgba(143,183,216,.55); border-radius: 12px; color: #e8f4ff; background: rgba(11,31,52,.55); font-size: 11px; }
        .admin-activity-link { width: 100%; text-align: left; cursor: pointer; font-family: inherit; }
        .admin-history-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
        .admin-history-table { overflow: hidden; border: 1px solid rgba(126,169,210,.55); border-radius: 12px; background: rgba(22,52,82,.75); }
        .admin-history-head { display: grid; grid-template-columns: .9fr 1fr 1.1fr 1fr; gap: 5px; padding: 9px; color: #ffe2a8; background: rgba(12,31,51,.7); font-size: 10px; font-weight: 900; }
        .admin-history-empty { padding: 22px 12px; color: #bed6ed; font-size: 11px; line-height: 1.45; text-align: center; }
        .admin-player-preview { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid rgba(126,169,210,.55); border-radius: 12px; color: #d9eafb; background: rgba(22,52,82,.9); }
        .admin-player-avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: #335b7e; font-size: 20px; }
        .admin-player-preview span:last-child { display: flex; flex-direction: column; gap: 3px; }
        .admin-player-preview b { color: #ffe2a8; font-size: 12px; }
        .admin-player-preview small { color: #a9c4dc; font-size: 10px; }
        .admin-sanction-button { background: linear-gradient(#ffc781,#d46a47); box-shadow: 0 3px 0 #823d2c; color: #fff6eb; }
        .admin-field { display: flex; flex-direction: column; gap: 5px; color: #bed6ed; font-size: 11px; font-weight: 800; }
        .admin-field input,.admin-field select,.admin-field textarea { width: 100%; min-width: 0; border: 1px solid #6d9bc3; border-radius: 10px; padding: 10px; color: #17324a; background: #eff7ff; font-family: inherit; font-size: 13px; font-weight: 700; outline: none; }
        .admin-field textarea { resize: vertical; min-height: 88px; }
        .admin-fields-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
        .admin-primary { width: 100%; border: 0; border-radius: 12px; padding: 11px; color: #4a3a1e; background: linear-gradient(#ffe5ae,#d99a4f); box-shadow: 0 3px 0 #805323; font-family: inherit; font-size: 13px; font-weight: 900; }
        .admin-primary:disabled { opacity: .58; cursor: not-allowed; }
        .admin-form-hint { color: #a9c4dc; font-size: 10px; line-height: 1.35; }
        .admin-modal-footer { flex: none; display: flex; align-items: center; gap: 7px; color: #b9d0e4; font-size: 10px; }
        .admin-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #f0bd67; box-shadow: 0 0 8px rgba(240,189,103,.65); }

        @media (max-width: 420px) {
            .den-modal { padding: 9px; }
            .den-modal-card { max-height: 84%; border-radius: 16px; }
            .den-card { padding: 9px; }
            .den-card h3 { font-size: 14px; }
            .den-card p { font-size: 11px; }
            .den-progress-label { font-size: 10px; }
            .den-stat-grid { grid-template-columns: 1fr 1fr; }
            .den-tab { font-size: 11px; }
            .admin-modal-card { gap: 9px; padding: 11px; }
            .admin-tab { padding: 7px 8px; font-size: 11px; }
            .admin-welcome { padding: 10px; }
        }

        /* Берлога-разделы работают как самостоятельные страницы, а не всплывающие окна. */
        .den-modal {
            position: absolute; inset: 0 0 75px; z-index: 80; display: none;
            justify-content: center; align-items: stretch; overflow: hidden;
            padding: calc(96px + max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px))) 12px 12px;
            background: linear-gradient(180deg, #153d65, #0b2440);
        }
        .den-modal.show { display: flex; }
        .den-modal-card, #admin-modal .admin-modal-card {
            width: min(100%, 720px); height: 100%; max-height: none; min-height: 0;
            display: flex; flex-direction: column; gap: 10px; overflow: hidden;
            margin: 0 auto; padding: 0; color: #eff6ff;
            border: 0; border-radius: 0; background: transparent; box-shadow: none;
        }
        .den-modal-head {
            flex: none; min-height: 54px; padding: 8px 10px;
            border: 1px solid rgba(155,218,250,.8); border-radius: 14px;
            background: linear-gradient(145deg, rgba(45,101,148,.98), rgba(20,57,91,.98));
            box-shadow: 0 3px 0 rgba(7,29,51,.65);
        }
        .page-back {
            flex: none; min-height: 38px; border: 1px solid #b9e8ff; border-radius: 11px;
            padding: 7px 11px; color: #f4fbff; background: linear-gradient(#4388bd,#24547f);
            box-shadow: 0 2px 0 #123b60; font-family: inherit; font-size: 12px; font-weight: 900; cursor: pointer;
        }
        .page-back:active { transform: translateY(1px); box-shadow: 0 1px 0 #123b60; }
        .den-modal-body { flex: 1 1 auto; min-height: 0; }
        #den-modal[data-section="quests"] .den-modal-body { overflow: hidden; }
        #den-modal[data-section="quests"] .den-list { flex: 1 1 auto; min-height: 0; display: grid; grid-template-rows: repeat(5, minmax(0, 1fr)); gap: 5px; }
        #den-modal[data-section="quests"] .den-card { min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 5px 8px; }
        #den-modal[data-section="quests"] .den-card h3 { margin-bottom: 1px; font-size: 13px; }
        #den-modal[data-section="quests"] .den-card p { font-size: 10px; line-height: 1.2; }
        #den-modal[data-section="quests"] .den-status { padding: 3px 5px; font-size: 9px; }
        #den-modal[data-section="quests"] .den-progress-label { margin: 2px 0 1px; font-size: 9px; }
        #den-modal[data-section="quests"] .den-progress { height: 5px; }
        #den-modal[data-section="quests"] .den-action { margin-top: 2px; padding: 4px 8px; font-size: 10px; }
        #admin-modal .admin-panel-content { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
        #admin-modal .admin-modal-footer { flex: none; }
        @media (max-width: 420px) {
            .den-modal { padding: calc(96px + max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px))) 9px 9px; }
            .den-modal-head { gap: 6px; padding: 7px; }
            .page-back { min-height: 36px; padding: 6px 8px; font-size: 11px; }
        }
        @media (max-height: 700px) {
            #den-modal[data-section="quests"] .den-modal-card { gap: 6px; }
            #den-modal[data-section="quests"] .den-modal-head { min-height: 44px; padding: 5px 8px; }
            #den-modal[data-section="quests"] .den-modal-body { gap: 4px; }
            #den-modal[data-section="quests"] .den-card { padding: 3px 6px; }
            #den-modal[data-section="quests"] .den-card h3 { font-size: 12px; }
            #den-modal[data-section="quests"] .den-card p { font-size: 9px; }
        }
        @media (max-height: 620px) {
            #den-modal[data-section="quests"] .den-card p { display: none; }
            #den-modal[data-section="quests"] .den-card { gap: 2px; }
            #den-modal[data-section="quests"] .den-action { padding: 3px 7px; }
        }
