/* ===== ДИЗАЙН-СИСТЕМА ===== */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #141428;
    --bg-tertiary: #1e1e3a;
    --bg-hover: rgba(255,255,255,0.06);

    --accent-gold: #ffd966;
    --accent-gold-dark: #f0c040;
    --accent-blue: #2481cc;
    --accent-green: #4caf50;
    --accent-red: #f44336;
    --accent-purple: #7c4dff;

    --sp-xs: 4px;
    --sp-sm: 8px;
    --sp-md: 16px;
    --sp-lg: 24px;
    --sp-xl: 32px;
    --sp-2xl: 48px;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 32px;

    --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);

    --tr-fast: 0.15s ease;
    --tr-normal: 0.3s ease;

    /* Чёрная обводка текста — многослойная text-shadow (работает везде, в т.ч. Telegram WebView) */
    --text-outline: 1px 0 #000, -1px 0 #000, 0 1px #000, 0 -1px #000,
                    1px 1px #000, -1px -1px #000, 1px -1px #000, -1px 1px #000;
    /* Обводка + мягкая тень для глубины */
    --text-outline-shadow: 1px 0 #000, -1px 0 #000, 0 1px #000, 0 -1px #000,
                           1px 1px #000, -1px -1px #000, 1px -1px #000, -1px 1px #000,
                           0 0 6px rgba(0,0,0,0.6);

    /* 🔥 Принудительно тёмная тема — игнорируем светлые темы Telegram */
    color-scheme: dark;
    --tg-theme-bg-color: #0a0a1a;
    --tg-theme-secondary-bg-color: #141428;
    --tg-theme-text-color: #ffffff;
    --tg-theme-hint-color: rgba(255,255,255,0.5);
    --tg-theme-link-color: #2481cc;
    --tg-theme-button-color: #7c4dff;
    --tg-theme-button-text-color: #ffffff;
}

/* 🔥 Принудительная тёмная тема — с более высоким приоритетом, чем инлайн-переменные
   Telegram WebApp SDK (SDK навешивает --tg-theme-* инлайново на :root, что перебивает
   обычные правила). !important гарантирует тёмный фон для ВСЕХ пользователей. */
:root, :root.theme-dark, .theme-dark {
    --tg-theme-bg-color: #0a0a1a !important;
    --tg-theme-secondary-bg-color: #141428 !important;
    --tg-theme-text-color: #ffffff !important;
    --tg-theme-hint-color: rgba(255,255,255,0.5) !important;
    --tg-theme-link-color: #2481cc !important;
    --tg-theme-button-color: #7c4dff !important;
    --tg-theme-button-text-color: #ffffff !important;
    color-scheme: dark !important;
}
html {
    background: #0a0a1a !important;
}
body {
    background: #0a0a1a !important;
    color: #ffffff !important;
}
@media (prefers-color-scheme: light) {
    html, body {
        background: #0a0a1a !important;
        color: #ffffff !important;
    }
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--tg-theme-bg-color, var(--bg-primary));
    color: #fff;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    letter-spacing: 0.15px;
    line-height: 1.45;
    font-size: 15px;
}

/* ===== ПРИВЕТСТВЕННЫЙ ЭКРАН ===== */
#welcome {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(145deg, #0a0a1a 0%, #1a1a3e 50%, #0f0f2e 100%);
    padding: 20px;
    animation: welcomeFadeIn 0.6s ease-out;
}

@keyframes welcomeFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.welcome-card {
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-xl);
    padding: var(--sp-2xl) var(--sp-xl) var(--sp-xl);
    max-width: 480px;
    width: 100%;
    will-change: transform;
    contain: layout style paint;
    text-align: center;
    box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.1);
}

.logo {
    font-size: 64px;
    margin-bottom: var(--sp-md);
    display: block;
    animation: logoFloat 3s ease-in-out infinite;
}

.welcome-card h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #f0e6a0, #ffd966, #f0c040);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--sp-sm);
    animation: gradientShift 3s ease infinite;
}

.subtitle {
    font-size: 16px;
    color: rgba(255,255,255,0.6);
    margin-bottom: var(--sp-xl);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-md);
    margin-bottom: var(--sp-md);
}

#gameLink {
    padding: var(--sp-lg) 20px;
    border-radius: var(--radius-lg);
    border: 2px solid rgba(255,255,255,0.12);
    background: rgba(0,0,0,0.2);
    color: #fff;
    font-size: 16px;
    outline: none;
    transition: border-color var(--tr-normal), box-shadow var(--tr-normal);
}

#gameLink:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 4px rgba(255, 217, 102, 0.15);
}

#gameLink::placeholder { color: rgba(255,255,255,0.3); }

#openBtn {
    padding: var(--sp-lg);
    border-radius: var(--radius-lg);
    border: none;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-dark));
    color: #1a1a2e;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform var(--tr-fast), box-shadow var(--tr-normal);
    box-shadow: 0 4px 20px rgba(255, 217, 102, 0.3);
}

#openBtn:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(255, 217, 102, 0.45); }
#openBtn:active { transform: scale(0.97); }
#openBtn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.auth-error {
    color: var(--accent-red);
    font-size: 14px;
    margin-top: var(--sp-sm);
    padding: var(--sp-sm) var(--sp-md);
    background: rgba(244, 67, 54, 0.1);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(244, 67, 54, 0.2);
    display: none;
}

/* ===== ОСНОВНОЙ ДАШБОРД ===== */
#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

