/* Press Start 2P (SIL OFL 1.1, see assets/fonts/OFL.txt), self-hosted —
   "latin" subset only: covers German umlauts, ß, „ “ · — */
@font-face {
  font-family: 'Press Start 2P';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("assets/fonts/press-start-2p-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --jungle-dark: #0c1b0f;
  --jungle-mid: #163a1d;
  --jungle-light: #2f6b2f;
  --amber: #ffb400;
  --amber-dim: #7a5900;
  --blood: #d6321c;
  --good: #7cff5a;
  --bad: #ff5a5a;
  --panel: #1a120a;
  --panel-edge: #4a2f12;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Press Start 2P', monospace;
  -webkit-font-smoothing: none;
  image-rendering: pixelated;
  touch-action: none;
}

img { max-width: 100%; }
[hidden] { display: none !important; }

#gameWrap {
  position: fixed;
  inset: 0;
  background: var(--jungle-dark);
  overflow: hidden;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: none;
}

/* small fixed-size 3D viewport for the gun model — JS moves it around via
   transform, independent of the full-screen game/background canvas */
#gunLayer {
  inset: auto;
  top: 0;
  left: 0;
  width: 170px;
  height: 214px;
  z-index: 10;
  pointer-events: none;
  will-change: transform;
  opacity: 0;
  transition: opacity 0.25s;
}
#gunLayer.armed { opacity: 1; }

#crosshair {
  position: absolute;
  top: 0;
  left: 0;
  width: 28px;
  height: 28px;
  z-index: 12;
  pointer-events: none;
  will-change: transform;
  transform: translate(-100px, -100px);
  opacity: 0;
  transition: opacity 0.25s;
}
#crosshair.armed { opacity: 1; }
#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: #ff3b3b;
  box-shadow: 0 0 4px rgba(255,59,59,0.8);
}
/* vertical bar, split top/bottom with a gap in the middle */
#crosshair::before {
  left: 13px; top: 0; width: 2px; height: 10px;
  box-shadow: 0 0 4px rgba(255,59,59,0.8), 0 18px 0 0 #ff3b3b;
}
/* horizontal bar, split left/right with a gap in the middle */
#crosshair::after {
  top: 13px; left: 0; width: 10px; height: 2px;
  box-shadow: 0 0 4px rgba(255,59,59,0.8), 18px 0 0 0 #ff3b3b;
}

/* ---------- Start screen ---------- */
.overlay-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  background:
    radial-gradient(ellipse at center, rgba(30,60,20,0.9) 0%, rgba(4,10,5,0.98) 70%),
    repeating-linear-gradient(0deg, rgba(0,0,0,0.25) 0px, rgba(0,0,0,0.25) 1px, transparent 1px, transparent 3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 24px;
  text-align: center;
  color: var(--amber);
}

.crt-title h1 {
  font-size: clamp(2rem, 8vw, 4rem);
  margin: 0;
  color: var(--amber);
  text-shadow:
    0 0 6px var(--amber),
    3px 3px 0 var(--blood),
    6px 6px 0 rgba(0,0,0,0.6);
  letter-spacing: 4px;
  animation: flicker 3.5s infinite;
}

.subtitle {
  margin-top: 12px;
  font-size: 0.6rem;
  color: var(--good);
  letter-spacing: 2px;
}

@keyframes flicker {
  0%, 92%, 100% { opacity: 1; }
  93% { opacity: 0.7; }
  95% { opacity: 1; }
  96% { opacity: 0.6; }
  97% { opacity: 1; }
}

.startBox {
  border: 3px solid var(--panel-edge);
  background: rgba(20, 14, 6, 0.85);
  padding: 24px 20px;
  max-width: 480px;
  box-shadow: 0 0 0 4px #000, 0 0 30px rgba(255,180,0,0.15);
}

.startBox p {
  font-size: 0.7rem;
  line-height: 1.8;
  color: #e8d9b8;
  margin: 0 0 14px;
}

.startBox .small { font-size: 0.6rem; color: #9bb98a; }
.startBox .tiny { font-size: 0.5rem; color: #6a8a5f; margin-top: 18px; margin-bottom: 0; }

.good { color: var(--good); }
.bad { color: var(--bad); }

.arcadeBtn {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 14px 22px;
  background: var(--blood);
  color: #fff2d6;
  border: 3px solid #7a1a0e;
  box-shadow: 0 5px 0 #7a1a0e, 0 5px 12px rgba(0,0,0,0.5);
  cursor: pointer;
  letter-spacing: 2px;
  animation: pulse 1.4s infinite;
}
.arcadeBtn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #7a1a0e;
}

@keyframes pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.25); }
}

/* ---------- Scroll button (opens the bug tutorial) ---------- */
/* wrapper is only as wide as the start box; the scroll hangs off its right
   edge, bottom-aligned with the box */
