/* Jungle Rush — 16-bit arcade chrome. Chunky bordered boxes, a pixel font,
 * hard drop shadows and optional CRT scanlines. */
:root {
  --px: 'Press Start 2P', ui-monospace, monospace;
  --ink: #fff7e0;
  --shadow: #0a0a0a;
  --gold: #ffd33d;
  --leaf: #6ee7b7;
  --red: #ff3b3b;
  --orange: #ff9a1f;
  --panel: #12301f;
  --panel2: #0b1f14;
  --rim: #f4e9c1;
  --hud: clamp(8px, 1.05vw, 13px);
}
html, body { background: #0b1a09; }
body { font-family: var(--px); color: var(--ink); -webkit-font-smoothing: none; }
#screen { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; image-rendering: pixelated; touch-action: none; cursor: default; }
body.playing #screen { cursor: none; }
button, input { font-family: var(--px); }

/* ---------- CRT + vignettes ---------- */
#scan { position: fixed; inset: 0; pointer-events: none; z-index: 30; display: none;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,.18) 0 1px, transparent 1px 3px);
  box-shadow: inset 0 0 120px rgba(0,0,0,.55); }
body.crt #scan { display: block; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 4; transition: box-shadow .25s; }
#vignette[data-s="red"] { box-shadow: inset 0 0 70px 10px rgba(255,40,40,.42); }
#vignette[data-s="orange"] { box-shadow: inset 0 0 60px 8px rgba(255,140,30,.3); }
#vignette[data-s="green"] { box-shadow: inset 0 0 70px 10px rgba(52,211,153,.28); }
#vignette[data-s="hurt"] { box-shadow: inset 0 0 140px 44px rgba(220,30,30,.75); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; font-size: var(--hud); line-height: 1.75; }
#hud[hidden] { display: none; }
#hud.dim .hud-block, #hud.dim .hint, #hud.dim #alertPill { opacity: .35; }
.hud-block { position: absolute; top: max(10px, env(safe-area-inset-top)); text-shadow: 2px 2px 0 var(--shadow), -1px -1px 0 var(--shadow), 1px -1px 0 var(--shadow), -1px 1px 0 var(--shadow); white-space: nowrap; }
.hud-block.tl { left: 14px; }
.hud-block.tr { right: 14px; text-align: right; }
.hud-block .k { color: #e8e0c0; }
.hud-block .k.gold { color: var(--gold); }
.hud-block .row { display: flex; align-items: center; gap: .5em; }
.hud-block.tr .row { justify-content: flex-end; }
.ico { height: 1.15em; image-rendering: pixelated; filter: drop-shadow(1px 1px 0 #000); }
.hearts { display: inline-flex; gap: .25em; }
.hearts img { height: 1.1em; image-rendering: pixelated; filter: drop-shadow(1px 1px 0 #000); }

#alertPill { position: absolute; left: 50%; top: max(10px, env(safe-area-inset-top)); transform: translateX(-50%); padding: .55em .9em .65em; min-width: 15em; text-align: center;
  background: rgba(8,16,10,.85); border: 3px solid #2d4a35; box-shadow: 0 0 0 2px #000, 4px 4px 0 2px rgba(0,0,0,.45); color: #cfe9d6; font-size: calc(var(--hud) * .9); }
#alertPill i { display: block; height: 4px; margin-top: .45em; background: #000; }
#alertPill b { display: block; height: 100%; width: 0; background: currentColor; transition: width .2s linear; }
#alertPill[data-s="red"] { color: #fff; background: #7a0d0d; border-color: var(--red); animation: blink .35s steps(2) infinite; }
#alertPill[data-s="orange"] { color: #ffe1b0; background: #5a2a06; border-color: var(--orange); }
#alertPill[data-s="green"] { color: var(--leaf); border-color: #2f9e6e; }
#alertPill[data-s="teal"] { color: #9ee7d8; }

#ticker { position: absolute; left: 50%; top: calc(max(10px, env(safe-area-inset-top)) + 5.2em); transform: translateX(-50%); max-width: min(92vw, 60em); text-align: center;
  padding: .6em 1em; font-size: calc(var(--hud) * .85); line-height: 1.6; background: rgba(6,12,8,.88); border: 2px solid #3d6b4c; box-shadow: 3px 3px 0 rgba(0,0,0,.5); }
#ticker[hidden] { display: none; }
#ticker[data-k="warn"] { border-color: var(--orange); color: #ffd9a0; }
#ticker[data-k="danger"] { border-color: var(--red); color: #ffb3b3; }
#ticker[data-k="ok"] { color: var(--leaf); }
#ticker.pop { animation: pop .18s steps(3); }

.hud-block .kbd { color: #a9c4b0; }
body.touch .hud-block .kbd { display: none; }

/* ---------- pop-out intel map ---------- */
#mapPop { position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; pointer-events: auto; background: rgba(0,0,0,.25); }
#mapPop[hidden] { display: none; }
.map-box { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px; background: rgba(8,18,12,.9);
  border: 4px solid var(--rim); box-shadow: 0 0 0 4px #000, 8px 8px 0 4px rgba(0,0,0,.5); max-width: 94vw; }
.map-head { display: flex; justify-content: space-between; gap: 14px; width: 100%; font-size: 9px; color: var(--gold); }
#mapZone { color: #cfe2d4; }
#mapCanvas { display: block; height: min(70vh, 640px); width: auto; max-width: 88vw; image-rendering: pixelated; border: 2px solid #2d4a35; }
.map-bar { display: block; width: 100%; height: 5px; background: #000; }
.map-bar b { display: block; height: 100%; width: 100%; background: var(--leaf); }
.map-foot { font-size: 7px; color: #a9c4b0; display: flex; align-items: center; gap: 4px; }
.map-foot .me { display: inline-block; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 9px solid #34ff7a; }
.map-foot .foe { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ff3b3b; box-shadow: 0 0 6px #ff3b3b; }
.hint { position: absolute; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); white-space: nowrap; font-size: calc(var(--hud) * .78);
  padding: .7em 1.1em; background: rgba(5,8,6,.78); border: 2px solid #2a3a2e; text-shadow: 1px 1px 0 #000; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; overflow: auto; background: rgba(4,10,6,.45); }
.screen[hidden] { display: none; }
#title { background: linear-gradient(to bottom, rgba(4,10,6,.25), rgba(4,10,6,.6)); }
.box { position: relative; width: min(680px, 100%); padding: 22px 24px 20px; background: linear-gradient(var(--panel), var(--panel2));
  border: 4px solid var(--rim); box-shadow: 0 0 0 4px #000, inset 0 0 0 3px #2b5a3d, 8px 8px 0 4px rgba(0,0,0,.55); font-size: 10px; line-height: 1.9; }
.box.narrow { width: min(420px, 100%); }
.box h2 { margin: 6px 0 4px; font-size: 20px; text-align: center; color: var(--gold); text-shadow: 3px 3px 0 #7a3b06, 5px 5px 0 #000; }
.eyebrow { text-align: center; font-size: 8px; color: var(--leaf); letter-spacing: .05em; }
.eyebrow.ok { color: var(--leaf); }
.muted { color: #a9c4b0; text-align: center; }
.center { text-align: center; }
.gold { color: var(--gold); }
.h { color: var(--gold); margin-bottom: 6px; font-size: 9px; }

.logo { margin: 10px 0 6px; text-align: center; font-size: clamp(26px, 6.4vw, 46px); line-height: 1.1; font-weight: 400; color: var(--gold);
  text-shadow: 3px 3px 0 #d2531b, 6px 6px 0 #6b1d06, 9px 9px 0 #000; letter-spacing: .02em; }
.logo span:last-child { color: #8ef0a6; text-shadow: 3px 3px 0 #1d7a3e, 6px 6px 0 #0b3a1b, 9px 9px 0 #000; }
.sub { text-align: center; color: #cfe2d4; margin: 6px 0 14px; font-size: 9px; }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.mode { text-align: left; padding: 10px; color: var(--ink); background: #0a1a10; border: 3px solid #2d4a35; box-shadow: 3px 3px 0 #000; cursor: pointer; line-height: 1.7; }
.mode b { display: block; font-size: 9px; font-weight: 400; color: #e8e0c0; }
.mode small { display: block; font-size: 7px; color: #8fb09a; }
.mode:hover { border-color: #5a8c69; }
.mode.on { border-color: var(--gold); background: #1f3a16; }
.mode.on b { color: var(--gold); }
.mode.on b::before { content: '\25B6  '; }
.title-cols { display: grid; grid-template-columns: 1.15fr 1fr; gap: 14px; }
.rules p { margin: 0 0 2px; font-size: 8px; color: #cfe2d4; }
.rules em { font-style: normal; color: var(--leaf); }
.lb { background: rgba(0,0,0,.3); border: 2px solid #2d4a35; padding: 8px 10px; }
.lb-row { display: grid; grid-template-columns: 2.2em 1fr 5.6em 4.2em 2.6em; gap: 6px; font-size: 8px; color: #d6e6da; }
.lb-row.me { color: #000; background: var(--gold); animation: blink .6s steps(2) infinite; }
.lb-row span:nth-child(3) { color: var(--gold); text-align: right; }
.lb-row.me span:nth-child(3) { color: #000; }
.deploy { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.deploy label { font-size: 9px; color: #e8e0c0; }
.deploy input { width: 11em; padding: 8px; font-size: 10px; color: var(--gold); background: #000; border: 3px solid #2d4a35; outline: none; text-transform: uppercase; }
.deploy input:focus { border-color: var(--gold); }
.btn { padding: 10px 14px; font-size: 10px; color: var(--ink); background: #1d3a27; border: 3px solid #5a8c69; box-shadow: 3px 3px 0 #000; cursor: pointer; }
.btn:hover { border-color: var(--rim); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
.btn.go { color: #000; background: var(--gold); border-color: #fff4b0; }
.blink { text-align: center; margin-top: 12px; color: var(--leaf); animation: blink 1s steps(2) infinite; font-size: 9px; }

.clr-main { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; margin: 12px 0; }
.grade { text-align: center; padding: 8px 16px; background: #000; border: 3px solid var(--gold); }
.grade small { display: block; font-size: 8px; color: #e8e0c0; }
.grade b { display: block; font-size: 40px; line-height: 1.2; font-weight: 400; color: var(--gold); text-shadow: 3px 3px 0 #7a3b06; }
.grade b[data-grade="S+"], .grade b[data-grade="S"] { color: #8ef0a6; text-shadow: 3px 3px 0 #1d7a3e; }
.grade b[data-grade="C"] { color: #ff9a9a; text-shadow: 3px 3px 0 #6b1d1d; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 0; font-size: 9px; }
.stats dt { color: #a9c4b0; }
.stats dd { margin: 0; text-align: right; }
.stats.wide { max-width: 360px; margin: 14px auto; }
.bar { height: 10px; background: #000; border: 2px solid #2d4a35; margin: 6px 0; }
.bar b { display: block; height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--leaf) 0 6px, #2f9e6e 6px 8px); transition: width .8s steps(16); }
.intel { margin: 12px 0; padding: 10px; background: rgba(0,0,0,.3); border: 2px solid #2d4a35; font-size: 8px; }
.intel p { margin: 2px 0; color: #cfe2d4; }
.intel .tip { color: var(--leaf); }
#clear .btn, #pause .btn { display: block; width: 100%; }
.stack { display: grid; gap: 8px; margin: 12px 0; }
.keys { display: grid; grid-template-columns: auto auto; gap: 2px 12px; font-size: 7px; color: #a9c4b0; justify-content: center; }
.keys span:nth-child(odd) { color: var(--gold); }
#overTitle[data-k="win"] { color: #8ef0a6; text-shadow: 3px 3px 0 #1d7a3e, 5px 5px 0 #000; }
#overTitle[data-k="lose"] { color: #ff6b6b; text-shadow: 3px 3px 0 #6b1d1d, 5px 5px 0 #000; }
.row-btns { display: flex; gap: 10px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

/* ---------- touch: round buttons ---------- */
#tpad, #ttop, #stick { display: none; }
.rb { position: absolute; border-radius: 50%; padding: 0; display: grid; place-items: center; font-size: 7px; line-height: 1; color: var(--ink);
  background: rgba(8,20,13,.5); border: 3px solid rgba(244,233,193,.85); box-shadow: 0 3px 0 rgba(0,0,0,.55), inset 0 0 0 2px rgba(0,0,0,.35);
  text-shadow: 1px 1px 0 #000; touch-action: none; -webkit-tap-highlight-color: transparent; transition: transform .06s, background .1s; }
.rb.down { transform: translate(-50%, -50%) scale(.9) !important; background: rgba(255,211,61,.35); }
body.touch #ttop { display: flex; gap: 12px; position: fixed; left: 50%; transform: translateX(-50%); top: max(10px, env(safe-area-inset-top)); z-index: 12; }
#ttop .rb { position: relative; width: 46px; height: 46px; }
#ttop .rb.down { transform: scale(.9) !important; }
.burger { display: grid; gap: 4px; }
.burger i { display: block; width: 18px; height: 3px; background: var(--ink); box-shadow: 1px 1px 0 #000; }
#tMap { font-size: 7px; }
#tMap em { position: absolute; right: -4px; top: -4px; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; font-style: normal; font-size: 7px; color: #000; background: var(--gold); border: 2px solid #000; }
#tMap.empty { opacity: .45; }
#tMap.empty em { background: #64748b; }
#tMap.open { background: rgba(52,211,153,.5); border-color: var(--leaf); }

/* action ring: crouch in the middle, the rest around it */
body.touch #tpad { display: block; position: fixed; right: max(8px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); width: 196px; height: 196px; z-index: 12; }
#tpad .rb { width: 58px; height: 58px; transform: translate(-50%, -50%); }
#tpad .c { left: 50%; top: 50%; width: 62px; height: 62px; font-size: 6px; }
#tpad .n { left: 50%; top: 15%; }
#tpad .s { left: 50%; top: 85%; width: 52px; height: 52px; }
#tpad .w { left: 15%; top: 50%; width: 52px; height: 52px; }
#tpad .e { left: 85%; top: 50%; width: 66px; height: 66px; border-color: var(--gold); color: var(--gold); font-size: 8px; }
#tCrouch.on { background: var(--gold); color: #000; text-shadow: none; border-color: #fff4b0; box-shadow: 0 0 14px rgba(255,211,61,.8), 0 3px 0 rgba(0,0,0,.55); }
body.touch #hud .hint { display: none; }
body.touch #stick:not([hidden]) { display: block; position: fixed; z-index: 12; width: 104px; height: 104px; margin: -52px 0 0 -52px; border-radius: 50%; border: 3px solid rgba(244,233,193,.5); background: rgba(0,0,0,.22); pointer-events: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,211,61,.7); border: 3px solid #000; transform: translate(-50%, -50%); }
body.touch .hud-block { font-size: 8px; }
body.touch #alertPill { top: calc(max(10px, env(safe-area-inset-top)) + 58px); }
body.touch #ticker { top: calc(max(10px, env(safe-area-inset-top)) + 100px); }

@keyframes blink { 50% { opacity: .45; } }
@keyframes pop { 0% { transform: translateX(-50%) scale(.85); } 100% { transform: translateX(-50%) scale(1); } }

@media (max-width: 640px) {
  .modes, .title-cols { grid-template-columns: 1fr; }
  .box { padding: 16px 14px; }
  :root { --hud: 8px; }
  #hudTimeRow, .hud-block.tl .row:nth-child(6), .hud-block.tl > div:nth-child(2), #hudDistRow, #hudStealthRow { display: none; }
  .hud-block.tr { right: auto; left: 14px; top: calc(max(10px, env(safe-area-inset-top)) + 7.4em); text-align: left; }
  .hud-block.tr .row { justify-content: flex-start; }
  #alertPill { left: auto; right: 10px; transform: none; min-width: 0; padding: .5em .7em; }
  #ticker { top: calc(max(10px, env(safe-area-inset-top)) + 16em); width: 92vw; }
  body.touch #alertPill { top: max(10px, env(safe-area-inset-top)); }
  #hudDistRow, #hudMapRow { display: none; }
}
@media (prefers-reduced-motion: reduce) { .blink, #alertPill[data-s="red"], .lb-row.me { animation: none; } }
