* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --khaki: #d8cba0;
  --khaki-dim: #a89b74;
  --blood: #c0392b;
  --blood-dark: #7a1010;
  --panel: rgba(16, 17, 12, 0.92);
  --edge: #4a4a38;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0c0d09;
  font-family: "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  cursor: none;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */

#hud {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 5;
}

#topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(rgba(8, 9, 5, 0.75), transparent);
}

#stats { width: 240px; }

.barwrap { display: flex; align-items: center; margin-bottom: 6px; }

.barlabel {
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 14px; letter-spacing: 2px;
  color: var(--khaki);
  width: 30px;
  text-shadow: 1px 1px 0 #000;
}

.bar {
  flex: 1; height: 14px;
  display: flex;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--edge);
  box-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.bar span {
  display: block; height: 100%; width: 100%;
  transition: width 0.15s ease-out;
}

.hpbar #hpfill, .hpbar #hpfill2 { background: linear-gradient(#7fb84a, #4c7a24); }
.hpbar #hpfill.low, .hpbar #hpfill2.low { background: linear-gradient(#d9534f, #8f1d1d); }
.hpbar #hpover {                       /* overheal — lighter green */
  width: 0;
  background: linear-gradient(#c4ef92, #8ecf5a);
}
.hpbar span.god {
  background: linear-gradient(#f2d868, #b8921e);
  box-shadow: 0 0 8px rgba(242, 216, 104, 0.7);
}
.arbar span { background: linear-gradient(#8fb6d0, #4a7590); }

/* P2 downed: pulsing red distress cue on the co-op HP bar */
.downedpulse { animation: downedpulse 0.7s ease-in-out infinite alternate; }
@keyframes downedpulse {
  from { background: #b3352a; }
  to { background: #5e120c; }
}

#scorebox { text-align: center; }

#score {
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 34px; letter-spacing: 3px;
  color: var(--khaki);
  text-shadow: 2px 2px 0 #000, 0 0 12px rgba(216, 203, 160, 0.25);
}

#hiscore {
  font-size: 12px; letter-spacing: 2px;
  color: var(--khaki-dim);
  text-shadow: 1px 1px 0 #000;
}

#progbox { width: 240px; text-align: right; }

#proglabel {
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 13px; letter-spacing: 2px;
  color: var(--khaki);
  text-shadow: 1px 1px 0 #000;
  margin-bottom: 4px;
}

#progbar {
  height: 10px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--edge);
}

#progbar span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #7a6a2e, #cbb35a);
}

/* weapon slots */

#wpns {
  position: absolute; bottom: 14px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 8px;
  /* crisp, aliased HUD text (matches the entity editor) — no font smoothing */
  -webkit-font-smoothing: none;
  font-smooth: never;
  text-rendering: optimizeSpeed;
}

.wpn {
  position: relative;
  min-width: 96px;
  padding: 5px 10px 4px;
  background: var(--panel);
  border: 1px solid var(--edge);
  text-align: center;
  opacity: 0.35;
  transition: opacity 0.15s, border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}

.wpn.unlocked { opacity: 0.85; }

.wpn .wicon {
  display: block;
  height: 28px;
  max-width: 88px;
  margin: 1px auto 0;
  object-fit: contain;
  filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.75)) saturate(0.35);
  transition: filter 0.15s, transform 0.12s;
}

.wpn.unlocked .wicon {
  filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.75)) saturate(0.9);
}

.wpn.active {
  opacity: 1;
  border-color: #ffd23e;
  background: rgba(58, 54, 34, 0.92);
  transform: translateY(-6px) scale(1.08);
  box-shadow: 0 0 16px rgba(255, 210, 62, 0.35), 0 6px 14px rgba(0, 0, 0, 0.65),
              inset 0 0 12px rgba(255, 210, 62, 0.10);
}

.wpn.active .wicon {
  filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.8)) saturate(1.15) brightness(1.1);
  transform: scale(1.06);
}

