* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1c1c22;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #e6e6e8;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* Desktop: hide cursor over game; mobile keeps default for UI taps */
body.desktop-cursor {
  cursor: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

#top-left {
  position: absolute;
  top: 22px;
  left: 24px;
}

.district {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.35em;
  color: #c8c8cc;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.coords {
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: #7a7a80;
  font-variant-numeric: tabular-nums;
}

.hunt-stat {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #7ef0c8;
  text-shadow: 0 0 10px rgba(80, 255, 200, 0.55), 0 1px 2px rgba(0, 0, 0, 0.7);
  font-variant-numeric: tabular-nums;
}

#hunt-progress {
  color: #c8c4ff;
  text-shadow: 0 0 10px rgba(160, 140, 255, 0.45), 0 1px 2px rgba(0, 0, 0, 0.7);
}

.chip-timer {
  color: #ffe08a !important;
  border-color: rgba(255, 200, 80, 0.35) !important;
  letter-spacing: 0.2em;
  font-variant-numeric: tabular-nums;
}

.chip-timer.urgent {
  color: #ff6b7a !important;
  border-color: rgba(255, 80, 100, 0.5) !important;
  animation: timerPulse 0.8s ease-in-out infinite alternate;
}

@keyframes timerPulse {
  from { box-shadow: 0 0 8px rgba(255, 60, 80, 0.25); }
  to { box-shadow: 0 0 16px rgba(255, 60, 80, 0.55); }
}

#collect-prompt {
  position: absolute;
  top: 58%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #f0f0f4;
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(16, 16, 20, 0.78);
  border-radius: 3px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

#collect-prompt.hidden {
  display: none;
}

#cash-popup {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.08em;
  pointer-events: none;
  text-shadow: 0 0 16px currentColor, 0 2px 6px rgba(0, 0, 0, 0.7);
  animation: cashFloat 0.9s ease-out forwards;
}

#cash-popup.gain {
  color: #6fffc0;
}

#cash-popup.loss {
  color: #ff6b7c;
}

#cash-popup.hidden {
  display: none;
}

@keyframes cashFloat {
  0% { opacity: 0; transform: translateX(-50%) translateY(8px) scale(0.9); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.05); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-28px) scale(1); }
}

.controls .hunt-rules {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.35;
  color: #8a8a94;
  max-width: 280px;
}

.hunt-final {
  font-size: 13px;
  color: #a8a8ae;
  margin-bottom: 6px;
}

.hunt-final strong {
  color: #7ef0c8;
  font-size: 1.15em;
}

#hunt-overlay {
  position: fixed;
  inset: 0;
  z-index: 22;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 12px;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  background: rgba(10, 10, 12, 0.9);
  backdrop-filter: blur(10px);
  cursor: default;
  pointer-events: auto;
}

#hunt-overlay.hidden {
  display: none;
}

#top-right {
  position: absolute;
  top: 22px;
  right: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.chip {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(28, 28, 32, 0.75);
  color: #b8b8be;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

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

#crosshair .ring {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(200, 200, 205, 0.55);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
}

#crosshair .dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 3px;
  margin: -1.5px 0 0 -1.5px;
  border-radius: 50%;
  background: #d8d8dc;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.35);
}

#bottom-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 18px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #6e6e74;
  opacity: 0.9;
}

#bottom-hint kbd {
  display: inline-block;
  padding: 2px 6px;
  margin-right: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  background: rgba(32, 32, 36, 0.75);
  color: #b0b0b6;
  font-size: 10px;
  font-family: inherit;
}

#vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.28) 100%);
  pointer-events: none;
}

#scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  opacity: 0.4;
}

#overlay, #pause-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Keep visible margin so panel top/bottom never sit flush with the viewport */
  padding: 20px 12px;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(10, 10, 12, 0.88);
  backdrop-filter: blur(10px);
  cursor: default;
  pointer-events: auto;
}

#overlay.hidden, #pause-overlay.hidden {
  display: none;
}

.panel {
  text-align: center;
  max-width: 420px;
  width: min(420px, calc(100vw - 28px));
  /* margin:auto keeps the panel centered; with overlay padding, top/bottom stay visible */
  margin: auto;
  flex-shrink: 0;
  padding: 22px 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(165deg, rgba(28, 28, 32, 0.97), rgba(18, 18, 20, 0.98));
  box-shadow:
    0 12px 48px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  border-radius: 4px;
}

/* Landing art — fixed height so panel width/controls stay stable */
.panel-art {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100px;
  object-fit: cover;
  object-position: center 45%;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  margin: 0 0 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 0.35em;
  color: #8a8a90;
  margin-bottom: 8px;
  text-shadow: none;
}

.panel h1 {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.1;
  color: #ececee;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
  margin-bottom: 8px;
}

.panel h2 {
  font-size: 26px;
  letter-spacing: 0.2em;
  color: #e0e0e4;
  margin-bottom: 16px;
  text-shadow: none;
}

.tagline {
  font-size: 13px;
  line-height: 1.4;
  color: #9a9aa0;
  margin-bottom: 6px;
}

.byline {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: #b0b0b6;
  margin-bottom: 12px;
  text-shadow: none;
}

.also {
  margin-top: 10px;
  font-size: 12px;
}

