* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #1e2a1e;
    --panel: #2b3a2b;
    --panel-light: #384938;
    --accent: #8bc34a;
    --gold: #ffd54f;
    --text: #e8f0e0;
    --text-dim: #a7b8a0;
    --danger: #ef5350;
}

html, body {
    height: 100%;
    font-family: "Segoe UI", "Trebuchet MS", Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ── Верхняя панель ─────────────────────────────── */

#topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: var(--panel);
    border-bottom: 2px solid #00000040;
    flex: 0 0 auto;
    z-index: 5;
}

.logo {
    font-size: 20px;
    font-weight: bold;
}

.topbar-center {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 18px;
    font-weight: bold;
    background: var(--panel-light);
    padding: 6px 14px;
    border-radius: 20px;
}

#coins-value {
    color: var(--gold);
}

button {
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--panel-light);
    border: 1px solid #ffffff22;
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

button:hover {
    background: #465846;
}

button:active {
    transform: scale(0.96);
}

#expand-btn {
    background: #33691e;
    font-weight: bold;
}

#expand-btn:hover {
    background: #3f7d26;
}

#expand-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#sell-mode-btn.active {
    background: var(--danger);
    border-color: #fff5;
}

/* ── Основная область ───────────────────────────── */

#main {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

#field-wrap {
    flex: 1 1 auto;
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

#field {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Подсказка управления */
#controls-hint {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: #00000080;
    color: var(--text);
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 12.5px;
    pointer-events: none;
    white-space: nowrap;
    max-width: 95%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Чип выбранного товара / режима сноса */
#selection-chip {
    position: absolute;
    top: 48px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    background: #1b5e20e6;
    border: 1px solid var(--accent);
    color: var(--text);
    padding: 7px 8px 7px 16px;
    border-radius: 18px;
    font-size: 13px;
    z-index: 4;
    white-space: nowrap;
}

#selection-chip.hidden {
    display: none;
}

#chip-cancel {
    padding: 2px 9px;
    border-radius: 50%;
    font-size: 12px;
    line-height: 1.4;
}

/* ── Меню с иконками ────────────────────────────── */

#menu-bar {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    background: #1c281cdd;
    border: 1px solid #ffffff20;
    border-radius: 18px;
    padding: 8px 10px;
    z-index: 4;
    backdrop-filter: blur(4px);
}

.menu-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 78px;
    padding: 8px 10px;
    border-radius: 12px;
    background: transparent;
    border: 1px solid transparent;
}

.menu-btn:hover {
    background: #38493880;
}

.menu-btn.active {
    background: var(--panel-light);
    border-color: var(--accent);
}

.menu-icon {
    font-size: 26px;
    line-height: 1.1;
}

.menu-label {
    font-size: 11.5px;
    color: var(--text-dim);
}

.menu-btn.active .menu-label {
    color: var(--text);
}

.badge {
    position: absolute;
    top: 2px;
    right: 6px;
    background: var(--danger);
    color: #fff;
    font-size: 10.5px;
    font-style: normal;
    font-weight: bold;
    border-radius: 10px;
    padding: 1px 6px;
    pointer-events: none;
}

.badge.hidden {
    display: none;
}

/* Всплывающее уведомление */
#toast {
    position: absolute;
    bottom: 92px;
    left: 50%;
    transform: translateX(-50%);
    background: #000000cc;
    color: var(--text);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 15px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    white-space: nowrap;
    z-index: 6;
}

#toast.show {
    opacity: 1;
}

/* ── Выезжающая панель ──────────────────────────── */

#panel {
    flex: 0 0 0;
    width: 0;
    background: var(--panel);
    border-left: 2px solid #00000040;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: flex-basis 0.22s ease, width 0.22s ease;
}

#panel.open {
    flex: 0 0 340px;
    width: 340px;
}

#panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px 10px;
    flex: 0 0 auto;
}

#panel-title {
    font-size: 18px;
    white-space: nowrap;
}

#panel-close {
    padding: 4px 10px;
    border-radius: 8px;
}

#panel-body {
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 14px 14px;
    min-width: 310px;
}

.panel-summary {
    background: var(--panel-light);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 12.5px;
    color: var(--text-dim);
    line-height: 1.5;
}

.panel-summary b {
    color: var(--text);
}

.panel-section {
    font-size: 14px;
    margin-top: 4px;
}

.panel-empty {
    color: var(--text-dim);
    font-size: 13px;
    line-height: 1.6;
    padding: 8px 4px;
}

.panel-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Вкладки магазина ───────────────────────────── */

#shop-tabs {
    display: flex;
    gap: 6px;
}

.tab {
    flex: 1;
    padding: 8px 2px;
    font-size: 12px;
    border-radius: 8px 8px 0 0;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}

.tab.active {
    background: var(--panel-light);
    border-bottom-color: var(--accent);
    font-weight: bold;
}

/* ── Карточки (магазин/гардероб/склад/кухня) ────── */

.shop-item {
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--panel-light);
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.shop-item.static {
    cursor: default;
}

.shop-item:not(.static):hover {
    background: #465846;
}

.shop-item.selected {
    border-color: var(--accent);
    background: #3c5a2e;
}

.shop-item.locked {
    opacity: 0.45;
}

.shop-item.locked .mini-btn {
    pointer-events: none;
}

.shop-item .icon {
    font-size: 30px;
    flex: 0 0 auto;
}

.shop-item .info {
    flex: 1 1 auto;
    min-width: 0;
}

.shop-item .name {
    font-weight: bold;
    font-size: 14px;
}

.shop-item .name .qty {
    color: var(--gold);
    font-weight: bold;
}

.shop-item .props {
    font-size: 11.5px;
    color: var(--text-dim);
    line-height: 1.45;
    margin-top: 2px;
}

.shop-item .price {
    color: var(--gold);
    font-weight: bold;
    font-size: 13.5px;
    white-space: nowrap;
}

.row-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 0 0 auto;
}

.mini-btn {
    font-size: 11.5px;
    padding: 5px 9px;
    border-radius: 7px;
    white-space: nowrap;
}

.mini-btn.strong {
    background: #33691e;
    font-weight: bold;
}