.wpn.active .wkey { color: #ffd23e; }

.wpn.pulse { animation: wpnpulse 0.45s ease-out; }

@keyframes wpnpulse {
  0% { box-shadow: 0 0 0 3px rgba(203, 179, 90, 0.9); }
  100% { box-shadow: 0 0 0 3px rgba(203, 179, 90, 0); }
}

.wpn .wkey {
  position: absolute; top: 2px; left: 5px;
  font-size: 10px; color: var(--khaki-dim); letter-spacing: 1px;
}

.wpn .wname {
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 11px; letter-spacing: 1px;
  color: var(--khaki);
}

.wpn .wammo {
  font-size: 12px; font-weight: bold; color: #cbb35a;
}

.wpn .wammo.empty { color: #b3554a; }

/* coop: persistent DOWNED alert (how-to-revive) */
#downalert {
  position: absolute; top: 20%; left: 0; right: 0;
  text-align: center;
  pointer-events: none;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 26px; letter-spacing: 3px;
  color: #ffe08a;
  text-shadow: 2px 2px 0 #000, 0 0 18px rgba(210, 40, 20, 0.85);
  animation: downpulse 0.9s ease-in-out infinite alternate;
}
@keyframes downpulse { from { opacity: 0.65; } to { opacity: 1; } }

/* debug overlay (Shift+D) */
#debug {
  position: absolute; top: 8px; left: 8px; z-index: 60;
  font-family: "SF Mono", "Courier New", monospace;
  font-size: 11px; line-height: 1.5;
  color: #cfe0b8;
  background: rgba(8, 10, 6, 0.72);
  border: 1px solid rgba(150, 200, 110, 0.3);
  border-radius: 4px;
  padding: 7px 10px;
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 1px 2px #000;
}
#debug .dk {
  display: inline-block; width: 74px;
  color: #7fa85c; text-transform: uppercase; letter-spacing: 0.5px;
}
#debug.hidden { display: none; }

/* banner */

#banner {
  position: absolute; top: 26%; left: 0; right: 0;
  text-align: center;
  animation: bannerin 0.4s ease-out;
}

@keyframes bannerin {
  from { opacity: 0; transform: scale(1.4); }
  to { opacity: 1; transform: scale(1); }
}

#banner h2 {
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 54px; letter-spacing: 8px;
  color: var(--khaki);
  text-shadow: 3px 3px 0 #000, 0 0 24px rgba(0,0,0,0.8);
}

#banner p {
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 20px; letter-spacing: 6px;
  color: var(--blood);
  text-shadow: 2px 2px 0 #000;
}

/* multi-kill combo popup */

#combo {
  position: absolute; top: 13%; left: 0; right: 0;
  text-align: center;
  pointer-events: none;
}

.comboline {
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 38px; letter-spacing: 5px;
  color: #ffd23e;
  text-shadow: 2px 2px 0 var(--blood-dark), 4px 4px 0 #000, 0 0 22px rgba(255, 160, 40, 0.5);
  animation: combopop 2.4s ease-out forwards;
}

.comboline.ef {
  font-size: 26px; letter-spacing: 4px;
  color: #ff9a3e;
}

.comboline.super {
  font-size: 50px; letter-spacing: 7px;
  color: #ff5a24;
  text-shadow: 2px 2px 0 #000, 4px 4px 0 #000, 0 0 32px rgba(255, 90, 20, 0.8);
}

.comboline.road {
  font-size: 30px; letter-spacing: 4px;
  color: #ff4d3a;
  text-shadow: 2px 2px 0 var(--blood-dark), 4px 4px 0 #000, 0 0 22px rgba(200, 30, 20, 0.6);
}

.comboline.gold {
  font-size: 30px; letter-spacing: 4px;
  color: #ffdf5a;
  text-shadow: 2px 2px 0 #6a4a00, 4px 4px 0 #000, 0 0 24px rgba(255, 210, 70, 0.75);
}

.comboline.ambush {
  font-size: 30px; letter-spacing: 4px;
  color: #9be27a;
  text-shadow: 2px 2px 0 #14300a, 4px 4px 0 #000, 0 0 22px rgba(120, 220, 90, 0.6);
}

@keyframes combopop {
  0% { opacity: 0; transform: scale(2.2); }
  7% { opacity: 1; transform: scale(1); }
  85% { opacity: 1; transform: scale(1.03); }
  100% { opacity: 0; transform: scale(1.06); }
}

/* damage vignette + pickup flash */

#vignette {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 6;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(140, 8, 8, 0.75) 100%);
  opacity: 0;
  transition: opacity 0.5s ease-out;
}