#sidebar {
    width: 220px;
    background: var(--tg-theme-secondary-bg-color, var(--bg-secondary));
    padding: var(--sp-lg) var(--sp-sm);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

/* Бейдж уровня в сайдбаре */
.sidebar-header {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    padding-bottom: var(--sp-md);
    margin-bottom: var(--sp-md);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-level-badge {
    position: relative;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}

.sidebar-level-badge .level-bg {
    width: 56px;
    height: 56px;
    object-fit: contain;
    display: block;
}

.sidebar-level-badge .level-num {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    text-shadow: var(--text-outline);
    line-height: 1;
}

.sidebar-level-info { flex: 1; overflow: hidden; }

.sidebar-level-info .level-numbers {
    font-size: 15px;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    text-shadow: var(--text-outline);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-level-info .level-max { font-size: 13px; color: rgba(255,255,255,0.55); }

.sidebar-username {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    text-shadow: var(--text-outline);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.menu-header {
    font-size: 16px;
    font-weight: 700;
    color: rgba(255,255,255,0.5);
    text-shadow: var(--text-outline);
    text-align: center;
    padding-bottom: var(--sp-md);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: var(--sp-md);
}

#sidebar ul {
    list-style: none;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--sp-xs);
}

.menu-item {
    padding: 12px var(--sp-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--tr-fast);
    font-size: 15px;
    color: rgba(255,255,255,0.7);
    text-shadow: var(--text-outline);
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
}

.menu-item .menu-icon { font-size: 24px; line-height: 1; }
.menu-item .menu-icon img { width: 36px; height: 36px; object-fit: contain; display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)); }

/* 🎲 Звериный двор: баланс с иконками */
.pets-balance-card { display: flex; gap: 6px; justify-content: space-between; flex-wrap: wrap; padding: 12px 10px; }
.pets-balance-item { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 72px; justify-content: center; }
.pets-balance-item .res-icon { width: 24px; height: 24px; object-fit: contain; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4)); }
.pets-balance-num { font-weight: 700; font-size: 15px; line-height: 1.1; }

.menu-item:hover { background: var(--bg-hover); color: #fff; }

.menu-item.active {
    background: var(--tg-theme-button-color, var(--accent-blue));
    color: #fff;
    font-weight: 600;
}

.menu-footer {
    text-align: center;
    font-size: 12px;
    color: rgba(255,255,255,0.4);
    margin-top: var(--sp-md);
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: var(--sp-md);
}

#userInfo {
    font-size: 13px;
    color: rgba(255,255,255,0.6);
    margin-bottom: var(--sp-xs);
}

.logout-link {
    color: var(--accent-red);
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    display: inline-block;
    padding: var(--sp-xs) var(--sp-sm);
}

.logout-link:hover { text-decoration: underline; }

#content {
    flex: 1;
    padding: var(--sp-lg);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-primary);
    contain: layout style;
    will-change: scroll-position;
}

#content.tab-enter { animation: tabEnter 0.15s ease-out; }

@keyframes tabEnter {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== КАРТОЧКИ ===== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--sp-sm);
}

.card {
    background: var(--tg-theme-secondary-bg-color, var(--bg-secondary));
    border-radius: var(--radius-md);
    padding: var(--sp-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255,255,255,0.04);
    transition: transform 0.12s, box-shadow 0.2s;
    min-width: 0;
    overflow: hidden;
    content-visibility: auto;
    contain-intrinsic-size: 80px;
    contain: layout style;
}

