:root {
    --bg-dark: #0a0e1a;
    --bg-dark-2: #0f172a;
    --accent: #38bdf8;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --danger: #fb7185;
    --success: #34d399;
    --like-color: #f43f5e;
    --gold: #fbbf24;
    --vibe: #a855f7;
    --glass-bg: rgba(30, 41, 59, 0.55);
    --glass-bg-2: rgba(20, 28, 46, 0.65);
    --glass-border: rgba(255, 255, 255, 0.12);
    --metal-hi: rgba(255, 255, 255, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', -apple-system, sans-serif; }
html, body {
    background: radial-gradient(ellipse at top, #131b30 0%, var(--bg-dark) 60%);
    color: var(--text-main);
    height: 100vh; width: 100vw; overflow: hidden; position: relative;
}

/* Vibrant Animated Background */
.bg-orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; filter: blur(90px); }
.orb { position: absolute; border-radius: 50%; opacity: 0.45; animation: float 15s infinite ease-in-out alternate; }
.orb-1 { width: 400px; height: 400px; background: var(--accent); top: -10%; left: -10%; }
.orb-2 { width: 500px; height: 500px; background: var(--vibe); bottom: -20%; right: -10%; animation-delay: -5s; }
.orb-3 { width: 300px; height: 300px; background: var(--like-color); top: 40%; left: 40%; animation-delay: -10s; }
@keyframes float { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(50px, 50px) scale(1.1); } }

/* ============ METALLIC GLASS SYSTEM ============ */
/* Every panel: dark brushed-metal base + glass blur + soft top highlight + deep shadow + subtle live shimmer */
.glass-card {
    position: relative;
    background:
        linear-gradient(155deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0) 30%),
        linear-gradient(180deg, var(--glass-bg) 0%, var(--glass-bg-2) 100%);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 18px;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.08) inset,
        0 -1px 0 rgba(0,0,0,0.3) inset,
        0 12px 30px rgba(0,0,0,0.45),
        0 2px 6px rgba(0,0,0,0.3);
    margin-bottom: 14px;
    transition: box-shadow 0.35s ease, transform 0.35s ease, border-color 0.35s ease;
}
.glass-card:hover {
    border-color: rgba(255,255,255,0.2);
    box-shadow:
        0 1px 0 rgba(255,255,255,0.12) inset,
        0 -1px 0 rgba(0,0,0,0.3) inset,
        0 16px 40px rgba(0,0,0,0.5),
        0 0 24px rgba(56, 189, 248, 0.08);
}
/* Thin animated sheen sweeping across panels — alive, not static */
.glass-card::before {
    content: ""; position: absolute; inset: 0; border-radius: 18px; pointer-events: none;
    background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,0.05) 50%, transparent 60%);
    background-size: 250% 250%;
    animation: sheen 8s ease-in-out infinite;
    opacity: 0.6;
}
@keyframes sheen {
    0%, 100% { background-position: 200% 200%; }
    50% { background-position: -50% -50%; }
}

.glass-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(10px);
    display: flex; justify-content: center; align-items: center; z-index: 9999;
    transition: opacity 0.5s ease;
}
.glass-btn {
    border: 1px solid var(--glass-border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.35), 0 1px 0 rgba(255,255,255,0.1) inset;
}

/* Typography & Base UI */
.glow-text { text-shadow: 0 0 10px currentColor; }
.gold-text { color: var(--gold); }
.vibe-text { color: var(--vibe); }
.text-muted { color: var(--text-muted); font-size: 0.9rem; }
.text-small { font-size: 0.8rem; color: var(--text-muted); line-height: 1.4; margin-bottom: 10px; }
.danger-text { color: var(--danger); text-decoration: none; }
.error-msg { color: var(--danger); margin-top: 10px; font-size: 0.85rem; min-height: 1.2em; }
.tier-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

input, textarea {
    width: 100%; padding: 12px; margin: 8px 0;
    background: rgba(0,0,0,0.28); border: 1px solid var(--glass-border);
    color: var(--text-main); border-radius: 12px; resize: none; transition: 0.3s; outline: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3) inset;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 12px rgba(56, 189, 248, 0.35), 0 2px 6px rgba(0,0,0,0.3) inset; }