.mini-btn.strong:hover {
    background: #3f7d26;
}

/* Ингредиенты рецептов */
.ing-ok {
    color: var(--accent);
}

.ing-no {
    color: var(--danger);
}

/* Прогресс крафта */
.craft-bar {
    margin-top: 6px;
    height: 8px;
    border-radius: 4px;
    background: #1b2a1b;
    overflow: hidden;
}

.craft-fill {
    display: block;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #8bc34a, #ffd54f);
    border-radius: 4px;
    transition: width 0.4s linear;
}

/* Скроллбар панели */
#panel-body::-webkit-scrollbar {
    width: 6px;
}

#panel-body::-webkit-scrollbar-thumb {
    background: #ffffff30;
    border-radius: 3px;
}

@media (max-width: 800px) {
    #main {
        flex-direction: column;
    }
    #panel {
        width: 100%;
        border-left: none;
        border-top: 2px solid #00000040;
        transition: flex-basis 0.22s ease;
    }
    #panel.open {
        flex: 0 0 45%;
        width: 100%;
    }
    #panel-body {
        min-width: 0;
    }
    .menu-label {
        display: none;
    }
    .menu-btn {
        min-width: 52px;
    }
}

/* ── Апдейт: кристаллы, заказы, настройки, рыбалка ─────────── */
.gem-stat #gems-value {
    color: #4fc3f7;
    font-weight: bold;
}

.mini-btn.gem {
    background: #155a8a;
    color: #cfeaff;
    font-weight: bold;
    margin-top: 5px;
}

.mini-btn.gem:hover {
    background: #1a6da6;
}

/* Кнопка разблокировки за 💎 кликабельна даже на «закрытом» товаре */
.shop-item.locked .mini-btn.gem {
    pointer-events: auto;
    opacity: 1;
}

.mini-btn:disabled {
    opacity: 0.45;
    pointer-events: none;
}

/* Переназначение клавиш */
.key-btn {
    min-width: 86px;
    text-align: center;
    background: #2e4630;
    border: 1px solid #5b7a52;
    font-weight: bold;
}

.key-btn.waiting {
    background: #7a5b18;
    border-color: var(--gold);
    animation: keypulse 0.9s infinite alternate;
}

@keyframes keypulse {
    from { box-shadow: 0 0 0 0 #ffd54f55; }
    to { box-shadow: 0 0 0 6px #ffd54f22; }
}

/* Слайдер чувствительности камеры */
.sens-range {
    width: 130px;
    accent-color: var(--accent);
}

/* ── Апдейт v5: топливо, карта, торговцы, работники, кухня ── */

.fuel-stat #fuel-value {
    color: #ffab91;
    font-weight: bold;
}

/* Полноэкранные оверлеи (карта / лобби торговца / поездка) */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: var(--bg);
    display: flex;
    flex-direction: column;
}

.overlay.hidden {
    display: none;
}

.overlay-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    background: var(--panel);
    border-bottom: 2px solid #00000040;
    flex: 0 0 auto;
}

.overlay-head h2 {
    font-size: 19px;
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.overlay-stats {
    display: flex;
    gap: 12px;
    font-size: 15px;
    background: var(--panel-light);
    padding: 6px 14px;
    border-radius: 18px;
    white-space: nowrap;
}

.overlay-stats .ov-coins { color: var(--gold); }
.overlay-stats .ov-fuel { color: #ffab91; }

.overlay-close {
    font-weight: bold;
    background: #5d4037;
}

/* Карта окрестностей */
#map-canvas {
    position: relative;
    flex: 1 1 auto;
    margin: 14px;
    border-radius: 16px;
    overflow: hidden;
    background:
        radial-gradient(circle at 30% 20%, #4e8a3c 0%, transparent 45%),
        radial-gradient(circle at 75% 70%, #3d7733 0%, transparent 50%),
        linear-gradient(160deg, #558b46 0%, #3e7032 55%, #356329 100%);
    border: 2px solid #00000035;
}

#map-roads {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

#map-roads path {
    fill: none;
    stroke: #d7c08a;
    stroke-width: 1.1;
    stroke-dasharray: 2.2 1.6;
    stroke-linecap: round;
    opacity: 0.85;
}

.map-node {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    text-align: center;
    z-index: 2;
    transition: transform 0.15s;
}

.map-node:hover {
    transform: translate(-50%, -50%) scale(1.08);
}

.map-node .node-icon {
    font-size: 44px;
    line-height: 1;
    background: #1c281cd9;
    border: 2px solid #ffffff30;
    border-radius: 50%;
    padding: 14px;
    box-shadow: 0 4px 14px #00000060;
}

.map-node:hover .node-icon {
    border-color: var(--gold);
}

.map-node .node-label {
    background: #000000a8;
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 12.5px;
    font-weight: bold;
    line-height: 1.35;
}

.map-node .node-label i {
    font-weight: normal;
    color: var(--text-dim);
    font-size: 11px;
}

.map-node .node-sub {
    background: #00000080;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 11px;
    color: var(--text-dim);
    max-width: 190px;
}

.farm-node .node-icon {
    border-color: var(--accent);
}

/* Узел «вы здесь» — некликабельный, подсвечен */
.map-node.here {
    cursor: default;
}

.map-node.here:hover {
    transform: translate(-50%, -50%);
}

.map-node.here .node-icon {
    border-color: var(--gold);
    box-shadow: 0 0 18px #ffd54f80, 0 4px 14px #00000060;
}

.map-node.here .node-sub {
    color: var(--gold);
    font-weight: bold;
}

/* Поездка */
#travel-overlay {
    background: #142014ee;
    align-items: center;
    justify-content: center;
}

.travel-inner {
    text-align: center;
}

.travel-tractor {
    font-size: 64px;
    animation: travel-bounce 0.5s infinite alternate ease-in-out;
}

@keyframes travel-bounce {
    from { transform: translateX(-30px) rotate(-2deg); }
    to { transform: translateX(30px) rotate(2deg); }
}

#travel-text {
    margin-top: 14px;
    font-size: 17px;
    color: var(--text-dim);
}

/* Лобби торговца */
#trader-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 980px;
    width: 100%;
    margin: 0 auto;
}

