/* ============================ XENOFALL UI ============================ */
:root {
  --ink: #e8f0ff;
  --muted: #8da0c0;
  --accent: #3aa0ff;
  --accent2: #46e8a0;
  --danger: #ff3a5e;
  --hp: #46e8a0;
  --armor: #3aa0ff;
  --panel: rgba(8, 12, 20, 0.86);
  --line: rgba(120, 160, 220, 0.22);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: #05060a; color: var(--ink);
  font-family: 'Rajdhani', system-ui, sans-serif; -webkit-user-select: none; user-select: none; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair;
  touch-action: none; -webkit-user-select: none; user-select: none; }

/* ---- screen FX ---- */
.fx-flash { position: fixed; inset: 0; pointer-events: none; z-index: 8; opacity: 0; transition: opacity .06s; mix-blend-mode: screen; }
.fx-vignette { position: fixed; inset: 0; pointer-events: none; z-index: 9; opacity: 0; transition: opacity .2s;
  box-shadow: inset 0 0 200px 60px rgba(255, 30, 50, 0.85); }
.fx-vignette.show { opacity: 1; }
.fx-lowhp { position: fixed; inset: 0; pointer-events: none; z-index: 7; opacity: 0;
  box-shadow: inset 0 0 160px 40px rgba(255, 30, 50, 0.5); }
.fx-lowhp.show { opacity: 1; animation: lowpulse 1.1s ease-in-out infinite; }
@keyframes lowpulse { 50% { opacity: .35; } }

.fx-power { position: fixed; inset: 0; pointer-events: none; z-index: 6; opacity: 0; transition: opacity .25s ease; box-shadow: inset 0 0 240px 60px currentColor; }
.power-timers { display: flex; gap: 8px; margin-top: 6px; justify-content: center; }
.power-chip { font: 700 12px/1 Orbitron, system-ui, sans-serif; letter-spacing: .08em; padding: 4px 8px; border-radius: 6px; background: rgba(0,0,0,.45); border: 1px solid currentColor; }

.crosshair { position: fixed; left: 50%; top: 50%; width: 26px; height: 26px; transform: translate(-50%, -50%);
  z-index: 6; pointer-events: none; }
.crosshair span { position: absolute; background: rgba(230, 245, 255, 0.85); box-shadow: 0 0 4px rgba(0,0,0,.6); }
.crosshair span:nth-child(1) { left: 50%; top: 0; width: 2px; height: 9px; transform: translateX(-50%); }
.crosshair span:nth-child(2) { left: 50%; bottom: 0; width: 2px; height: 9px; transform: translateX(-50%); }
.crosshair span:nth-child(3) { top: 50%; left: 0; height: 2px; width: 9px; transform: translateY(-50%); }
.crosshair span:nth-child(4) { top: 50%; right: 0; height: 2px; width: 9px; transform: translateY(-50%); }
.hitmarker { position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%); z-index: 7;
  color: #fff; font-size: 22px; font-weight: 700; opacity: 0; pointer-events: none; text-shadow: 0 0 6px #000; }
.hitmarker.show { opacity: 1; animation: hitpop .12s ease; }
@keyframes hitpop { 0% { transform: translate(-50%,-50%) scale(1.5); } 100% { transform: translate(-50%,-50%) scale(1); } }

/* ---- HUD ---- */
.hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; display: none; font-family: 'Rajdhani', sans-serif; }
.hud.show { display: block; }
.hud-objective { position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 16px;
  font-size: 15px; letter-spacing: .04em; backdrop-filter: blur(6px); white-space: nowrap; }
.obj-tag { color: var(--accent2); font-weight: 700; font-family: 'Orbitron', sans-serif; font-size: 12px; }

.boss { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); width: min(560px, 80vw); display: none; }
.boss.show { display: block; }
.boss-label { text-align: center; font-family: 'Orbitron', sans-serif; font-weight: 700; color: var(--danger);
  letter-spacing: .2em; font-size: 13px; margin-bottom: 4px; text-shadow: 0 0 10px rgba(255,58,94,.6); }