input:disabled, textarea:disabled, button:disabled { opacity: 0.5; cursor: not-allowed; }

button {
    cursor: pointer; font-weight: bold; transition: 0.2s; border-radius: 12px; padding: 10px 16px; border: none;
}
button:active:not(:disabled) { transform: scale(0.96); }
.btn-primary {
    background: linear-gradient(155deg, #5cc9fb 0%, var(--accent) 30%, #2563eb 100%);
    color: #fff; border: none;
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35), 0 1px 0 rgba(255,255,255,0.4) inset;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.15); transform: translateY(-1px); }
.btn-outline { background: rgba(255,255,255,0.03); color: var(--text-main); }
.btn-outline:hover:not(:disabled) { background: rgba(255,255,255,0.1); }
.btn-full { width: 100%; }
.small-btn { padding: 6px 10px; font-size: 0.8rem; border-radius: 8px; }

/* ============ NO-SCROLL APP LAYOUT ============ */
/* Whole app fits the viewport. Only .posts-scroll (the feed) may scroll. */
.app-layout {
    display: grid;
    grid-template-columns: 270px 1fr 300px;
    height: 100vh;
    max-width: 1400px; margin: 0 auto;
    gap: 16px; padding: 16px;
    animation: fadeIn 0.6s ease forwards;
    overflow: hidden;
}
.hidden { display: none !important; }

/* Sidebars: fixed-height column that never needs scrolling.
   flex + min-height:0 lets inner flexible panels (shop, social) shrink to fit
   instead of overflowing the viewport. */
.sidebar-left, .sidebar-right {
    display: flex; flex-direction: column;
    height: 100%; min-height: 0; overflow: hidden;
}
.sidebar-left > .glass-card, .sidebar-right > .glass-card { flex-shrink: 0; }

/* Panels that should absorb remaining vertical space and scroll internally
   only if truly necessary (kept small enough in practice not to need it) */
.shop-card-flex, .social-card-flex {
    flex: 1; min-height: 0; display: flex; flex-direction: column;
    margin-bottom: 0;
}
.shop-card-flex #shop-grid { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.social-card-flex .tab-content { flex: 1; min-height: 0; overflow-y: auto; }
.social-card-flex { overflow: hidden; }

/* Left Sidebar */
.profile-card { text-align: center; }
.avatar-preview { font-size: 3rem; margin-bottom: 8px; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4)); display: inline-block; }
.stats-row { display: flex; justify-content: center; gap: 18px; margin: 10px 0; font-weight: bold; }
.profile-actions-row { display: flex; gap: 8px; }
.profile-actions-row button { flex: 1; font-size: 0.78rem; padding: 8px 6px; }
.economy-info h3 { margin-bottom: 8px; display: flex; align-items: center; gap: 6px; font-size: 1rem; }
.global-stats-mini { display: flex; gap: 8px; }
.global-stats-mini div { flex: 1; background: rgba(0,0,0,0.35); padding: 7px; border-radius: 8px; font-size: 0.78rem; text-align: center; box-shadow: 0 2px 4px rgba(0,0,0,0.3) inset; }
.global-perk-box {
    margin-top: 8px; padding: 7px; background: rgba(0,0,0,0.3); border-radius: 8px;
    font-size: 0.75rem; text-align: center; font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3) inset;
    animation: perkPulse 3s ease-in-out infinite;
}
@keyframes perkPulse { 0%, 100% { opacity: 0.85; } 50% { opacity: 1; } }

/* Session IP display (client-side only, never persisted) */
.ip-display { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--glass-border); font-size: 0.72rem; color: var(--text-muted); }
#session-ip { color: var(--accent); font-family: monospace; }

/* Custom tooltip on info icon — rendered via JS into a fixed-position layer
   so it escapes .sidebar-left's overflow:hidden and never gets clipped by
   neighboring panels (shop / feed). */