.trader-greet {
    display: flex;
    gap: 16px;
    align-items: center;
    background: var(--panel);
    border-radius: 14px;
    padding: 14px 18px;
}

.trader-avatar {
    font-size: 52px;
    background: var(--panel-light);
    border-radius: 50%;
    padding: 12px;
    line-height: 1;
}

.trader-greet p {
    color: var(--text-dim);
    font-size: 13.5px;
    margin-top: 4px;
    font-style: italic;
}

.trader-cols {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.trader-col {
    flex: 1 1 0;
    background: var(--panel);
    border-radius: 14px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.trader-col h3 {
    font-size: 15px;
    padding: 2px 4px 6px;
}

@media (max-width: 720px) {
    .trader-cols { flex-direction: column; }
    .trader-col { width: 100%; }
}

/* Кухня: сцена с поварихой */
.kitchen-scene {
    position: relative;
    flex: 0 0 auto;               /* B1: не даём панели сжимать сцену — повариха была видна наполовину */
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(180deg, #3a4a3a 0%, #2e3d2e 70%, #243224 100%);
    border-radius: 12px;
    padding: 22px 10px 12px;
    overflow: hidden;
}

.cook {
    font-size: 42px;
    line-height: 1.35;            /* эмодзи выше строки — не режем макушку */
    padding-top: 4px;
    transform-origin: 50% 90%;
    animation: cook-idle 2.8s infinite ease-in-out; /* дышит даже без готовки */
}

@keyframes cook-idle {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-2px) rotate(-2deg); }
}

.kitchen-scene.cooking .cook {
    animation: cook-bob 0.8s infinite ease-in-out;
}

@keyframes cook-bob {
    0%, 100% { transform: rotate(-4deg) translateY(0); }
    50% { transform: rotate(4deg) translateY(-3px); }
}

.stove-block {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stove-pan {
    font-size: 26px;
    line-height: 1;
    margin-bottom: -4px;
    z-index: 1;
}

.kitchen-scene.cooking .stove-pan {
    animation: pan-flip 1.1s infinite ease-in-out;
}

@keyframes pan-flip {
    0%, 100% { transform: translateY(0) rotate(0); }
    30% { transform: translateY(-7px) rotate(-12deg); }
    60% { transform: translateY(0) rotate(4deg); }
}

.stove-body {
    width: 74px;
    height: 44px;
    background: #455a64;
    border-radius: 7px 7px 4px 4px;
    border: 2px solid #263238;
    position: relative;
}

.stove-body::before, .stove-body::after {
    content: "";
    position: absolute;
    top: 6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #263238;
    box-shadow: inset 0 0 0 3px #37474f;
}

.stove-body::before { left: 8px; }
.stove-body::after { right: 8px; }

.kitchen-scene.cooking .stove-body::before {
    background: radial-gradient(circle, #ff7043 30%, #263238 75%);
}

.stove-steam {
    position: absolute;
    bottom: 58px;
    font-size: 16px;
    opacity: 0;
    pointer-events: none;
}

.kitchen-scene.cooking .stove-steam {
    animation: steam-rise 1.6s infinite ease-out;
}

.stove-steam.s2 { animation-delay: 0.55s !important; margin-left: 16px; }
.stove-steam.s3 { animation-delay: 1.1s !important; margin-left: -16px; }

@keyframes steam-rise {
    0% { opacity: 0; transform: translateY(0) scale(0.7); }
    25% { opacity: 0.85; }
    100% { opacity: 0; transform: translateY(-34px) scale(1.25); }
}

.cook-status {
    position: absolute;
    top: 8px;
    left: 10px;
    background: #00000070;
    border-radius: 9px;
    padding: 3px 9px;
    font-size: 11.5px;
    color: var(--text-dim);
}

.stove-level-tag {
    position: absolute;
    top: 8px;
    right: 10px;
    background: #00000070;
    border-radius: 9px;
    padding: 3px 9px;
    font-size: 11.5px;
    color: var(--gold);
    font-weight: bold;
}

/* ════════════════════════════════════════════════════════════
   Апдейт v5 (тред B): красота лобби-панелей 💅
   — градиенты, акценты по типу панели, новые элементы
   ════════════════════════════════════════════════════════════ */

#panel {
    background: linear-gradient(170deg, #2e3f2e 0%, #283628 55%, #243024 100%);
    box-shadow: inset 2px 0 8px #00000033;
}

#panel-head {
    background: linear-gradient(180deg, #ffffff10, transparent);
    border-bottom: 1px solid #ffffff14;
    margin-bottom: 4px;
}

#panel-title {
    text-shadow: 0 2px 6px #00000066;
}

.panel-summary {
    background: linear-gradient(145deg, #3c4f3c, #344434);
    border: 1px solid #ffffff12;
    box-shadow: 0 2px 6px #00000028;
}

.panel-section {
    letter-spacing: 0.4px;
    border-bottom: 1px solid #ffffff14;
    padding-bottom: 4px;
}

.shop-item {
    background: linear-gradient(145deg, #3a4c3a, #324232);
    border: 1px solid #ffffff10;
    box-shadow: 0 2px 5px #00000022;
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.shop-item:not(.static):hover,
.shop-item.static:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px #00000033;
    border-color: #ffffff22;
}

/* Акцентные полоски слева у карточек — цвет зависит от панели */
#panel[data-panel] .shop-item { border-left: 3px solid #ffffff18; }
#panel[data-panel="shop"] .shop-item { border-left-color: #8bc34a88; }
#panel[data-panel="orders"] .shop-item { border-left-color: #ffd54f88; }
#panel[data-panel="petshop"] .shop-item { border-left-color: #f48fb188; }
#panel[data-panel="bridge"] .shop-item { border-left-color: #90caf988; }
#panel[data-panel="kitchen"] .shop-item { border-left-color: #ffab9188; }
#panel[data-panel="wardrobe"] .shop-item { border-left-color: #ce93d888; }
#panel[data-panel="warehouse"] .shop-item { border-left-color: #bcaaa488; }
#panel[data-panel="settings"] .shop-item { border-left-color: #b0bec588; }

/* Полоса настроения питомца */
.happy-fill {
    background: linear-gradient(90deg, #f06292, #f8bbd0);
    transition: width 0.4s ease;
}

/* Большая кнопка действия (нанять работника и т.п.) */
.big-action {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border-radius: 12px;
    margin-top: 4px;
    box-shadow: 0 3px 8px #00000040;
}


/* ════════ Места на карте: плашка, зоны, мини-игры ════════ */

/* Плашка активного места (вверху слева) */
#place-bar {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #00000096;
    border: 1px solid #ffffff22;
    padding: 6px 8px 6px 14px;
    border-radius: 16px;
    z-index: 5;
}

#place-bar.hidden { display: none; }

#place-bar-name {
    font-weight: bold;
    font-size: 13.5px;
}

#place-bar button {
    background: #ffffff18;
    border: 1px solid #ffffff28;
    color: var(--text, #fff);
    font: inherit;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 10px;
    cursor: pointer;
}

#place-bar button:hover { background: #ffffff30; }

/* Подсказка ближайшей интерактивной зоны */
#zone-hint {
    position: absolute;
    bottom: 86px;
    left: 50%;
    transform: translateX(-50%);
    background: #000000b0;
    border: 1px solid #ffd54f55;
    color: #fff;
    padding: 7px 16px;
    border-radius: 14px;
    font-size: 13px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 5;
}

#zone-hint.hidden { display: none; }

#zone-hint b {
    background: #ffd54f;
    color: #3e2723;
    border-radius: 6px;
    padding: 1px 7px;
    margin-right: 6px;
    font-size: 12px;
}

/* Товар дня на рынке */
.day-special {
    margin-top: 4px;
    color: var(--gold, #ffd54f);
    font-size: 12.5px;
}

/* ════ v7.0: уровень фермера 🌟 ════ */
.level-stat {
    position: relative;
    min-width: 64px;
}

#level-bar {
    display: block;
    width: 34px;
    height: 5px;
    margin-left: 5px;
    background: #00000055;
    border-radius: 3px;
    overflow: hidden;
}

#level-fill {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #ffd54f, #ffb300);
    border-radius: 3px;
    transition: width 0.4s;
}

