:root {
  --ink: #15131c;
  --panel: #262338;
  --panel-hi: #3d3858;
  --panel-lo: #120f1c;
  --gold: #ffd23f;
  --red: #e8423f;
  --txt: #ecebf5;
  --dim: #9a97b3;
  --px: "Press Start 2P", monospace;
  --vt: "VT323", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0d0b14; color: var(--txt); font-family: var(--vt); font-size: 20px; overflow: hidden; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; }

/* bevelled 32-bit panel */
.box, .panel {
  background: linear-gradient(180deg, var(--panel-hi), var(--panel) 30%, var(--panel) 80%, #1d1a2c);
  border: 3px solid var(--ink);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.18), inset -2px -2px 0 rgba(0, 0, 0, 0.45), 4px 4px 0 rgba(0, 0, 0, 0.5);
}
.btn {
  font-family: var(--px); font-size: 12px; padding: 12px 18px; cursor: pointer;
  background: linear-gradient(180deg, #ff6b5a, var(--red) 50%, #a82320);
  border: 3px solid var(--ink); color: #fff; text-shadow: 2px 2px 0 var(--ink);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.35), inset -2px -2px 0 rgba(0, 0, 0, 0.35);
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translate(2px, 2px); }

/* ---------------- menu */
.screen { position: fixed; inset: 0; }
#menu { overflow-y: auto; display: flex; justify-content: center; align-items: flex-start; padding: 36px 16px; }
.menu-bg { position: fixed; inset: 0; background-size: cover; background-position: center bottom; image-rendering: pixelated; filter: brightness(0.75); }
.panel { position: relative; width: min(980px, 100%); padding: 28px 32px 22px; }
.logo { margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 0 18px; justify-content: center; font-family: var(--px); font-size: clamp(22px, 4.2vw, 44px); letter-spacing: 2px; }
.logo span {
  background: linear-gradient(180deg, #fff 0%, #ffe9a0 30%, #ffb000 55%, #c24d00 56%, #ff8c1a 80%, #ffd23f 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(3px 3px 0 var(--ink)) drop-shadow(-1px -1px 0 var(--ink));
}
.logo span:nth-child(2) { background-image: linear-gradient(180deg, #fff 0%, #ffd0d0 30%, #ff5a4f 55%, #8a1010 56%, #e8423f 80%, #ff8c7a 100%); }
.tag { text-align: center; color: var(--dim); margin: 0 0 18px; font-size: 22px; }
.row { display: flex; gap: 10px; justify-content: center; }
#urlForm input {
  flex: 1; max-width: 560px; font-family: var(--vt); font-size: 28px; padding: 6px 14px;
  background: #0d0b14; color: #fff; border: 3px solid var(--ink); box-shadow: inset 3px 3px 0 rgba(0, 0, 0, 0.6); outline: none;
}
#urlForm input:focus { border-color: var(--gold); }
.quick { margin-top: 12px; flex-wrap: wrap; }
.chip { font-size: 20px; padding: 2px 12px; cursor: pointer; background: #1b1829; border: 2px solid #4a4466; color: var(--dim); }
.chip:hover { color: #fff; border-color: var(--gold); }
.sec { font-family: var(--px); font-size: 13px; margin: 26px 0 12px; color: var(--gold); text-shadow: 2px 2px 0 var(--ink); }
.sec small { font-family: var(--vt); font-size: 18px; color: var(--dim); text-shadow: none; margin-left: 8px; }

.chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 10px; }
.char {
  cursor: pointer; padding: 8px; text-align: center; background: #1b1829; border: 3px solid var(--ink);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.08); transition: transform 0.08s;
}
.char:hover { transform: translateY(-2px); }
.char.on { border-color: var(--gold); background: #2e2940; box-shadow: 0 0 0 2px var(--ink), 0 0 18px rgba(255, 210, 63, 0.35); }
.char canvas { width: 100%; aspect-ratio: 48 / 36; image-rendering: pixelated; background: linear-gradient(#2b3b5c, #3b5374 70%, #3f6b3a 70%, #2d4f29); border: 2px solid var(--ink); }
.char .n { font-family: var(--px); font-size: 10px; margin-top: 6px; }
.char .cn { color: var(--gold); font-size: 20px; }
.char .d { color: var(--dim); font-size: 16px; line-height: 1.05; min-height: 34px; }
.char .stat { display: flex; align-items: center; gap: 4px; font-size: 14px; color: var(--dim); }
.char .stat i { flex: 1; height: 6px; background: #0d0b14; border: 1px solid var(--ink); position: relative; }
.char .stat i b { position: absolute; inset: 0 auto 0 0; background: var(--gold); }
.char .sp { margin-top: 4px; font-size: 16px; color: #9be7ff; }

.arsenal { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 6px; }
.arm { display: flex; align-items: center; gap: 6px; padding: 4px 6px; background: #1b1829; border: 2px solid #2f2a44; font-size: 17px; }
.arm canvas { width: 52px; height: 28px; image-rendering: pixelated; }
.arm b { font-family: var(--px); font-size: 8px; display: block; }
.arm span { color: var(--dim); }
.controls { margin-top: 18px; color: var(--dim); }
.controls summary { cursor: pointer; font-family: var(--px); font-size: 11px; color: var(--txt); }
.controls table { margin-top: 8px; border-collapse: collapse; }
.controls td { padding: 2px 14px 2px 0; }
.controls td:first-child { color: var(--gold); white-space: nowrap; }
.foot { text-align: center; color: #6c688a; margin: 16px 0 0; }

/* ---------------- game */
#game { background: #fff; cursor: none; }
#stage { position: absolute; inset: 0; overflow: hidden; }
#site { position: absolute; left: 0; top: 0; border: 0; pointer-events: none; background: #fff; }
#fx { position: absolute; left: 0; top: 0; image-rendering: pixelated; }
#hud { position: absolute; inset: 0; pointer-events: none; font-family: var(--vt); }
#hud .box { position: absolute; padding: 6px 10px; }
.hud-tl { left: 10px; top: 10px; display: flex; gap: 8px; align-items: center; }
#portrait { width: 60px; height: 60px; image-rendering: pixelated; background: #1b1829; border: 2px solid var(--ink); }
.hud-bars { width: 190px; }
.pname { font-family: var(--px); font-size: 9px; margin-bottom: 4px; }
.bar { position: relative; height: 14px; background: #0d0b14; border: 2px solid var(--ink); margin-top: 3px; overflow: hidden; }
.bar > div { position: absolute; inset: 0 auto 0 0; width: 100%; }
.bar span { position: absolute; inset: 0; font-size: 15px; line-height: 10px; text-align: center; text-shadow: 1px 1px 0 var(--ink), -1px -1px 0 var(--ink); }
/* segmented look */
.bar > div::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 8px, rgba(0, 0, 0, 0.45) 8px 10px); }
.hp > div { background: linear-gradient(#8dff7a, #2ecc40 50%, #1b8a28); }
.hp > div.mid { background: linear-gradient(#ffe68a, #ffb000 50%, #b86e00); }
.hp > div.low { background: linear-gradient(#ff9a8a, #e8423f 50%, #8a1010); }
.fuel { height: 8px; }
.fuel > div { background: linear-gradient(#b8f4ff, #27c3d9); }
.sp > div { background: linear-gradient(#e3b8ff, #8a3cff 50%, #4b1a9a); }
.sp.ready > div { background: linear-gradient(#fff6c2, #ffd23f 50%, #c28a00); animation: pulse 0.6s infinite alternate; }
@keyframes pulse { to { filter: brightness(1.35); } }
.hud-top { left: 50%; top: 10px; transform: translateX(-50%); width: min(420px, 50vw); text-align: center; }
.dlabel { font-family: var(--px); font-size: 9px; color: var(--gold); margin-bottom: 3px; text-shadow: 1px 1px 0 var(--ink); }
.dest { height: 16px; }
.dest > div { background: linear-gradient(#ff9a5a, #ff5a1f 50%, #a82320); }
.dest span { line-height: 12px; }
.hud-tr { right: 10px; top: 10px; text-align: right; min-width: 150px; font-size: 22px; }
.combo { font-family: var(--px); font-size: 12px; color: var(--gold); text-shadow: 2px 2px 0 var(--ink); min-height: 14px; }
.combo.big { color: #ff5a1f; font-size: 16px; }
.center { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); font-family: var(--px); font-size: 22px; text-align: center; line-height: 1.5;
  color: #fff; text-shadow: 3px 3px 0 var(--ink), -2px -2px 0 var(--ink); white-space: nowrap; }
.wname { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); font-family: var(--px); font-size: 12px; color: #fff; text-shadow: 2px 2px 0 var(--ink); transition: opacity 0.3s; white-space: nowrap; }
.wname small { font-family: var(--vt); font-size: 20px; color: var(--gold); }
.hud-bottom { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: center; align-items: flex-end; gap: 12px; }
.weapons { display: flex; gap: 3px; pointer-events: auto; }
.wslot { position: relative; width: 48px; height: 40px; background: rgba(27, 24, 41, 0.9); border: 2px solid var(--ink); box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.12); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.wslot canvas { width: 44px; height: 24px; image-rendering: pixelated; }
.wslot i { position: absolute; left: 2px; top: -2px; font-style: normal; font-size: 14px; color: var(--dim); }
.wslot.on { border-color: var(--gold); background: rgba(70, 60, 30, 0.95); transform: translateY(-4px); }
.wslot.on i { color: var(--gold); }
.wslot .cd { position: absolute; left: 0; bottom: 0; height: 3px; background: #ff5a1f; }
#hud .grenades { position: static; display: flex; gap: 4px; padding: 4px 6px; }
.gslot { width: 26px; height: 26px; border: 2px solid var(--ink); display: flex; align-items: center; justify-content: center; opacity: 0.5; }
.gslot b { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); }
.gslot.on { opacity: 1; border-color: var(--gold); }
.gname { font-size: 16px; color: var(--dim); align-self: center; margin-left: 2px; }
.hints { left: 10px; bottom: 64px; font-size: 18px; line-height: 1.15; opacity: 0; transition: opacity 0.5s; }
.hints.show { opacity: 1; }
.hints b { color: var(--gold); font-weight: normal; }

.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10, 8, 18, 0.55); cursor: default; }
.overlay .box { padding: 22px 30px; text-align: center; display: flex; flex-direction: column; gap: 10px; min-width: 300px; }
.overlay h2 { font-family: var(--px); font-size: 16px; margin: 0 0 8px; color: var(--gold); text-shadow: 2px 2px 0 var(--ink); }
#statsTable { font-size: 22px; border-collapse: collapse; }
#statsTable td { padding: 2px 12px; text-align: left; }
#statsTable td:last-child { color: var(--gold); text-align: right; }
.spinner { width: 28px; height: 28px; margin: 6px auto 0; background: var(--gold); border: 3px solid var(--ink); animation: spin 0.7s steps(4) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
