/* Panthera — UI stylesheet. Dark space console with neon accents. */

:root {
  --bg: #05070d;
  --panel: #0d1220;
  --panel2: #131a2c;
  --edge: #223050;
  --text: #d7deea;
  --dim: #7e8ba0;
  --hl: #ffd77a;
  --good: #7ade9a;
  --bad: #ff8a7a;
  --acc: #4aa3ff;
  --font: 'Segoe UI', system-ui, sans-serif;
  --mono: 'Cascadia Code', Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  user-select: none;
}

#app { display: flex; flex-direction: column; height: 100%; }

/* ============ TOP BAR ============ */
#topbar {
  display: flex; align-items: center; gap: 18px;
  height: 46px; padding: 0 14px;
  background: linear-gradient(180deg, #10182c, #0a0f1d);
  border-bottom: 1px solid var(--edge);
  flex-shrink: 0; z-index: 30;
}
#tb-title {
  font-weight: 800; letter-spacing: 3px; font-size: 15px;
  background: linear-gradient(90deg, #7ac8ff, #d78aff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
#tb-loc { font-size: 13px; color: var(--dim); white-space: nowrap; }
#tb-loc b { color: var(--text); }
#tb-stats { display: flex; gap: 16px; align-items: center; margin-left: auto; }
.stat { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.stat label { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.stat .bar {
  width: 74px; height: 8px; border-radius: 4px;
  background: #1a2338; overflow: hidden; border: 1px solid #263252;
}
.stat .bar > div { height: 100%; border-radius: 3px; transition: width .3s; }
#ap-fill { background: linear-gradient(90deg, #3f8cff, #7ac8ff); }
#hull-fill { background: #6adf7a; }
#shield-fill { background: #5ab8ff; }
#tb-buttons { display: flex; gap: 6px; }
#tb-buttons button, #sidebar button {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--edge); border-radius: 6px;
  padding: 5px 10px; cursor: pointer; font-size: 12px; font-family: var(--font);
}
#tb-buttons button:hover, #sidebar button:hover { background: #1c2742; border-color: #35507e; }

/* ============ MAIN AREA ============ */
#main { position: relative; flex: 1; overflow: hidden; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }

/* sidebar (minimap + nav) */
#sidebar {
  position: absolute; left: 10px; top: 10px; width: 168px;
  background: rgba(10, 15, 28, 0.88); border: 1px solid var(--edge); border-radius: 10px;
  padding: 8px; z-index: 10; backdrop-filter: blur(4px);
}
#minimap { width: 150px; height: 104px; border-radius: 6px; display: block; }
#sidebar .nav { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 8px; }
#sidebar button { font-size: 11px; padding: 5px 4px; }

/* right panel */
#panel {
  position: absolute; right: 0; top: 0; bottom: 26px; width: 380px;
  background: rgba(11, 16, 30, 0.9);
  border-left: 1px solid var(--edge);
  transform: translateX(102%); transition: transform .22s ease;
  overflow-y: auto; z-index: 20; padding: 14px;
  backdrop-filter: blur(8px);
}
#panel.open { transform: translateX(0); }
#panel::-webkit-scrollbar { width: 8px; }
#panel::-webkit-scrollbar-thumb { background: #223050; border-radius: 4px; }

.p-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.p-head h2 { font-size: 17px; }
.p-sub { color: var(--dim); font-size: 12px; margin-top: 2px; }
.x {
  background: none; border: none; color: var(--dim); font-size: 15px; cursor: pointer; padding: 2px 6px;
}
.x:hover { color: #fff; }

h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--acc); margin: 14px 0 6px; }
.dim { color: var(--dim); }
.small { font-size: 12px; line-height: 1.45; }
.tiny { font-size: 11px; }
.hl { color: var(--hl); }
.good { color: var(--good); }
.bad { color: var(--bad); }