/* ════ v7.0: оверлей нового уровня и ежедневной награды ════ */
.levelup-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #00000088;
    animation: lv-fade 0.25s;
}

@keyframes lv-fade { from { opacity: 0; } }

.levelup-card {
    background: linear-gradient(180deg, #2f4632, #243224);
    border: 2px solid #7cb34277;
    border-radius: 16px;
    padding: 26px 34px;
    text-align: center;
    color: #eef4e9;
    max-width: 440px;
    box-shadow: 0 18px 60px #000a;
    animation: lv-pop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes lv-pop { from { transform: scale(0.7); opacity: 0; } }

.levelup-card h2 { margin: 4px 0 8px; font-size: 26px; }
.levelup-burst { font-size: 44px; animation: cook-idle 1.6s infinite; }
.levelup-reward { font-size: 15px; color: #ffd54f; margin: 4px 0 10px; }
.levelup-unlocks { font-size: 13.5px; color: #c5d6bd; line-height: 1.55; margin: 0 0 12px; }

.levelup-card .overlay-btn {
    background: linear-gradient(180deg, #8bc34a, #689f38);
    border: none;
    border-radius: 10px;
    color: #1b2a14;
    font-weight: 700;
    font-size: 15px;
    padding: 9px 28px;
    cursor: pointer;
}

.levelup-card .overlay-btn:hover { filter: brightness(1.08); }

.daily-row {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin: 12px 0 16px;
    flex-wrap: wrap;
}

.daily-card {
    background: #1d2a1d;
    border: 1px solid #44604444;
    border-radius: 10px;
    padding: 7px 6px;
    min-width: 52px;
    font-size: 11.5px;
    line-height: 1.4;
    color: #b9cab2;
}

.daily-card b { display: block; font-size: 11px; color: #8fa888; margin-bottom: 2px; }
.daily-card.past { opacity: 0.45; }
.daily-card.today {
    border-color: #ffd54f;
    background: #3a3517;
    color: #ffe49a;
    box-shadow: 0 0 12px #ffd54f44;
}

/* ════ v7.0: достижения 🏆 ════ */
.shop-item.ach-done { border-color: #ffd54f66; background: #33391f; }
.shop-item.ach-done .icon { filter: drop-shadow(0 0 6px #ffd54f88); }

/* ════ v7.0: панель теплицы ════ */
.gh-opts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.gh-opts .mini-btn { font-size: 11.5px; }

/* ════════════════════════════════════════════════════════════
   v7.2 — Twemoji: consistent emoji images
   ════════════════════════════════════════════════════════════ */

/* Make Twemoji images inline and properly sized */
img.emoji {
    height: 1.2em;
    width: 1.2em;
    margin: 0 0.05em 0 0.1em;
    vertical-align: -0.2em;
    display: inline-block;
    pointer-events: none;
}

/* Larger emoji for specific contexts */
.menu-icon img.emoji {
    height: 26px;
    width: 26px;
    vertical-align: middle;
}

.shop-item .icon img.emoji {
    height: 30px;
    width: 30px;
}

.stat-icon img.emoji {
    height: 1.1em;
    width: 1.1em;
}

.logo img.emoji {
    height: 1.1em;
    width: 1.1em;
}

.node-icon img.emoji {
    height: 44px;
    width: 44px;
}

.trader-avatar img.emoji {
    height: 52px;
    width: 52px;
}

.travel-tractor img.emoji {
    height: 64px;
    width: 64px;
}

.tab img.emoji {
    height: 1em;
    width: 1em;
}

.cook img.emoji {
    height: 46px;
    width: 46px;
}

.stove-pan img.emoji {
    height: 26px;
    width: 26px;
}

.stove-steam img.emoji {
    height: 16px;
    width: 16px;
}

/* Toast emoji */
#toast img.emoji {
    height: 1.15em;
    width: 1.15em;
}

/* ════════════════════════════════════════════════════════════
   v7.2 — 3D Depth Effects for All Overlay Interfaces
   ════════════════════════════════════════════════════════════ */

/* Overlay entrance animation */
.overlay:not(.hidden) {
    animation: overlay-enter 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes overlay-enter {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(12px);
        filter: blur(4px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }
}

/* Overlay head: glassmorphism depth */
.overlay-head {
    backdrop-filter: blur(16px) saturate(1.5);
    -webkit-backdrop-filter: blur(16px) saturate(1.5);
    background: rgba(43, 58, 43, 0.88);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35), inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}

/* Map canvas: enhanced depth (no perspective — keeps node positioning) */
#map-canvas {
    box-shadow:
        inset 0 2px 16px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* Map nodes: enhanced hover effect */
.map-node {
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), filter 0.25s;
}

.map-node:not(.farm-node):hover {
    transform: translate(-50%, -50%) scale(1.12);
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.5));
}

.map-node .node-icon {
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.45),
        0 2px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        0 0 0 2px rgba(255, 255, 255, 0.08);
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.map-node:not(.farm-node):hover .node-icon {
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.55),
        0 4px 12px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        0 0 0 2px var(--gold);
}

.map-node .node-label {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.map-node .node-sub {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Map roads: animated dashes */
#map-roads path {
    animation: road-flow 3s linear infinite;
    stroke-dasharray: 2.2 1.6;
}

@keyframes road-flow {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: -7.6; }
}

/* Trader overlay: depth and glassmorphism */
.trader-greet {
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    transform-style: preserve-3d;
}

.trader-greet:hover {
    transform: perspective(900px) rotateX(1deg) rotateY(-1.5deg) translateY(-2px);
    box-shadow:
        0 8px 28px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.trader-avatar {
    box-shadow:
        0 4px 14px rgba(0, 0, 0, 0.35),
        inset 0 -2px 6px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

.trader-greet:hover .trader-avatar {
    transform: scale(1.05) translateZ(8px);
}

.trader-col {
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    transform-style: preserve-3d;
}

.trader-col:hover {
    transform: translateY(-2px);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

/* Travel overlay: enhanced tractor effect (keeps original animation) */
.travel-tractor {
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.6));
}

.travel-inner::before {
    content: '';
    display: block;
    width: 260px;
    height: 8px;
    margin: 24px auto 0;
    background: repeating-linear-gradient(90deg,
        #d7c08a44 0, #d7c08a44 16px,
        transparent 16px, transparent 28px);
    border-radius: 4px;
    animation: road-scroll 0.6s linear infinite;
    transform: perspective(300px) rotateX(40deg);
}

@keyframes road-scroll {
    from { background-position-x: 0; }
    to { background-position-x: -28px; }
}

/* Panel: 3D depth for all cards */
#panel {
    transform-style: preserve-3d;
    box-shadow:
        inset 2px 0 12px rgba(0, 0, 0, 0.2),
        -4px 0 20px rgba(0, 0, 0, 0.15);
}

.shop-item {
    transform-style: preserve-3d;
    transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.15s ease, border-color 0.15s ease;
}

.shop-item:not(.static):hover {
    transform: translateY(-2px) perspective(600px) rotateX(1deg);
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.shop-item.selected {
    box-shadow:
        0 0 0 2px var(--accent),
        0 4px 16px rgba(139, 195, 74, 0.2);
}

/* Panel summary: frosted glass */
.panel-summary {
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* Kitchen scene 3D depth */
.kitchen-scene {
    box-shadow:
        inset 0 2px 16px rgba(0, 0, 0, 0.25),
        0 4px 14px rgba(0, 0, 0, 0.2);
    transform-style: preserve-3d;
}

/* ════════════════════════════════════════════════════════════
   v7.2 — Enhanced Click / Press Effects
   ════════════════════════════════════════════════════════════ */

/* All interactive buttons: 3D press feel */
button, .mini-btn, .tab, .menu-btn {
    position: relative;
    overflow: hidden;
    transform-origin: center center;
    transition: transform 0.12s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.12s ease,
                background 0.15s ease,
                border-color 0.15s ease;
}

button:not(:disabled):active,
.mini-btn:not(:disabled):active,
.tab:active,
.menu-btn:active {
    transform: translateY(2px) scale(0.96);
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);
    transition-duration: 0.06s;
}

/* Ripple effect via CSS */
button::before,
.mini-btn::before,
.tab::before,
.menu-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%),
        rgba(255, 255, 255, 0.25) 0%,
        rgba(255, 255, 255, 0.08) 40%,
        transparent 70%);
    opacity: 0;
    transform: scale(0);
    border-radius: inherit;
    pointer-events: none;
    z-index: 1;
}

button.ripple::before,
.mini-btn.ripple::before,
.tab.ripple::before,
.menu-btn.ripple::before {
    animation: ripple-expand 0.5s ease-out forwards;
}

@keyframes ripple-expand {
    0% {
        opacity: 1;
        transform: scale(0);
    }
    100% {
        opacity: 0;
        transform: scale(2.5);
    }
}

/* Enhanced hover glow for action buttons */
.mini-btn.strong:not(:disabled):hover {
    box-shadow: 0 2px 10px rgba(51, 105, 30, 0.5), 0 0 0 1px rgba(139, 195, 74, 0.2);
}

.mini-btn.gem:not(:disabled):hover {
    box-shadow: 0 2px 10px rgba(21, 90, 138, 0.5), 0 0 0 1px rgba(79, 195, 247, 0.2);
}

/* Menu button enhanced press */
.menu-btn:active .menu-icon {
    transform: scale(0.88);
    transition: transform 0.08s;
}

.menu-btn .menu-icon {
    transition: transform 0.15s ease;
}

.menu-btn:hover .menu-icon {
    transform: scale(1.08);
}

/* Expand button 3D press */
#expand-btn:not(:disabled):hover {
    box-shadow: 0 4px 14px rgba(63, 125, 38, 0.4);
    transform: translateY(-1px);
}

#expand-btn:not(:disabled):active {
    box-shadow: 0 1px 4px rgba(63, 125, 38, 0.3);
    transform: translateY(2px) scale(0.97);
}

