* {
    box-sizing: border-box;
    user-select: none;
    transition: background-color 0.2s ease, border-color 0.2s, box-shadow 0.2s, color 0.2s;
}
:root {
    --bg-gradient-start: #1a2634;
    --bg-gradient-end: #0e1419;
    --container-bg: rgba(22, 30, 38, 0.85);
    --panel-bg: #0b1014;
    --text-primary: #ffffff;
    --text-secondary: #c0d0e0;
    --accent-gold: #FFB347;
    --accent-glow: #ffd966;
    --card-bg: #1e2a32;
    --card-border: #3a4a56;
    --stat-bg: #0f181f;
    --button-click-bg: radial-gradient(circle at 30% 20%, #ffd966, #e67e22);
    --button-shadow: #b45f1b;
    --buy-btn-bg: #3a6b47;
    --buy-btn-shadow: #1e3a2f;
    --reset-bg: #3c2e2b;
    --reset-text: #ffb4a2;
    --health-color: #e74c3c;
    --hunger-color: #f39c12;
    --cold-color: #3498db;
}
body.light-theme {
    --bg-gradient-start: #f0f2f5;
    --bg-gradient-end: #d6dce2;
    --container-bg: rgba(245, 248, 250, 0.95);
    --panel-bg: #ffffff;
    --text-primary: #1e2a32;
    --text-secondary: #4a6272;
    --accent-gold: #e67e22;
    --accent-glow: #f39c12;
    --card-bg: #ffffff;
    --card-border: #cfdde6;
    --stat-bg: #eef2f5;
    --button-click-bg: radial-gradient(circle at 30% 20%, #ffe0a3, #f0b27a);
    --button-shadow: #b45f1b;
    --buy-btn-bg: #2c6e49;
    --buy-btn-shadow: #1e462f;
    --reset-bg: #e0cfc9;
    --reset-text: #b85c3a;
}
body {
    background: linear-gradient(145deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    margin: 0;
    padding: 20px;
    color: var(--text-primary);
    flex-direction: column;
}

/* Авторизация */
.auth-container {
    background: var(--container-bg);
    backdrop-filter: blur(4px);
    border-radius: 64px;
    padding: 30px 25px;
    width: 100%;
    max-width: 450px;
    text-align: center;
    box-shadow: 0 25px 45px rgba(0,0,0,0.3);
}
.auth-container h2 {
    margin-top: 0;
    color: var(--accent-gold);
}
.auth-container input {
    width: 100%;
    padding: 12px;
    margin: 8px 0;
    border-radius: 40px;
    border: 1px solid var(--card-border);
    background: var(--stat-bg);
    color: var(--text-primary);
    font-size: 1rem;
}
.auth-container button {
    width: 100%;
    margin-top: 12px;
}
.switch-link {
    color: var(--accent-gold);
    cursor: pointer;
    text-decoration: underline;
    margin-top: 15px;
    display: inline-block;
}
.error-msg {
    color: #ff8888;
    margin-top: 10px;
    font-size: 0.85rem;
}

/* Splash screen */
#splash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0b1014;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    transition: opacity 0.3s ease;
}
#splash img {
    max-width: 80%;
    max-height: 70%;
    object-fit: contain;
    border-radius: 32px;
}
.splash-text {
    margin-top: 20px;
    padding: 10px 24px;
    background: rgba(0, 0, 0, 0.8);
    color: #ffffff;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 40px;
    letter-spacing: 1px;
    backdrop-filter: blur(4px);
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    animation: pulse 1.5s infinite;
}

/* ===== ЭНЕРГИЯ ===== */
.energy-fill {
    background: linear-gradient(90deg, #f1c40f, #e67e22) !important;
}

@keyframes pulse {
    0% { opacity: 0.7; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.02); }
    100% { opacity: 0.7; transform: scale(1); }
}

/* Игровой контейнер */
.game-container {
    background: var(--container-bg);
    backdrop-filter: blur(4px);
    border-radius: 64px;
    box-shadow: 0 25px 45px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
    width: 95%;
    max-width: 1600px;
    display: none;
    gap: 24px;
    padding: 24px;
    margin: 0 auto;
}

/* Левая колонка (локация) */
.game-left {
    flex: 2;
    min-width: 300px;
    position: relative;
    background: transparent;
    border-radius: 48px;
    overflow: hidden;
    aspect-ratio: 4 / 3;
}

/* Правая колонка (персонаж) */
.game-right {
    flex: 1;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.player-nick {
    font-size: 1.4rem;
    font-weight: bold;
    text-align: center;
    background: var(--panel-bg);
    padding: 8px;
    border-radius: 60px;
}
.avatar-gif {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 32px;
    background: transparent !important;
    border: 3px solid var(--accent-gold);
    object-fit: contain;
    align-self: center;
    position: relative;
}

/* Единый фон через псевдоэлементы */
.game-left::before,
.avatar-gif::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: var(--location-bg, none);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    border-radius: inherit;
}

.game-left::before {
    border-radius: 48px;
}

.avatar-gif::before {
    border-radius: 32px;
}

/* Скрываем старый фоновый слой в левой колонке */
.location-bg {
    display: none;
}

/* Название локации */
.location-name {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    z-index: 2;
    text-align: center;
    font-size: 1.3rem;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    padding: 10px;
    border-radius: 60px;
    color: var(--accent-gold);
}

/* Контейнер для кликабельных зон (SVG) */
.location-zones {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}
.location-zones svg {
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.location-zones circle {
    pointer-events: visible;
    cursor: pointer;
    transition: fill 0.1s, stroke 0.1s;
    fill: rgba(0, 200, 0, 0.3);
    stroke: rgba(0, 200, 0, 0.7);
    stroke-width: 2;
}
.location-zones circle:hover {
    fill: rgba(0, 200, 0, 0.6);
    stroke: rgba(0, 200, 0, 1);
}

/* Статистика */
.stats-panel {
    background: var(--panel-bg);
    border-radius: 48px;
    padding: 16px 20px;
}
.stat {
    margin-bottom: 12px;
}
.stat-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.85rem;
}
.stat-bar {
    height: 12px;
    background: var(--stat-bg);
    border-radius: 12px;
    overflow: hidden;
}
.stat-fill {
    height: 100%;
    border-radius: 12px;
    width: 100%;
    transition: width 0.3s ease;
}
.health-fill { background: var(--health-color); }
.hunger-fill { background: var(--hunger-color); }
.cold-fill { background: var(--cold-color); }
.money {
    background: var(--accent-gold);
    color: #1e2a32;
    padding: 10px;
    border-radius: 40px;
    text-align: center;
    font-weight: bold;
    margin-top: 16px;
}

/* Кнопки */
.action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.action-btn {
    flex: 1;
    background: var(--buy-btn-bg);
    border: none;
    padding: 12px 0;
    border-radius: 40px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    box-shadow: 0 2px 0 var(--buy-btn-shadow);
    transition: 0.05s linear;
}
.action-btn:active {
    transform: translateY(2px);
}
.settings-item {
    text-align: center;
}
.reset-btn {
    background: var(--reset-bg);
    color: var(--reset-text);
    border: none;
    padding: 10px 25px;
    border-radius: 40px;
    font-weight: bold;
    cursor: pointer;
}
.game-footer {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}
.modal-content {
    background: var(--card-bg);
    border-radius: 48px;
    padding: 24px;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid var(--card-border);
}
.modal-content h3 {
    margin-top: 0;
    color: var(--accent-gold);
}
.inventory-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.inventory-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--stat-bg);
    padding: 10px 16px;
    border-radius: 40px;
    gap: 10px;
    flex-wrap: wrap;
}
.item-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 2;
}
.item-icon {
    font-size: 1.6rem;
}
.item-name {
    font-weight: bold;
}
.item-count {
    background: var(--card-bg);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.8rem;
}
.use-btn, .equip-btn, .unequip-btn, .action-location-btn {
    background: var(--buy-btn-bg);
    border: none;
    padding: 6px 16px;
    border-radius: 40px;
    color: white;
    cursor: pointer;
    font-weight: bold;
}
.unequip-btn {
    background: #7f8c8d;
}
.equipment-slots {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.slot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--stat-bg);
    padding: 12px 16px;
    border-radius: 40px;
}
.slot-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.slot-icon {
    font-size: 1.5rem;
}
.slot-name {
    font-weight: bold;
}
.slot-empty {
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.close-modal {
    background: var(--reset-bg);
    margin-top: 20px;
    padding: 8px 24px;
    border: none;
    border-radius: 40px;
    cursor: pointer;
    color: var(--text-primary);
    width: 100%;
}
.global-footer {
    text-align: center;
    margin-top: 30px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.7;
}
.global-footer p {
    margin: 4px 0;
}

/* Стили для карты */
.map-container {
    position: relative;
    display: inline-block;
    width: 100%;
    background: var(--stat-bg);
    border-radius: 32px;
    padding: 8px;
}
.map-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 24px;
}
.map-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
.map-overlay circle {
    pointer-events: visible;
    cursor: pointer;
    transition: stroke 0.1s, fill 0.1s;
    fill: rgba(0, 200, 0, 0.25);
    stroke: rgba(0, 200, 0, 0.6);
    stroke-width: 2;
}
.map-overlay circle:hover {
    fill: rgba(0, 200, 0, 0.5);
    stroke: rgba(0, 200, 0, 1);
}
.location-tooltip {
    position: fixed;
    background: rgba(0,0,0,0.8);
    color: #ffd966;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 1001;
    white-space: nowrap;
    font-weight: bold;
}

