/* ============================================================
   Antimatter Frontier — holographic dashboard. Mobile-first.
   Palette: deep space black · electric cyan (matter) · magenta (antimatter)
   · gold accents · danger red. GPT-dashboard instrumentation aesthetic.
   ============================================================ */

:root {
    --bg: #06090f;
    --panel: rgba(11, 17, 26, 0.86);
    --panel-solid: #0a0f17;
    --line: rgba(53, 214, 255, 0.16);
    --line-strong: rgba(53, 214, 255, 0.4);
    --cy: #35d6ff;
    --cy-dim: #1d6f8c;
    --mg: #ff2d78;
    --gd: #ffb028;
    --dn: #ff3b46;
    --pos: #54e08a;
    --neg: #ff6b6b;
    --txt: #e8f4ff;
    --muted: #7d93ad;
    --mono: 'SF Mono', 'JetBrains Mono', ui-monospace, 'Fira Code', Menlo, Consolas, monospace;
    --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --top-h: 50px;
    --res-h: 70px;
    --tab-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--txt);
    user-select: none;
    -webkit-user-select: none;
    overscroll-behavior: none;
}
.cy { color: var(--cy); } .mg { color: var(--mg); } .gd { color: var(--gd); } .dn { color: var(--dn); }
.pos { color: var(--pos) !important; } .neg { color: var(--neg) !important; }