/* Sell button active glow */
#sell-mode-btn.active {
    box-shadow: 0 0 12px rgba(239, 83, 80, 0.4);
    animation: danger-pulse 1.5s infinite ease-in-out;
}

@keyframes danger-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(239, 83, 80, 0.3); }
    50% { box-shadow: 0 0 20px rgba(239, 83, 80, 0.5); }
}

/* Overlay close button 3D press */
.overlay-close:hover {
    background: #7d5249;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
}

.overlay-close:active {
    transform: translateY(1px);
    box-shadow: none;
}

/* Map node click effect */
.map-node:not(.farm-node):active .node-icon {
    transform: scale(0.92);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.3),
        inset 0 2px 6px rgba(0, 0, 0, 0.2);
    transition-duration: 0.06s;
}

/* Panel open/close 3D transition */
#panel {
    transition: flex-basis 0.28s cubic-bezier(0.22, 1, 0.36, 1),
                width 0.28s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.28s ease;
}

#panel.open {
    box-shadow:
        inset 2px 0 12px rgba(0, 0, 0, 0.2),
        -8px 0 30px rgba(0, 0, 0, 0.25);
}

/* Toast entrance with 3D pop */
#toast.show {
    animation: toast-pop 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes toast-pop {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(10px) scale(0.85);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

/* Overlay stats pill: depth */
.overlay-stats {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Topbar: subtle depth */
#topbar {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 5;
}

/* Stat pills: depth */
.stat {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s ease;
}

.stat:hover {
    transform: translateY(-1px);
}

/* Menu bar: glassmorphism depth */
#menu-bar {
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px) saturate(1.4);
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
}