/* Блок времени и погоды */
.time-weather {
    text-align: center;
    font-size: 1rem;
    font-weight: bold;
    background: var(--stat-bg);
    padding: 8px 12px;
    border-radius: 60px;
    margin: 8px 0;
    color: var(--accent-gold);
    letter-spacing: 1px;
}

/* ===== СЛОИ ДЛЯ ПОГОДНЫХ ЭФФЕКТОВ ===== */
#darkOverlay,
#particlesCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 4;
}
#particlesCanvas {
    z-index: 5;
}
.location-zones {
    z-index: 6 !important;
}
/* ===== ЛОГ ДЕЙСТВИЙ (ИСТОРИЯ) ===== */
.log-container {
    background: var(--panel-bg);
    border-radius: 48px;
    padding: 12px 16px;
    margin: 8px 0;
}

.log-header {
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--accent-gold);
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.log-panel {
    max-height: 150px;
    overflow-y: auto;
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 4px;
}

/* Стили для отдельных записей лога */
.log-entry {
    padding: 4px 8px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-left: 3px solid var(--accent-gold);
    color: var(--text-secondary);
    transition: 0.1s;
}

.log-entry:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Цвета для разных типов сообщений */
.log-entry.location {
    border-left-color: #3498db;
}
.log-entry.item {
    border-left-color: #2ecc71;
}
.log-entry.combat {
    border-left-color: #e74c3c;
}
.log-entry.economy {
    border-left-color: #f1c40f;
}
.log-entry.weather {
    border-left-color: #9b59b6;
}
.log-entry.system {
    border-left-color: #95a5a6;
}