.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.card .label {
    font-size: 13px;
    color: rgba(255,255,255,0.5);
    text-shadow: 0 1px 2px rgba(0,0,0,0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
}

.card .value {
    font-size: 22px;
    font-weight: 700;
    margin-top: var(--sp-xs);
    color: #fff;
    text-shadow: var(--text-outline-shadow);
}

.card .value.gold { color: var(--accent-gold); }
.card .value.blue { color: var(--accent-blue); }
.card .value.green { color: var(--accent-green); }
.card .value.purple { color: var(--accent-purple); }

.card .sub {
    font-size: 14px;
    color: rgba(255,255,255,0.7);
    text-shadow: 0 1px 2px rgba(0,0,0,0.7);
    margin-top: var(--sp-xs);
    line-height: 1.4;
}

/* Иконки ресурсов */
.res-icon {
    display: inline-block;
    vertical-align: middle;
    object-fit: contain;
    border-radius: 4px;
}
.value .res-icon { vertical-align: -5px; margin-right: 6px; }
.sub .res-icon { vertical-align: -3px; margin-right: 2px; }

/* ===== АККАУНТ + УРОВЕНЬ ===== */
.account-row {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
}

.level-badge {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.level-badge .level-bg {
    width: 48px;
    height: 48px;
    object-fit: contain;
    display: block;
}

.level-badge .level-num {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    text-shadow: var(--text-outline-shadow);
    line-height: 1;
    z-index: 2;
}

.account-info { flex: 1; min-width: 0; }

.account-name {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    text-shadow: var(--text-outline-shadow);
    margin-bottom: var(--sp-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Прогресс-бар опыта */
.level-bar {
    position: relative;
    height: 26px;
    background: rgba(0,0,0,0.45);
    border-radius: 13px;
    border: 1px solid rgba(255,255,255,0.08);
    overflow: hidden;
}

.level-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    border-radius: 15px;
    transition: width 0.5s ease;
}

.level-bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    text-shadow: var(--text-outline-shadow);
    white-space: nowrap;
    z-index: 2;
    pointer-events: none;
}

.level-divider { opacity: 0.6; margin: 0 2px; }
.level-max { opacity: 0.7; font-size: 12px; }

/* ===== РЕСУРСЫ (без заголовков) ===== */
.resource-row {
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
    padding: 2px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.resource-row:last-child { border-bottom: none; }

.resource-value {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    text-shadow: var(--text-outline-shadow);
}

.resource-value.gold { color: var(--accent-gold); }
.resource-value.blue { color: var(--accent-blue); }

.resource-sep {
    color: rgba(255,255,255,0.25);
    margin: 0 4px;
}

.resource-limit {
    font-size: 13px;
    font-weight: 500;
    opacity: 0.45;
}

/* Монеты — 3 равные колонки */
.coins-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.coin-group {
    display: flex;
    align-items: center;
    gap: 3px;
}

.coin-icon img { vertical-align: middle; }

.coin-num {
    font-size: 15px;
    font-weight: 800;
    color: #fff;
    text-shadow: var(--text-outline-shadow);
}

.coin-sep {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.3);
}

.coin-lim {
    font-size: 13px;
    font-weight: 700;
    color: rgba(255,255,255,0.45);
}

/* ===== ВРЕМЯ СЕРВЕРА ===== */
.time-row {
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
    flex-wrap: nowrap;
    justify-content: center;
    overflow: hidden;
}

.time-label {
    font-size: 12px;
    font-weight: 700;
    color: rgba(255,255,255,0.5);
    flex-shrink: 0;
}

.time-value {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 13px;
    color: rgba(255,255,255,0.85);
    text-shadow: var(--text-outline);
}

.time-sep {
    color: rgba(255,255,255,0.2);
    flex-shrink: 0;
}

/* ===== КНОПКИ НАВИГАЦИИ (шестёрки, мастерская) ===== */
.card-clickable {
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.card-clickable:hover {
    border-color: rgba(255,217,102,0.3);
    background: var(--bg-hover);
}

.nav-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-xs);
}

.nav-btn {
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-xs);
    padding: var(--sp-sm) var(--sp-xs) !important;
    text-align: center;
}

.nav-btn:hover {
    border-color: rgba(255,217,102,0.3);
    background: var(--bg-hover);
}

.nav-btn-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.nav-btn-text {
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    text-shadow: var(--text-outline-shadow);
    white-space: nowrap;
}

.nav-btn-arrow {
    font-size: 16px;
    color: rgba(255,255,255,0.3);
    margin-top: -2px;
}

/* ===== BUYER VALUTES (компактная сетка) ===== */
.bv-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-xs);
}

.bv-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
}

.bv-val {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    text-shadow: var(--text-outline-shadow);
}

/* ===== ПРОГРЕСС-БАР (задачи) ===== */
.progress-bar {
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    height: 8px;
    margin-top: var(--sp-xs);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    border-radius: 10px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: width;
}

.progress-fill.complete {
    background: linear-gradient(90deg, var(--accent-green), #66bb6a);
}

.progress-text {
    font-size: 12px;
    color: rgba(255,255,255,0.6);
    text-shadow: 0 1px 2px rgba(0,0,0,0.7);
    margin-top: 2px;
}

/* ===== АКТИВНОСТИ ===== */
.activity-card {
    background: var(--tg-theme-secondary-bg-color, var(--bg-secondary));
    border-radius: var(--radius-md);
    padding: var(--sp-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255,255,255,0.04);
    margin-bottom: var(--sp-md);
    transition: border-color var(--tr-normal);
}

.activity-card.ready { border-color: rgba(76, 175, 80, 0.4); }

.activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-sm);
    margin-bottom: var(--sp-sm);
}

.activity-name {
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    text-shadow: var(--text-outline);
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
}

.activity-cooldown {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-gold);
    text-shadow: var(--text-outline);
    font-variant-numeric: tabular-nums;
}

.activity-cooldown.ready { color: var(--accent-green); }

.activity-xp-bar {
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    height: 6px;
    overflow: hidden;
    margin-bottom: var(--sp-sm);
}

.activity-xp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-blue));
    border-radius: 10px;
    transition: width 0.6s ease;
}

.activity-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-sm);
}

.activity-xp-text {
    font-size: 13px;
    color: rgba(255,255,255,0.6);
    text-shadow: 0 1px 2px rgba(0,0,0,0.7);
}

/* ===== КНОПКИ ===== */
.btn {
    background: var(--tg-theme-button-color, var(--accent-blue));
    color: #fff;
    border: none;
    padding: var(--sp-sm) var(--sp-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: opacity var(--tr-fast), transform var(--tr-fast);
}

.btn:hover { opacity: 0.85; transform: translateY(-1px); }
.btn:active { transform: scale(0.96); }

.btn-green {
    background: linear-gradient(135deg, var(--accent-green), #43a047);
    box-shadow: 0 4px 16px rgba(76, 175, 80, 0.3);
    text-shadow: var(--text-outline);
}

.btn-green:hover { box-shadow: 0 6px 24px rgba(76, 175, 80, 0.4); opacity: 1; }

.btn-full { width: 100%; padding: var(--sp-md); font-size: 16px; }

/* ===== АВТОМАТИЗАЦИЯ ===== */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sp-md) 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.setting-row:last-of-type { border-bottom: none; }

.setting-label {
    font-size: 16px;
    color: rgba(255,255,255,0.85);
    text-shadow: var(--text-outline);
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
}

.switch {
    position: relative;
    width: 56px;
    height: 30px;
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 15px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
    contain: layout style;
}

.switch:hover {
    box-shadow: 0 0 10px rgba(255,255,255,0.1);
}

.switch.on {
    background: var(--accent-green);
    border-color: var(--accent-green);
    box-shadow: 0 0 14px rgba(76, 175, 80, 0.45);
}

.switch .knob {
    position: absolute;
    width: 24px;
    height: 24px;
    background: #fff;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: left 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    will-change: transform;
}

.switch.on .knob { left: 29px; }

/* Маленький слайдер (для карточек авторитетов) */
.switch-sm {
    position: relative;
    width: 38px;
    height: 20px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
    contain: layout style;
}
.switch-sm:hover { box-shadow: 0 0 8px rgba(255,255,255,0.1); }
.switch-sm.on {
    background: var(--accent-green);
    border-color: var(--accent-green);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.4);
}
.switch-sm .knob {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: left 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    will-change: transform;
}
.switch-sm.on .knob { left: 21px; }