.boss-track { height: 14px; background: rgba(0,0,0,.6); border: 1px solid var(--danger); border-radius: 8px; overflow: hidden; }
.boss-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #ff3a5e, #ff8a3d); transition: width .15s; }

.hud-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: flex-end;
  justify-content: space-between; padding: 18px 26px; gap: 18px; }
.hud-left { display: flex; flex-direction: column; gap: 10px; width: 240px; }
.vital-row { display: flex; justify-content: space-between; align-items: baseline; }
.vlabel { font-family: 'Orbitron', sans-serif; font-size: 11px; letter-spacing: .12em; color: var(--muted); }
.vval { font-family: 'Orbitron', sans-serif; font-size: 26px; font-weight: 900; }
.vtrack { height: 10px; background: rgba(0,0,0,.55); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin-top: 2px; }
.vfill { height: 100%; transition: width .18s; }
.vfill.hp { background: linear-gradient(90deg, #2bd47e, #7affc0); }
.vfill.armor { background: linear-gradient(90deg, #2b7fff, #7ac8ff); }

.hud-center { flex: 1; display: flex; justify-content: center; align-items: flex-end; }
.weapon-slots { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; }
.wslot { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px;
  font-size: 12px; color: var(--muted); letter-spacing: .03em; }
.wslot.cur { color: var(--ink); border-color: var(--accent); box-shadow: 0 0 12px rgba(58,160,255,.4); }
.wslot b { color: var(--accent2); }

.hud-right { text-align: right; width: 240px; }
.ammo { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.ammo-num { font-family: 'Orbitron', sans-serif; font-size: 42px; font-weight: 900; text-shadow: 0 0 16px rgba(58,160,255,.4); }
.ammo-name { font-size: 14px; color: var(--muted); letter-spacing: .06em; margin-top: 2px; }
.score-row { display: flex; gap: 14px; justify-content: flex-end; margin-top: 8px; font-size: 13px; color: var(--muted); }
.score-row b { color: var(--ink); font-family: 'Orbitron', sans-serif; }

.toast { position: absolute; top: 96px; left: 50%; transform: translateX(-50%) translateY(-10px);
  background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 22px; text-align: center;
  opacity: 0; backdrop-filter: blur(6px); box-shadow: 0 0 24px rgba(58,160,255,.3); }
.toast.show { animation: toastIn 2.2s ease forwards; }
@keyframes toastIn { 0% { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(.95); }
  12% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  82% { opacity: 1; } 100% { opacity: 0; } }
.toast-title { font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 18px; letter-spacing: .08em; }
.toast-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---- overlays ---- */
.overlay { position: fixed; inset: 0; z-index: 20; display: none; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(120% 120% at 50% 0%, rgba(20,30,60,.6), rgba(3,4,8,.95));
  backdrop-filter: blur(4px); padding: 24px; text-align: center; }
.overlay.show { display: flex; animation: fade .3s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.back-link { position: fixed; top: 16px; left: 18px; color: var(--ink); text-decoration: none; font-weight: 600;
  background: var(--panel); border: 1px solid var(--line); padding: 7px 13px; border-radius: 999px; font-size: 14px; }
.back-link:hover { border-color: var(--accent); }

.title-wrap { margin-bottom: 26px; }
.game-title { font-family: 'Orbitron', sans-serif; font-weight: 900; font-size: clamp(48px, 12vw, 120px);
  letter-spacing: .06em; line-height: 1; background: linear-gradient(180deg, #d6ecff, #3aa0ff);
  -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: 0 0 60px rgba(58,160,255,.4); }
.game-title span { color: var(--danger); -webkit-text-fill-color: var(--danger); text-shadow: 0 0 40px rgba(255,58,94,.5); }
.game-tag { color: var(--muted); font-size: clamp(15px, 2.4vw, 20px); margin-top: 8px; letter-spacing: .04em; }

.menu-buttons { display: flex; flex-direction: column; gap: 12px; width: min(320px, 80vw); margin: 0 auto; }
.btn { font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 16px; letter-spacing: .08em;
  padding: 14px 22px; border-radius: 10px; border: 1px solid var(--line); background: rgba(20,28,44,.7);
  color: var(--ink); cursor: pointer; transition: transform .12s, border-color .12s, box-shadow .12s; pointer-events: auto; }
.btn:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 6px 24px rgba(58,160,255,.3); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #2b6fff); border-color: transparent; color: #04101f; }
.btn.primary:hover { box-shadow: 0 8px 30px rgba(58,160,255,.5); }

.level-select-wrap { margin-top: 28px; width: min(640px, 92vw); }
.ls-title { font-family: 'Orbitron', sans-serif; font-size: 13px; letter-spacing: .2em; color: var(--muted); margin-bottom: 10px; }
.level-select { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.lvl-btn { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(20,28,44,.6); color: var(--ink); cursor: pointer; text-align: left;
  font-family: 'Rajdhani', sans-serif; pointer-events: auto; transition: border-color .12s, transform .12s; }
.lvl-btn:hover:not(.locked) { border-color: var(--accent); transform: translateY(-2px); }
.lvl-btn.locked { opacity: .4; cursor: not-allowed; }
.lvl-num { font-family: 'Orbitron', sans-serif; font-weight: 900; font-size: 20px; color: var(--accent); }
.lvl-name { font-size: 15px; font-weight: 600; }
.menu-best { margin-top: 18px; color: var(--accent2); font-family: 'Orbitron', sans-serif; font-size: 13px; letter-spacing: .06em; }
.menu-controls { margin-top: 14px; color: var(--muted); font-size: 13px; letter-spacing: .03em; }

.brief-card, .panel-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 30px 34px; max-width: 560px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.brief-eyebrow { font-family: 'Orbitron', sans-serif; font-size: 12px; letter-spacing: .25em; color: var(--accent2); margin-bottom: 8px; }
.brief-title { font-family: 'Orbitron', sans-serif; font-size: 26px; margin-bottom: 16px; letter-spacing: .04em; }
.brief-text { color: #cdd9ee; font-size: 17px; line-height: 1.6; margin-bottom: 18px; }
.brief-obj { font-family: 'Orbitron', sans-serif; font-size: 13px; color: var(--accent); letter-spacing: .06em;
  border-top: 1px solid var(--line); padding-top: 14px; margin-bottom: 22px; }
.brief-actions { display: flex; gap: 12px; justify-content: center; }
.brief-actions .btn { width: auto; }

.panel-h { font-family: 'Orbitron', sans-serif; font-size: 34px; letter-spacing: .08em; margin-bottom: 16px; }
.panel-h.danger { color: var(--danger); text-shadow: 0 0 30px rgba(255,58,94,.5); }
.panel-h.win { color: var(--accent2); text-shadow: 0 0 30px rgba(70,232,160,.5); }
.panel-sub { color: var(--muted); margin-bottom: 20px; font-size: 16px; }
.panel-story { color: #cdd9ee; font-size: 16px; line-height: 1.6; margin-bottom: 14px; }

.set-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 4px;
  border-bottom: 1px solid var(--line); font-size: 16px; }
.set-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
.set-row input[type=range] { width: 160px; accent-color: var(--accent); }

@media (max-width: 640px) {
  .hud-left, .hud-right { width: 130px; }
  .ammo-num { font-size: 30px; }
  .vval { font-size: 20px; }
}

/* ---- touch controls ---- */
.touch { display: none; }
/* only show when the body is flagged as a touch device */
body.touch-device .touch { display: block; position: absolute; inset: 0; z-index: 6; pointer-events: none; }
/* keep weapon slots visible + tappable on touch even on small screens */
body.touch-device .weapon-slots { display: flex !important; flex-direction: column; align-items: center; gap: 5px; }
/* lift the vitals/ammo/slots clear of the control cluster */
body.touch-device .hud-bottom { padding: 14px 16px 120px; align-items: flex-start; }
body.touch-device .hud-center { align-items: flex-start; }
body.touch-device .hud-left, body.touch-device .hud-right { width: 116px; }
/* tappable weapon slots */
body.touch-device .wslot { pointer-events: auto; padding: 7px 11px; font-size: 13px; white-space: nowrap; }

.tc-stick { position: absolute; left: calc(26px + env(safe-area-inset-left)); bottom: calc(34px + env(safe-area-inset-bottom)); width: 150px; height: 150px;
  border-radius: 50%; border: 2px solid rgba(120,160,220,.35); background: rgba(8,12,20,.32);
  box-shadow: inset 0 0 22px rgba(58,160,255,.18); pointer-events: auto; touch-action: none;
  -webkit-user-select: none; user-select: none; }
.tc-knob { position: absolute; left: 50%; top: 50%; width: 62px; height: 62px; margin: -31px 0 0 -31px;
  border-radius: 50%; background: radial-gradient(circle at 40% 35%, rgba(122,200,255,.9), rgba(43,111,255,.7));
  border: 1px solid rgba(230,245,255,.5); box-shadow: 0 0 16px rgba(58,160,255,.55);
  transition: transform .04s linear; will-change: transform; }

.tc-right { position: absolute; right: calc(22px + env(safe-area-inset-right)); bottom: calc(30px + env(safe-area-inset-bottom)); width: 230px; height: 230px; pointer-events: none; }
.tc-btn { position: absolute; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-family: 'Orbitron', sans-serif; font-weight: 700; letter-spacing: .04em;
  color: var(--ink); background: rgba(8,12,20,.4); border: 2px solid rgba(120,160,220,.35);
  box-shadow: inset 0 0 18px rgba(58,160,255,.16); pointer-events: auto; touch-action: none;
  -webkit-user-select: none; user-select: none; backdrop-filter: blur(2px); }
.tc-btn:active, .tc-btn.tc-down { transform: scale(.93); border-color: var(--accent); box-shadow: 0 0 18px rgba(58,160,255,.5); }
.tc-fire { right: 0; bottom: 6px; width: 104px; height: 104px; font-size: 18px;
  border-color: rgba(255,120,90,.5); color: #ffd9cf; box-shadow: inset 0 0 22px rgba(255,90,60,.25); }
.tc-fire:active, .tc-fire.tc-down { border-color: var(--danger); box-shadow: 0 0 22px rgba(255,58,94,.6); }
.tc-cycle { right: 116px; bottom: 30px; width: 66px; height: 66px; font-size: 14px; }
.tc-use { right: 36px; bottom: 122px; width: 70px; height: 70px; font-size: 15px; color: var(--accent2); border-color: rgba(70,232,160,.45); }
.tc-dash { right: 132px; bottom: 108px; width: 64px; height: 64px; font-size: 13px; color: #ffd23a; border-color: rgba(255,210,58,.5); }
#tcJump { right: 132px; bottom: 180px; width: 64px; height: 64px; font-size: 13px; color: #b0e8ff; border-color: rgba(58,160,255,.5); }
.tc-pause { position: absolute; top: 14px; right: 16px; width: 48px; height: 48px; font-size: 18px; letter-spacing: 0; }

/* arcade-ui fullscreen button: push below the in-game pause button (48px + 14px top + 8px gap = 70px) */
.arcade-ui-fs { top: 70px !important; }

/* ---- landscape touch tuning ---- */
@media (orientation: landscape) {
  body.touch-device .hud-bottom { padding-bottom: 90px; }

  /* shrink joystick ~20% in landscape */
  .tc-stick { width: 120px; height: 120px; bottom: calc(20px + env(safe-area-inset-bottom)); }
  .tc-knob  { width: 50px; height: 50px; margin: -25px 0 0 -25px; }

  /* shrink right cluster ~17% and drop it a little */
  .tc-right { width: 192px; height: 192px; bottom: calc(16px + env(safe-area-inset-bottom)); }
  .tc-fire  { width: 88px; height: 88px; font-size: 16px; }
  .tc-cycle { width: 56px; height: 56px; font-size: 12px; right: 98px; bottom: 24px; }
  .tc-use   { width: 58px; height: 58px; font-size: 13px; right: 30px; bottom: 100px; }
  .tc-dash  { width: 54px; height: 54px; font-size: 11px; right: 110px; bottom: 90px; }
  #tcJump   { width: 54px; height: 54px; font-size: 11px; right: 110px; bottom: 150px; }
}