.startBoxWrap { position: relative; }

.scrollBtn {
  position: absolute;
  left: calc(100% + 22px);
  bottom: 0;
  width: 112px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  background: none;
  border: 0;
  font-family: inherit;
  cursor: pointer;
  filter: drop-shadow(0 5px 0 rgba(0,0,0,0.55));
  animation: scrollBob 2.4s ease-in-out infinite;
}
.scrollBtn:hover { filter: drop-shadow(0 5px 0 rgba(0,0,0,0.55)) brightness(1.12); }
.scrollBtn:active { animation: none; transform: translateY(3px); }
.scrollBtn:focus-visible { outline: 3px solid var(--good); outline-offset: 4px; }

@keyframes scrollBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* the two wooden rolls, a little wider than the paper */
.scrollRoll {
  display: block;
  height: 16px;
  margin: 0 -6px;
  border: 3px solid #2e1a06;
  border-radius: 8px;
  background: linear-gradient(180deg, #e0a552 0%, #b8791f 45%, #7a4a12 100%);
  position: relative;
  z-index: 1;
}

.scrollPaper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 6px 12px;
  margin: -2px 0;
  border-left: 3px solid #a8814a;
  border-right: 3px solid #a8814a;
  background:
    repeating-linear-gradient(0deg, rgba(120,80,30,0.10) 0px, rgba(120,80,30,0.10) 2px, transparent 2px, transparent 6px),
    linear-gradient(90deg, #d9bf86 0%, #f0dfae 18%, #f0dfae 82%, #d9bf86 100%);
  color: #4a2f12;
}
.scrollKicker { font-size: 0.4rem; letter-spacing: 1px; }
.scrollMark {
  font-size: 2rem;
  line-height: 1;
  color: var(--blood);
  text-shadow: 2px 2px 0 rgba(74,47,18,0.35);
}
.scrollLabel { font-size: 0.42rem; letter-spacing: 0.5px; line-height: 1.5; }

/* ---------- Tutorial popup ---------- */
.tutorialModal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,0.78);
  touch-action: pan-y;
}

.tutorialBox {
  width: min(600px, 100%);
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
  border: 3px solid var(--panel-edge);
  background: #140d05;
  box-shadow: 0 0 0 4px #000, 0 0 40px rgba(255,180,0,0.2);
  text-align: left;
}

.tutorialHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--panel-edge);
  color: var(--amber);
  font-size: 0.6rem;
  letter-spacing: 1px;
  border-bottom: 3px solid #000;
}
.tutorialClose {
  font-family: inherit;
  font-size: 0.7rem;
  padding: 6px 9px;
  background: #000;
  color: var(--amber);
  border: 2px solid var(--amber-dim);
  cursor: pointer;
}
.tutorialClose:hover { color: #fff2d6; border-color: var(--amber); }

.tutorialBody {
  padding: 20px 20px 8px;
  overflow-y: auto;
  min-height: 0;
  touch-action: pan-y;
}
.tutorialPage h2 {
  margin: 0 0 18px;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--amber);
  text-shadow: 2px 2px 0 var(--blood);
}
.tutorialPage p {
  margin: 0 0 16px;
  font-size: 0.62rem;
  line-height: 2;
  color: #e8d9b8;
}
.tutorialPage .hl { color: var(--amber); }

.tipBox {
  margin: 0 0 16px;
  padding: 14px 14px 2px;
  border: 2px dashed var(--good);
  background: rgba(124,255,90,0.06);
}
.tipLabel {
  display: inline-block;
  margin-bottom: 10px;
  padding: 3px 6px;
  font-size: 0.5rem;
  background: var(--good);
  color: #0c1b0f;
  letter-spacing: 1px;
}
.tutorialPage .tutorialGo { color: var(--good); }

.tutorialFoot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 16px;
}
.tutorialDots { display: flex; gap: 8px; }
.tutorialDots span {
  width: 10px;
  height: 10px;
  background: #3a2a14;
  border: 2px solid #000;
}
.tutorialDots span.on { background: var(--amber); }

.arcadeBtn.small {
  font-size: 0.6rem;
  padding: 10px 14px;
  animation: none;
}
.arcadeBtn.ghost {
  background: #3a2a14;
  border-color: #000;
  box-shadow: 0 5px 0 #000;
  color: #e8d9b8;
}
.arcadeBtn:disabled { opacity: 0.35; cursor: default; }

/* not enough room beside the start box: put the scroll under it, right-aligned */
@media (max-width: 860px) {
  .scrollBtn {
    position: relative;
    left: auto;
    bottom: auto;
    width: 96px;
    margin: 26px 0 0 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scrollBtn { animation: none; }
}

/* ---------- HUD (Doom-style status bar) ---------- */
#hud {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  background:
    linear-gradient(180deg, var(--panel-edge) 0%, var(--panel) 8%, var(--panel) 100%);
  border-top: 4px solid #000;
  box-shadow: 0 -4px 0 var(--panel-edge), inset 0 2px 0 rgba(255,255,255,0.05);
  pointer-events: none;
  user-select: none;
}