#flash {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 6;
  opacity: 0;
  transition: opacity 0.4s ease-out;
}

/* ---------- overlays ---------- */

.screen {
  position: absolute; inset: 0;
  z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(20, 22, 12, 0.55), rgba(5, 6, 3, 0.88));
}

.panel {
  text-align: center;
  padding: 40px 60px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-top: 3px solid var(--blood);
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.85);
  max-width: 640px;
}

#ovbanner {
  display: block;
  width: 440px;
  max-width: 100%;
  height: auto;
  margin: 0 auto 10px;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.7));
}

#ovtag {
  font-family: Impact, Haettenswiler, "Arial Narrow Bold", sans-serif;
  font-size: 14px; letter-spacing: 6px;
  color: var(--blood);
  text-shadow: 1px 1px 0 #000;
}

#ovtitle {
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 64px; letter-spacing: 6px; line-height: 1;
  color: var(--khaki);
  text-shadow: 3px 3px 0 var(--blood-dark), 6px 6px 0 #000;
  margin: 6px 0 10px;
}

#ovsub {
  font-size: 15px; letter-spacing: 2px;
  color: var(--khaki-dim);
  margin-bottom: 14px;
}

#ovlines {
  font-family: "Courier New", monospace;
  font-size: 15px;
  color: var(--khaki);
  line-height: 1.7;
  margin-bottom: 18px;
  white-space: pre-line;
}

/* end-of-mission tally: a real 3-column table (label / count / bonus) —
   centered as a block, columns aligned regardless of stat widths */
#ovlines .tallygrid {
  display: inline-grid;
  grid-template-columns: auto minmax(64px, auto) minmax(72px, auto);
  column-gap: 22px;
  text-align: left;
}
#ovlines .tallyrow { display: contents; }
#ovlines .tallyrow span:nth-child(2) { text-align: right; }
#ovlines .tallyrow span:nth-child(3) { text-align: right; color: #cbb35a; }
#ovlines .tallyrow.wide span { grid-column: 1 / -1; text-align: center; margin-top: 8px; }

#ovbtn {
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 22px; letter-spacing: 4px;
  color: #14150d;
  background: linear-gradient(#d8cba0, #a89b74);
  border: 1px solid #14150d;
  padding: 12px 44px;
  cursor: pointer;
  box-shadow: 0 4px 0 #55503a, 0 8px 18px rgba(0,0,0,0.6);
}

#ovbtn:hover { background: linear-gradient(#eadfb8, #baa87e); }
#ovbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 #55503a; }

/* All dialogs stack their buttons vertically: primary action on top,
   BACK/CANCEL/MAIN MENU always last (CSS order fixes the btn3/2/1 DOM
   order; #ovaudio slots between primary and BACK on the Options screen). */
#ovbtns { display: flex; flex-direction: column; align-items: center; gap: 12px; }
#ovbtns #ovbtn { order: 1; }
#ovbtns #ovaudio {
  order: 2;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  width: 340px;
  margin: 0;
}
#ovaudio label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 16px; letter-spacing: 2px;
  color: var(--khaki);
  background: linear-gradient(#3d3d30, #262620);
  border: 1px solid #55503a;
}
#ovaudio input[type="range"] { flex: 1; accent-color: #cbb35a; cursor: pointer; }
#ovbtns #ovbtn2 { order: 3; }
#ovbtns #ovbtn3 { order: 4; }
#ovbtns button { min-width: 340px; }

/* overlay text input (join code / call sign) */
#ovinput {
  display: block;
  margin: 0 auto 16px;
  width: 340px;
  padding: 12px 16px;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 26px; letter-spacing: 6px; text-align: center;
  color: var(--khaki);
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--edge);
  outline: none;
}
#ovinput:focus { border-color: #cbb35a; box-shadow: 0 0 10px rgba(203, 179, 90, 0.35); }