.info-dot { position: relative; cursor: help; font-size: 0.82rem; color: var(--text-muted); display: inline-flex; }
.custom-tooltip {
    display: none; position: fixed; top: 0; left: 0;
    width: 240px; background: rgba(10, 14, 26, 0.98); border: 1px solid var(--glass-border);
    border-radius: 12px; padding: 14px; font-size: 0.76rem; line-height: 1.5; color: var(--text-main);
    text-align: left; z-index: 6000; box-shadow: 0 12px 30px rgba(0,0,0,0.6); font-weight: normal;
}
.custom-tooltip.visible { display: block; }

/* Shop */
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start; }
.shop-item { padding: 10px; text-align: center; margin-bottom: 0; }
.shop-item.equipped { border-color: var(--success); box-shadow: 0 0 14px rgba(52, 211, 153, 0.35), 0 1px 0 rgba(255,255,255,0.08) inset; }
.shop-item-emoji { font-size: 1.5rem; }
.shop-item-name { font-size: 0.74rem; font-weight: bold; margin: 4px 0 2px; }
.shop-item-cost { font-size: 0.7rem; color: var(--gold); margin-bottom: 6px; }
.cost-was { color: var(--text-muted); text-decoration: line-through; font-size: 0.65rem; }
.shop-action-btn { width: 100%; font-size: 0.7rem; padding: 5px 6px; }

/* Center Feed */
.feed-container { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.posts-scroll { flex: 1; min-height: 0; overflow-y: auto; padding-right: 5px; scrollbar-width: thin; }
.composer { flex-shrink: 0; }
.composer textarea { background: transparent; border: none; font-size: 1.05rem; padding: 0; box-shadow: none; margin: 0; }
.composer-header { display: flex; gap: 15px; margin-bottom: 10px; }
.composer-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--glass-border); padding-top: 10px; }

