/* DOOMED - fullscreen canvas stage + menu chrome. No frameworks. */

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #05070a; color: #d8e0e8;
  font-family: "Menlo", "DejaVu Sans Mono", "Courier New", monospace;
  -webkit-font-smoothing: none;
  /* mobile hygiene: no rubber-band, no pull-to-refresh, no text selection,
     no long-press callout, no pinch/double-tap zoom anywhere */
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  position: fixed;                 /* stops iOS scrolling the body */
  width: 100%;
}

#stage { position: fixed; inset: 0; background: #000; cursor: none; touch-action: none; }
#stage.cursor-on { cursor: crosshair; }

/* the raycast buffer is tiny; let the GPU stretch it, nearest-neighbour */
#view, #hud {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}
#hud { pointer-events: none; }

/* faint CRT scanlines + vignette */
#stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,.16) 0 1px, rgba(0,0,0,0) 1px 3px),
    radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,.55) 100%);
  mix-blend-mode: multiply;
}

/* ---------------- menus ---------------- */
#overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(6,10,16,.72) 0%, rgba(2,4,6,.94) 75%);
  opacity: 0; pointer-events: none; transition: opacity .18s ease;
  cursor: default;
}
#overlay.show { opacity: 1; pointer-events: auto; }

.panel { display: none; text-align: center; padding: 28px 40px; max-width: 640px;
  border: 2px solid #2a3a48; background: rgba(8,12,18,.9);
  box-shadow: 0 0 0 2px #000, 0 18px 60px rgba(0,0,0,.8); }
.panel.show { display: block; }

h1 {
  font-size: 68px; letter-spacing: 14px; margin: 0 0 4px;
  color: #ff4b2b; text-shadow: 0 0 18px rgba(255,75,43,.55), 0 4px 0 #6b1408;
}
h2 { font-size: 40px; letter-spacing: 8px; margin: 0 0 14px; color: #ffb24b; }
h2.dead { color: #ff2b2b; text-shadow: 0 0 22px rgba(255,0,0,.6); }
h2.won  { color: #52ff8a; text-shadow: 0 0 22px rgba(80,255,140,.5); }
.sub { color: #7f8fa0; margin: 0 0 22px; font-size: 13px; letter-spacing: 1px; }

button.big {
  font: inherit; font-size: 20px; letter-spacing: 3px; cursor: pointer;
  padding: 12px 30px; margin: 4px 0 18px; color: #0a0d10;
  background: linear-gradient(#ffd257, #e08c1c); border: 2px solid #6d4406;
  box-shadow: 0 4px 0 #6d4406, 0 8px 18px rgba(0,0,0,.6);
}
button.big:hover { filter: brightness(1.12); }
button.big:active { transform: translateY(3px); box-shadow: 0 1px 0 #6d4406; }

.controls {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 22px;
  font-size: 12.5px; color: #9fb0c0; text-align: left;
  border-top: 1px solid #223140; padding-top: 14px; margin-top: 4px;
}
.controls b { color: #ffd257; }
.hint { font-size: 12px; color: #6f8090; margin: 12px 0 0; }
.key  { color: #ffd257; }
.exit { color: #52ff8a; }
.stats { font-size: 15px; color: #b9c8d6; line-height: 1.7; margin-bottom: 12px; }
.stats b { color: #ffd257; }

/* =============== touch controls ===============
   Only ever shown when body carries .touch (set by main.js on a coarse
   pointer). Everything is inset by the safe-area so the notch and the
   home indicator never sit under a thumb.                              */
#touch-ui { display: none; }
/* only on a touch device, and only while actually playing */
body.touch.ingame #touch-ui { display: block; }

/* the scanline multiply layer is a full-screen compositing job; drop it
   on phones where the GPU budget is the raycaster's                   */
body.touch #stage::after {
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 60%, rgba(0,0,0,.5) 100%);
  mix-blend-mode: normal;
}

#touch-ui { position: absolute; inset: 0; z-index: 8; pointer-events: none; }

.tb {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font: inherit; font-weight: 700; letter-spacing: 1px;
  color: #ffe6b0;
  background: radial-gradient(circle at 35% 30%, rgba(90,110,130,.42), rgba(10,16,22,.34));
  border: 2px solid rgba(190,215,235,.42);
  box-shadow: 0 2px 10px rgba(0,0,0,.55), inset 0 0 12px rgba(0,0,0,.35);
  -webkit-backdrop-filter: blur(1px); backdrop-filter: blur(1px);
  padding: 0; margin: 0;
  transition: transform .06s ease, background .06s ease;
}
.tb span { pointer-events: none; text-shadow: 0 1px 2px #000; }
.tb.on {
  transform: scale(.93);
  background: radial-gradient(circle at 35% 30%, rgba(255,190,90,.62), rgba(120,60,10,.45));
  border-color: rgba(255,220,150,.85);
}

#tb-fire {
  width: 88px; height: 88px; font-size: 15px;
  right: calc(14px + env(safe-area-inset-right, 0px));
  /* clears the HUD status bar in both orientations */
  bottom: calc(104px + env(safe-area-inset-bottom, 0px));
  border-color: rgba(255,140,90,.55);
}
#tb-fire.on { border-color: #ffd257; }
.tb.sm { width: 56px; height: 56px; font-size: 11px; }
.tb.tiny { width: 42px; height: 34px; font-size: 11px; border-radius: 8px; }

#tb-use {
  right: calc(112px + env(safe-area-inset-right, 0px));
  bottom: calc(90px + env(safe-area-inset-bottom, 0px));
}
#tb-wpn {
  right: calc(30px + env(safe-area-inset-right, 0px));
  bottom: calc(200px + env(safe-area-inset-bottom, 0px));
}
#tb-run {
  right: calc(106px + env(safe-area-inset-right, 0px));
  bottom: calc(164px + env(safe-area-inset-bottom, 0px));
}
#tb-pause {
  left: 50%; margin-left: -21px;
  top: calc(8px + env(safe-area-inset-top, 0px));
}

/* the analog stick: appears wherever the left thumb lands */
#tstick {
  position: absolute; width: 118px; height: 118px; margin: -59px 0 0 -59px;
  border-radius: 50%;
  border: 2px dashed rgba(180,210,235,.35);
  background: radial-gradient(circle, rgba(20,30,40,.28), rgba(6,10,14,.16));
  opacity: 0; transition: opacity .12s ease;
  pointer-events: none;
}
#tstick.on { opacity: 1; }
#tstick-knob {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px;
  margin: -27px 0 0 -27px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(220,235,250,.55), rgba(90,120,145,.35));
  border: 2px solid rgba(230,240,250,.5);
  box-shadow: 0 3px 12px rgba(0,0,0,.6);
}

/* touch menus: fit a 390px-tall landscape phone */
body.touch .panel {
  max-width: min(92vw, 560px); max-height: 88vh; overflow: auto;
  padding: 16px 20px;
  -webkit-overflow-scrolling: touch;
}
body.touch h1 { font-size: 40px; letter-spacing: 8px; }
body.touch h2 { font-size: 26px; letter-spacing: 5px; }
body.touch .sub { font-size: 11px; margin-bottom: 14px; }
body.touch .controls { font-size: 11px; grid-template-columns: 1fr; gap: 3px; }
body.touch .hint { font-size: 11px; }
body.touch .stats { font-size: 13px; }
body.touch button.big { font-size: 17px; padding: 14px 26px; }
#controls-touch { display: none; }
body.touch #controls-keyboard { display: none; }
body.touch #controls-touch { display: grid; }
