/* Базовые настройки */
* {
    box-sizing: border-box;
}

:root {
    --bg-1: #0b1020;
    --bg-2: #0f1530;
    --panel: rgba(18, 24, 48, 0.72);
    --panel-border: rgba(255, 255, 255, 0.12);
    --text: #e8ecf3;
    --muted: #a8b0c2;
    --accent: #7cc2ff;
    --accent-2: #8b79ff;
    --danger: #ff5d6c;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --radius: 14px;
}

html, body {
    margin: 0;
    height: 100%;
    background: radial-gradient(1200px 800px at 20% 0%, var(--bg-2), var(--bg-1));
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Inter, Arial, "Noto Sans", system-ui, sans-serif;
    overflow: hidden;
}

/* Канвас на весь экран */
#gameCanvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    display: block;
}

.top-action {
    position: fixed;
    top: 12px;
    z-index: 30;
}

#locationMenuButton {
    left: 12px;
}

#settingsButton {
    right: 12px;
}

/* Информационная панель */
#ui {
    position: fixed;
    top: 64px;
    right: 16px;
    min-width: 260px;
    max-width: 360px;
    padding: 14px 16px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    line-height: 1.55;
    z-index: 10;
}

#ui #itemsStatus {
    margin-top: 10px;
    color: var(--muted);
}

#ui span {
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* Блок управления */
#controls {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10;
}

/* Кнопки */
button {
    appearance: none;
    border: 0;
    border-radius: 12px;
    padding: 10px 14px;
    min-width: 180px;
    color: #0a0f1a;
    background: linear-gradient(180deg, #9ad4ff, #6ebeff);
    font-weight: 700;
    letter-spacing: 0.2px;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(124, 194, 255, 0.35), inset 0 1px 0 rgba(255,255,255,0.45);
    transition: transform 0.08s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

button:hover {
    filter: brightness(1.05);
    box-shadow: 0 10px 22px rgba(124, 194, 255, 0.45), inset 0 1px 0 rgba(255,255,255,0.55);
}

button:active {
    transform: translateY(1px);
    box-shadow: 0 6px 14px rgba(124, 194, 255, 0.28), inset 0 1px 0 rgba(255,255,255,0.4);
}

button[disabled], button:disabled {
    cursor: not-allowed;
    filter: grayscale(0.4) brightness(0.85);
    opacity: 0.7;
}

/* Варианты кнопок */
button.secondary {
    background: linear-gradient(180deg, #d5d9e6, #c7cede);
    color: #1a2236;
    box-shadow: 0 8px 18px rgba(208, 216, 232, 0.35), inset 0 1px 0 rgba(255,255,255,0.55);
}

button.danger {
    background: linear-gradient(180deg, #ff98a3, #ff6c7b);
    color: #23070a;
    box-shadow: 0 8px 18px rgba(255, 109, 123, 0.35), inset 0 1px 0 rgba(255,255,255,0.45);
}

/* Модалки магазина/событий */
.event-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 560px;
    width: calc(100% - 32px);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 18px 16px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    -webkit-overflow-scrolling: touch;
    z-index: 26000;
}

.event-modal div:first-child {
    font-weight: 800;
    font-size: 20px;
    margin-bottom: 10px;
    color: #ffffff;
}

.event-modal button {
    width: 100%;
    margin: 6px 0;
}

/* Меню локаций (поверх всего) */
#locationModal {
    z-index: 26001 !important;
    max-width: 520px;
    width: calc(100% - 32px);
    background: rgba(16, 20, 36, 0.95) !important;
    color: var(--text) !important;
    border: 1px solid var(--panel-border) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow) !important;
}

#locationModal button {
    width: 100%;
    margin: 6px 0;
}

/* Адаптивность */
@media (max-width: 900px) {
    #ui {
        top: 60px;
        right: 12px;
        min-width: 220px;
        font-size: 14px;
    }
    #controls {
        left: 50%;
        bottom: 12px;
        transform: translateX(-50%);
        width: calc(100% - 24px);
        justify-content: center;
        gap: 8px;
        padding: 10px;
    }
    button {
        min-width: 140px;
        padding: 9px 12px;
        font-size: 14px;
    }
}

@media (max-width: 520px) {
    #ui {
        top: 58px;
        left: 12px;
        right: 12px;
        max-width: unset;
        min-width: 0;
        max-height: 34vh;
        overflow-y: auto;
    }
    #controls {
        width: calc(100% - 24px);
        max-height: 42vh;
        overflow-y: auto;
    }
    button {
        min-width: min(100%, 180px);
    }
}

/* Скрытие экрана загрузки после инициализации */
#loadingScreen.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: -1 !important;
}

/* Стили для экранов игры */
.game-screen {
    transition: opacity 0.3s ease;
}

.menu-button {
    appearance: none;
    border: 0;
    border-radius: 12px;
    padding: 12px 24px;
    color: #0a0f1a;
    background: linear-gradient(180deg, #9ad4ff, #6ebeff);
    font-weight: 700;
    letter-spacing: 0.2px;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(124, 194, 255, 0.35), inset 0 1px 0 rgba(255,255,255,0.45);
    transition: transform 0.08s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.menu-button:hover {
    filter: brightness(1.05);
    box-shadow: 0 10px 22px rgba(124, 194, 255, 0.45), inset 0 1px 0 rgba(255,255,255,0.55);
}

.menu-button:active {
    transform: translateY(1px);
    box-shadow: 0 6px 14px rgba(124, 194, 255, 0.28), inset 0 1px 0 rgba(255,255,255,0.4);
}

.menu-button.secondary {
    background: linear-gradient(180deg, #d5d9e6, #c7cede);
    color: #1a2236;
    box-shadow: 0 8px 18px rgba(208, 216, 232, 0.35), inset 0 1px 0 rgba(255,255,255,0.55);
}

.menu-button.danger {
    background: linear-gradient(180deg, #ff98a3, #ff6c7b);
    color: #23070a;
    box-shadow: 0 8px 18px rgba(255, 109, 123, 0.35), inset 0 1px 0 rgba(255,255,255,0.45);
}