/* tabs */
.tabs { display: flex; gap: 2px; margin-bottom: 10px; border-bottom: 1px solid var(--edge); }
.tab {
  background: none; border: none; color: var(--dim); padding: 7px 10px; cursor: pointer;
  font-size: 13px; font-family: var(--font); border-bottom: 2px solid transparent;
}
.tab.on { color: #fff; border-bottom-color: var(--acc); }
.tab:hover { color: #fff; }

/* buttons */
.b {
  background: linear-gradient(180deg, #234, #1a2740); color: var(--text);
  border: 1px solid #35507e; border-radius: 6px;
  padding: 7px 12px; cursor: pointer; font-size: 13px; font-family: var(--font);
  transition: filter .12s;
}
.b:hover:not(:disabled) { filter: brightness(1.3); }
.b:disabled { opacity: 0.38; cursor: default; }
.b.xs { padding: 2px 7px; font-size: 11px; border-radius: 4px; }
.b.sell { border-color: #7e4035; background: linear-gradient(180deg, #432, #402018); }
.b.wide { display: block; width: 100%; margin-top: 8px; text-align: center; }
.b.ghost { background: none; border-style: dashed; cursor: default; }
.b.big-b { font-size: 15px; padding: 11px; font-weight: 600; }

/* market table — .acts may wrap to a second line rather than h-scroll the panel */
.mkt { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: auto; }
.mkt th { text-align: left; color: var(--dim); font-weight: 500; font-size: 11px; padding: 3px 3px; }
.mkt td { padding: 4px 3px; border-top: 1px solid #1a2338; vertical-align: middle; }
.mkt .r { text-align: right; }
.mkt .acts { text-align: right; }
.mkt .acts .b { margin: 1px 0 1px 2px; }
.buyp { color: #8fc8ff; }
.sellp { color: var(--hl); }
.lb .me td { background: rgba(74, 163, 255, 0.12); }
.cargo-line { font-size: 13px; margin-bottom: 8px; color: var(--dim); }

/* cards & rows */
.card {
  background: var(--panel2); border: 1px solid var(--edge); border-radius: 8px;
  padding: 10px; margin: 8px 0;
}
.card-t { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 2px; border-top: 1px solid #1a2338; font-size: 13px;
}
.row.shop span:first-child { color: #b8c4d8; }
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; font-size: 12px; color: var(--dim); margin: 6px 0; }
.statgrid.big { grid-template-columns: 1fr 1fr; font-size: 13px; }
.statgrid b { color: var(--text); }
.svc { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.svc.col { flex-direction: column; align-items: stretch; }
.svc.col .b { text-align: left; }

/* skill bars */
.skill { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; }
.skill span { flex: 0 0 110px; }
.pbar {
  flex: 1; height: 7px; background: #1a2338; border-radius: 4px; overflow: hidden;
  border: 1px solid #263252; min-width: 40px;
}
.pbar > div { height: 100%; border-radius: 3px; transition: width .25s; }
.pbar .sk { background: linear-gradient(90deg, #4aa3ff, #7ac8ff); }
.pbar .hull { background: #6adf7a; }
.pbar .shield { background: #5ab8ff; }
.pbar .armor { background: #c8a45a; }

.news-item { padding: 7px 2px; border-bottom: 1px solid #1a2338; font-size: 12.5px; line-height: 1.4; }

/* ============ TOASTS ============ */
#toasts {
  position: absolute; top: 12px; right: 394px; width: 320px; z-index: 40;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: rgba(13, 18, 32, 0.95); border: 1px solid var(--edge); border-left: 3px solid var(--acc);
  border-radius: 8px; padding: 10px 12px; font-size: 13px; line-height: 1.4;
  opacity: 0; transform: translateX(24px); transition: all .3s ease;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.good { border-left-color: var(--good); }
.toast.bad { border-left-color: var(--bad); }
.toast.big { border-left-color: var(--hl); font-size: 14px; }

/* ============ TOOLTIP ============ */
#tooltip {
  position: fixed; display: none; z-index: 60; pointer-events: none;
  background: rgba(8, 12, 24, 0.96); border: 1px solid #2c3d63; border-radius: 7px;
  padding: 8px 11px; font-size: 12.5px; line-height: 1.5; max-width: 300px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.6);
}

/* ============ NEWS TICKER ============ */
#ticker {
  height: 26px; background: #070b15; border-top: 1px solid var(--edge);
  display: flex; align-items: center; padding: 0 12px; font-size: 12px;
  color: #9fb4d8; flex-shrink: 0; overflow: hidden; white-space: nowrap;
}
#ticker::before {
  content: 'GNN'; color: var(--bg); background: var(--acc); font-weight: 700;
  border-radius: 3px; padding: 1px 6px; margin-right: 10px; font-size: 10px; letter-spacing: 1px;
}
#ticker-text.slide { animation: tickIn .5s ease; display: inline-block; }
@keyframes tickIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ============ OBJECTIVE (tutorial) ============ */
#objective {
  position: absolute; left: 10px; bottom: 12px; width: 300px; z-index: 10;
  background: rgba(10, 15, 28, 0.92); border: 1px solid #2c5a3f; border-radius: 10px;
  padding: 10px 12px; display: none;
}
.obj-head { font-size: 10px; letter-spacing: 2px; color: var(--good); display: flex; justify-content: space-between; align-items: center; }
.obj-step { font-size: 13.5px; font-weight: 600; margin: 5px 0 3px; }
.obj-tip { font-size: 11.5px; line-height: 1.4; }
.obj-claim { margin-top: 8px; }
.obj-later { margin-top: 5px; opacity: 0.6; }
.tiny-x { font-size: 11px; padding: 0 3px; }

/* tutorial pointer arrow — bobs above the current step's target */
#tut-arrow {
  position: fixed; z-index: 70; display: none; pointer-events: none;
  font-size: 20px; color: var(--good);
  text-shadow: 0 0 10px rgba(110, 220, 140, 0.85), 0 0 3px rgba(0, 0, 0, 0.9);
  animation: tutBob 1.1s ease-in-out infinite;
}
@keyframes tutBob { 0%, 100% { margin-top: 0; } 50% { margin-top: 7px; } }

/* ============ MODALS ============ */
#modal-root { display: none; }
.modal-back {
  position: fixed; inset: 0; background: rgba(3, 5, 10, 0.72); z-index: 80;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .18s ease;
}
.modal-back.dark { background: rgba(3, 5, 10, 0.88); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--panel); border: 1px solid #2c3d63; border-radius: 14px;
  padding: 18px; max-width: 860px; width: min(92vw, 860px); max-height: 88vh; overflow-y: auto;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.7);
  animation: popIn .2s ease;
}
@keyframes popIn { from { transform: scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h2 { margin-bottom: 8px; }

/* galaxy map modal */
.galmap-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 8px; }
.galmap-head .x { margin-left: auto; }
#galmap-cv { display: block; border-radius: 8px; width: 100%; }

/* ============ COMBAT ============ */
.combat-modal { max-width: 780px; }
.c-title { text-align: center; font-size: 13px; letter-spacing: 4px; color: var(--bad); margin-bottom: 10px; }
.combat { display: grid; grid-template-columns: 190px 1fr 190px; gap: 14px; }
.c-side {
  background: var(--panel2); border: 1px solid var(--edge); border-radius: 10px;
  padding: 10px; text-align: center;
}
.c-side.flash { animation: hitFlash .35s ease; }
@keyframes hitFlash {
  0% { background: #4a1a20; border-color: #a04040; }
  100% { background: var(--panel2); border-color: var(--edge); }
}
.c-name { font-weight: 700; font-size: 13.5px; margin-bottom: 6px; }
.c-portrait { width: 110px; height: 110px; margin: 0 auto; display: block; }
.c-bars { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.c-bar { display: flex; align-items: center; gap: 6px; font-size: 10.5px; }
.c-bar label { flex: 0 0 38px; color: var(--dim); text-align: left; }
.c-bar span { flex: 0 0 52px; text-align: right; color: var(--dim); font-family: var(--mono); font-size: 10px; }
.c-mid { display: flex; flex-direction: column; min-height: 260px; }
.c-round { text-align: center; color: var(--dim); font-size: 11px; letter-spacing: 2px; margin-bottom: 6px; }
.c-log {
  flex: 1; overflow-y: auto; background: #080c16; border: 1px solid #1a2338; border-radius: 8px;
  padding: 8px 10px; font-size: 12.5px; line-height: 1.55; max-height: 300px;
}
.c-line { animation: tickIn .25s ease; }
.c-actions { display: flex; gap: 8px; margin-top: 14px; justify-content: center; flex-wrap: wrap; }
.c-actions .b { min-width: 130px; }
.c-end { text-align: center; }
.c-end h3 { font-size: 16px; color: var(--hl); letter-spacing: 2px; }

/* ============ LAUNCH SCREEN ============ */
.ng-modal { max-width: 480px; text-align: center; }
.newgame h1 {
  font-size: 42px; letter-spacing: 14px; font-weight: 800; margin: 6px 0 2px;
  background: linear-gradient(90deg, #7ac8ff, #d78aff, #ffd77a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { color: var(--dim); font-size: 13.5px; line-height: 1.5; margin-bottom: 16px; }
.ng-label {
  display: block; text-align: left; font-size: 11px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--acc); margin: 14px 0 6px;
}
.ng-note { margin-top: 12px; line-height: 1.5; }
.ng-signin { margin-top: 14px; opacity: 0.7; }
.newgame .big-b { margin-top: 18px; font-size: 17px; padding: 13px 18px; }

/* text inputs (claim form etc.) */
.txt {
  width: 100%; background: #0a0f1d; color: var(--text); border: 1px solid var(--edge);
  border-radius: 7px; padding: 9px 12px; font-size: 15px; font-family: var(--font);
}

/* claim modal */
.claim-modal { max-width: 420px; }
.claim-perks { margin: 8px 0 4px 18px; line-height: 1.7; }
.claim .svc { margin-top: 14px; }
#cl-err { margin-top: 8px; min-height: 1em; }

/* help */
.help { max-width: 560px; }
.help h2 { margin-top: 14px; font-size: 15px; color: var(--acc); }
.help h2:first-child { margin-top: 0; }
.help p { margin: 6px 0; }

/* ============ S1.2 MOBILE & TOUCH ============ */
#game { touch-action: none; }
button { touch-action: manipulation; }

/* context action stack — touch devices only; anticipated actions as floating
   pills (primary at the bottom, thumb-closest; minis above it) */
#ctx-stack {
  display: none;
  position: absolute; right: 14px; bottom: 18px; z-index: 15;
  flex-direction: column; align-items: flex-end; gap: 8px;
}
body.touch #ctx-stack.show { display: flex; }
#ctx-btn {
  display: flex;
  min-height: 60px; min-width: 60px; padding: 0 20px;
  align-items: center; justify-content: center; gap: 8px;
  border-radius: 32px; border: 1px solid #4a7ab8;
  background: linear-gradient(180deg, #2b4a7a, #1c3054); color: #fff;
  font-size: 15px; font-weight: 700; font-family: var(--font);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.55);
  cursor: pointer;
}
#ctx-btn:active { filter: brightness(1.3); }
#ctx-icon { font-size: 20px; }
.ctx-mini {
  min-height: 44px; padding: 0 16px;
  display: flex; align-items: center; gap: 6px;
  border-radius: 24px; border: 1px solid #35507e;
  background: rgba(13, 18, 32, 0.92); color: var(--text);
  font-size: 13.5px; font-weight: 600; font-family: var(--font);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  cursor: pointer; backdrop-filter: blur(4px);
}
.ctx-mini:active { filter: brightness(1.4); }

/* action satellite — radial menu around the selected tile + floating intel chip */
#satellite { display: none; position: absolute; inset: 0; z-index: 16; pointer-events: none; }
body.touch #satellite.show { display: block; }
.sat-node {
  position: absolute; transform: translate(-50%, -50%);
  pointer-events: auto;
  background: none; border: none; color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-family: var(--font);
  animation: satIn .16s ease;
}
@keyframes satIn { from { opacity: 0; transform: translate(-50%, -50%) scale(0.7); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.sat-ring {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; border: 1.5px solid #35507e; background: rgba(13, 20, 38, 0.92);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
}
.sat-b.prime .sat-ring { border-color: #5ee1ff; box-shadow: 0 0 12px rgba(94, 225, 255, 0.4); }
.sat-node:active .sat-ring { filter: brightness(1.5); }
.sat-lab {
  font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
}
.sat-sub { font-size: 9.5px; color: var(--dim); min-height: 11px; text-shadow: 0 1px 3px #000; }
.sat-sub.bad { color: var(--bad); }
.sat-x .sat-ring { width: 34px; height: 34px; font-size: 13px; color: var(--dim); border-color: #3a3f52; }
.sat-chip {
  position: absolute; transform: translate(-50%, -100%); pointer-events: none;
  background: rgba(9, 14, 27, 0.95); border: 1px solid #2c3d63; border-radius: 8px;
  padding: 6px 10px; line-height: 1.5; width: max-content; max-width: 250px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.6);
}
.sat-chip.below { transform: translate(-50%, 0); }

/* mobile top-left bar (replaces sidebar) & bottom-sheet grip: off on desktop */
#mobilebar { display: none; }
.sheet-grip { display: none; }

/* narrow desktop (901–1180px): the full stat row used to push ?/⚙ off-screen —
   trim to the essentials; ▾ expands the rest onto a wrap row */
@media (max-width: 1180px) and (min-width: 901px) {
  #topbar { gap: 10px; flex-wrap: wrap; height: auto; min-height: 46px; }
  #tb-stats { gap: 10px; }
  .stat .bar { width: 56px; }
  .stat.x2 { display: none; }
  #topbar.expanded .stat.x2 { display: flex; }
  #tb-more { display: inline-block; }
}

@media (max-width: 900px) {
  /* --- top bar: AP · credits · hull; ▾ expands the rest on a wrap row --- */
  #topbar { flex-wrap: wrap; height: auto; min-height: 50px; padding: 4px 8px; gap: 8px; }
  #tb-title { font-size: 13px; letter-spacing: 2px; }
  #tb-loc { display: none; }
  #tb-stats { gap: 10px; margin-left: auto; }
  .stat .bar { width: 48px; }
  .stat.x2 { display: none; }
  #topbar.expanded .stat.x2 { display: flex; }
  #topbar.expanded #tb-loc { display: block; order: 9; flex-basis: 100%; padding-bottom: 4px; }
  #tb-buttons button { min-width: 42px; min-height: 42px; }
  #tb-more { display: inline-block; }

  /* --- sidebar folds to two buttons --- */
  #sidebar { display: none; }
  #mobilebar { display: flex; position: absolute; left: 10px; top: 10px; gap: 8px; z-index: 10; }
  #mobilebar button {
    min-width: 46px; min-height: 46px; font-size: 19px;
    background: rgba(10, 15, 28, 0.88); color: var(--text);
    border: 1px solid var(--edge); border-radius: 10px; cursor: pointer;
    backdrop-filter: blur(4px);
  }

  /* --- right panel becomes a bottom sheet (half / full snap) --- */
  #panel {
    top: auto; left: 0; right: 0; bottom: 26px; width: 100%;
    height: 46%;
    border-left: none; border-top: 1px solid var(--edge);
    border-radius: 16px 16px 0 0;
    transform: translateY(110%);
    transition: transform .25s ease, height .2s ease;
  }
  #panel.open { transform: translateY(0); }
  #panel.sheet-full { height: calc(100% - 54px); }
  .sheet-grip {
    display: block; position: sticky; top: -14px; z-index: 5;
    margin: -14px -14px 6px; padding: 12px 0 8px;
    background: linear-gradient(180deg, rgba(11, 16, 30, 0.98) 70%, rgba(11, 16, 30, 0));
    cursor: pointer;
  }
  .sheet-grip::before {
    content: ''; display: block; width: 46px; height: 5px; margin: 0 auto;
    border-radius: 3px; background: #35507e;
  }

  /* --- toasts & objective fit the phone (toasts clear the mobile bar) --- */
  #toasts { left: 68px; right: 12px; width: auto; top: 8px; }
  #objective { left: 8px; bottom: 16px; width: calc(100% - 118px); max-width: 300px; }

  /* --- ≥44px hit targets (spec §7) --- */
  .b { min-height: 44px; }
  .b.xs { min-height: 40px; padding: 8px 12px; }
  .tab { min-height: 44px; padding: 11px 12px; }
  .x { min-width: 44px; min-height: 44px; }
  .tiny-x { min-width: 30px; min-height: 30px; }
  .mkt .acts { white-space: normal; }
  .mkt .acts .b { margin: 2px 0 2px 2px; }

  /* --- combat modal, portrait --- */
  .combat { grid-template-columns: 1fr; gap: 8px; }
  .c-portrait { width: 72px; height: 72px; }
  .c-mid { min-height: 150px; }
  .c-log { max-height: 150px; }
  .c-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .c-actions .b { min-width: 0; }
  .modal { padding: 14px; max-height: 92vh; }
}

/* menu sheet (mobile ☰) */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.menu-grid .b { min-height: 56px; font-size: 15px; }
