/* KEY HUNTER — gaya tactical shooter: navy gelap, aksen merah, panel bersudut */

:root {
  --bg: #0f1923;
  --bg-deep: #080f16;
  --red: #ff4655;
  --teal: #00d9c0;
  --cream: #ece8e1;
  --dim: #7e8b96;
  --line: rgba(236, 232, 225, 0.14);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--cream);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

.stage {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

canvas#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* ---------- lapisan atmosfer ---------- */

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(65% 55% at 50% 50%, transparent 30%, rgba(4, 8, 12, 0.72) 100%),
    linear-gradient(180deg, rgba(4, 8, 12, 0.5) 0%, transparent 22%, transparent 78%, rgba(4, 8, 12, 0.6) 100%);
}

.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.7) 0 1px, transparent 1px 3px);
}

/* ---------- HUD ---------- */

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hud button { pointer-events: auto; }

.mm-frame {
  position: absolute;
  top: 18px;
  left: 18px;
  width: 150px;
  height: 150px;
  padding: 6px;
  background: rgba(9, 17, 24, 0.62);
  border: 1px solid var(--line);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%);
  backdrop-filter: blur(6px);
}

#minimap {
  width: 100%;
  height: 100%;
  display: block;
}

.mm-tag {
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 8px;
  color: var(--dim);
  letter-spacing: 0.24em;
}

.center-top {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.level-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  color: var(--dim);
  border-left: 2px solid var(--red);
  background: rgba(9, 17, 24, 0.5);
}

.level-chip b {
  font-size: 13px;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.objective {
  padding: 5px 14px;
  background: rgba(9, 17, 24, 0.66);
  border: 1px solid var(--line);
  color: var(--cream);
  font-size: 10px;
  letter-spacing: 0.2em;
  clip-path: polygon(8px 0, 100% 0, 100% 100%, 0 100%, 0 8px);
  transition: color 0.2s ease, border-color 0.2s ease;
}

.objective.open {
  color: var(--teal);
  border-color: rgba(0, 217, 192, 0.45);
}

.right-top {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: right;
}

.stat span { font-size: 8px; color: var(--dim); letter-spacing: 0.22em; }

.stat b {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.btns { display: flex; gap: 6px; }

button.ico {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  background: rgba(9, 17, 24, 0.62);
  color: var(--cream);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%);
  transition: border-color 0.15s ease, background 0.15s ease;
}

button.ico:hover { border-color: rgba(255, 70, 85, 0.6); background: rgba(255, 70, 85, 0.12); }

/* crosshair */

.crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  opacity: 0.85;
}

.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  background: rgba(236, 232, 225, 0.85);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
}

.crosshair::before { left: 50%; top: 0; width: 1px; height: 6px; transform: translateX(-50%); }
.crosshair::after { top: 50%; left: 0; height: 1px; width: 6px; transform: translateY(-50%); }

.crosshair span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--red);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 6px var(--red);
}

/* bottom bar */