/* Selection chip: depth */
#selection-chip {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Craft progress bar: 3D inset */
.craft-bar {
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.craft-fill {
    box-shadow: 0 0 6px rgba(139, 195, 74, 0.3);
}

/* Badge: pop effect */
.badge:not(.hidden) {
    animation: badge-pop 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes badge-pop {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ════════════════════════════════════════════════════════════
   v7.4: управление только мышью/пальцами + мобильные устройства
   ════════════════════════════════════════════════════════════ */

/* Канвас принимает все жесты сам (без скролла/зума страницы) */
#field {
    touch-action: none;
}

html, body {
    overscroll-behavior: none;   /* без pull-to-refresh */
}

#app {
    height: 100dvh;              /* честная высота на мобильных браузерах */
}

/* UI не выделяется и не подсвечивается при тапах */
#topbar, #menu-bar, #place-bar, #controls-hint, #zone-hint,
#selection-chip, #queue-chip, .overlay-head, #panel-head {
    -webkit-user-select: none;
    user-select: none;
}

button, .menu-btn, .mini-btn, .tab {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;  /* без задержки 300мс и двойного тапа */
}

/* Плашка зоны теперь кнопка: клик/тап = действие */
#zone-hint {
    pointer-events: auto;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
}

#zone-hint:hover {
    border-color: #ffd54faa;
    box-shadow: 0 0 12px #ffd54f44;
}

/* Чип очереди сбора с кнопкой отмены */
#queue-chip {
    position: absolute;
    top: 48px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #0d47a1cc;
    border: 1px solid #4fc3f788;
    color: var(--text);
    padding: 6px 8px 6px 14px;
    border-radius: 16px;
    font-size: 13px;
    white-space: nowrap;
    z-index: 4;
}

#queue-chip.hidden { display: none; }

#queue-cancel {
    padding: 2px 9px;
    border-radius: 50%;
    font-size: 12px;
    line-height: 1.4;
}

/* Кнопка полного экрана */
#fullscreen-btn {
    font-size: 17px;
    line-height: 1.1;
    padding: 6px 12px;
}

#fullscreen-btn.active {
    background: #465846;
    border-color: var(--accent);
}

#fullscreen-btn.hidden { display: none; }

/* Учёт «чёлки» и скруглений экрана телефона */
#topbar {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-top: max(10px, env(safe-area-inset-top));
}

#menu-bar {
    bottom: calc(16px + env(safe-area-inset-bottom));
    max-width: calc(100% - 16px);
}

/* ── Сенсорные устройства: крупные элементы под палец 👆 ───── */
@media (pointer: coarse) {
    button {
        padding: 10px 16px;
        font-size: 15px;
    }

    .mini-btn {
        min-height: 38px;
        min-width: 44px;
    }

    .menu-btn {
        min-width: 56px;
        padding: 10px 12px;
    }

    #panel-close, #chip-cancel, #queue-cancel {
        min-width: 38px;
        min-height: 38px;
    }

    .overlay-close {
        padding: 10px 18px;
    }

    #zone-hint {
        font-size: 15px;
        padding: 11px 22px;
        bottom: 96px;
    }

    input[type="range"].sens-range {
        height: 32px;
    }
}

/* ── Телефоны: компактная верхняя панель (узкие ИЛИ низкие экраны) ── */
@media (max-width: 760px), (max-height: 480px) {
    #topbar {
        gap: 8px;
        padding-top: max(6px, env(safe-area-inset-top));
        padding-bottom: 6px;
        overflow-x: auto;          /* панель скроллится, ничего не теряем */
        scrollbar-width: none;
    }

    #topbar::-webkit-scrollbar { display: none; }

    .topbar-left .logo {
        font-size: 16px;
        white-space: nowrap;
    }

    .topbar-center {
        gap: 6px;
        flex: 1 1 auto;
    }

    .stat {
        font-size: 14px;
        padding: 4px 9px;
        gap: 4px;
        white-space: nowrap;
    }

    .topbar-right {
        display: flex;
        gap: 6px;
    }

    #topbar button {
        white-space: nowrap;
        padding: 6px 10px;
        font-size: 13px;
    }

    #controls-hint {
        font-size: 11px;
        max-width: 92%;
    }

    #menu-bar {
        gap: 4px;
        padding: 6px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    #menu-bar::-webkit-scrollbar { display: none; }

    #queue-chip {
        top: 40px;
        font-size: 12px;
    }

    .overlay-head h2 {
        font-size: 16px;
    }

    .overlay-head h2 small { display: none; }
}