/* Горизонтальный скролл пилюль сложности */
.auth-diff-scroll {
    display: flex;
    gap: 3px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 1px;
}
.auth-diff-scroll::-webkit-scrollbar { display: none; }
.auth-diff-btn {
    flex: 0 0 auto;
    padding: 2px 7px;
    font-size: 11px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}

/* Подпись к слайдеру */
.switch-label {
    font-size: 11px;
    opacity: 0.6;
    margin-left: 2px;
    white-space: nowrap;
}

/* XP-прогресс и кулдаун у активностей */
.act-xp-bar {
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-top: var(--sp-xs);
}
.act-xp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-green));
    border-radius: 3px;
    transition: width var(--tr-normal);
}
.act-xp-text {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 2px;
}
.act-cd-text {
    font-size: 11px;
    opacity: 0.5;
    margin-left: auto;
    white-space: nowrap;
}

.interval-group {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
}

.interval-input {
    width: 60px;
    background: rgba(0,0,0,0.3);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    padding: var(--sp-sm);
    font-size: 15px;
    text-align: center;
    outline: none;
    transition: border-color var(--tr-normal);
}

.interval-input:focus { border-color: var(--accent-gold); }
.interval-dash { color: rgba(255,255,255,0.3); font-size: 16px; }

/* ===== РЕЙД ===== */
.raid-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: var(--sp-md);
}
.raid-tab {
    flex: 1;
    padding: var(--sp-sm) var(--sp-xs);
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--tr-fast);
    text-align: center;
}
.raid-tab:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.85);
}
.raid-tab.active {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
    color: #fff;
    text-shadow: var(--text-outline);
}

/* Ресурсы рейда */
.raid-resource {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    text-shadow: var(--text-outline);
}

/* Способности босса */
.boss-power {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 2px 8px;
    background: rgba(255,200,0,0.08);
    border: 1px solid rgba(255,200,0,0.15);
    border-radius: var(--radius-sm);
    color: rgba(255,200,0,0.7);
    cursor: default;
}

/* Селектор сложности */
.boss-diff-select {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    outline: none;
    cursor: pointer;
    transition: border-color var(--tr-fast);
}
.boss-diff-select:hover, .boss-diff-select:focus {
    border-color: var(--accent-gold);
}
.boss-diff-select option {
    background: #1a1a2e;
    color: #fff;
}

/* Заблокированный босс */
.boss-locked .boss-controls button:disabled,
.boss-locked .boss-controls select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.boss-locked img {
    filter: grayscale(1);
}

/* Масштабированный переключатель (для боссов) */
.switch[style*="--switch-scale:0.7"] {
    transform: scale(0.8);
    transform-origin: left center;
}

/* ===== БОЕВОЙ ИНТЕРФЕЙС ===== */
.fight-ui {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.fight-enemy .fight-header {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    margin-bottom: var(--sp-xs);
}

.fight-name {
    font-size: 16px;
    font-weight: 700;
    text-shadow: var(--text-outline);
    flex: 1;
}

.fight-hp-text {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-red);
    text-align: center;
    text-shadow: var(--text-outline);
}

.fight-player .fight-bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fight-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fight-bar-label {
    font-size: 14px;
    width: 20px;
    text-align: center;
}

.fight-bar-val {
    font-size: 13px;
    font-weight: 700;
    min-width: 50px;
    text-align: right;
    color: rgba(255,255,255,0.9);
    text-shadow: var(--text-outline);
}

/* Скиллы */
.fight-skills {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-xs);
}

.fight-skill-btn {
    padding: var(--sp-sm);
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: #fff;
    cursor: pointer;
    transition: all var(--tr-fast);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.fight-skill-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.12);
    border-color: var(--accent-gold);
    transform: translateY(-1px);
}

.fight-skill-btn:active:not(:disabled) {
    transform: scale(0.97);
}

.fight-skill-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.fight-skill-btn.on-cooldown {
    opacity: 0.5;
    border-color: rgba(255,255,255,0.05);
}

.skill-name {
    font-size: 12px;
    font-weight: 600;
}

.skill-info {
    font-size: 10px;
    opacity: 0.6;
}

/* 🎒 Энергетические предметы в бою */
.fight-energy-items {
    display: flex;
    gap: 6px;
    margin-bottom: var(--sp-sm);
    flex-wrap: wrap;
}

.energy-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    cursor: pointer;
    min-width: 56px;
    transition: all 0.15s;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
}

