/* ============================================================
   Dark War Survival — Map Page Styles (style.css)
   Matches hub.html glass/glow aesthetic. Mobile-first.
   ============================================================ */

:root {
    --bg-dark: #080b12;
    --bg-glass: rgba(15, 20, 35, 0.62);
    --bg-glass-strong: rgba(15, 20, 35, 0.90);
    --bg-card: rgba(20, 28, 50, 0.5);
    --text-main: #e8eaf0;
    --text-dim: #7a82a0;
    --text-bright: #ffffff;
    --primary: #6c5ce7;
    --primary-glow: rgba(108, 92, 231, 0.4);
    --accent: #ffd32a;
    --accent-glow: rgba(255, 211, 42, 0.3);
    --discord-blurple: #5865F2;
    --border: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(120, 140, 255, 0.18);
    --danger: #ff4757;
    --danger-glow: rgba(255, 71, 87, 0.3);
    --success: #2ed573;
    --gradient-1: linear-gradient(135deg, #6c5ce7 0%, #a855f7 100%);
    --gradient-gold: linear-gradient(135deg, #ffd32a 0%, #ff9f43 100%);
    --gradient-danger: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
}

/* ── Reset ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    position: relative;
    height: 100vh;
    width: 100vw;
}

/* ── Animated Background Mesh ── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 80% 60% at 10% 20%, rgba(108, 92, 231, 0.13) 0%, transparent 55%),
        radial-gradient(ellipse 60% 80% at 90% 80%, rgba(168, 85, 247, 0.09) 0%, transparent 55%),
        radial-gradient(ellipse 50% 40% at 50% 50%, rgba(255, 211, 42, 0.04) 0%, transparent 50%);
    animation: meshDrift 18s ease-in-out infinite alternate;
}

@keyframes meshDrift {
    0%   { transform: scale(1) translate(0, 0); }
    100% { transform: scale(1.06) translate(-12px, 10px); }
}

/* ── Utility ── */
.hidden { display: none !important; }

.screen {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* ─────────────────────────────────────────────────────────
   LOGIN SCREEN
   ───────────────────────────────────────────────────────── */
#login-screen {
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--bg-glass);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    padding: 52px 44px;
    border-radius: 24px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow:
        0 12px 48px rgba(0, 0, 0, 0.5),
        0 0 70px rgba(108, 92, 231, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    max-width: 440px;
    width: 90%;
    position: relative;
    overflow: hidden;
}

/* Glowing border gradient */
.login-card::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(135deg,
        rgba(108, 92, 231, 0.35),
        transparent 40%,
        transparent 60%,
        rgba(255, 211, 42, 0.2));
    border-radius: 25px;
    z-index: -1;
    animation: borderPulse 4s ease-in-out infinite alternate;
}

@keyframes borderPulse {
    0%   { opacity: 0.3; }
    100% { opacity: 0.85; }
}

/* Shimmer line on top edge */
.login-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--accent), var(--primary));
    background-size: 200% 100%;
    animation: shimmerLine 3s linear infinite;
    border-radius: 24px 24px 0 0;
}

@keyframes shimmerLine {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.login-card h1 {
    font-size: 2rem;
    margin-bottom: 4px;
    font-weight: 900;
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.login-card h2 {
    color: var(--text-dim);
    font-weight: 600;
    margin-bottom: 16px;
    font-size: 0.85rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.login-card p {
    color: var(--text-dim);
    margin-bottom: 32px;
    font-size: 0.88rem;
    line-height: 1.65;
}

/* ─────────────────────────────────────────────────────────
   BUTTONS
   ───────────────────────────────────────────────────────── */
.btn {
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.discord-btn {
    background: var(--gradient-1);
    color: #fff;
    width: 100%;
    box-shadow: 0 4px 20px var(--primary-glow);
    letter-spacing: 0.3px;
}

.discord-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 34px var(--primary-glow);
    filter: brightness(1.1);
}

.sm-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: all 0.2s;
    cursor: pointer;
    font-family: inherit;
}

.sm-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-glow);
    color: var(--text-bright);
}

.outline-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 5px 12px;
    font-size: 0.78rem;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s;
    cursor: pointer;
    font-family: inherit;
}

.outline-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-bright);
    border-color: var(--border-glow);
}

/* ─────────────────────────────────────────────────────────
   APP SCREEN
   ───────────────────────────────────────────────────────── */
#app-screen {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ─────────────────────────────────────────────────────────
   TOPBAR
   ───────────────────────────────────────────────────────── */
.topbar {
    flex-shrink: 0;
    height: 56px;
    background: var(--bg-glass-strong);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    gap: 10px;
    z-index: 100;
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: none;
}

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

/* Gradient accent line */
.topbar::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary), var(--accent), transparent);
    opacity: 0.4;
    pointer-events: none;
}

