:root {
  --ink: #0b0a08;
  --amber: #ffb03a;
  --amber-dim: #c97a1c;
  --paper: #f2e6cf;
  --blood: #e0412c;
  --cyan: #4fd3e8;
  --green: #7be04a;
  --head: "Bungee", "Arial Black", Impact, sans-serif;
  --ui: "Barlow Condensed", "Arial Narrow", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #150e09;
  color: var(--paper);
  font-family: var(--ui);
  -webkit-user-select: none;
  user-select: none;
  cursor: default;
}

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }

#vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 52%, rgba(24,10,2,.55) 88%, rgba(12,5,2,.85) 100%);
  mix-blend-mode: multiply;
}
#flash {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(208,40,20,0) 35%, rgba(208,40,20,.72) 100%);
  opacity: 0; transition: opacity .18s ease-out;
}

#crosshair { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; }
#crosshair .ch { position: absolute; background: #ffeccd; box-shadow: 0 0 0 1.5px rgba(0,0,0,.85); border-radius: 1px; }
#crosshair .t, #crosshair .b { width: 2.5px; height: 9px; left: 21.75px; }
#crosshair .l, #crosshair .r { height: 2.5px; width: 9px; top: 21.75px; }
#crosshair .t { top: 3px; } #crosshair .b { top: 34px; }
#crosshair .l { left: 3px; } #crosshair .r { left: 34px; }
#crosshair .dot { width: 3px; height: 3px; left: 21.5px; top: 21.5px; border-radius: 50%; opacity: .9; }
#crosshair.aim .dot { background: var(--blood); }

#hitmark { position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; opacity: 0; }
#hitmark i { position: absolute; width: 12px; height: 2.5px; background: #fff; box-shadow: 0 0 0 1.5px #000; }
#hitmark i:nth-child(1) { left: 4px; top: 6px; transform: rotate(45deg); }
#hitmark i:nth-child(2) { right: 4px; top: 6px; transform: rotate(-45deg); }
#hitmark i:nth-child(3) { left: 4px; bottom: 6px; transform: rotate(-45deg); }
#hitmark i:nth-child(4) { right: 4px; bottom: 6px; transform: rotate(45deg); }
#hitmark.on { animation: hitpop .22s ease-out; }

#reloadBar {
  position: absolute; left: 50%; top: calc(50% + 30px); transform: translateX(-50%);
  width: 78px; height: 6px; background: rgba(8,6,4,.82);
  border: 2px solid var(--ink); box-shadow: 2px 2px 0 rgba(0,0,0,.5);
}
#reloadBar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #ffb03a, #ffe6b0); }
#hitmark.crit i { background: #ffd23f; }
@keyframes hitpop { 0% { opacity: 1; transform: scale(.7); } 100% { opacity: 0; transform: scale(1.25); } }

.panel {
  background: rgba(16,11,8,.72);
  border: 2.5px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(0,0,0,.65), inset 0 0 0 1.5px rgba(255,176,58,.22);
  padding: 5px 12px;
}

#topbar { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: stretch; }
#roundPanel { text-align: center; clip-path: polygon(9px 0, 100% 0, calc(100% - 9px) 100%, 0 100%); }
#roundLabel { font-family: var(--head); font-size: 15px; letter-spacing: .5px; color: var(--amber); line-height: 1.1; }
#objective { font-size: 13px; letter-spacing: 2.4px; color: #e7d8bb; }
#enemyPanel { display: flex; align-items: center; gap: 6px; font-size: 12px; letter-spacing: 2px; color: #d6c4a4; }
#enemyPanel b { font-family: var(--head); font-size: 20px; color: var(--paper); }
#cashPanel { display: flex; align-items: center; gap: 2px; font-family: var(--head); font-size: 13px; color: #7be04a; }
#cashPanel b { font-size: 18px; color: #9bf06a; }