.energy-item:hover {
    background: rgba(255,255,255,0.12);
    border-color: var(--accent-gold, #ffd43b);
    transform: translateY(-1px);
}

.energy-item:active {
    transform: scale(0.95);
}

.energy-item .energy-item-progress {
    display: none;
    width: 100%;
    height: 3px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
}

.energy-item .energy-item-progress div {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #ffd43b, #ff922b);
    transition: width 0.3s;
}

/* Анимация использования */
.energy-item.using {
    animation: energyPulse 0.5s ease-out;
}

@keyframes energyPulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 212, 59, 0.4); }
    100% { box-shadow: 0 0 0 10px rgba(255, 212, 59, 0); }
}

.fight-result {
    border: 1px solid var(--accent-gold);
    background: rgba(255,200,0,0.06);
}

/* ===== ЗАДАЧИ (на главной) ===== */
.task-item {
    padding: var(--sp-xs) 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.task-item:last-child { border-bottom: none; padding-bottom: 0; }

/* ===== АДАПТИВ: МОБИЛЬНЫЕ ===== */
@media (max-width: 700px) {
    #app { flex-direction: column; }

    /* Сайдбар → нижняя панель навигации */
    #sidebar {
        width: 100%;
        height: auto;
        padding: 0;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid rgba(255,255,255,0.08);
        order: 2;
        flex-shrink: 0;
        background: var(--tg-theme-secondary-bg-color, var(--bg-secondary));
    }

    /* Бейдж уровня — компактный, слева */
    .sidebar-header {
        padding: var(--sp-sm);
        margin: 0;
        border-bottom: none;
        border-right: 1px solid rgba(255,255,255,0.08);
        flex-shrink: 0;
    }

    .sidebar-level-badge { width: 40px; height: 40px; }
    .sidebar-level-badge .level-bg { width: 40px; height: 40px; }
    .sidebar-level-badge .level-num { font-size: 15px; }
    .sidebar-level-info { display: none; }

    .menu-header { display: none; }

    /* Меню — горизонтальное, с иконками и текстом */
    #sidebar ul {
        flex-direction: row;
        flex: 1;
        gap: 0;
        padding: 0;
    }

    .menu-item {
        flex: 1;
        flex-direction: column;
        justify-content: center;
        padding: var(--sp-xs) 0;
        font-size: 11px;
        gap: 2px;
        border-radius: 0;
        text-align: center;
    }

    .menu-item .menu-icon { font-size: 24px; }
    .menu-item .menu-icon img { width: 32px; height: 32px; }
    .menu-item .menu-text { font-size: 10px; }

    .menu-item.active { border-radius: 0; margin: 0; }
    .menu-item::after { display: none; }

    /* Footer — кнопка выхода справа */
    .menu-footer {
        display: flex;
        align-items: center;
        border-top: none;
        border-left: 1px solid rgba(255,255,255,0.08);
        padding: var(--sp-sm);
        margin: 0;
        flex-shrink: 0;
    }

    #userInfo { display: none; }
    .menu-footer > div:last-child { display: none; }

    .logout-link {
        font-size: 18px;
        padding: var(--sp-sm);
    }

    #content {
        padding: var(--sp-sm);
        order: 1;
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* Главная: 1 колонка на мобильном */
    .card-grid { grid-template-columns: 1fr; gap: var(--sp-sm); }

    .welcome-card { padding: var(--sp-xl) var(--sp-lg) var(--sp-lg); }
    .welcome-card h1 { font-size: 24px; }
}

@media (max-width: 380px) {
    .activity-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--sp-xs);
    }

    .menu-item .menu-text { font-size: 9px; }
    .menu-item .menu-icon { font-size: 22px; }
    .menu-item .menu-icon img { width: 30px; height: 30px; }
}

/* ===== СПИННЕР ЗАГРУЗКИ ВКЛАДОК ===== */
.tab-loader {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top: 3px solid var(--accent-blue, #4e8eff);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== РЫБАЛКА (ИВЕНТЫ) ===== */
.fishing-overlay {
    width: 100%;
    max-width: 100%;
}

.fishing-header {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    margin-bottom: var(--sp-lg);
}

.fishing-close {
    background: none;
    border: none;
    color: var(--accent-blue, #4e8eff);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: opacity var(--tr-fast);
    flex-shrink: 0;
}
.fishing-close:hover { opacity: 0.7; }

.fishing-balances {
    display: flex;
    gap: var(--sp-lg);
    flex-wrap: wrap;
    margin-top: var(--sp-xs);
}

.fishing-balance {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,0.05);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
}

.fishing-balance-val {
    font-weight: 700;
    font-size: 15px;
    color: rgba(255,255,255,0.9);
    font-variant-numeric: tabular-nums;
    text-shadow: var(--text-outline);
}

.fishing-balance-label {
    font-size: 12px;
    color: rgba(255,255,255,0.45);
}

.fishing-progress-val {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-blue, #4e8eff);
    text-shadow: var(--text-outline);
    margin-top: var(--sp-xs);
}

.fishing-territory {
    padding: var(--sp-sm) 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.fishing-territory:last-child { border-bottom: none; }
.fishing-territory.locked { opacity: 0.4; }

.fishing-territory-name {
    font-weight: 600;
    font-size: 14px;
    color: rgba(255,255,255,0.85);
    text-shadow: var(--text-outline);
}

.fishing-territory-info {
    font-size: 12px;
    color: rgba(255,255,255,0.45);
    margin-top: 2px;
}

#fishingLog {
    max-height: 400px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.6;
    font-family: 'Courier New', monospace;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-sm);
    padding: var(--sp-sm);
}

/* ===== АРЕНА ===== */

.arena-card {
    border-left: 3px solid rgba(201,151,0,0.3);
    transition: border-color 0.2s, transform 0.15s;
}

.arena-card:hover {
    border-left-color: rgba(201,151,0,0.6);
}

.smuggling-btn {
    transition: transform 0.15s, background 0.15s, border-color 0.15s;
}

.smuggling-btn:hover {
    background: rgba(255,255,255,0.1) !important;
    border-color: rgba(255,255,255,0.25) !important;
    transform: translateY(-2px);
}

.smuggling-btn:active {
    transform: translateY(0);
}

.arena-stat {
    background: rgba(255,255,255,0.04);
    border-radius: var(--radius-sm);
    padding: var(--sp-sm);
    text-align: center;
}

/* ===== АРЕНА v4 — детальное меню ===== */

.arena-detail-hero {
    background: linear-gradient(135deg, rgba(201,151,0,0.12), rgba(201,151,0,0.04));
    border: 1px solid rgba(201,151,0,0.2);
    border-radius: var(--radius);
    padding: var(--sp-md);
    margin-bottom: var(--sp-sm);
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
}

.arena-detail-hero .arena-hero-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    flex-shrink: 0;
}