.logo {
    font-weight: 900;
    font-size: 1.1rem;
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.3px;
    flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────
   TOOLBAR NAV GROUPS / ITEMS
   ───────────────────────────────────────────────────────── */
.tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.nav-group {
    display: flex;
    gap: 3px;
    background: rgba(0, 0, 0, 0.22);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
    align-items: center;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.nav-item:hover:not(:disabled) {
    color: var(--text-bright);
    background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
    color: var(--text-bright);
    background: var(--gradient-1);
    box-shadow: 0 2px 10px var(--primary-glow);
}

.nav-item:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Select dropdown within nav-group */
select.nav-item {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 22px;
    background-color: rgba(0, 0, 0, 0.3);
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E") no-repeat right 7px center;
    background-size: 7px auto;
    color: var(--text-main);
}

select.nav-item option {
    background: #1a1e30;
    color: var(--text-main);
}

/* Small text/color inputs inside toolbar */
.custom-input {
    background: rgba(0, 0, 0, 0.35);
    color: var(--text-bright);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 11px;
    font-family: inherit;
    text-align: center;
    transition: border-color 0.2s;
}

.custom-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.custom-input:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─────────────────────────────────────────────────────────
   BADGE / USER INFO
   ───────────────────────────────────────────────────────── */
.badge {
    background: rgba(108, 92, 231, 0.15);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.74rem;
    font-weight: 700;
    border: 1px solid rgba(108, 92, 231, 0.2);
    white-space: nowrap;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#coin-balance {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
    font-size: 13px;
    background: rgba(255, 211, 42, 0.08);
    border: 1px solid rgba(255, 211, 42, 0.18);
    border-radius: 20px;
    padding: 4px 12px;
    color: var(--accent);
    white-space: nowrap;
}

#avatar-display {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(108, 92, 231, 0.45);
    object-fit: cover;
    flex-shrink: 0;
}

#username-display {
    font-weight: 700;
    font-size: 13px;
    color: var(--text-main);
    white-space: nowrap;
}

#logout-btn {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 71, 87, 0.25);
    color: var(--danger);
    background: rgba(255, 71, 87, 0.06);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

#logout-btn:hover {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 2px 12px var(--danger-glow);
}

.divider {
    width: 1px;
    height: 26px;
    background: var(--border);
    flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────
   MAP CONTAINER
   ───────────────────────────────────────────────────────── */
.map-container {
    flex: 1;
    overflow: auto;
    background: #050810;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#map-canvas {
    display: block;
    background: #fff;
    max-width: 100%;
    max-height: calc(100vh - 60px);
    width: auto;
    height: auto;
    object-fit: contain;
    box-shadow:
        0 0 0 1px rgba(108, 92, 231, 0.12),
        0 0 40px rgba(108, 92, 231, 0.1),
        0 0 80px rgba(0, 0, 0, 0.5);
    /* Auto-scales to fit container perfectly, keeping aspect ratio */
}

/* ─────────────────────────────────────────────────────────
   LOADING OVERLAY
   ───────────────────────────────────────────────────────── */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(8, 11, 18, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    pointer-events: none;
    z-index: 10;
    letter-spacing: 0.3px;
}

.loading-overlay::before {
    content: '⚔️';
    font-size: 2.2rem;
    animation: loadingPulse 1.4s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% { transform: scale(1);    opacity: 1;   }
    50%       { transform: scale(1.15); opacity: 0.65; }
}

/* ─────────────────────────────────────────────────────────
   SCROLLBAR
   ───────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(108, 92, 231, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(108, 92, 231, 0.55); }

/* ═══════════════════════════════════════════════════════
   MOBILE RESPONSIVENESS
   ═══════════════════════════════════════════════════════ */

/* 900px and below: hide text labels, compress toolbar */
@media (max-width: 900px) {
    .hide-mobile { display: none !important; }

    .topbar {
        height: auto;
        min-height: 50px;
        padding: 6px 10px;
        gap: 6px;
        justify-content: flex-start;
    }

    .logo { font-size: 0.95rem; }

    .tools { gap: 5px; }

    .nav-group { padding: 3px; gap: 2px; }

    .nav-item {
        font-size: 11px;
        padding: 4px 8px;
    }

    .user-info { gap: 6px; }

    #username-display { display: none; }

    #coin-balance { font-size: 11px; padding: 3px 8px; }

    #avatar-display { width: 24px; height: 24px; }

    .badge { font-size: 10px; padding: 3px 8px; }

    /* Map fills screen — let it scroll naturally */
    .map-container {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Login card tighter on mobile */
    .login-card {
        padding: 36px 24px;
        border-radius: 20px;
    }
}

/* 480px and below: ultra-compact */
@media (max-width: 480px) {
    .topbar { padding: 5px 8px; gap: 5px; }

    .nav-item { font-size: 10px; padding: 3px 6px; }

    select.nav-item { max-width: 100px; }

    .logo { font-size: 0.88rem; }

    .login-card { padding: 28px 18px; }

    .login-card h1 { font-size: 1.7rem; }
}
