/* Vector Defense — Hexforge UI shell */
:root {
  --night: #0a1420;
  --night2: #0e1c2e;
  --panel: rgba(18, 30, 48, .82);
  --line: #22334a;
  --ink: #eef4fb;
  --ink2: #9db0c8;
  --ink3: #5f7189;
  --brass: #d9a441;
  --gold: #e8c37a;
  --hex: #38bdf8;
  --shimmer: #d24be0;
  --good: #a3e635;
  --bad: #f87171;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* author display rules must not override the hidden attribute */
html, body {
  margin: 0; height: 100%;
  background: var(--night);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

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

/* top bar */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px max(14px, env(safe-area-inset-left)) 10px max(14px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--night2), var(--night));
}
.brand { font-family: var(--mono); font-size: 13px; letter-spacing: .22em; color: var(--brass); }
.stats { display: flex; gap: 8px; margin-left: auto; }
.stat {
  display: flex; flex-direction: column; align-items: center; line-height: 1.1;
  background: rgba(6,12,21,.5); border: 1px solid var(--line); border-radius: 9px;
  padding: 5px 12px; min-width: 62px;
}
.stat em { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink3); font-style: normal; }
.stat b { font-size: 17px; font-variant-numeric: tabular-nums; }
.stat.core b { color: var(--hex); }
.stat.core.low b { color: var(--bad); }
.tools { display: flex; gap: 8px; }

.btn {
  font-family: var(--mono); font-size: 12.5px; letter-spacing: .03em;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 8px 13px; border-radius: 9px; cursor: pointer;
}
.btn:hover { border-color: var(--hex); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--hex); outline-offset: 2px; }
.btn.primary { background: var(--brass); color: var(--night); border-color: var(--brass); font-weight: 600; }
.btn.on { border-color: var(--good); color: var(--good); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* stage */
#stage { position: relative; flex: 1; min-height: 0; }
#cv { display: block; width: 100%; height: 100%; touch-action: none; }
/* WebGL units layer + 2D UI overlay, stacked over the 2D world; clicks pass through to #cv */
#gl, #ui { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.hint {
  position: absolute; bottom: 96px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 11.5px; color: var(--ink3);
  background: rgba(7,12,21,.5); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 13px; pointer-events: none; transition: opacity .5s; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}

/* build palette */
.buildbar {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 94vw;
}
.bbtn {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 14px 8px 8px; color: var(--ink); backdrop-filter: blur(6px);
  transition: border-color .15s, box-shadow .15s, transform .05s;
}
.bbtn:hover { border-color: var(--gold); }
.bbtn:active { transform: translateY(1px); }
.bbtn.active { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass), 0 10px 24px -14px rgba(217,164,65,.6); }
.bbtn.poor { opacity: .5; }
.bico { width: 48px; height: 48px; display: block; }
.btxt { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.bn { font-size: 13px; }
.bc { font-family: var(--mono); font-size: 12px; color: var(--gold); font-variant-numeric: tabular-nums; }

/* cash flash on an unaffordable action */
@keyframes cashflash { 0%,100% { color: var(--ink); } 30% { color: var(--bad); } }
.stat.flash b { animation: cashflash .4s ease; }

/* build / upgrade panel */
.panel {
  position: absolute; top: 14px; right: 14px; width: 232px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 20px 50px -24px rgba(0,0,0,.8); backdrop-filter: blur(6px);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--gold);
}
.panel-head .x { background: none; border: 0; color: var(--ink3); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.panel-head .x:hover { color: var(--ink); }
.panel-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }

.rows { display: flex; flex-direction: column; gap: 7px; }
.row { display: flex; justify-content: space-between; font-size: 13px; }
.row span { color: var(--ink2); }
.row b { font-variant-numeric: tabular-nums; }
.row .up { color: var(--good); font-size: 11px; }

.buy {
  width: 100%; text-align: center; font-family: var(--mono); font-size: 12.5px;
  border: 1px solid var(--brass); background: rgba(217,164,65,.12); color: var(--gold);
  padding: 10px; border-radius: 10px; cursor: pointer;
}
.buy:hover { background: rgba(217,164,65,.2); }
.buy:disabled { opacity: .4; cursor: not-allowed; border-color: var(--line); color: var(--ink3); background: transparent; }
.hexlabel { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* game over */
.over {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(6,11,20,.72); backdrop-filter: blur(3px);
}
.over-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 26px 30px; text-align: center; max-width: 320px;
}
.over-card h2 { margin: 0 0 6px; color: var(--bad); }
.over-card p { margin: 0 0 18px; color: var(--ink2); }

@media (max-width: 560px) {
  .brand { display: none; }
  .panel { top: auto; bottom: 54px; right: 10px; left: 10px; width: auto; }
}
