:root {
  --amber: #ffb347;
  --amber-hi: #ffd27a;
  --teal: #4fd1c5;
  --ink: #f3e9dc;
  --muted: #b3a597;
  --glass: rgba(14, 10, 12, 0.8);
  --line: rgba(255, 179, 71, 0.28);
  --title: 'Black Ops One', Impact, sans-serif;
  --body: 'Rajdhani', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #050304;
  overflow: hidden;
  font-family: var(--body);
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}
#viewport { position: fixed; inset: 0; }
#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1600px;
  height: 900px;
  transform-origin: center;
}
canvas { display: block; width: 1600px; height: 900px; touch-action: none; }
#ui, #overlay { position: absolute; inset: 0; pointer-events: none; }
#ui > *, #overlay > * { pointer-events: auto; }
#ui > .title-screen, #ui > .intro { pointer-events: none; }
#ui > .title-screen .menu, #ui > .title-screen .menu * { pointer-events: auto; }
button { font-family: var(--body); cursor: pointer; }
button:disabled { cursor: not-allowed; }

.gear { color: var(--amber-hi); }

/* ---------- buttons ---------- */
.btn {
  min-width: 300px;
  padding: 13px 30px;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(40, 28, 24, 0.85), rgba(16, 11, 12, 0.9));
  border: 1px solid var(--line);
  border-radius: 4px;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s, color 0.15s;
}
.btn:hover { border-color: var(--amber); box-shadow: 0 0 22px rgba(255, 140, 50, 0.3); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  color: #1a0d06;
  background: linear-gradient(180deg, #ffd27a, #ff9a3a);
  border-color: #ffd27a;
  box-shadow: 0 0 28px rgba(255, 140, 50, 0.35);
}
.btn.primary:hover { color: #000; box-shadow: 0 0 36px rgba(255, 160, 60, 0.6); }
.btn.ghost { background: transparent; border-color: rgba(255, 255, 255, 0.12); color: var(--muted); }

/* ---------- title ---------- */
.title-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 46px;
  background: radial-gradient(ellipse at 50% 42%, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0) 60%);
}
.logo { text-align: center; }
.logo .kicker {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--amber-hi);
  text-shadow: 0 0 18px rgba(255, 140, 50, 0.6);
}
.logo h1 {
  margin: 6px 0 4px;
  font-family: var(--title);
  font-weight: 400;
  font-size: 168px;
  line-height: 1;
  letter-spacing: 0.06em;
  color: #fff1dc;
  text-shadow: 0 0 40px rgba(255, 120, 40, 0.75), 0 4px 0 #6a2a10, 0 10px 30px rgba(0, 0, 0, 0.8);
  animation: flicker 6s infinite;
}
.logo .sub { font-size: 22px; font-weight: 600; color: var(--ink); opacity: 0.85; max-width: 760px; margin: 0 auto; text-shadow: 0 2px 8px #000; }
.menu { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.hint { position: absolute; bottom: 26px; font-size: 16px; font-weight: 600; letter-spacing: 0.08em; color: var(--muted); text-shadow: 0 2px 6px #000; }
@keyframes flicker {
  0%, 91%, 94%, 100% { opacity: 1; }
  92% { opacity: 0.7; }
  93% { opacity: 0.95; }
  95% { opacity: 0.8; }
}

/* ---------- manual ---------- */
.manual {
  position: absolute;
  inset: 40px 60px;
  padding: 32px 40px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
}
.manual h2 { font-family: var(--title); font-weight: 400; font-size: 44px; margin: 0 0 14px; color: var(--amber-hi); letter-spacing: 0.06em; }
.manual .cols { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 36px; flex: 1; overflow: auto; }
.manual h4 { margin: 10px 0 8px; font-size: 16px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--teal); }
.manual p { margin: 0 0 12px; font-size: 18px; line-height: 1.35; color: var(--ink); opacity: 0.9; }
.manual ul { list-style: none; margin: 0; padding: 0; }
.manual .keys li { font-size: 17px; margin-bottom: 8px; }
.manual .list li { margin-bottom: 12px; font-size: 17px; }
.manual .list span { color: var(--muted); font-size: 16px; }
.manual .btn { align-self: center; margin-top: 18px; }
kbd {
  display: inline-block;
  min-width: 26px;
  padding: 1px 7px;
  margin: 0 2px;
  font-family: var(--body);
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-bottom-width: 3px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
}

/* ---------- intro card ---------- */
.intro {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0.15) 70%);
  animation: introFade 2.9s ease forwards;
}
.intro-k { font-size: 20px; font-weight: 700; letter-spacing: 0.6em; text-transform: uppercase; color: var(--amber-hi); }
.intro h2 {
  margin: 10px 0;
  font-family: var(--title);
  font-weight: 400;
  font-size: 110px;
  letter-spacing: 0.05em;
  color: #fff1dc;
  text-shadow: 0 0 36px rgba(255, 120, 40, 0.7), 0 8px 24px #000;
  animation: introZoom 2.9s ease forwards;
}
.intro p { margin: 0; font-size: 24px; font-weight: 600; color: var(--ink); opacity: 0.9; text-shadow: 0 2px 8px #000; }
.intro-foe { margin-top: 20px; font-size: 19px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); }
.intro-foe b { color: #ff7a5a; }
@keyframes introFade { 0% { opacity: 0; } 12% { opacity: 1; } 82% { opacity: 1; } 100% { opacity: 0; } }
@keyframes introZoom { from { transform: scale(1.12); letter-spacing: 0.2em; } to { transform: scale(1); letter-spacing: 0.05em; } }

/* ---------- fortify panel ---------- */
.panel {
  position: absolute;
  top: 96px;
  width: 400px;
  max-height: 790px;
  padding: 16px 18px 18px;
  background: var(--glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.panel.right { right: 20px; }
.panel.left { left: 20px; }
.ph { display: flex; justify-content: space-between; align-items: flex-end; }
.ph .kick { font-size: 13px; font-weight: 700; letter-spacing: 0.25em; text-transform: uppercase; }
.ph h3 { margin: 2px 0 0; font-family: var(--title); font-weight: 400; font-size: 34px; letter-spacing: 0.06em; }
.scrap { font-size: 28px; font-weight: 700; color: var(--amber-hi); text-shadow: 0 0 14px rgba(255, 180, 80, 0.4); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1;
  padding: 8px 0 7px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.tabs button.on { color: var(--amber-hi); border-bottom-color: var(--amber); }
.tabs button:hover { color: var(--ink); }
.tb { display: flex; flex-direction: column; gap: 7px; overflow-y: auto; max-height: 470px; padding-right: 2px; }
.card {
  text-align: left;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  color: var(--ink);
  transition: border-color 0.12s, background 0.12s;
}
.card:hover:not(:disabled) { border-color: var(--amber); background: rgba(255, 179, 71, 0.07); }
.card.on { border-color: var(--teal); background: rgba(79, 209, 197, 0.12); box-shadow: inset 0 0 0 1px var(--teal); }
.card:disabled { opacity: 0.4; }
.card-h { display: flex; justify-content: space-between; font-size: 18px; font-weight: 700; }
.card .ds, .row .ds, .sel .ds { font-size: 15px; color: var(--muted); line-height: 1.25; margin-top: 2px; }
.card .st { font-size: 14px; color: var(--teal); margin-top: 3px; font-weight: 600; }
.row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 5px;
}
.row .rl { flex: 1; }
.row .nm { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.row .nm i { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.row .own { color: var(--teal); font-size: 16px; }
.pips { display: inline-flex; gap: 3px; margin-left: 4px; }
.pips b { width: 14px; height: 6px; background: rgba(255, 255, 255, 0.12); border-radius: 1px; }
.pips b.on { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.buy {
  min-width: 84px;
  padding: 7px 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255, 179, 71, 0.12);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.buy:hover:not(:disabled) { border-color: var(--amber); background: rgba(255, 179, 71, 0.22); }
.buy:disabled { opacity: 0.35; }
.buy.sell { background: rgba(255, 90, 60, 0.1); border-color: rgba(255, 90, 60, 0.35); }
.sel { padding: 10px 12px; border: 1px solid var(--teal); border-radius: 5px; background: rgba(79, 209, 197, 0.07); }
.sel-h { display: flex; justify-content: space-between; font-size: 18px; }
.sel-h span { color: var(--teal); font-weight: 700; }
.sel .next { color: var(--teal); }
.sel-b { display: flex; gap: 8px; margin-top: 8px; }
.sel-b .buy { flex: 1; }
.tip { font-size: 14px; color: var(--muted); line-height: 1.3; }
.deploy { min-width: 0; width: 100%; }

/* ---------- battle bar ---------- */
.bar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 12px 10px 18px;
  background: var(--glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  transition: opacity 0.2s;
  white-space: nowrap;
}
.bar.off { opacity: 0.35; pointer-events: none; }
.who { font-family: var(--title); font-size: 18px; letter-spacing: 0.05em; }
.weps { display: flex; gap: 5px; }
.wbtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
  padding: 4px 6px 5px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 2px solid var(--wc);
  border-radius: 4px;
  color: var(--ink);
  position: relative;
}
.wbtn.on { background: rgba(255, 179, 71, 0.16); border-color: var(--amber); border-bottom-color: var(--wc); box-shadow: 0 0 14px rgba(255, 160, 60, 0.35); }
.wbtn:hover { border-color: var(--amber); }
.wk { position: absolute; top: 2px; left: 4px; font-size: 10px; color: var(--muted); }
.wn { font-size: 13px; font-weight: 700; }
.wc { font-size: 15px; font-weight: 700; color: var(--wc); }
.ctl { display: flex; align-items: center; gap: 8px; }
.ctl label { font-size: 13px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.ctl output { min-width: 40px; font-size: 22px; font-weight: 700; color: var(--amber-hi); text-align: right; }
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 140px;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  outline: none;
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--amber-hi);
  box-shadow: 0 0 10px rgba(255, 180, 80, 0.7);
  cursor: pointer;
}
input[type='range']::-moz-range-thumb { width: 16px; height: 16px; border: none; border-radius: 50%; background: var(--amber-hi); }
.fire {
  padding: 14px 30px;
  font-family: var(--title);
  font-size: 24px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #1a0700;
  background: linear-gradient(180deg, #ff9a4a, #e0401a);
  border: 1px solid #ffb070;
  border-radius: 5px;
  box-shadow: 0 0 24px rgba(255, 90, 30, 0.5);
}
.fire:hover { box-shadow: 0 0 36px rgba(255, 110, 40, 0.8); color: #000; }
.corner {
  position: absolute;
  right: 20px;
  bottom: 20px;
  width: 44px;
  height: 44px;
  font-size: 16px;
  color: var(--muted);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.panel.right ~ .corner { right: auto; left: 20px; }
.corner:hover { color: var(--ink); border-color: var(--amber); }

/* ---------- modals ---------- */
.modal-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}
.modal {
  min-width: 480px;
  max-width: 640px;
  padding: 34px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
  text-align: center;
}
.modal h2 { margin: 0 0 6px; font-family: var(--title); font-weight: 400; font-size: 48px; letter-spacing: 0.05em; color: #fff1dc; }
.modal p { margin: 0 0 6px; font-size: 19px; color: var(--muted); line-height: 1.35; }
.result.win h2 { color: var(--amber-hi); text-shadow: 0 0 30px rgba(255, 160, 60, 0.6); }
.result.lose h2 { color: #ff6a4a; text-shadow: 0 0 30px rgba(255, 60, 40, 0.5); }
.modal table { width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: 19px; }
.modal td { padding: 6px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); text-align: left; }
.modal td:last-child { text-align: right; font-weight: 700; }
.modal tr.tot td { border-bottom: none; padding-top: 10px; font-size: 22px; color: var(--amber-hi); font-weight: 700; }
.mb { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