/* ---------- ambient backdrop + 3D viewport ---------- */
.af-bg { position: fixed; inset: 0; z-index: 0; background:
        radial-gradient(120% 90% at 50% -10%, #0c1626 0%, #06090f 55%, #04060a 100%); }
.af-grid { position: absolute; inset: 0; opacity: 0.5;
    background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 46px 46px; mask-image: radial-gradient(80% 80% at 50% 40%, #000 30%, transparent 85%); }
.af-vignette { position: absolute; inset: 0; box-shadow: inset 0 0 200px 40px #000a; }
#af-viewport { position: fixed; inset: 0; z-index: 1; touch-action: none; }
#af-viewport canvas { display: block; width: 100% !important; height: 100% !important; }

/* ---------- top bar ---------- */
.af-top {
    position: fixed; top: 0; left: 0; right: 0; height: var(--top-h); z-index: 30;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 0 10px; padding-top: env(safe-area-inset-top);
    background: linear-gradient(180deg, #06090fee, #06090fbb 70%, transparent);
    backdrop-filter: blur(6px);
}
.af-top-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.af-home { color: var(--cy); text-decoration: none; font-size: 20px; line-height: 1;
    border: 1px solid var(--line); border-radius: 7px; width: 30px; height: 30px;
    display: grid; place-items: center; flex: none; }
.af-home:hover { background: #35d6ff18; }
.af-brand { display: flex; align-items: baseline; gap: 5px; font-family: var(--mono); min-width: 0; }
.af-brand-sig { color: var(--cy); font-weight: 700; letter-spacing: 1px; font-size: 13px; }
.af-brand-sep { color: var(--cy-dim); }
.af-brand-title { color: var(--txt); font-size: 12px; letter-spacing: 1px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; }
.af-tag { font-family: var(--mono); font-size: 9px; letter-spacing: 1px; color: var(--gd);
    border: 1px solid #ffb02855; border-radius: 4px; padding: 2px 5px; white-space: nowrap; flex: none; }
.af-top-right { display: flex; align-items: center; gap: 7px; flex: none; }
.af-clock { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.af-time { display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.af-time-btn { background: transparent; color: var(--muted); border: none; font-family: var(--mono);
    font-size: 10px; padding: 6px 7px; cursor: pointer; letter-spacing: -1px; }
.af-time-btn.is-active { background: var(--cy); color: #04222e; font-weight: 700; }
.af-icon-btn { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 7px;
    background: transparent; color: var(--cy); font-family: var(--mono); cursor: pointer; }

/* ---------- resource bar ---------- */
.af-resourcebar {
    position: fixed; top: calc(var(--top-h) + env(safe-area-inset-top)); left: 0; right: 0; height: var(--res-h); z-index: 28;
    display: flex; gap: 7px; padding: 7px 10px; overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; background: linear-gradient(180deg, #070b12dd, #070b1299);
    -webkit-overflow-scrolling: touch;
}
.af-resourcebar::-webkit-scrollbar { display: none; }
.af-res {
    flex: 1 0 auto; min-width: 92px; padding: 6px 9px; border-radius: 8px;
    background: var(--panel); border: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 1px; position: relative; overflow: hidden;
}
.af-res::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--cy); opacity: 0.8; }
.af-res--am::before { background: var(--mg); }
.af-res--money::before { background: var(--gd); }
.af-res--integrity::before { background: var(--dn); }
.af-res-label { font-family: var(--mono); font-size: 8.5px; letter-spacing: 1.2px; color: var(--muted); }
.af-res-val { font-family: var(--mono); font-size: 15px; font-weight: 700; color: var(--txt); line-height: 1.15; }
.af-res--am .af-res-val { color: #ff7ab0; }
.af-res--money .af-res-val { color: #ffd27a; }
.af-res-sub { font-family: var(--mono); font-size: 9px; color: var(--muted); }
.af-int-bar { height: 4px; background: #ffffff14; border-radius: 3px; overflow: hidden; margin-top: 3px; }
.af-int-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #54e08a, #35d6ff);
    transition: width 0.3s; }
.af-int-fill.is-warn { background: linear-gradient(90deg, var(--gd), var(--mg)); }
.af-int-fill.is-crit { background: linear-gradient(90deg, var(--dn), #ff8a3b); animation: pulseCrit 0.8s infinite; }
@keyframes pulseCrit { 50% { opacity: 0.4; } }

/* ---------- target bar ---------- */
.af-target {
    position: fixed; left: 50%; transform: translateX(-50%);
    top: calc(var(--top-h) + var(--res-h) + env(safe-area-inset-top) + 6px);
    z-index: 26; width: min(560px, calc(100% - 20px)); padding: 8px 14px;
    background: var(--panel); border: 1px solid var(--line-strong);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px), calc(100% - 12px) 100%, 0 100%);
    box-shadow: 0 4px 24px #000a, inset 0 0 24px #35d6ff10;
}
.af-target-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.af-target-kicker { font-family: var(--mono); font-size: 9px; letter-spacing: 1.5px; color: var(--cy); }
.af-target-name { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--txt);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.af-target-bar { position: relative; height: 12px; margin: 6px 0 4px; border-radius: 7px;
    background: #ffffff10; border: 1px solid var(--line); overflow: hidden; }
.af-target-fill { height: 100%; width: 0%; border-radius: 7px;
    background: linear-gradient(90deg, #1d6f8c, var(--cy) 70%, #aef3ff);
    box-shadow: 0 0 14px #35d6ffaa; transition: width 0.4s ease; }
.af-target.is-ready .af-target-fill { background: linear-gradient(90deg, var(--mg), #ff8ac0); box-shadow: 0 0 16px var(--mg); }
.af-target-pct { position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
    font-family: var(--mono); font-size: 9px; color: #fff; text-shadow: 0 0 4px #000; }
.af-target-foot { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10px; color: var(--muted); }

/* ---------- ticker ---------- */
.af-ticker { position: fixed; left: 0; right: 0; z-index: 20; text-align: center;
    bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 4px);
    font-family: var(--mono); font-size: 10px; color: var(--cy-dim); pointer-events: none;
    opacity: 0; transition: opacity 0.4s; padding: 0 12px; }
.af-ticker.is-show { opacity: 0.85; }

/* ---------- panel host (bottom sheet on mobile) ---------- */
.af-panelhost {
    position: fixed; left: 0; right: 0; z-index: 24;
    bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
    height: 46vh; max-height: 460px;
    background: linear-gradient(180deg, #0a0f17f2, #070b12fb);
    border-top: 1px solid var(--line-strong); box-shadow: 0 -10px 40px #000b;
    padding: 12px 12px 14px; overflow-y: auto; -webkit-overflow-scrolling: touch;
    backdrop-filter: blur(10px);
}
.af-panel-title { font-family: var(--mono); font-size: 11px; letter-spacing: 2px; color: var(--cy);
    padding-bottom: 8px; margin-bottom: 10px; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 8px; }
.af-panel-title::before { content: '▸'; color: var(--mg); }

/* overview */
.af-overview { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.af-ov-row { display: flex; justify-content: space-between; align-items: baseline; gap: 6px;
    padding: 9px 11px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.af-ov-row span { font-family: var(--mono); font-size: 9px; letter-spacing: 0.5px; color: var(--muted); }
.af-ov-row b { font-family: var(--mono); font-size: 14px; color: var(--txt); }

/* subtabs */
.af-subtabs { display: flex; gap: 6px; margin-bottom: 10px; }
.af-subtab { flex: 1; background: var(--panel); border: 1px solid var(--line); color: var(--muted);
    font-family: var(--mono); font-size: 10px; letter-spacing: 0.5px; padding: 8px 4px; border-radius: 7px; cursor: pointer; }
.af-subtab.is-active { border-color: var(--cy); color: var(--cy); background: #35d6ff12; box-shadow: inset 0 0 12px #35d6ff15; }

/* buy / research list */
.af-buylist { display: flex; flex-direction: column; gap: 8px; }
.af-buyitem { display: flex; align-items: stretch; gap: 10px; padding: 10px 11px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 9px; }
.af-buyitem.is-done { opacity: 0.6; }
.af-buyitem-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.af-buyitem-name { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--txt);
    display: flex; align-items: center; gap: 6px; }
.af-owned { font-family: var(--mono); font-size: 10px; color: var(--cy); font-weight: 400; }
.af-owned--done { color: var(--pos); }
.af-buyitem-desc { font-size: 11px; color: var(--muted); line-height: 1.3; }
.af-buyitem-stats { font-family: var(--mono); font-size: 10px; color: #9fb6cc; margin-top: 1px; }
.af-done-tag { align-self: center; font-family: var(--mono); font-size: 10px; color: var(--pos);
    border: 1px solid #54e08a55; border-radius: 6px; padding: 4px 8px; }
.af-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 18px; font-style: italic; }

/* buttons */
.af-btn { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 0.5px;
    border: 1px solid var(--cy); background: #35d6ff14; color: var(--cy); border-radius: 8px;
    padding: 9px 12px; cursor: pointer; white-space: nowrap; transition: background 0.15s, transform 0.05s; }
.af-btn:hover { background: #35d6ff26; }
.af-btn:active { transform: translateY(1px); }
.af-buy-btn { align-self: center; min-width: 84px; text-align: center; }
.af-buy-btn.is-locked { border-color: #3a4757; color: #56697d; background: #ffffff06; cursor: not-allowed; }
.af-btn-ghost { border-color: var(--line); color: var(--muted); background: transparent; }
.af-btn-ghost:hover { border-color: var(--cy); color: var(--cy); background: #35d6ff10; }
.af-btn-launch { border-color: var(--mg); color: #ffd0e4; background: #ff2d7820; width: 100%;
    padding: 13px; font-size: 14px; box-shadow: 0 0 20px #ff2d7830; }
.af-btn-launch:hover { background: #ff2d7833; }
.af-btn-launch:disabled { border-color: #4a3340; color: #8a6679; background: #ffffff06; box-shadow: none; cursor: not-allowed; }
.af-btn-danger { border-color: var(--dn); color: #ffd2d2; background: #ff3b4622; }

/* hire staff */
.af-staff { display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin-top: 10px; padding: 10px 11px; background: var(--panel); border: 1px dashed var(--line); border-radius: 9px; }
.af-staff-label { font-family: var(--mono); font-size: 12px; color: var(--txt); }
.af-staff-sub { font-size: 10px; color: var(--muted); }

/* archetypes */
.af-archetypes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 12px; }
.af-arch { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
    padding: 9px; cursor: pointer; color: var(--txt); transition: border-color 0.15s, box-shadow 0.15s; }
.af-arch.is-sel { border-color: var(--accent); box-shadow: 0 0 16px -2px var(--accent), inset 0 0 18px -8px var(--accent); }
.af-arch-name { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--accent); }
.af-arch-bars { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 9px; color: var(--muted); margin: 4px 0; }
.af-arch-desc { font-size: 9.5px; color: var(--muted); line-height: 1.3; }

/* mission monitor */
.af-monitor { position: relative; width: 100%; aspect-ratio: 16/9; max-height: 200px;
    border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; margin-bottom: 12px;
    background: radial-gradient(120% 120% at 70% 40%, #1a1030, #05070d);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 12px 100%, 0 calc(100% - 12px)); }
.af-monitor canvas { width: 100%; height: 100%; display: block; }
.af-monitor-hud { position: absolute; inset: 0; pointer-events: none; padding: 8px 10px;
    display: flex; flex-direction: column; justify-content: space-between; }
.af-monitor-tag { font-family: var(--mono); font-size: 9px; letter-spacing: 2px; color: var(--cy); }
.af-monitor-status { font-family: var(--mono); font-size: 10px; color: var(--gd); align-self: flex-end; }

/* planner */
.af-planner { display: flex; flex-direction: column; gap: 10px; }
.af-planner-row { display: flex; align-items: center; gap: 10px; }
.af-planner-row label { font-family: var(--mono); font-size: 10px; letter-spacing: 1px; color: var(--muted); flex: none; width: 72px; }
.af-planner-row select { flex: 1; font-family: var(--mono); font-size: 12px; color: var(--txt);
    background: var(--panel-solid); border: 1px solid var(--line); border-radius: 7px; padding: 8px; }
.af-planner-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.af-pl-stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px;
    display: flex; flex-direction: column; gap: 2px; }
.af-pl-stat span { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.5px; color: var(--muted); }
.af-pl-stat b { font-family: var(--mono); font-size: 14px; color: var(--txt); }
.af-pl-stat--am { border-color: #ff2d7855; background: #ff2d7810; }
.af-pl-stat--am b { color: #ff7ab0; }
.af-prestige-row { display: flex; justify-content: center; }

/* ---------- bottom tab bar ---------- */
.af-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 32; height: calc(var(--tab-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: flex; background: linear-gradient(0deg, #06090f, #070b12ee); border-top: 1px solid var(--line-strong); }
.af-tab { flex: 1; background: transparent; border: none; color: var(--muted); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-family: var(--mono); font-size: 9px; letter-spacing: 1px; position: relative; }
.af-tab-ico { font-size: 17px; line-height: 1; }
.af-tab.is-active { color: var(--cy); }
.af-tab.is-active::after { content: ''; position: absolute; top: 0; left: 20%; right: 20%; height: 2px;
    background: var(--cy); box-shadow: 0 0 8px var(--cy); }
.af-tab-badge { position: absolute; top: 6px; right: calc(50% - 22px); width: 14px; height: 14px;
    background: var(--mg); color: #fff; border-radius: 50%; font-size: 10px; display: grid; place-items: center; animation: pulseCrit 1s infinite; }

/* ---------- overlays ---------- */
.af-overlay { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center;
    padding: 20px; background: #04060caa; backdrop-filter: blur(8px); }
.af-overlay.is-open { display: flex; }
.af-dialog { width: min(520px, 100%); max-height: 86vh; overflow-y: auto;
    background: linear-gradient(180deg, #0b121cf5, #080d15f8); border: 1px solid var(--line-strong);
    border-radius: 14px; padding: 26px 24px; box-shadow: 0 20px 80px #000c, inset 0 0 40px #35d6ff0c;
    clip-path: polygon(0 14px, 14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%); }
.af-dialog-icon { font-size: 40px; text-align: center; margin-bottom: 8px; }
.af-dialog-title { font-family: var(--mono); font-size: 20px; letter-spacing: 2px; text-align: center;
    color: var(--cy); margin-bottom: 14px; }
.af-dialog--breach .af-dialog-title { color: var(--dn); text-shadow: 0 0 20px #ff3b4666; }
.af-dialog--breach .af-dialog-icon { color: var(--dn); animation: pulseCrit 0.6s infinite; }
.af-dialog--win .af-dialog-title { color: var(--gd); text-shadow: 0 0 30px #ffb02866; }
.af-dialog-body { font-size: 14px; line-height: 1.6; color: #cdddf0; margin-bottom: 18px; }
.af-dialog-actions { display: flex; gap: 10px; }
.af-dialog-actions .af-btn { flex: 1; }
.af-help-body p { margin-bottom: 11px; font-size: 13px; }
.af-help-eq { font-family: var(--mono); font-size: 12px; color: var(--cy); text-align: center;
    border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #35d6ff08; }
.af-help-foot { font-size: 12px; color: var(--muted); font-style: italic; }

/* journey overlay */
.af-journey { position: relative; width: min(900px, 100%); aspect-ratio: 16/10; max-height: 86vh;
    border: 1px solid var(--line-strong); border-radius: 14px; overflow: hidden;
    background: radial-gradient(120% 120% at 80% 45%, #241038, #05070d 70%); }
.af-journey canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.af-journey-hud { position: absolute; inset: 0; padding: 18px; display: flex; flex-direction: column;
    justify-content: space-between; pointer-events: none; }
.af-journey-top { display: flex; justify-content: space-between; align-items: center; }
.af-journey-dest { font-family: var(--mono); font-size: 16px; letter-spacing: 2px; color: var(--gd); }
.af-journey-drive { font-family: var(--mono); font-size: 10px; letter-spacing: 1px; color: var(--cy); }
.af-journey-clocks { display: flex; gap: 16px; justify-content: center; }
.af-clockbox { text-align: center; background: #05070d99; border: 1px solid var(--line); border-radius: 10px; padding: 10px 18px; }
.af-clockbox span { font-family: var(--mono); font-size: 9px; letter-spacing: 1.5px; color: var(--cy); display: block; }
.af-clockbox b { font-family: var(--mono); font-size: 22px; color: #fff; }
.af-clockbox--earth span { color: var(--gd); }
.af-journey-progress { height: 5px; background: #ffffff14; border-radius: 4px; overflow: hidden; margin-top: 12px; }
.af-journey-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--cy), var(--mg)); box-shadow: 0 0 10px var(--mg); }
#af-journey-skip { position: absolute; bottom: 16px; right: 16px; pointer-events: auto; }

/* ---------- toasts ---------- */
.af-toasts { position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
    bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 22px);
    display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.af-toast { font-family: var(--mono); font-size: 11px; letter-spacing: 0.5px; color: var(--txt);
    background: #0b121cf2; border: 1px solid var(--line-strong); border-left: 3px solid var(--cy);
    border-radius: 7px; padding: 8px 14px; opacity: 0; transform: translateY(10px); transition: all 0.3s; }
.af-toast.is-in { opacity: 1; transform: translateY(0); }
.af-toast--good { border-left-color: var(--pos); }
.af-toast--danger { border-left-color: var(--dn); color: #ffd2d2; }

/* ---------- desktop: dock the panel host on the left ---------- */
@media (min-width: 980px) {
    :root { --res-h: 64px; }
    .af-panelhost {
        left: 14px; right: auto; top: calc(var(--top-h) + var(--res-h) + 16px);
        bottom: calc(var(--tab-h) + 14px); width: 400px; height: auto; max-height: none;
        border: 1px solid var(--line-strong); border-radius: 14px;
        clip-path: polygon(0 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%);
    }
    .af-target { left: calc(400px + 14px + (100% - 400px) / 2); }
    .af-overview { grid-template-columns: 1fr 1fr; }
    .af-tabs { left: 14px; width: 400px; right: auto; border-radius: 0 0 14px 14px;
        background: #070b12f5; border: 1px solid var(--line-strong); border-top: none; bottom: 14px; }
    .af-monitor { max-height: 230px; }
    .af-ticker { left: 420px; right: 14px; }
    .af-toasts { left: calc(420px + (100% - 420px) / 2); }
}

/* tall phones: a touch more sheet */
@media (max-height: 700px) { .af-panelhost { height: 50vh; } .af-monitor { max-height: 150px; } }