/* Время в логе */
.log-time {
    color: var(--accent-gold);
    font-size: 0.65rem;
    margin-right: 8px;
    font-weight: bold;
}

/* Скроллбар для лога */
.log-panel::-webkit-scrollbar {
    width: 4px;
}
.log-panel::-webkit-scrollbar-track {
    background: var(--stat-bg);
    border-radius: 4px;
}
.log-panel::-webkit-scrollbar-thumb {
    background: var(--accent-gold);
    border-radius: 4px;
}

/* ===== БЛОК ОПЫТА И УРОВНЯ ===== */
.exp-panel {
    background: var(--panel-bg);
    border-radius: 48px;
    padding: 12px 16px;
    margin: 8px 0;
}

.exp-header {
    font-size: 0.85rem;
    font-weight: bold;
    text-align: center;
    color: var(--accent-gold);
    margin-bottom: 6px;
    letter-spacing: 1px;
}

.exp-bar {
    height: 12px;
    background: var(--stat-bg);
    border-radius: 12px;
    overflow: hidden;
    margin: 6px 0;
}

.exp-fill {
    height: 100%;
    background: linear-gradient(90deg, #9b59b6, #8e44ad);
    border-radius: 12px;
    width: 0%;
    transition: width 0.3s ease;
}

.exp-text {
    font-size: 0.7rem;
    text-align: center;
    color: var(--text-secondary);
}

/* ===== ТОП ИГРОКОВ (ПОДСВЕТКА МЕСТ) ===== */
.top-player-1 {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(255, 215, 0, 0.1));
    border-left: 5px solid #FFD700;
    font-weight: bold;
}
.top-player-2 {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.3), rgba(192, 192, 192, 0.1));
    border-left: 5px solid #C0C0C0;
}
.top-player-3 {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.3), rgba(205, 127, 50, 0.1));
    border-left: 5px solid #CD7F32;
}
.player-rank {
    display: inline-block;
    width: 35px;
    font-weight: bold;
}
.player-level {
    background: var(--card-bg);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.8rem;
    margin-left: 12px;
}
.player-exp {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: 12px;
}
.top-refresh-btn {
    background: var(--buy-btn-bg);
    border: none;
    padding: 6px 16px;
    border-radius: 40px;
    color: white;
    cursor: pointer;
    font-size: 0.8rem;
    margin-bottom: 12px;
    display: inline-block;
}