/* Posts */
.post { padding: 15px; animation: slideDown 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.post-boosted { border-top: 2px solid var(--gold); box-shadow: 0 0 20px rgba(251, 191, 36, 0.15); }
.post-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.post-name { font-weight: bold; text-shadow: 0 0 5px currentColor; cursor: pointer; }
.post-handle, .post-time { color: var(--text-muted); font-size: 0.85rem; }
.post-time { margin-left: auto; }
.post-stats-badge { background: rgba(0,0,0,0.3); padding: 2px 6px; border-radius: 10px; font-size: 0.75rem; margin-left: 5px; border: 1px solid var(--glass-border); }
.boost-badge { color: var(--gold); border-color: var(--gold); }
.post-content { font-size: 1rem; line-height: 1.5; margin-bottom: 15px; }
.post-actions { display: flex; gap: 15px; align-items: center; }
.action-btn { background: transparent; font-size: 0.95rem; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.action-btn:hover { color: var(--text-main); }
.action-btn.liked { color: var(--like-color); text-shadow: 0 0 8px var(--like-color); }
.delete-btn { margin-left: auto; color: var(--danger); }
.avatar-small.hover-target, .post-name.hover-target { cursor: pointer; }

/* Right Sidebar */
.game-card { padding-bottom: 14px; }
.vibe-btn-anim {
    background: linear-gradient(155deg, #c084fc 0%, var(--vibe) 40%, #6d28d9 100%);
    font-size: 1.05rem; padding: 13px; margin-top: 8px;
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.4), 0 1px 0 rgba(255,255,255,0.3) inset;
    animation: pulse 2s infinite;
}
.leaderboard h4 { margin: 12px 0 8px; color: var(--text-muted); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.5px; }
#leaderboard-list { list-style: none; font-size: 0.86rem; display: flex; flex-direction: column; gap: 6px; }
.lb-item {
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(0,0,0,0.25); padding: 7px 10px; border-radius: 8px;
    transition: 0.25s; cursor: pointer;
    box-shadow: 0 1px 0 rgba(255,255,255,0.05) inset;
}
.lb-item:hover { background: rgba(255,255,255,0.1); transform: scale(1.02) translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.lb-stats { font-size: 0.78rem; color: var(--gold); }

/* Social Tabs */
.tabs { display: flex; border-bottom: 1px solid var(--glass-border); margin-bottom: 8px; flex-shrink: 0; }
.tab-btn { flex: 1; background: transparent; color: var(--text-muted); border-radius: 0; padding: 8px 5px; position: relative; }
.tab-btn.active { color: var(--accent); border-bottom: 2px solid var(--accent); }
.badge { background: var(--danger); color: white; padding: 2px 6px; border-radius: 12px; font-size: 0.68rem; position: absolute; top: 0; right: 5px; animation: popIn 0.3s; }
.tab-content { display: none; scrollbar-width: thin; }
.social-card-flex .tab-content.active { display: block; flex: 1; min-height: 0; overflow-y: auto; }
.tab-content.active { display: block; }
.user-list { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.user-item { display: flex; justify-content: space-between; align-items: center; padding: 7px 8px; background: rgba(0,0,0,0.25); border-radius: 8px; font-size: 0.85rem; box-shadow: 0 1px 0 rgba(255,255,255,0.05) inset; }
.empty-state { color: var(--text-muted); font-size: 0.82rem; text-align: center; padding: 10px; }

/* Live Hover Card — viewport-aware so it never gets clipped */
#hover-card {
    position: fixed; width: 240px; padding: 14px; z-index: 5000;
    box-shadow: 0 16px 40px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.1) inset;
    pointer-events: none; animation: popIn 0.15s ease;
}
.hc-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.hc-avatar { font-size: 1.8rem; border-radius: 50%; }
.hc-name { font-weight: bold; font-size: 0.95rem; }
.hc-handle { font-size: 0.75rem; color: var(--text-muted); }
.hc-bio { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 8px; font-style: italic; }
.hc-stats { display: flex; gap: 16px; margin: 8px 0; }
.hc-stats div { font-size: 0.85rem; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hc-stats span { font-size: 0.65rem; color: var(--text-muted); }
.hc-tier { font-size: 0.75rem; font-weight: bold; text-align: center; margin-top: 4px; }
.hc-status { font-size: 0.72rem; color: var(--text-muted); text-align: center; margin-top: 4px; }

/* Facebook Style Bottom Chat Sidebar */
.chat-sidebar { position: fixed; bottom: 0; right: 20px; width: 280px; border-radius: 16px 16px 0 0; padding: 0; margin: 0; z-index: 1000; display: flex; flex-direction: column; transition: transform 0.3s ease; }
.chat-sidebar.collapsed { transform: translateY(calc(100% - 45px)); }
.chat-sidebar-header { padding: 12px 15px; font-weight: bold; background: rgba(255,255,255,0.05); border-bottom: 1px solid var(--glass-border); cursor: pointer; display: flex; justify-content: space-between; border-radius: 16px 16px 0 0; }
.chat-sidebar-header:hover { background: rgba(255,255,255,0.1); }
.chat-sidebar-body { height: 280px; overflow-y: auto; padding: 10px; }
.friend-chat-item { cursor: pointer; transition: 0.2s; }
.friend-chat-item:hover { background: rgba(255,255,255,0.1); }

/* Chat Box */
.chat-box { position: fixed; bottom: 0; right: 320px; width: 320px; border-radius: 16px 16px 0 0; padding: 0; margin: 0; z-index: 1000; display: flex; flex-direction: column; box-shadow: 0 -12px 36px rgba(0,0,0,0.55); animation: slideUp 0.3s; }
.chat-header { background: rgba(0,0,0,0.35); padding: 12px; display: flex; justify-content: space-between; align-items: center; border-radius: 16px 16px 0 0; border-bottom: 1px solid var(--glass-border); font-weight: bold; }
.chat-messages { height: 280px; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 8px 14px; border-radius: 18px; max-width: 80%; font-size: 0.9rem; word-wrap: break-word; }
.msg.sent { background: var(--accent); color: white; align-self: flex-end; border-bottom-right-radius: 4px; box-shadow: 0 2px 8px rgba(56,189,248,0.35); }
.msg.recv { background: rgba(255,255,255,0.1); border: 1px solid var(--glass-border); align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-input-area { display: flex; padding: 10px; gap: 5px; border-top: 1px solid var(--glass-border); background: rgba(0,0,0,0.25); }
.chat-input-area input { margin: 0; border-radius: 20px; }

/* Toasts */
#toast-container { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 10000; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: var(--glass-bg); backdrop-filter: blur(12px); border: 1px solid var(--glass-border);
    color: white; padding: 12px 24px; border-radius: 30px; font-size: 0.9rem; font-weight: bold;
    box-shadow: 0 8px 24px rgba(0,0,0,0.45), 0 1px 0 rgba(255,255,255,0.15) inset;
    animation: slideUp 0.3s ease, fadeOut 0.3s ease 3s forwards;
}

/* Modal */
.modal-box { width: 340px; }
.modal-box h3 { margin-bottom: 15px; }
.form-group { margin-bottom: 12px; text-align: left; }
.form-group label { font-size: 0.8rem; color: var(--text-muted); }
.modal-actions { display: flex; gap: 10px; margin-top: 10px; }
.modal-actions button { flex: 1; }

/* ============ MOBILE GATE ============ */
.mobile-gate {
    position: fixed; inset: 0; z-index: 20000;
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(ellipse at center, #16213a 0%, #060911 75%);
    overflow: hidden; padding: 24px;
}
.mobile-gate-orb {
    position: absolute; width: 340px; height: 340px; border-radius: 50%;
    background: radial-gradient(circle, rgba(56,189,248,0.35), rgba(168,85,247,0.2) 60%, transparent 75%);
    filter: blur(50px); top: 10%; left: 50%; transform: translateX(-50%);
    animation: gatePulse 4s ease-in-out infinite;
}
@keyframes gatePulse { 0%, 100% { opacity: 0.6; transform: translateX(-50%) scale(1); } 50% { opacity: 1; transform: translateX(-50%) scale(1.15); } }
.mobile-gate-card {
    position: relative; z-index: 1; max-width: 380px; width: 100%;
    text-align: center; padding: 36px 26px;
    background: linear-gradient(155deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0) 30%), linear-gradient(180deg, var(--glass-bg) 0%, var(--glass-bg-2) 100%);
    border: 1px solid var(--glass-border); border-radius: 24px;
    backdrop-filter: blur(18px);
    box-shadow: 0 1px 0 rgba(255,255,255,0.1) inset, 0 20px 50px rgba(0,0,0,0.6);
    animation: fadeIn 0.7s ease forwards;
}
.mobile-gate-icon { font-size: 2.6rem; margin-bottom: 6px; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.4)); }
.mobile-gate-card h1 { font-size: 1.8rem; color: var(--accent); margin-bottom: 4px; }
.mobile-gate-title { font-weight: bold; font-size: 1rem; color: var(--text-main); margin-bottom: 14px; }
.mobile-gate-text { color: var(--text-muted); font-size: 0.88rem; line-height: 1.6; margin-bottom: 18px; }
.mobile-gate-pill {
    display: inline-block; padding: 8px 18px; border-radius: 30px;
    background: rgba(0,0,0,0.35); border: 1px solid var(--glass-border);
    font-size: 0.75rem; color: var(--vibe); font-weight: bold; letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) inset;
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: scale(1); } }
@keyframes popIn { from { opacity: 0; transform: scale(0.5); } to { opacity: 1; transform: scale(1); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { to { opacity: 0; visibility: hidden; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.4); } 70% { box-shadow: 0 0 0 15px rgba(168, 85, 247, 0); } 100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0); } }

/* Thin scrollbars for the areas that do scroll (feed, shop grid, tab lists) */
.posts-scroll::-webkit-scrollbar, #shop-grid::-webkit-scrollbar, .tab-content::-webkit-scrollbar, .chat-messages::-webkit-scrollbar, .chat-sidebar-body::-webkit-scrollbar {
    width: 6px;
}
.posts-scroll::-webkit-scrollbar-thumb, #shop-grid::-webkit-scrollbar-thumb, .tab-content::-webkit-scrollbar-thumb, .chat-messages::-webkit-scrollbar-thumb, .chat-sidebar-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15); border-radius: 10px;
}