/* ── Телефон в альбомной ориентации: экономим высоту ───────── */
@media (max-height: 480px) {
    #topbar {
        padding-top: 4px;
        padding-bottom: 4px;
    }

    .menu-btn .menu-label { display: none; }

    .menu-btn { min-width: 48px; }

    #menu-bar {
        bottom: calc(8px + env(safe-area-inset-bottom));
    }

    #zone-hint { bottom: 72px; }

    #controls-hint { display: none; }  /* подсказка съедает место */

    #panel.open { flex: 0 0 60%; }
}

/* ════════════════════════════════════════════════════════════
   v7.5 — Оверлеи как 3D-всплывающие статичные квадраты
   ════════════════════════════════════════════════════════════ */

:root {
    /* десктоп: квадрат по меньшей стороне окна */
    --card-size: min(720px, 86vmin);
}

/* мобильные: свой размер квадрата */
@media (pointer: coarse), (max-width: 760px) {
    :root {
        --card-size: min(96vw, 86dvh);
    }
}

@keyframes pop3d {
    from {
        transform: perspective(900px) rotateX(18deg) scale(0.8);
        opacity: 0;
    }
}

@keyframes pop3d-center {
    from {
        transform: translate(-50%, -50%) perspective(900px) rotateX(18deg) scale(0.8);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%);
    }
}

/* Полноэкранные оверлеи (карта, торговец) → затемнённый фон + квадратная карточка */
.overlay {
    background: #0c140cbb;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    align-items: center;
    justify-content: center;
}

.overlay-card {
    width: var(--card-size);
    height: var(--card-size);
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border: 2px solid #7cb34255;
    border-radius: 18px;
    box-shadow: 0 24px 80px #000c;
    overflow: hidden;
    animation: pop3d 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}

/* Боковая панель (магазин/гардероб/склад/кухня/работники/награды/настройки)
   → статичный квадрат по центру экрана */
#panel {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: var(--card-size);
    height: var(--card-size);
    display: none;
    z-index: 18;
    border: 2px solid #7cb34255;
    border-radius: 18px;
    box-shadow: 0 24px 80px #000c;
    transition: none;
    flex: none;
}

#panel.open {
    display: flex;
    width: var(--card-size);
    flex: none;
    animation: pop3d-center 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}

/* Экран поездки → квадратная карточка на затемнённом фоне */
#travel-overlay {
    background: #0c140cdd;
}

.travel-inner {
    width: var(--card-size);
    height: var(--card-size);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 2px solid #7cb34255;
    border-radius: 18px;
    box-shadow: 0 24px 80px #000c;
    animation: pop3d 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}

/* Награды дня / новый уровень → тот же квадратный формат */
.levelup-card {
    width: var(--card-size);
    height: var(--card-size);
    max-width: var(--card-size);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    animation: pop3d 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

/* Подгонка содержимого под квадрат на телефоне */
@media (pointer: coarse), (max-width: 760px) {
    .overlay-card .overlay-head,
    #panel #panel-head {
        padding: 10px 12px;
    }

    #map-canvas {
        margin: 10px;
    }

    #trader-body {
        padding: 12px;
    }

    .levelup-card {
        padding: 18px 16px;
    }
}

/* Карта в маленьком квадрате: компактные узлы, чтобы не налезали */
@media (pointer: coarse), (max-width: 760px) {
    .map-node .node-icon {
        font-size: 26px;
        padding: 8px;
        border-width: 1.5px;
    }

    .map-node .node-icon img.emoji {
        width: 26px;
        height: 26px;
    }

    .map-node .node-label {
        font-size: 10.5px;
        padding: 3px 7px;
    }

    .map-node .node-label i {
        font-size: 9.5px;
    }

    .map-node .node-sub {
        display: none;
    }
}

/* ════════════════════════════════════════════════════════════
   v8.0 — Аккаунты: окно входа и панель друзей (поверх игры)
   ════════════════════════════════════════════════════════════ */

#auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 30% 20%, #2e4a26 0%, transparent 55%),
        radial-gradient(circle at 75% 75%, #24401f 0%, transparent 55%),
        #15200f;
}

#auth-overlay.hidden {
    display: none;
}

.auth-card {
    width: min(400px, 92vw);
    max-height: 94dvh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 26px 28px;
    background: var(--bg);
    border: 2px solid #7cb34255;
    border-radius: 18px;
    box-shadow: 0 24px 80px #000c;
    text-align: center;
    animation: pop3d 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.auth-logo {
    font-size: 52px;
    line-height: 1;
}

.auth-logo img.emoji {
    width: 52px;
    height: 52px;
}

.auth-title {
    margin: 0;
    font-size: 26px;
}

.auth-sub {
    margin: 0;
    color: var(--text-dim);
    font-size: 13.5px;
}

.auth-tabs {
    display: flex;
    gap: 6px;
    background: #00000035;
    border-radius: 12px;
    padding: 4px;
}

.auth-tabs button {
    flex: 1;
    padding: 9px 0;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--text-dim);
    font-weight: bold;
    cursor: pointer;
}

.auth-tabs button.active {
    background: #7cb34233;
    color: var(--text);
}

#auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#auth-form input {
    padding: 11px 14px;
    border-radius: 11px;
    border: 1.5px solid #ffffff22;
    background: #00000035;
    color: var(--text);
    font-size: 15px;
    outline: none;
}

#auth-form input:focus {
    border-color: #7cb342aa;
}

#auth-error {
    padding: 8px 12px;
    border-radius: 10px;
    background: #5a1f1faa;
    border: 1px solid #c0392b66;
    color: #ffb3a7;
    font-size: 13px;
}

#auth-error.hidden {
    display: none;
}

#auth-submit {
    padding: 12px 0;
    border: none;
    border-radius: 12px;
    background: linear-gradient(180deg, #7cb342, #558b2f);
    color: #fff;
    font-size: 15.5px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 12px #00000050;
}

#auth-submit:disabled {
    opacity: 0.6;
    cursor: wait;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dim);
    font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #ffffff20;
}

.auth-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 11px 0;
    border-radius: 12px;
    background: #ffffffeb;
    color: #333;
    font-size: 14.5px;
    font-weight: bold;
    text-decoration: none;
    box-shadow: 0 4px 12px #00000050;
}