.also a {
  color: #b8b8be;
  text-decoration: none;
  letter-spacing: 0.06em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.also a:hover {
  color: #f0f0f2;
  border-bottom-color: #f0f0f2;
}

.controls {
  list-style: none;
  text-align: left;
  display: inline-block;
  margin-bottom: 14px;
  color: #a8a8ae;
  font-size: 12px;
}

.controls li {
  margin: 5px 0;
}

.controls kbd {
  display: inline-block;
  min-width: 22px;
  padding: 3px 7px;
  margin-right: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  background: rgba(40, 40, 44, 0.9);
  color: #d0d0d4;
  font-size: 11px;
  font-family: inherit;
  text-align: center;
}

.btn-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

button {
  display: inline-block;
  padding: 12px 28px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(180deg, #3a3a40, #2a2a2e);
  color: #f2f2f4;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.2em;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  border-radius: 2px;
  min-width: 220px;
}

button:hover {
  background: linear-gradient(180deg, #4a4a52, #34343a);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.5);
  transform: scale(1.02);
}

button.btn-secondary {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.18);
  color: #c0c0c6;
  font-weight: 700;
  letter-spacing: 0.14em;
  box-shadow: none;
}

/* Menu music toggle sits under Enter */
#overlay #mute-btn {
  margin-top: 10px;
}

button.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.3);
  color: #f0f0f2;
  box-shadow: none;
}

a.btn-donate {
  display: inline-block;
  margin-top: 8px;
  padding: 10px 24px;
  border: 1px solid rgba(255, 196, 80, 0.45);
  background: linear-gradient(180deg, rgba(80, 58, 20, 0.85), rgba(48, 36, 12, 0.9));
  color: #f5e6c0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  border-radius: 2px;
  min-width: 220px;
}

a.btn-donate:hover {
  background: linear-gradient(180deg, rgba(100, 72, 24, 0.95), rgba(60, 44, 14, 0.95));
  border-color: rgba(255, 210, 100, 0.7);
  color: #fff6dc;
  box-shadow: 0 6px 24px rgba(180, 120, 20, 0.25);
  transform: scale(1.02);
}

.btn-row a.btn-donate {
  margin-top: 0;
}

.hint {
  margin-top: 10px;
  font-size: 11px;
  color: #6a6a70;
  letter-spacing: 0.06em;
}

/* Desktop vs mobile helper classes (toggled by JS) */
body.is-mobile .desktop-only { display: none !important; }
body:not(.is-mobile) .mobile-only { display: none !important; }

/* ─── Mobile touch UI ─────────────────────────────────────────────────────── */
#touch-ui {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
}

#touch-ui.hidden {
  display: none;
}

#joy-zone {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(20px, env(safe-area-inset-bottom));
  width: 140px;
  height: 140px;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

#joy-base {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: rgba(20, 20, 24, 0.45);
  position: relative;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.35);
}

#joy-stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(230, 230, 236, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  will-change: transform;
}

.touch-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: rgba(200, 200, 210, 0.75);
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

#look-hint {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(160px, calc(env(safe-area-inset-bottom) + 140px));
  text-align: right;
  max-width: 120px;
  line-height: 1.35;
  pointer-events: none;
  opacity: 0.7;
}

#touch-actions {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto;
}

.touch-btn {
  min-width: 88px !important;
  width: 88px;
  height: 88px;
  padding: 0 !important;
  border-radius: 50% !important;
  font-size: 11px !important;
  letter-spacing: 0.1em !important;
  background: rgba(30, 30, 36, 0.55) !important;
  border: 2px solid rgba(255, 255, 255, 0.25) !important;
  color: #eeeef2 !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35) !important;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.touch-btn:active,
.touch-btn.active {
  background: rgba(80, 80, 90, 0.75) !important;
  border-color: rgba(255, 255, 255, 0.45) !important;
  transform: scale(0.96);
}

/* Pause FAB sits under HUD chips; clickable even when body cursor is hidden */
#top-right .fab {
  cursor: pointer;
  z-index: 12;
}

.fab {
  pointer-events: auto;
  min-width: 44px !important;
  width: 44px;
  height: 44px;
  padding: 0 !important;
  border-radius: 10px !important;
  font-size: 12px !important;
  letter-spacing: 0 !important;
  line-height: 44px;
  text-align: center;
  background: rgba(28, 28, 32, 0.75) !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  color: #ddd !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35) !important;
  margin-top: 8px;
  align-self: flex-end;
}

.fab.hidden {
  display: none !important;
}

#top-right {
  align-items: flex-end;
}

/* Mobile panel / layout tweaks */
@media (max-width: 700px), (pointer: coarse) {
  #overlay, #pause-overlay {
    padding: 16px 10px;
  }

  .panel {
    max-width: min(420px, calc(100vw - 28px));
    width: min(420px, calc(100vw - 28px));
    padding: 18px 18px;
    margin: auto;
  }

  .panel-art {
    height: 88px;
    margin-bottom: 10px;
  }

  .panel h1 {
    font-size: 28px;
    letter-spacing: 0.08em;
  }

  .tagline {
    font-size: 12px;
  }

  .controls {
    margin-bottom: 12px;
  }

  #top-left {
    top: max(12px, env(safe-area-inset-top));
    left: 12px;
  }

  #top-right {
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
  }

  .district {
    font-size: 11px;
    letter-spacing: 0.2em;
  }

  .chip {
    font-size: 10px;
    padding: 5px 8px;
  }

  #crosshair {
    opacity: 0.45;
  }

  button {
    min-width: min(220px, 70vw);
    padding: 16px 24px;
  }

  a.btn-donate {
    min-width: min(220px, 70vw);
    padding: 12px 20px;
  }

  #overlay, #pause-overlay {
    touch-action: pan-y;
  }

  #overlay .panel,
  #pause-overlay .panel {
    touch-action: pan-y;
  }
}