.bottom-bar {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 16px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.keys { display: flex; gap: 10px; align-items: center; }

.key-slot {
  width: 15px;
  height: 15px;
  transform: rotate(45deg);
  border: 1px solid rgba(255, 70, 85, 0.55);
  background: rgba(255, 70, 85, 0.07);
  transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.key-slot.got {
  background: var(--red);
  border-color: #ff7a86;
  box-shadow: 0 0 14px rgba(255, 70, 85, 0.75);
}

.hint {
  font-size: 9px;
  color: rgba(126, 139, 150, 0.85);
  letter-spacing: 0.16em;
  text-align: right;
}

/* ---------- stick sentuh ---------- */

.stick {
  position: absolute;
  left: 24px;
  bottom: 62px;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: 1px solid rgba(236, 232, 225, 0.14);
  background: radial-gradient(circle, rgba(236, 232, 225, 0.05), rgba(236, 232, 225, 0.01));
  display: none;
  opacity: 0.5;
}

body.touch .stick { display: block; }

.knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  border: 1px solid rgba(255, 70, 85, 0.6);
  background: rgba(255, 70, 85, 0.16);
  box-shadow: 0 0 18px rgba(255, 70, 85, 0.2);
}

/* ---------- overlay ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 15, 22, 0.82);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.overlay.show { opacity: 1; pointer-events: auto; }

.panel {
  width: min(430px, 100%);
  padding: 26px 26px 22px;
  background: linear-gradient(160deg, rgba(20, 32, 42, 0.95), rgba(11, 20, 27, 0.97));
  border: 1px solid var(--line);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: rise 0.26s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.brandline {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--red);
  text-transform: uppercase;
  margin-bottom: 14px;
}

.brandline .sq {
  width: 7px;
  height: 7px;
  background: var(--red);
  transform: rotate(45deg);
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(32px, 10vw, 50px);
  line-height: 0.9;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1 em {
  font-style: normal;
  color: transparent;
  -webkit-text-stroke: 1.5px rgba(236, 232, 225, 0.5);
}

.lede {
  margin: 0 0 20px;
  font-size: 12.5px;
  line-height: 1.65;
  letter-spacing: 0.01em;
  text-transform: none;
  color: #a7b4be;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.metric {
  padding: 10px 12px;
  border-left: 2px solid rgba(255, 70, 85, 0.5);
  background: rgba(236, 232, 225, 0.03);
}

.metric span {
  display: block;
  font-size: 8px;
  letter-spacing: 0.24em;
  color: var(--dim);
  margin-bottom: 4px;
}

.metric b {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.02em;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 18px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--cream);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn.primary {
  background: var(--red);
  color: #14060a;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%);
}

.btn.primary:hover { filter: brightness(1.12); }

.btn.primary::after { content: "\2192"; font-size: 15px; }

.btn.ghost {
  margin-top: 8px;
  border-color: var(--line);
  color: #b9c4cc;
  clip-path: none;
}

.btn.ghost:hover { border-color: rgba(255, 70, 85, 0.5); color: var(--cream); }

.controls {
  margin-top: 18px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 14px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: none;
  color: var(--dim);
}

.controls b {
  color: var(--cream);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid rgba(236, 232, 225, 0.22);
  background: rgba(236, 232, 225, 0.06);
  color: var(--cream);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9.5px;
}

.big {
  font-size: clamp(44px, 13vw, 64px);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: -0.02em;
}

.big small { font-size: 0.4em; color: var(--dim); letter-spacing: 0.1em; }

.subline {
  margin: 8px 0 20px;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--dim);
  text-transform: uppercase;
}

.badge {
  display: inline-block;
  margin-bottom: 10px;
  padding: 4px 10px;
  background: rgba(255, 70, 85, 0.14);
  border-left: 2px solid var(--red);
  color: #ff8a94;
  font-size: 9px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.row2 { display: flex; gap: 8px; margin-top: 8px; }
.row2 .btn { margin-top: 0; justify-content: center; }

/* ---------- indikator bahaya ---------- */

.danger {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  background: radial-gradient(72% 62% at 50% 50%, transparent 56%, rgba(255, 70, 85, 0.22) 100%);
  box-shadow: inset 0 0 90px rgba(255, 70, 85, 0.16);
}

/* ---------- mode hantu ---------- */

.ghost-veil {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  background:
    radial-gradient(75% 65% at 50% 50%, rgba(120, 235, 255, 0.04) 0%, rgba(30, 110, 160, 0.20) 100%),
    linear-gradient(180deg, rgba(80, 200, 255, 0.05), rgba(20, 60, 90, 0.10));
  mix-blend-mode: screen;
}

body.ghost .ghost-veil { opacity: 1; }

button.ico.on {
  border-color: rgba(0, 217, 192, 0.7);
  background: rgba(0, 217, 192, 0.18);
  color: #bff8ef;
}

/* ---------- amunisi ---------- */

.ammo {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 10px;
  border-right: 2px solid var(--red);
  background: rgba(9, 17, 24, 0.55);
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 10px);
  pointer-events: auto;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.ammo-bar {
  width: 76px;
  height: 4px;
  background: rgba(236, 232, 225, 0.18);
  overflow: hidden;
}

.ammo-bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--cream);
  transition: width 0.07s linear;
}

.ammo.reloading .ammo-bar i { background: var(--gold); }
.ammo.empty .ammo-bar i { background: var(--red); }

.ammo-num { display: flex; align-items: baseline; gap: 4px; }

.ammo-num b {
  font-size: 22px;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.ammo-num span { font-size: 10px; color: var(--dim); }

.ammo-tag { font-size: 8px; letter-spacing: 0.2em; color: var(--dim); }

.ammo.reloading { border-right-color: var(--gold); }
.ammo.reloading .ammo-tag { color: var(--gold); }
.ammo.empty .ammo-num b { color: var(--red); }

/* ---------- tombol tembak (sentuh) ---------- */

.fire-btn {
  position: absolute;
  right: 22px;
  bottom: 92px;
  z-index: 4;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1px solid rgba(255, 70, 85, 0.45);
  background: rgba(255, 70, 85, 0.14);
  color: #ffb3ba;
  font-size: 22px;
  display: none;
  touch-action: none;
}

body.touch .fire-btn { display: block; }
.fire-btn:active { background: rgba(255, 70, 85, 0.32); }

/* crosshair saat kena */

.crosshair { transition: transform 0.08s ease; }

.crosshair.hit { transform: translate(-50%, -50%) scale(1.45); }

.crosshair.hit::before,
.crosshair.hit::after { background: var(--red); }

@media (max-width: 560px) {
  .mm-frame { width: 96px; height: 96px; top: 12px; left: 12px; padding: 5px; }
  .mm-tag { font-size: 7px; bottom: 2px; right: 5px; }
  .right-top { top: 12px; right: 12px; gap: 8px; }
  .stat.best { display: none; }
  .stat b { font-size: 13px; }
  .stat span { font-size: 7px; }
  .right-top button.ico { width: 26px; height: 26px; font-size: 11px; }
  .center-top { top: 10px; gap: 6px; }
  .level-chip { padding: 3px 8px; }
  .level-chip b { font-size: 11px; }
  .level-chip span { font-size: 8px; }
  .objective { font-size: 8px; padding: 3px 9px; letter-spacing: 0.14em; }
  .bottom-bar { left: 12px; right: 12px; bottom: 12px; }
  .hint { display: none; }
  .ammo { gap: 7px; padding: 5px 9px; }
  .ammo-tag { display: none; }
  .ammo-num b { font-size: 18px; }
  .fire-btn { right: 16px; bottom: 76px; width: 64px; height: 64px; }
  .stick { left: 18px; bottom: 54px; width: 104px; height: 104px; }
  .knob { width: 40px; height: 40px; margin: -20px 0 0 -20px; }
}

@media (max-height: 460px) {
  .mm-frame { width: 84px; height: 84px; }
  .controls { display: none; }
}