#bossbar { position: absolute; top: 86px; left: 50%; transform: translateX(-50%); width: min(620px, 62vw); text-align: center; }
#bossName { font-family: var(--head); font-size: 15px; letter-spacing: 2px; color: #ff6a4d; text-shadow: 2px 2px 0 #000; }
#bossTrack { height: 14px; background: rgba(10,7,5,.85); border: 2.5px solid var(--ink); box-shadow: 3px 3px 0 rgba(0,0,0,.6); }
#bossFill { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff5b34, #ffb03a); transition: width .12s linear; }

#leftPanel { position: absolute; left: 20px; bottom: 18px; display: flex; gap: 10px; align-items: flex-end; }
.lvl {
  width: 46px; height: 46px; display: grid; place-items: center;
  font-family: var(--head); font-size: 20px; color: var(--ink);
  background: var(--amber); border: 2.5px solid var(--ink);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  transform: rotate(-3deg);
}
.bars { width: min(290px, 34vw); display: flex; flex-direction: column; gap: 4px; }
.bar { position: relative; height: 20px; background: rgba(10,7,5,.8); border: 2.5px solid var(--ink); box-shadow: 3px 3px 0 rgba(0,0,0,.6); overflow: hidden; }
.bar i { position: absolute; inset: 0; display: block; transform-origin: left center; transition: transform .12s linear; }
.bar.hp i { background: linear-gradient(180deg, #ff6a4d, #b8261a); }
.bar.sh { height: 9px; }
.bar.sh i { background: linear-gradient(180deg, #8fe9f7, #2b8fb5); }
.bar.xp { height: 7px; border-width: 2px; }
.bar.xp i { background: linear-gradient(180deg, #d8d36a, #8f8a24); }
#hpText { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; font-weight: 800; letter-spacing: 1.6px; color: #fff; text-shadow: 1.5px 1.5px 0 #000; }

#rightPanel { position: absolute; right: 20px; bottom: 18px; text-align: right; }

#slots { display: flex; flex-direction: column; gap: 3px; align-items: stretch; margin-bottom: 5px; }
.slot {
  display: flex; gap: 7px; align-items: center; justify-content: flex-end;
  font-size: 11px; letter-spacing: 1.6px; color: #8d7f6b;
  background: rgba(12,8,6,.62); border: 2px solid #1e1712; border-right-width: 4px;
  padding: 2px 8px; transition: color .12s, background .12s;
}
.slot .key { font-family: var(--head); font-size: 10px; color: #5d5145; }
.slot .nm { max-width: 172px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.slot .mg { font-family: var(--head); font-size: 10px; font-style: normal; color: #9c8b73; }
.slot.active { background: rgba(34,22,13,.92); color: var(--paper); box-shadow: 2px 2px 0 rgba(0,0,0,.55); }
.slot.active .key { color: var(--amber); }
.slot.active .nm { color: var(--amber); }

#compare {
  position: absolute; right: 20px; bottom: 210px; width: 286px;
  padding: 7px 11px 9px; background: rgba(12,8,6,.92);
  border: 2.5px solid var(--ink); border-left: 6px solid #fff;
  box-shadow: 4px 4px 0 rgba(0,0,0,.6);
  animation: cmpIn .16s ease-out;
}
@keyframes cmpIn { from { opacity: 0; transform: translateY(10px); } }
#cmpTop { display: flex; justify-content: space-between; gap: 8px; font-size: 10px; letter-spacing: 1.6px; font-weight: 700; color: #8d7f6b; }
#cmpName { font-family: var(--head); font-size: 14px; line-height: 1.2; margin: 2px 0 5px; }
.cmpRow { display: flex; align-items: baseline; gap: 6px; font-size: 12px; letter-spacing: 1.2px; color: #ab9c84; }
.cmpRow .lbl { width: 50px; }
.cmpRow b { color: #f2e6cf; font-weight: 800; }
.cmpRow em { font-style: normal; font-size: 11px; margin-left: auto; }
.cmpRow em.up { color: #7be04a; }
.cmpRow em.down { color: #ff6a4d; }
.cmpRow em.same { color: #7d6f5c; }
#cmpHint { margin-top: 6px; font-size: 10px; letter-spacing: 2px; color: var(--amber); }

@media (max-width: 720px) {
  #compare { width: 46vw; bottom: 196px; right: 8px; }
  .slot .nm { max-width: 34vw; }
}
#weaponCard {
  background: rgba(16,11,8,.76); border: 2.5px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(0,0,0,.65);
  padding: 6px 12px 8px; min-width: 282px;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
  border-right-width: 6px;
}
#wTop { display: flex; justify-content: space-between; gap: 12px; font-size: 10px; letter-spacing: 1.8px; font-weight: 700; margin-bottom: 1px; }
#wRarity { color: #d8d3c6; }
#wMaker { color: #9b8f7c; }
#wName { font-family: var(--head); font-size: 15px; line-height: 1.25; margin: 1px 0 2px; color: var(--paper); }
#wStats { font-size: 13px; letter-spacing: 1.4px; color: #cdbd9f; }
#wStats b { color: #fff; }
#wStats em { color: #6b5c48; font-style: normal; }
#ammoRow { font-family: var(--head); font-size: 34px; line-height: 1; margin-top: 4px; text-shadow: 3px 3px 0 rgba(0,0,0,.75); }
#ammoRow b { color: var(--paper); }
#ammoRow span { color: #7d6f5c; font-size: 22px; margin: 0 3px; }
#ammoRow i { color: #a8763f; font-style: normal; font-size: 20px; }
#ammoRow.low b { color: #ff5b34; }
#reloadHint { font-family: var(--head); font-size: 12px; letter-spacing: 3px; color: var(--amber); animation: blink .7s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }

#prompt {
  position: absolute; left: 50%; top: 60%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: rgba(14,10,7,.85); border: 2.5px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(0,0,0,.65);
  padding: 6px 14px; font-size: 15px; letter-spacing: 2.2px; font-weight: 700;
}
kbd {
  font-family: var(--ui); font-weight: 800; font-size: 12px; letter-spacing: 1px;
  background: var(--paper); color: var(--ink); border: 2px solid var(--ink);
  border-radius: 3px; padding: 1px 5px; box-shadow: 2px 2px 0 rgba(0,0,0,.6);
}

#banner { position: absolute; left: 0; right: 0; top: 24%; text-align: center; }
#bannerBig {
  display: inline-block; font-family: var(--head); font-size: clamp(26px, 5vw, 58px);
  color: var(--paper); letter-spacing: 1px;
  padding: 6px 26px; background: rgba(12,8,6,.72);
  border-top: 4px solid var(--ink); border-bottom: 4px solid var(--ink);
  text-shadow: 4px 4px 0 #000, 0 0 24px rgba(255,150,40,.55);
  transform: rotate(-1.2deg);
}
#bannerSub { margin-top: 8px; font-size: 15px; letter-spacing: 4px; color: var(--amber); text-shadow: 2px 2px 0 #000; }
#banner.show { animation: bannerIn .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes bannerIn { 0% { opacity: 0; transform: scale(.8) rotate(2deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }

#toasts { position: absolute; right: 22px; top: 118px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.toast {
  font-family: var(--head); font-size: 12px; letter-spacing: 1.6px;
  padding: 4px 10px; background: rgba(12,8,6,.85);
  border: 2px solid var(--ink); box-shadow: 3px 3px 0 rgba(0,0,0,.6);
  animation: toastIn .25s ease-out, toastOut .5s ease-in 2.4s forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

#dmgLayer { position: absolute; inset: 0; overflow: hidden; }
.dmgNum {
  position: absolute; font-family: var(--head); font-size: 18px; color: #fff;
  text-shadow: 2.5px 2.5px 0 #000; will-change: transform, opacity;
  animation: dmgUp .8s ease-out forwards;
}
.dmgNum.crit { color: #ffd23f; font-size: 26px; }
.dmgNum.burn { color: #ff8a3d; }
.dmgNum.shock { color: #8fe9f7; }
.dmgNum.corr { color: #a6ff6b; }
.dmgNum.kill { color: #ff6a4d; font-size: 22px; }
@keyframes dmgUp {
  0% { opacity: 0; transform: translate(-50%, 0) scale(.6); }
  18% { opacity: 1; transform: translate(-50%, -14px) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -52px) scale(.95); }
}

/* ---------- Screens ---------- */
.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(30,16,8,.55), rgba(9,5,3,.94) 78%);
  z-index: 10;
}
#title { background: radial-gradient(ellipse at 50% 45%, rgba(60,26,10,.28), rgba(9,5,3,.82) 80%); }

.titleWrap { text-align: center; padding: 18px; max-width: 900px; }
.logo {
  font-family: var(--head); font-size: clamp(48px, 11vw, 132px); line-height: .9;
  color: var(--amber); letter-spacing: -1px;
  text-shadow: 0 0 0 #000, 6px 6px 0 #000, 10px 10px 0 rgba(0,0,0,.45), 0 0 46px rgba(255,140,30,.35);
  transform: rotate(-2deg);
}
.logo span { color: var(--paper); }
.tagline {
  margin-top: 12px; font-size: clamp(12px, 2.2vw, 18px); letter-spacing: .38em;
  color: #d7c3a2; text-shadow: 2px 2px 0 #000;
}
.startline {
  margin: 26px auto 0; display: inline-block; font-family: var(--head); font-size: 15px; letter-spacing: 3px;
  color: var(--ink); background: var(--amber); padding: 9px 22px;
  border: 3px solid var(--ink); box-shadow: 5px 5px 0 rgba(0,0,0,.7);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.03) rotate(-1deg); } }
.ctrlGrid {
  margin: 26px auto 0; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 7px 14px;
  max-width: 720px; font-size: 13px; letter-spacing: 1.6px; color: #cbb997; text-align: left;
}
.ctrlGrid div { display: flex; gap: 7px; align-items: center; }
.padline { margin-top: 16px; font-size: 12px; letter-spacing: 1.2px; color: #8f7f68; max-width: 660px; margin-left: auto; margin-right: auto; line-height: 1.5; }
.best { margin-top: 14px; font-size: 13px; letter-spacing: 2.6px; color: var(--amber); }

.menuWrap {
  text-align: center; padding: 26px 34px; min-width: min(520px, 92vw);
  background: rgba(14,10,7,.9);
  border: 3px solid var(--ink); box-shadow: 8px 8px 0 rgba(0,0,0,.65);
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
}
.menuTitle { font-family: var(--head); font-size: clamp(26px, 5vw, 46px); color: var(--amber); text-shadow: 4px 4px 0 #000; transform: rotate(-1deg); }
.overSub { margin-top: 6px; font-size: 14px; letter-spacing: 3px; color: #c2af8f; }

.btn {
  pointer-events: auto; cursor: pointer; display: block; margin: 12px auto 0;
  font-family: var(--head); font-size: 15px; letter-spacing: 2px;
  color: var(--paper); background: #2a1c12; border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 rgba(0,0,0,.6); padding: 9px 34px;
  transition: transform .1s, background .12s, color .12s;
}
.btn:hover, .btn.sel { background: var(--amber); color: var(--ink); transform: translate(-1px,-2px) rotate(-.6deg); }
.btn.sel { box-shadow: 4px 4px 0 #000, 0 0 0 2px rgba(255,176,58,.35); }

.settings { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.settings label { font-size: 12px; letter-spacing: 2.4px; color: #c9b795; display: flex; align-items: center; gap: 12px; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 190px; height: 6px; background: #3a2a1c; border: 2px solid var(--ink); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 18px; background: var(--amber); border: 2px solid var(--ink); cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 12px; height: 16px; background: var(--amber); border: 2px solid var(--ink); border-radius: 0; cursor: pointer; }

.menuCtrls { margin: 20px auto 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 10px; font-size: 12px; letter-spacing: 1.4px; color: #9d8c72; }
.menuCtrls div { display: flex; gap: 6px; align-items: center; justify-content: center; }

.stats { margin: 18px auto 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 26px; max-width: 380px; font-size: 14px; letter-spacing: 2px; color: #cbb997; text-align: left; }
.stats b { color: var(--paper); float: right; }

/* ---------- the scrap machine ---------- */
.shopWrap {
  width: min(1040px, 94vw); max-height: 88vh; overflow-y: auto;
  padding: 20px 24px 24px; text-align: left;
  background: rgba(14,10,7,.95); border: 3px solid var(--ink);
  box-shadow: 8px 8px 0 rgba(0,0,0,.65);
  clip-path: polygon(16px 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%, 0 16px);
}
.shopHead { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; }
.shopTitle { font-family: var(--head); font-size: clamp(20px, 3.4vw, 34px); color: var(--amber); text-shadow: 3px 3px 0 #000; transform: rotate(-.6deg); }
.shopCash { font-family: var(--head); font-size: clamp(18px, 2.6vw, 26px); color: #9bf06a; text-shadow: 3px 3px 0 #000; }
.shopSub { font-size: 11px; letter-spacing: 3px; color: #8d7f6b; margin: 2px 0 6px; }
#shopMsg { min-height: 17px; font-family: var(--head); font-size: 11px; letter-spacing: 2px; color: #f0c24a; margin-bottom: 10px; }
.shopOffers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.offerCard {
  display: flex; flex-direction: column; gap: 4px;
  background: rgba(28,19,12,.92); border: 2px solid var(--ink); border-left: 6px solid #fff;
  padding: 8px 10px 10px;
}
.ocTop { display: flex; justify-content: space-between; gap: 8px; font-size: 10px; letter-spacing: 1.4px; color: #9c8b73; font-weight: 700; }
.ocName { font-family: var(--head); font-size: 14px; line-height: 1.2; }
.ocStats { font-size: 11.5px; letter-spacing: 1.1px; color: #c6b69c; }
.ocCmp { display: flex; flex-direction: column; gap: 4px; margin: 5px 0 2px; }
.vsRow { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; font-size: 10.5px; letter-spacing: 1px; color: #8d7f6b; }
.vsLabel { width: 100%; color: #7d6f5c; letter-spacing: 1.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vsRow em { font-style: normal; padding: 0 4px; background: rgba(0,0,0,.35); }
.vsRow em.up { color: #7be04a; }
.vsRow em.down { color: #ff6a4d; }
.vsRow em.same { color: #8d7f6b; }
.offerCard .btn { margin: 6px 0 0; width: 100%; padding: 6px 10px; font-size: 12px; letter-spacing: 1.4px; }
.offerCard .btn[disabled], .slotRow .btn[disabled] { opacity: .45; cursor: not-allowed; background: #241a12; color: #a2957f; transform: none; }
.shopYours { margin-top: 16px; }
.yoursLabel { font-size: 11px; letter-spacing: 3px; color: #8d7f6b; margin-bottom: 6px; }
.slotRow {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; margin-bottom: 5px;
  background: rgba(26,18,12,.88); border: 2px solid var(--ink); border-left: 5px solid #fff;
}
.slotRow.active { background: rgba(48,31,17,.92); }
.slotRow .key { font-family: var(--head); font-size: 10px; color: var(--amber); width: 84px; letter-spacing: 1px; }
.slotRow .info { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.slotRow .info b { font-family: var(--head); font-size: 13px; font-weight: 400; }
.slotRow .info span { font-size: 11px; letter-spacing: 1.2px; color: #9c8b73; }
.slotRow .btn { margin: 0; padding: 5px 12px; font-size: 11px; }
.slotRow.empty { opacity: .5; }
#shopNext { margin-top: 16px; }
@media (max-width: 780px) {
  .shopOffers { grid-template-columns: 1fr; }
  .shopWrap { padding: 14px; }
  .slotRow .key { width: 44px; }
}

@media (max-width: 720px) {
  .ctrlGrid { grid-template-columns: repeat(2, minmax(0,1fr)); font-size: 12px; }
  #topbar { top: 8px; }
  #leftPanel { left: 8px; bottom: 8px; }
  #rightPanel { right: 8px; bottom: 8px; }
  .bars { width: 44vw; }
  #weaponCard { min-width: 0; width: 46vw; }
  #ammoRow { font-size: 26px; }
}