.arena-detail-hero .arena-hero-info {
    flex: 1;
    min-width: 0;
}

.arena-detail-hero .arena-hero-name {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 2px;
}

.arena-detail-hero .arena-hero-desc {
    font-size: 12px;
    opacity: 0.65;
    line-height: 1.4;
}

.arena-settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--sp-md);
    margin-bottom: var(--sp-sm);
}

.arena-settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-sm);
    gap: var(--sp-sm);
}

.arena-settings-row:last-child {
    margin-bottom: 0;
}

.arena-settings-label {
    font-size: 13px;
    font-weight: 600;
}

.arena-settings-hint {
    font-size: 11px;
    opacity: 0.55;
    margin-top: 2px;
}

.arena-pill-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.arena-pill {
    flex: 1;
    min-width: 0;
    padding: 8px 6px;
    text-align: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg);
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    user-select: none;
}

.arena-pill.selected {
    background: rgba(201,151,0,0.15);
    border-color: rgba(201,151,0,0.5);
    color: #ffc107;
}

.arena-pill.selected-green {
    background: rgba(81,207,102,0.12);
    border-color: rgba(81,207,102,0.5);
    color: #51cf66;
}

.arena-minion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
    margin-top: var(--sp-sm);
}

.arena-minion-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    transition: border-color 0.15s, transform 0.1s;
    position: relative;
}

.arena-minion-tile:hover {
    transform: translateY(-2px);
}

.arena-minion-tile.selected {
    border-color: #51cf66;
    box-shadow: 0 0 8px rgba(81,207,102,0.3);
}

.arena-minion-tile.locked {
    opacity: 0.4;
    cursor: default;
}

.arena-minion-tile img {
    width: 36px;
    height: 36px;
    border-radius: 6px;
}

.arena-minion-tile .arena-minion-name {
    font-size: 10px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 64px;
    opacity: 0.8;
}

.arena-minion-check {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 14px;
    color: #51cf66;
    text-shadow: 0 0 4px rgba(0,0,0,0.5);
}

.arena-last-fight {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--sp-md);
    margin-bottom: var(--sp-sm);
}

.arena-last-fight-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: var(--sp-sm);
}

.arena-last-fight-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.arena-last-fight-stat {
    text-align: center;
    background: rgba(255,255,255,0.04);
    border-radius: var(--radius-sm);
    padding: 6px 4px;
}

.arena-last-fight-stat .lf-val {
    font-size: 16px;
    font-weight: 700;
}

.arena-last-fight-stat .lf-label {
    font-size: 10px;
    opacity: 0.55;
}

.arena-start-btn {
    width: 100%;
    font-size: 15px;
    font-weight: 700;
    padding: var(--sp-md);
    margin-bottom: var(--sp-sm);
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s;
}

.arena-start-btn:active {
    transform: scale(0.98);
}

/* ===== СЕРВЕРНАЯ АРЕНА — СТАТУС ===== */
.server-arena-pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #51cf66;
    margin-right: 6px;
    animation: serverArenaPulse 1.5s ease-in-out infinite;
}

@keyframes serverArenaPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.7); }
}

.server-arena-card {
    background: linear-gradient(135deg, rgba(76,175,80,0.08), rgba(255,255,255,0.04));
    border: 1px solid rgba(76,175,80,0.2);
    border-radius: var(--radius-md);
    padding: var(--sp-md);
    margin-bottom: var(--sp-sm);
}

.server-arena-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-xs);
    text-align: center;
}