.hudPanel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px;
  min-width: 0;
}

.hudLabel {
  font-size: 0.5rem;
  color: var(--amber-dim);
  letter-spacing: 2px;
}

.hudCenter .hudLabel {
  white-space: nowrap;
  font-size: 0.38rem;
  letter-spacing: 0.5px;
}

.hudValue {
  font-size: clamp(1rem, 4vw, 1.6rem);
  color: var(--amber);
  text-shadow: 0 0 6px rgba(255,180,0,0.6);
}

.ammoLabel {
  font-size: 0.5rem;
  color: var(--good);
  margin-top: 2px;
}

.hudCenter { flex: 0 0 auto; width: 92px; }

.faceBox {
  width: 64px;
  height: 64px;
  background: #2a1c10;
  border: 3px solid #000;
  box-shadow: inset 0 0 0 2px var(--panel-edge);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.face {
  width: 46px;
  height: 46px;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 4px rgba(255,180,0,0.55));
  transition: transform 0.12s, filter 0.12s;
}

.face.happy {
  transform: scale(1.16);
  filter: drop-shadow(0 0 9px rgba(124,255,90,0.9)) brightness(1.3);
}
.face.hurt {
  transform: scale(0.92) rotate(-4deg);
  filter: drop-shadow(0 0 9px rgba(255,90,90,0.9)) sepia(1) saturate(6) hue-rotate(-40deg);
}

/* ---------- Mute button ---------- */
.muteBtn {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 10px;
  z-index: 30;
  font-size: 1.1rem;
  background: rgba(10, 8, 4, 0.7);
  border: 2px solid var(--panel-edge);
  color: var(--amber);
  padding: 8px 10px;
  cursor: pointer;
  line-height: 1;
}

/* ---------- Legal links (bottom of the start screen; the overlay is position: fixed) ---------- */
.legalLinks {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  gap: 10px;
  font-size: 0.5rem;
  color: #8aa77b;
}
.legalLinks a {
  color: inherit;
  text-decoration: none;
  padding: 6px 4px; /* bigger tap target on touch */
}
.legalLinks a:hover,
.legalLinks a:focus-visible { color: var(--amber); text-decoration: underline; }
.legalLinks a:focus-visible { outline: 2px solid var(--good); outline-offset: 2px; }

/* ---------- Back-to-website button (top left, mirrors the mute button) ---------- */
/* z-index 60: above the start screen (50) and the whole game, below the tutorial popup (80) */
.backBtn {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 10px;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  background: rgba(10, 8, 4, 0.7);
  border: 2px solid var(--panel-edge);
  color: var(--amber);
  cursor: pointer;
  line-height: 1;
}
.backBtn svg {
  display: block;
  fill: currentColor;
  filter: drop-shadow(3px 3px 0 var(--blood));
}
.backBtn:hover { border-color: var(--amber); }
.backBtn:active { transform: translateY(2px); }
.backBtn:focus-visible { outline: 3px solid var(--good); outline-offset: 3px; }

/* ---------- Popups (floating score text) ---------- */
#popupLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  overflow: hidden;
}

.popup {
  position: absolute;
  font-size: 0.75rem;
  font-family: 'Press Start 2P', monospace;
  transform: translate(-50%, -50%);
  animation: floatUp 0.8s ease-out forwards;
  white-space: nowrap;
  text-shadow: 2px 2px 0 #000;
}
.popup.good { color: var(--good); }
.popup.bad { color: var(--bad); }

@keyframes floatUp {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -140%) scale(1.3); }
}

/* ---------- 3D model credit (CC BY 4.0 requires attribution) ---------- */
.creditTag {
  position: absolute;
  left: 92px; /* right of the back button */
  top: calc(10px + env(safe-area-inset-top, 0px));
  z-index: 25;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.4rem;
  color: rgba(255,255,255,0.35);
  text-decoration: none;
  letter-spacing: 0.5px;
}
.creditTag:hover { color: rgba(255,255,255,0.7); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: var(--bad);
  padding: 8px 14px;
  font-size: 0.65rem;
  z-index: 60;
  border: 2px solid var(--bad);
}

@media (max-width: 480px) {
  .hudLabel { font-size: 0.42rem; }
  .ammoLabel { font-size: 0.42rem; }
  .faceBox { width: 48px; height: 48px; }
  .hudCenter { width: 70px; }
  .hudCenter .hudLabel { font-size: 0.3rem; letter-spacing: 0.3px; }
}