.auth-google:hover {
    background: #fff;
}

/* ---------- кнопка и панель друзей ---------- */

#friends-btn.hidden {
    display: none;
}

#friends-panel {
    position: absolute;
    bottom: 192px;
    left: 0;
    right: 0;
    margin: 0 auto;
    z-index: 60;
    width: min(320px, calc(100vw - 24px));
    max-height: min(440px, calc(100dvh - 240px));
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    background: var(--bg);
    border: 2px solid #7cb34255;
    border-radius: 16px;
    box-shadow: 0 18px 60px #000c;
    animation: pop3d 0.25s cubic-bezier(0.2, 1.4, 0.4, 1);
}

#friends-panel.hidden {
    display: none;
}

.friends-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.friends-title {
    font-weight: bold;
    font-size: 15px;
}

#friends-me {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
    color: var(--gold);
    font-size: 13px;
    font-weight: bold;
}

#friends-refresh,
#friends-close {
    flex: none;
    padding: 4px 8px;
    border: 1px solid #ffffff22;
    border-radius: 8px;
    background: #00000035;
    color: var(--text);
    cursor: pointer;
}

.friends-add {
    display: flex;
    gap: 6px;
}

.friends-add input {
    flex: 1;
    min-width: 0;
    padding: 9px 12px;
    border-radius: 10px;
    border: 1.5px solid #ffffff22;
    background: #00000035;
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.friends-add input:focus {
    border-color: #7cb342aa;
}

#friend-add-btn {
    flex: none;
    padding: 0 14px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(180deg, #7cb342, #558b2f);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
}

#friend-add-btn:disabled {
    opacity: 0.6;
}

#friends-msg {
    min-height: 0;
    font-size: 12.5px;
    color: var(--text-dim);
}

#friends-msg.error {
    color: #ffb3a7;
}

#friends-msg:empty {
    display: none;
}

#friends-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.friends-empty {
    padding: 14px 8px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
}

.friend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #00000030;
    border: 1px solid #ffffff14;
}

.friend-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: bold;
    font-size: 13.5px;
}

.friend-status {
    flex: none;
    font-size: 11.5px;
    color: var(--text-dim);
}

.friend-accept {
    flex: none;
    padding: 5px 10px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(180deg, #7cb342, #558b2f);
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
}

#logout-btn {
    flex: none;
    padding: 9px 0;
    border: 1px solid #c0392b55;
    border-radius: 10px;
    background: #3a1d1a;
    color: #ffb3a7;
    font-size: 13px;
    cursor: pointer;
}

/* ---------- нижняя панель друзей: квадратные аватарки ---------- */

#friends-bar {
    position: absolute;
    bottom: 106px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    background: #1c281cdd;
    border: 1px solid #ffffff20;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px) saturate(1.4);
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
    max-width: calc(100% - 16px);
}

#friends-bar.hidden {
    display: none;
}

#friends-slots {
    display: flex;
    gap: 7px;
}

.friends-arrow {
    flex: none;
    width: 26px;
    height: 52px;
    padding: 0;
    border: 1px solid #ffffff22;
    border-radius: 10px;
    background: #00000035;
    color: var(--text-dim);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.friends-arrow:hover:not(:disabled) {
    background: #ffffff18;
    color: var(--text);
}

.friends-arrow:disabled {
    opacity: 0.3;
    cursor: default;
}

.friend-slot {
    position: relative;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    border: 1px solid #ffffff22;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    cursor: default;
}

.friend-slot.empty {
    background: #00000028;
    border-style: dashed;
    border-color: #ffffff14;
}

.friend-slot.filled {
    color: #fff;
    font-weight: bold;
    font-size: 20px;
    text-shadow: 0 1px 3px #0008;
    box-shadow: inset 0 1px 0 #ffffff30, 0 2px 6px #0006;
    cursor: pointer;
    transition: transform 0.15s;
}

.friend-slot.filled:hover {
    transform: scale(1.08);
}

.friend-slot.add {
    background: #00000035;
    border: 1.5px dashed #7cb34288;
    color: var(--accent);
    font-size: 22px;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.friend-slot.add:hover {
    background: #7cb34226;
    transform: scale(1.08);
}

.friend-slot .slot-level {
    position: absolute;
    right: -5px;
    bottom: -5px;
    min-width: 19px;
    height: 19px;
    padding: 0 4px;
    border-radius: 7px;
    background: linear-gradient(180deg, #ffd54f, #ffb300);
    border: 1px solid #00000040;
    color: #4a3500;
    font-size: 11px;
    font-weight: bold;
    line-height: 17px;
    text-align: center;
    box-shadow: 0 2px 5px #0007;
}

.friend-slot .slot-pending {
    position: absolute;
    right: -5px;
    top: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    font-size: 10.5px;
    font-weight: bold;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 2px 5px #0007;
}

/* всплывающий ник под курсором — поверх рамки слота */
.friend-slot .slot-name {
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%);
    padding: 3px 9px;
    border-radius: 8px;
    background: #000000d0;
    border: 1px solid #ffffff22;
    color: var(--text);
    font-size: 11.5px;
    font-weight: bold;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}

.friend-slot:hover .slot-name {
    opacity: 1;
}

/* телефоны: панель друзей и нижняя панель компактнее */
@media (pointer: coarse), (max-width: 760px) {
    #friends-panel {
        bottom: 182px;
        right: 8px;
        left: 8px;
        width: auto;
        max-height: calc(100dvh - 230px);
    }

    #friends-bar {
        bottom: 102px;
        gap: 6px;
        padding: 6px 7px;
    }

    #friends-slots {
        gap: 6px;
    }

    .friend-slot {
        width: 44px;
        height: 44px;
        font-size: 17px;
    }

    .friends-arrow {
        height: 44px;
        width: 24px;
    }

    .auth-card {
        padding: 20px 18px;
    }
}

/* телефон в альбомной ориентации: прижимаем ниже */
@media (max-height: 480px) {
    #friends-bar {
        bottom: 64px;
    }

    #friends-panel {
        bottom: 122px;
        max-height: calc(100dvh - 130px);
    }
}
