:root {
  --bg: #07080d;
  --panel: #10141c;
  --ink: #ece8df;
  --muted: #8b92a3;
  --line: #232a38;
  --p1: #3aa0ff;
  --p2: #ff4f6e;
  --gold: #f0b429;
  --warn: #ff8a3d;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(1200px 700px at 50% -10%, #182033, var(--bg));
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

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

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px 8px;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0.08em;
}
.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.22em;
}
.tag { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.match-strip {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.match-strip strong { color: var(--ink); }

.screen { flex: 1; display: flex; flex-direction: column; }
.hidden { display: none !important; }

.select-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  gap: 16px;
  padding: 8px 22px 0;
}

.pilot-card {
  background: linear-gradient(180deg, #141a26, #0c1017);
  border: 1px solid var(--line);
  padding: 14px;
  min-height: 520px;
}
.pilot-label {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.pilot-label.p1 { color: var(--p1); }
.pilot-label.p2 { color: var(--p2); }
.portrait {
  width: 100%;
  height: 160px;
  background: #07090f;
  border: 1px solid #1b2230;
  display: block;
}
.pilot-card h2 { margin: 10px 0 4px; font-size: 20px; }
.ship-tag { color: var(--muted); font-size: 13px; min-height: 36px; margin: 0 0 10px; }

.stat-list { margin: 0; }
.stat-list div { margin: 0 0 7px; }
.stat-list dt {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.bar {
  height: 6px;
  background: #1a2130;
  margin-top: 3px;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #3aa0ff, #7ee0ff);
}
.pilot-card#card-p2 .bar > i { background: linear-gradient(90deg, #ff4f6e, #ffb36b); }

.kit { margin-top: 12px; font-size: 12px; color: #c8cdd8; }
.kit b { color: var(--gold); display: block; margin-top: 8px; }

.select-main { display: flex; flex-direction: column; min-width: 0; }
.select-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}
.select-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.diff-pick.hidden { display: none; }
select {
  background: #0d121b;
  color: var(--ink);
  border: 1px solid #2a3344;
  padding: 8px 10px;
  min-width: 180px;
}
.hint { margin: 0 0 2px auto; color: var(--muted); font-size: 12px; }

.roster {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.cell {
  position: relative;
  aspect-ratio: 1;
  background: #0c1119;
  color: var(--ink);
  border: 2px solid #243044;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  font-weight: 600;
  letter-spacing: 0;
  text-align: left;
}
.cell canvas { width: 100%; height: 100%; display: block; }
.cell .name {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 4px 6px;
  font-size: 11px;
  background: linear-gradient(transparent, #000c);
  letter-spacing: 0.04em;
}
.cell.hover-p1 { border-color: var(--p1); box-shadow: 0 0 0 1px var(--p1), inset 0 0 24px #3aa0ff22; }
.cell.hover-p2 { border-color: var(--p2); box-shadow: 0 0 0 1px var(--p2), inset 0 0 24px #ff4f6e22; }
.cell.locked-p1 { outline: 2px solid var(--p1); }
.cell.locked-p2 { outline: 2px solid var(--p2); outline-offset: -6px; }
.cell.dim { opacity: 0.45; }

.cpu-banner {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  border: 1px dashed #ff4f6e88;
  color: var(--p2);
  letter-spacing: 0.18em;
}
.cpu-pulse {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--p2);
  animation: pulse 0.7s infinite alternate;
}
@keyframes pulse { from { opacity: 0.3; } to { opacity: 1; } }

.select-foot {
  padding: 12px 22px 18px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
kbd {
  display: inline-block;
  border: 1px solid #3a4356;
  padding: 1px 5px;
  margin: 0 2px;
  font-size: 11px;
  color: #d6dbe6;
}

#screen-fight { position: relative; background: #000; }
#game {
  width: 100%;
  height: calc(100vh - 70px);
  display: block;
  background: #000;
}
#hud {
  position: absolute;
  left: 16px; right: 16px; top: 10px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  pointer-events: none;
}
.hud-ship { font-size: 12px; }
.hud-ship.p2 { text-align: right; }
.hud-ship .title { letter-spacing: 0.12em; text-transform: uppercase; font-size: 11px; }
.hud-ship.p1 .title { color: var(--p1); }
.hud-ship.p2 .title { color: var(--p2); }
.meter { height: 8px; background: #11161f; margin: 4px 0; border: 1px solid #2a3140; }
.meter > i { display: block; height: 100%; }
.meter.hp > i { background: #3ee08a; }
.meter.en > i { background: #49b6ff; }
.hud-center { text-align: center; }
#arena-chip { color: var(--muted); letter-spacing: 0.14em; font-size: 11px; }
#whip-chip {
  margin-top: 6px;
  color: #ffd36a;
  letter-spacing: 0.2em;
  font-size: 12px;
  text-shadow: 0 0 12px #ffb020;
}

.fight-splash {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #0006;
  z-index: 3;
  pointer-events: none;
}
.fight-vs {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #ffe7b8;
  font-size: 16px;
}
.fight-splash span {
  font-size: clamp(48px, 10vw, 110px);
  letter-spacing: 0.28em;
  color: #fff6e8;
  text-shadow: 0 0 24px #ffb020;
  animation: fightin 0.85s ease-out;
}
@keyframes fightin {
  from { transform: scale(2.2); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.result {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  background: #07080dcc;
  z-index: 4;
  text-align: center;
  gap: 8px;
}
.result h2 { margin: 0; letter-spacing: 0.16em; font-size: 36px; }
.result p { color: var(--muted); }
.result-actions { display: flex; gap: 10px; margin-top: 10px; }
button {
  background: var(--gold);
  color: #1a1204;
  border: 0;
  padding: 10px 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
}
button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid #3a4356;
}

.touch {
  position: absolute;
  left: 12px; right: 12px; bottom: 12px;
  display: flex;
  gap: 8px;
  justify-content: center;
  z-index: 2;
}
.touch button {
  min-width: 56px;
  min-height: 48px;
  background: #141a26cc;
  color: var(--ink);
  border: 1px solid #3a4356;
}

@media (max-width: 980px) {
  .select-layout { grid-template-columns: 1fr; }
  .pilot-card { min-height: 0; }
  #card-p2 { order: 3; }
  .roster { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .select-foot { flex-direction: column; gap: 6px; }
  .hint { margin-left: 0; }
}

@media (pointer: coarse) {
  .touch:not(.hidden) { display: flex; }
}

.preview-btn {
  align-self: end;
  padding: 8px 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 12px;
}

.preview-panel {
  margin: 10px 22px 0;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #141a26, #0c1017);
  padding: 12px 14px 14px;
  z-index: 5;
}
.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.preview-head h3 {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--gold);
}
.preview-body {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 16px;
  align-items: start;
}
#preview-canvas {
  width: 100%;
  max-width: 420px;
  height: auto;
  background: #07090f;
  border: 1px solid #1b2230;
  display: block;
}
.preview-copy .kit.long b { margin-top: 10px; }
.preview-copy .kit.long {
  font-size: 13px;
  line-height: 1.45;
  color: #d2d7e2;
}
.preview-note {
  margin: 12px 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
#btn-preview-lock { margin-top: 4px; }

.kit .kit-line { margin: 2px 0 0; }

@media (max-width: 980px) {
  .preview-body { grid-template-columns: 1fr; }
}

/* Alien portraits + banter */
.alien-chip {
  margin-top: 6px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  min-height: 14px;
}
.banter-line {
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid #2a3344;
  background: #0a0e16;
  color: #e8ecf4;
  font-size: 12px;
  line-height: 1.35;
  min-height: 38px;
  border-radius: 4px;
  position: relative;
}
.banter-line::before {
  content: "";
  position: absolute;
  left: 8px; top: -1px; right: 8px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.portrait {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.cell canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.fight-banter {
  margin: 0;
  max-width: 640px;
  text-align: center;
  color: #ffe7b8;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-shadow: 0 0 12px #000;
}
.result-banter {
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 14px;
  border: 1px solid #3a4356;
  background: #0c1018;
  color: #f0e6d0;
  font-size: 14px;
  font-style: italic;
  opacity: 1;
  animation: none;
  pointer-events: none;
  white-space: normal;
  line-height: 1.45;
}
.result {
  z-index: 20;
}
.result-banter,
.result h2,
.result p {
  opacity: 1 !important;
  animation: none !important;
}
.cpu-banner strong {
  letter-spacing: 0.08em;
  text-transform: none;
  font-size: 14px;
}
.cell .name small {
  display: block;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #9aa6c4;
  font-weight: 500;
}

.buff-row { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.hud-ship.p2 .buff-row { justify-content: flex-end; }
.buff-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border: 1px solid var(--buff, #ffe7b8);
  color: var(--buff, #ffe7b8);
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.06em;
  background: #0a0d14cc;
  text-shadow: 0 0 8px var(--buff, #ffe7b8);
}
.buff-chip i { font-style: normal; opacity: 0.75; font-size: 9px; }


/* Cross-site hub Menu — fixed corner, collapsed stays out of combat HUD */
.hub-nav {
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}
.hub-nav > * { pointer-events: auto; }
#hub-nav-toggle {
  margin: 0;
  padding: 6px 12px;
  border: 1px solid #3d4a66;
  border-radius: 999px;
  background: #0a0d14e6;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 18px #00000066;
}
#hub-nav-toggle:hover,
#hub-nav-toggle[aria-expanded="true"] {
  border-color: var(--gold);
  color: var(--gold);
}
.hub-nav-panel {
  min-width: 168px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0c1018f2;
  box-shadow: 0 10px 28px #00000088;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hub-nav-panel[hidden] { display: none !important; }
.hub-nav-panel a {
  display: block;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.02em;
}
.hub-nav-panel a:hover {
  background: #1a2233;
  color: var(--gold);
}
.hub-nav-panel a[aria-current="page"] {
  color: var(--gold);
  border: 1px solid #5a4a20;
  background: #18140c;
}