/* lobby list (FIND GAME screen) */
#ovlist { margin: 0 auto 16px; width: 420px; max-width: 90%; }
#ovlist .lobbyrow {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%;
  margin-bottom: 8px;
  padding: 10px 16px;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 18px; letter-spacing: 2px;
  color: var(--khaki);
  background: linear-gradient(#3d3d30, #262620);
  border: 1px solid #55503a;
  cursor: pointer;
}
#ovlist .lobbyrow:hover { background: linear-gradient(#4c4c3c, #30302a); border-color: #cbb35a; }
#ovlist .lobbyrow .age { font-size: 13px; color: var(--khaki-dim); letter-spacing: 1px; }
#ovlist .lobbyempty {
  padding: 14px 0; text-align: center;
  font-size: 14px; letter-spacing: 2px; color: var(--khaki-dim);
}

#ovbtn2, #ovbtn3, #ovbtn4 {
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 22px; letter-spacing: 4px;
  color: var(--khaki);
  background: linear-gradient(#3d3d30, #262620);
  border: 1px solid #55503a;
  padding: 12px 32px;
  cursor: pointer;
  box-shadow: 0 4px 0 #14150d, 0 8px 18px rgba(0,0,0,0.6);
}

#ovbtn2:hover, #ovbtn3:hover, #ovbtn4:hover { background: linear-gradient(#4c4c3c, #30302a); }
#ovbtn2:active, #ovbtn3:active, #ovbtn4:active { transform: translateY(3px); box-shadow: 0 1px 0 #14150d; }

#legacyrow input[type="checkbox"] { accent-color: #cbb35a; width: 18px; height: 18px; cursor: pointer; }

#ovhelp {
  margin-top: 22px;
  font-size: 13px; line-height: 1.9;
  color: var(--khaki-dim);
}

#ovhelp b { color: var(--khaki); }

/* ---- ABOUT: the 1996 legacy showcase ---- */
#ovbtns #ovbtn4 { order: 5; }

#ovabout {
  width: 520px;
  max-height: 70vh;
  overflow-y: auto;
  /* Windows: no chunky classic scrollbar — thin + themed when needed at all */
  scrollbar-width: thin;
  scrollbar-color: #55503a transparent;
  margin: 0 auto 18px;
  padding: 14px 14px 10px;
  border: 1px solid var(--edge);
  background:
    linear-gradient(rgba(8, 9, 6, 0.82), rgba(8, 9, 6, 0.82)),
    url('../assets/img/legacy/maptile.png');
  image-rendering: pixelated;
  -webkit-font-smoothing: none;
  text-rendering: optimizeSpeed;
}

#abbanner {
  display: block;
  width: 100%;                 /* 262px source at ~2x, nearest-neighbour */
  image-rendering: pixelated;
}

#abtags {
  position: relative;
  height: 22px;
  margin: 6px 0 2px;
}
#abtags span {
  position: absolute; inset: 0;
  opacity: 0;
  transition: opacity 0.8s;
  font-family: "SF Mono", "Courier New", monospace;
  font-size: 13px; line-height: 26px;
  color: #d8cba0;
}
#abtags span.on { opacity: 1; }

#abturn { padding: 2px 0 0; }
#abturn canvas {
  width: 210px; height: 210px;      /* 70px frames at 3x */
  image-rendering: pixelated;
  cursor: grab;
  touch-action: none;
}
#abturn canvas:active { cursor: grabbing; }
#abhint {
  font-size: 11px;
  color: #b3aa85;
  font-family: "SF Mono", "Courier New", monospace;
}

#abshelf {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 14px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--edge);
}
#abshelf figure { margin: 0; max-width: 100px; }
#abshelf img { image-rendering: pixelated; max-height: 96px; display: block; margin: 0 auto; }
#abshelf figcaption, #abshelf figcaption small {
  font-family: "SF Mono", "Courier New", monospace;
  display: block;
}
#abshelf figcaption { font-size: 13px; color: #e6dcb2; margin-top: 6px; letter-spacing: 0.5px; }
#abshelf figcaption small { font-size: 11px; color: #b3aa85; line-height: 1.5; margin-top: 2px; }

#abflag {
  width: 85px; height: 85px;
  margin: 0 auto;
  background: url('../assets/img/legacy/flag_strip.png') 0 0 no-repeat;
  image-rendering: pixelated;
}

#abcredits {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--edge);
  font-family: "SF Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #e6dcb2;
}

#abfoot {
  margin-top: 4px;
  font-family: "SF Mono", "Courier New", monospace;
  font-size: 11px;
  color: #b3aa85;
}