.server-arena-stats > div > div:first-child {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.server-arena-stats > div > div:last-child {
    font-size: 10px;
    opacity: 0.55;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== УЛУЧШЕННАЯ ТИПОГРАФИКА ===== */
.tab-title {
    font-weight: 800;
    letter-spacing: -0.3px;
    font-size: 18px;
}

.value {
    font-weight: 800;
    letter-spacing: -0.3px;
}

.sub {
    font-weight: 500;
    opacity: 0.65;
}

.activity-name {
    font-weight: 700;
    letter-spacing: -0.2px;
}

.fight-name {
    font-weight: 800;
    letter-spacing: -0.3px;
}

/* ===== БЫСТРЫЕ ПЕРЕХОДЫ ===== */
.card {
    transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.card:active {
    transform: scale(0.99);
}

/* ===== SKILL BUTTONS — БЫСТРЫЙ ОТКЛИК ===== */
.fight-skills .skill-btn {
    transition: transform 0.08s ease, background 0.12s ease;
}

.fight-skills .skill-btn:active {
    transform: scale(0.95);
}

/* ===== ПЛАВНОСТЬ БОЕВОГО ИНТЕРФЕЙСА ===== */
/* Прогресс-бары: плавная анимация ширины (не мерцает при re-render) */
/* (базовый стиль .progress-fill уже содержит transition: width 0.3s) */

/* Боевой UI: изоляция для предотвращения reflow */
.fight-ui {
    contain: layout style;
}

/* Карточки в бою: стабильные размеры */
.fight-ui .card {
    contain: layout style paint;
}

/* Скиллы: GPU-ускорение */
.fight-skill-btn {
    will-change: transform;
    contain: layout style;
}

/* Свернутый бой: плавное появление */
.fight-minimized-bar {
    animation: tabEnter 0.15s ease-out;
}

/* Рейд-вкладки: плавный переход */
.raid-tab {
    transition: background 0.15s, color 0.15s;
    will-change: background;
}

/* Карточки авторитетов: стабильный layout */
.auth-boss-card {
    contain: layout style;
    transition: border-color 0.15s;
}

/* Пилюли сложности: без layout shift */
.auth-diff-btn {
    transition: background 0.12s, color 0.12s;
    will-change: background;
}

/* Контент рейда: изоляция */
#raid-content {
    contain: layout style;
}

/* Список арен: плавность */
.arena-card {
    contain: layout style;
    transition: transform 0.12s, border-color 0.15s;
}

/* Серверная арена: плавная плашка */
.server-arena-pulse-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #51cf66;
    animation: serverArenaPulse 1.5s ease-in-out infinite;
    vertical-align: middle;
    margin-right: 4px;
}

/* ===== ТРЕЙ АВТОБОЯ (глобальный, на любой вкладке) ===== */

#autofight-dock {
    position: fixed;
    right: 10px;
    top: 10px;
    z-index: 9000;
    display: flex;
    gap: 6px;
    flex-direction: column;
    align-items: flex-end;
    max-width: 240px;
    pointer-events: none; /* контейнер не перехватывает клики, только плашки */
}

#autofight-dock:empty { display: none; }

.autofight-chip {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 12px;
    background: rgba(20, 20, 40, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
    user-select: none;
    transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
    animation: dockChipIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
    max-width: 220px;
}

.autofight-chip:hover { transform: translateY(-1px); border-color: rgba(255, 255, 255, 0.28); }
.autofight-chip:active { transform: scale(0.96); }

.autofight-chip-icon {
    font-size: 18px;
    flex: 0 0 auto;
}

.autofight-chip-info {
    flex: 1;
    min-width: 0;
    line-height: 1.15;
}

.autofight-chip-title {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.92);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autofight-chip-sub {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
}

.autofight-chip-stop {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 80, 80, 0.18);
    border: 1px solid rgba(255, 80, 80, 0.4);
    color: rgba(255, 120, 120, 0.95);
    font-size: 11px;
    transition: background 0.12s;
}

.autofight-chip-stop:hover { background: rgba(255, 80, 80, 0.35); }

@keyframes dockChipIn {
    from { opacity: 0; transform: translateY(12px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Пульсирующая точка-индикатор на плашке трея */
.autofight-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 auto;
    animation: serverArenaPulse 1.5s ease-in-out infinite;
}

/* ===== ПАНЕЛЬ НАБЛЮДЕНИЯ ЗА БОЕМ ===== */

#fight-watcher {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 20px;
    z-index: 9500;
    width: min(480px, calc(100vw - 16px));
    max-height: min(70vh, 600px);
    background: rgba(16, 16, 34, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 18px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: opacity 0.15s, transform 0.15s;
    contain: layout style;
}

#fight-watcher.fight-watcher-hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(16px);
    pointer-events: none;
    visibility: hidden;
}

#fight-watcher-content {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
    flex: 1;
    min-height: 0;
    scrollbar-width: thin;
}

#fight-watcher-content::-webkit-scrollbar { width: 4px; }
#fight-watcher-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 4px; }

/* Шапка панели наблюдения */
.fight-watcher-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    flex: 0 0 auto;
}

