:root {
    /* --- PALETTE --- */
    --bg-dark: #030305;
    --bg-panel: #0e0e12;
    --bg-card: #18181e;

    --border-light: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.2);

    --c-purple: #8b5cf6;
    --c-cyan: #06b6d4;
    --c-green: #10b981;
    --c-gold: #f59e0b;
    --c-red: #f43f5e;
    --c-text: #e2e8f0;
    --c-dim: #64748b;

    /* --- SHAPES --- */
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;

    /* --- FONTS --- */
    --font-ui: 'Plus Jakarta Sans', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; user-select: none; }

body {
    margin: 0; background: var(--bg-dark); color: var(--c-text);
    font-family: var(--font-ui); height: 100vh; overflow: hidden;
}

/* --- BACKGROUND FX --- */
.bg-ambient { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.4; }
.orb-1 { width: 400px; height: 400px; background: var(--c-purple); top: -100px; left: -100px; animation: float 20s infinite; }
.orb-2 { width: 300px; height: 300px; background: var(--c-cyan); bottom: -50px; right: -50px; animation: float 25s infinite reverse; }
.orb-3 { width: 200px; height: 200px; background: var(--c-red); top: 50%; left: 50%; transform: translate(-50%, -50%); opacity: 0.15; }

.bg-grid {
    position: absolute; inset: 0; z-index: 1; opacity: 0.05; pointer-events: none;
    background-image: linear-gradient(#fff 1px, transparent 1px), linear-gradient(90deg, #fff 1px, transparent 1px);
    background-size: 40px 40px;
}

@keyframes float { 0% { transform: translate(0,0); } 50% { transform: translate(30px, 50px); } 100% { transform: translate(0,0); } }

/* --- LAYOUT --- */
.ui-grid {
    position: relative; z-index: 10;
    display: grid; grid-template-columns: 320px 1fr 380px;
    height: 100vh; gap: 24px; padding: 24px;
}

/* --- PANELS GENERIC --- */
.panel {
    background: rgba(14, 14, 18, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    display: flex; flex-direction: column;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

/* --- SIDEBAR LEFT --- */
.brand { margin-bottom: 24px; display: flex; align-items: center; gap: 12px; }
.brand-logo {
    width: 40px; height: 40px; background: var(--c-purple); color: #fff;
    border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.2rem;
}
.brand-text h1 { margin: 0; font-size: 1.4rem; font-weight: 800; line-height: 1; }
.brand-text span { color: var(--c-purple); }
.brand-text small { font-size: 0.7rem; color: var(--c-dim); letter-spacing: 2px; }

/* Status Card */
.card { background: var(--bg-card); border-radius: var(--radius-md); padding: 16px; border: 1px solid var(--border-light); margin-bottom: 20px; }
.card-header { font-size: 0.75rem; color: var(--c-dim); font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sys-text { text-align: center; font-family: var(--font-mono); font-weight: 700; color: var(--c-green); letter-spacing: 1px; }
.sys-text.warn { color: var(--c-red); animation: pulse 1s infinite; }

.legacy-info { display: flex; justify-content: space-between; font-size: 0.85rem; margin: 10px 0; border-top: 1px solid var(--border-light); padding-top: 10px; }
.val-gold { color: var(--c-gold); font-weight: 700; }

/* Metrics */
.metrics-container { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.metric-box {
    background: linear-gradient(90deg, rgba(255,255,255,0.03), transparent);
    border-radius: var(--radius-md); padding: 12px 16px;
    border-left: 4px solid #333; transition: all 0.2s;
}
.metric-box:hover { background: rgba(255,255,255,0.05); transform: translateX(5px); }
.border-purple { border-left-color: var(--c-purple); }
.border-green { border-left-color: var(--c-green); }
.border-cyan { border-left-color: var(--c-cyan); }

.metric-head { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; font-weight: 700; color: var(--c-dim); margin-bottom: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.purple { background: var(--c-purple); box-shadow: 0 0 10px var(--c-purple); }
.dot.green { background: var(--c-green); box-shadow: 0 0 10px var(--c-green); }
.dot.cyan { background: var(--c-cyan); box-shadow: 0 0 10px var(--c-cyan); }

.metric-val { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 700; color: #fff; line-height: 1.2; }
.metric-rate { font-family: var(--font-mono); font-size: 0.8rem; color: var(--c-dim); }

/* Terminal */
.terminal-box { margin-top: auto; background: #000; border-radius: var(--radius-md); border: 1px solid var(--border-light); height: 140px; display: flex; flex-direction: column; overflow: hidden; }
.term-head { background: #111; padding: 6px 12px; font-size: 0.7rem; color: #666; display: flex; justify-content: space-between; align-items: center; }
.btn-mini { background: #222; border: none; color: #aaa; font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; cursor: pointer; }
.btn-mini:hover { color: #fff; background: #333; }
.term-body { flex: 1; padding: 10px; overflow-y: auto; font-family: var(--font-mono); font-size: 0.75rem; color: var(--c-cyan); opacity: 0.8; }
.log-line { margin-bottom: 4px; border-bottom: 1px solid rgba(255,255,255,0.05); }

/* --- CENTER STAGE --- */
.stage-center { display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; }

/* Rank */
.rank-badge { width: 100%; max-width: 400px; text-align: center; margin-bottom: 50px; }
.rank-label { font-size: 0.8rem; font-weight: 700; letter-spacing: 2px; color: var(--c-dim); }
#rank-name { font-size: 2.5rem; font-weight: 800; margin: 5px 0 15px 0; text-transform: uppercase; background: linear-gradient(to bottom, #fff, #999); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.progress-track { height: 10px; background: rgba(255,255,255,0.05); border-radius: 5px; overflow: hidden; margin-bottom: 8px; }
.progress-bar { height: 100%; background: var(--c-purple); width: 0%; border-radius: 5px; position: relative; transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.glint { position: absolute; top:0; left:0; width:100%; height:100%; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent); transform: translateX(-100%); animation: glint 2s infinite; }
@keyframes glint { 100% { transform: translateX(100%); } }

/* MAIN BUTTON (HAPTIC PAD) */
.haptic-pad {
    width: 320px; height: 180px;
    background: linear-gradient(145deg, #1a1a20, #0d0d10);
    border: 1px solid var(--border-light);
    border-radius: 24px;
    position: relative; cursor: pointer;
    box-shadow:
            0 20px 50px rgba(0,0,0,0.5),
            0 0 0 1px #000,
            inset 0 1px 1px rgba(255,255,255,0.1);
    transition: all 0.08s ease-out;
    outline: none; overflow: hidden;
}
.haptic-pad:active { transform: translateY(4px) scale(0.98); box-shadow: 0 5px 20px rgba(0,0,0,0.5); }
.pad-content { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; position: relative; z-index: 2; }
.pad-icon { font-size: 3rem; margin-bottom: 10px; filter: drop-shadow(0 0 15px rgba(139, 92, 246, 0.4)); transition: transform 0.1s; }
.haptic-pad:active .pad-icon { transform: scale(0.9); }
.pad-title { font-size: 1.2rem; font-weight: 800; color: #fff; letter-spacing: 1px; }
.pad-sub { font-size: 0.8rem; font-family: var(--font-mono); color: var(--c-dim); margin-top: 6px; }
.pad-glow { position: absolute; top:50%; left:50%; width: 200%; height: 200%; background: radial-gradient(circle, var(--c-purple) 0%, transparent 60%); opacity: 0; transform: translate(-50%, -50%); transition: opacity 0.2s; pointer-events: none; mix-blend-mode: screen; }
.haptic-pad:hover .pad-glow { opacity: 0.15; }
.haptic-pad:active .pad-glow { opacity: 0.3; }

/* Hype */
.hype-module { width: 320px; margin-top: 40px; }
.hype-header { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 700; margin-bottom: 8px; }
.val-red { color: var(--c-red); }
.hype-track { height: 6px; background: #222; border-radius: 3px; overflow: hidden; }
.hype-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--c-red), #fbbf24); border-radius: 3px; }

/* --- SIDEBAR RIGHT --- */
.tabs-wrapper { display: flex; gap: 4px; background: #000; padding: 4px; border-radius: var(--radius-md); margin-bottom: 20px; border: 1px solid var(--border-light); }
.tab { flex: 1; background: none; border: none; padding: 8px; color: var(--c-dim); font-weight: 700; border-radius: 8px; cursor: pointer; transition: all 0.2s; font-size: 0.8rem; }
.tab.active { background: var(--bg-card); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,0.3); }

.tab-pane { display: none; height: 100%; }
.tab-pane.active { display: block; animation: fadeUp 0.3s ease-out; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* LISTS */
.tab-content-area { flex: 1; overflow-y: auto; padding-right: 5px; }

.vertical-list { display: flex; flex-direction: column; gap: 8px; }
.setup-item {
    background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-md);
    padding: 12px; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: all 0.1s;
}
.setup-item:hover { background: rgba(255,255,255,0.05); border-color: var(--border-hover); }
.setup-item.can-buy { border-left: 3px solid var(--c-green); }
.setup-icon { font-size: 1.6rem; background: #000; width: 44px; height: 44px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.setup-info { flex: 1; }
.setup-name { font-weight: 700; font-size: 0.9rem; }
.setup-cost { font-family: var(--font-mono); font-size: 0.8rem; color: var(--c-dim); }
.setup-count { font-weight: 800; font-size: 1.1rem; color: #fff; background: #000; padding: 2px 8px; border-radius: 6px; }

/* GRID UPGRADES */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.upg-box {
    background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-md);
    padding: 10px; cursor: pointer; position: relative; overflow: hidden; transition: transform 0.2s;
}
.upg-box:hover { transform: translateY(-2px); border-color: var(--c-cyan); }
.upg-box.locked { opacity: 0.4; filter: grayscale(1); pointer-events: none; }
.upg-icon { font-size: 1.4rem; margin-bottom: 5px; }
.upg-name { font-weight: 700; font-size: 0.8rem; line-height: 1.2; margin-bottom: 2px; }
.upg-desc { font-size: 0.7rem; color: var(--c-dim); margin-bottom: 5px; }
.upg-cost { font-family: var(--font-mono); font-size: 0.75rem; color: var(--c-green); }

/* --- NOTIFICATIONS --- */
#toast-container { position: fixed; top: 24px; right: 24px; z-index: 5000; display: flex; flex-direction: column; gap: 12px; pointer-events: none; }
.toast {
    background: #111; border: 1px solid var(--border-light); border-radius: var(--radius-md);
    padding: 12px 16px; width: 280px; color: #fff; pointer-events: auto;
    display: flex; gap: 12px; align-items: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    animation: toastSlide 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.toast-icon { font-size: 1.4rem; }
.toast-content h4 { margin: 0; font-size: 0.85rem; color: var(--c-purple); }
.toast-content p { margin: 0; font-size: 0.75rem; color: var(--c-dim); }
@keyframes toastSlide { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* --- MODALS --- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(8px); z-index: 2000; display: flex; justify-content: center; align-items: center; }
.modal-box { background: var(--bg-panel); border: 1px solid var(--border-light); border-radius: 20px; padding: 30px; width: 420px; box-shadow: 0 20px 80px rgba(0,0,0,0.8); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.btn-close { background: none; border: none; color: #666; font-size: 1.2rem; cursor: pointer; }
.btn-close:hover { color: #fff; }
.input-field { width: 100%; background: #000; border: 1px solid #333; color: #fff; padding: 12px; border-radius: 8px; font-family: var(--font-mono); margin-bottom: 12px; outline: none; }
.input-field:focus { border-color: var(--c-purple); }
.btn-primary { background: var(--c-purple); color: #fff; border: none; padding: 12px; border-radius: 8px; font-weight: 700; cursor: pointer; width: 100%; }
.btn-primary:hover { opacity: 0.9; }
.btn-warning { width: 100%; background: var(--c-gold); color: #000; border: none; padding: 8px; border-radius: 6px; font-weight: 700; cursor: pointer; font-size: 0.8rem; margin-top: 10px; }
.btn-danger { background: var(--c-red); color: #fff; border: none; padding: 10px 20px; border-radius: 8px; font-weight: 700; cursor: pointer; }
.btn-sec { background: #333; color: #fff; border: none; padding: 10px 20px; border-radius: 8px; font-weight: 700; cursor: pointer; }
.controls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 15px; }

/* --- UTILS --- */
.hidden { display: none !important; }
.center { text-align: center; }
.warn-color { color: var(--c-gold); }
.divider { grid-column: span 2; font-size: 0.7rem; color: #666; text-align: center; margin: 10px 0; letter-spacing: 2px; }

/* PARTICLE */
#particles-container { position: absolute; inset: 0; pointer-events: none; z-index: 100; overflow: hidden; }
.particle { position: absolute; font-family: var(--font-mono); font-weight: 800; animation: particlePop 0.8s forwards; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
@keyframes particlePop { 0% { transform: scale(0.5); opacity: 1; } 100% { transform: translateY(-60px) scale(1.2); opacity: 0; } }