/* ===== КАСТОМНЫЕ СТИЛИ ДЛЯ ТОПА ===== */
#topModal .player-nick {
    font-size: 0.9rem;  /* ник помельче */
    font-weight: normal;
    background: var(--card-bg);
    padding: 2px 12px;
    border-radius: 40px;
    margin: 0 8px;
}

#topModal .player-rank {
    font-size: 1.2rem;   /* ранг крупнее */
    font-weight: bold;
    width: 50px;
    display: inline-block;
}

#topModal .player-level {
    font-size: 1rem;     /* уровень крупнее */
    font-weight: bold;
    background: none;
    padding: 0;
}

#topModal .player-exp {
    font-size: 0.85rem;  /* опыт крупнее */
    color: var(--accent-gold);
    margin-left: 12px;
}

#topModal .player-item {
    padding: 12px 16px;   /* больше отступы в строках */
    margin-bottom: 4px;
}

/* ===== МОДАЛЬНОЕ ОКНО ДЛЯ СОБЫТИЙ (УВЕЛИЧЕННОЕ, С ЦЕНТРИРОВАНИЕМ) ===== */
#eventModal .modal-content {
    max-width: 550px;
    width: 90%;
    text-align: center;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#eventModal h3 {
    font-size: 1.6rem;
    margin-top: 0;
    margin-bottom: 16px;
    color: var(--accent-gold);
    text-align: center;
}

#eventModal img {
    width: auto;
    max-width: 100%;
    max-height: 300px;
    height: auto;
    border-radius: 32px;
    margin: 0 auto 16px;
    display: block;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    object-fit: contain;
}

#eventModal p {
    font-size: 1.1rem;
    line-height: 1.4;
    margin-bottom: 20px;
    color: var(--text-primary);
    text-align: center;
}