.fight-watcher-header .fw-title {
    font-size: 13px;
    font-weight: 700;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fight-watcher-header .fw-actions {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
}

.fw-btn {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: background 0.12s;
    white-space: nowrap;
}

.fw-btn:hover { background: rgba(255, 255, 255, 0.12); }

.fw-btn-danger {
    background: rgba(255, 80, 80, 0.15);
    border-color: rgba(255, 80, 80, 0.35);
    color: rgba(255, 120, 120, 0.95);
}

.fw-btn-danger:hover { background: rgba(255, 80, 80, 0.3); }

.fw-btn-green {
    background: rgba(81, 207, 102, 0.15);
    border-color: rgba(81, 207, 102, 0.35);
    color: #51cf66;
}

.fw-btn-green:hover { background: rgba(81, 207, 102, 0.28); }

/* ═══════════════════════════════════════════════
    🔔 ЗВОНОЧЕК УВЕДОМЛЕНИЙ (АДАПТИВНЫЙ)
    ═══════════════════════════════════════════════ */
/* 1. Десктопный вид (внутри сайдбара) */
.bell-container {
    position: relative;
    margin-left: auto;
    cursor: pointer;
    padding: 5px;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    border-radius: 50%;
    background: transparent;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.bell-container:hover {
    background: rgba(255, 255, 255, 0.08);
}
.bell-container:active { transform: scale(0.9); }
.bell-icon { display: inline-flex; align-items: center; justify-content: center; }
.bell-icon img { width: 20px; height: 20px; display: block; }
.bell-container .badge {
    position: absolute;
    top: -2px;
    right: -4px;
    background: var(--accent-red, #ff5252);
    color: #fff;
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 10px;
    font-weight: 800;
    min-width: 14px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(255, 82, 82, 0.5);
    pointer-events: none;
}

/* 2. Мобильный вид: отвязываем от нижней панели, делаем парящей кнопкой */
@media (max-width: 700px) {
    .bell-container {
        position: fixed;
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
        margin: 0;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(30, 30, 50, 0.85); /* Стеклянный эффект */
        border: 1px solid rgba(255, 255, 255, 0.15);
        border-radius: 50%;
        z-index: 8500;
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
        touch-action: none; /* ⚡ Разрешаем drag без скролла */
    }
    .bell-container .bell-icon img {
        font-size: 18px;
        width: 18px;
        height: 18px;
    }
    .bell-container .badge {
        top: -2px;
        right: -2px;
        font-size: 10px;
        padding: 2px 6px;
        border: 2px solid var(--bg-primary, #0a0a1a); /* Вырез на фоне кнопки */
    }
    /* Сдвигаем трей автобоя ниже на мобилках, чтобы он не перекрывал звоночек */
    #autofight-dock {
        top: 56px !important;
    }
}

/* Модалка уведомлений */
.notif-modal-hidden { display: none !important; }
#notif-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: notifFadeIn 0.18s ease-out;
}
@keyframes notifFadeIn { from { opacity: 0; } to { opacity: 1; } }
.notif-modal-content {
    background: var(--bg-card, #16162a);
    border: 1px solid var(--border, rgba(255,255,255,0.1));
    border-radius: var(--radius, 14px);
    width: 92%;
    max-width: 420px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.notif-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px 4px;
}
.notif-modal-close {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text, #fff);
    border-radius: 8px;
    width: 30px;
    height: 30px;
    font-size: 14px;
    cursor: pointer;
}
.notif-modal-list {
    overflow-y: auto;
    padding: 8px 10px;
    flex: 1;
    min-height: 120px;
}
.notif-modal-footer { padding: 10px 14px; border-top: 1px solid var(--border, rgba(255,255,255,0.08)); }
.notif-item {
    display: flex;
    gap: 10px;
    padding: 10px 8px;
    border-radius: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.15s;
}
.notif-item:hover { background: rgba(255, 255, 255, 0.04); }
.notif-item:last-child { border-bottom: none; }
.notif-unread { background: rgba(78, 142, 255, 0.08); }
.notif-unread::before {
    content: '●';
    color: #4e8eff;
    font-size: 8px;
    align-self: flex-start;
    margin-top: 5px;
    flex-shrink: 0;
}
.notif-item-icon { font-size: 20px; flex-shrink: 0; margin-top: 2px; }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-text { font-size: 13px; line-height: 1.4; word-wrap: break-word; }
.notif-item-time { font-size: 10px; opacity: 0.45; margin-top: 3px; }

/* ⚡ Умный автобой боссов — пилюли самогона */
.boss-moonshine-pill.selected {
    background: rgba(255, 193, 7, 0.15) !important;
    border-color: rgba(255, 193, 7, 0.5) !important;
    color: #ffc107 !important;
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.2);
}
.boss-moonshine-pill:hover { border-color: rgba(255, 193, 7, 0.35); }
.boss-smart-card { border: 1px solid rgba(78, 142, 255, 0.2); }
.boss-smart-card h3 { color: var(--accent-blue, #4e8eff); }

/* ═══ 🎴 ИВЕНТ «ЖЕЛАНИЕ СТАРШЕГО» ═══ */
.elder-overlay {
    padding: 0;
}
.elder-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: var(--sp-md);
}
.elder-close {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--sp-text, #e0e0e0);
    padding: 6px 14px;
    border-radius: var(--radius-md, 10px);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.elder-close:hover { background: rgba(255, 255, 255, 0.15); }
.elder-close:active { transform: scale(0.95); }

.elder-grid {
    display: grid;
    gap: var(--sp-md, 12px);
    grid-template-columns: 1fr;
}

/* Заголовок карточки (прошлый ивент) */
.card-title {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    text-shadow: var(--text-outline-shadow, 0 1px 2px rgba(0,0,0,0.7));
    letter-spacing: 0.2px;
    margin-bottom: 4px;
}
.card-title img { flex-shrink: 0; }

/* Подпись настройки (прошлый ивент) */
.setting-label {
    font-size: 14px;
    color: rgba(255,255,255,0.85);
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.elder-balances {
    display: flex;
    align-items: center;
    gap: 12px;
}
.elder-balance {
    display: flex;
    align-items: center;
    gap: 6px;
}
.elder-balance-val {
    font-size: 15px;
    font-weight: 700;
    color: var(--sp-text, #e0e0e0);
}

.elder-step {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.elder-step:last-child { border-bottom: none; }

.elder-majong {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.elder-majong-level {
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md, 10px);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.elder-reward {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.elder-reward:last-child { border-bottom: none; }