#eventModal .action-btn {
    font-size: 1rem;
    padding: 10px 24px;
    margin: 5px;
    min-width: 120px;
    background: var(--buy-btn-bg);
    border: none;
    border-radius: 40px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    box-shadow: 0 2px 0 var(--buy-btn-shadow);
    transition: 0.05s linear;
}

#eventModal .action-btn:active {
    transform: translateY(2px);
}

#eventModal .event-choice-btn {
    background: var(--buy-btn-bg);
    border: none;
    padding: 10px 20px;
    border-radius: 40px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    margin: 6px;
    transition: 0.05s linear;
    box-shadow: 0 2px 0 var(--buy-btn-shadow);
}

#eventModal .event-choice-btn:active {
    transform: translateY(2px);
}
/* ========== АДАПТИВНОСТЬ (МЕДИА-ЗАПРОСЫ) ========== */

/* Десктопы, планшеты (ширина ≥ 901px) */
@media (min-width: 901px) {
    .game-container {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
    }
    .game-left {
        flex: 2 !important;
        width: auto !important;
    }
    .game-right {
        flex: 1.2 !important;
        width: auto !important;
    }
}

/* Планшеты и узкие десктопы (769px - 900px) */
@media (min-width: 769px) and (max-width: 900px) {
    .game-container {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: 16px;
        padding: 16px;
    }
    .game-left {
        flex: 1.8 !important;
        width: auto !important;
    }
    .game-right {
        flex: 1.2 !important;
        width: auto !important;
    }
}

/* Мобильные устройства (горизонтальная ориентация) */
@media (max-width: 768px) and (orientation: landscape) {
    .game-container {
        display: flex !important;
        flex-direction: row !important;
        gap: 12px;
        padding: 12px;
    }
    .game-left {
        flex: 1.5 !important;
        min-width: 200px;
        aspect-ratio: 16 / 10;
    }
    .game-right {
        flex: 1 !important;
        min-width: 220px;
        gap: 8px;
    }
    .avatar-gif {
        max-width: 120px;
    }
    .stats-panel {
        padding: 6px 10px;
    }
    .stat {
        margin-bottom: 4px;
    }
    .stat-header {
        font-size: 0.65rem;
    }
    .action-btn {
        padding: 6px 0;
        font-size: 0.65rem;
    }
    .log-panel {
        max-height: 80px;
    }
    .time-weather {
        font-size: 0.65rem;
        padding: 4px 8px;
    }
    .exp-panel {
        padding: 6px 10px;
    }
    .exp-header {
        font-size: 0.65rem;
    }
    .exp-text {
        font-size: 0.55rem;
    }
}

/* Мобильные устройства (вертикальная ориентация) */
@media (max-width: 768px) and (orientation: portrait) {
    .game-container {
        flex-direction: column !important;
        align-items: center;
        gap: 16px;
        padding: 16px;
    }
    .game-left {
        width: 100%;
        aspect-ratio: 16 / 9;
    }
    .avatar-gif {
        max-width: 200px;
    }
    .game-right {
        width: 100%;
    }
}

/* Очень маленькие экраны (до 480px) */
@media (max-width: 480px) {
    .action-btn { 
        font-size: 0.7rem; 
        padding: 8px 0; 
    }
    .inventory-item { 
        flex-direction: column; 
        text-align: center; 
    }
    .item-info { 
        justify-content: center; 
    }
    .slot { 
        flex-direction: column; 
        text-align: center; 
        gap: 8px; 
    }
}

/* Ультраширокие экраны (2000px+) */
@media (min-width: 2000px) {
    .game-container {
        width: 80%;
        max-width: 1800px;
    }
}

/* Промежуточные экраны (ноутбуки) */
@media (max-width: 1200px) and (min-width: 901px) {
    .game-container {
        width: 98%;
        padding: 16px;
        gap: 16px;
    }
    .location-name {
        font-size: 1.1rem;
        top: 8px;
        left: 8px;
        right: 8px;
    }
}

.game-container-hidden {
    display: none !important;
}
