/* Houbobraní HUD. The 3D canvas lives in #stage; #hud is a transparent overlay
   above it that lets pointer events fall through to the canvas (for camera drag)
   except on its own interactive controls. All colours are baked here — no theme
   system, no external fonts — to stay inside the strict CSP (script/style 'self'). */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #87ceeb;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#stage {
  position: fixed;
  inset: 0;
}

#stage canvas {
  display: block;
}

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

.hidden {
  display: none !important;
}

/* Anything interactive re-enables pointer events (the layer itself is pass-through). */
.icon-btn,
.legend-btn,
.legend-panel,
.shop-overlay,
.pick-btn,
.stick {
  pointer-events: auto;
}

/* ---- top-left cluster ---- */
.top-left {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.stat-panel {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  border-radius: 14px;
  padding: 6px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.coin-value {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.1;
}

.collected-value {
  font-size: 0.8rem;
  opacity: 0.7;
}

.icon-btn {
  border: 0;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 0 12px;
  cursor: pointer;
  color: #fff;
  background: rgba(55, 65, 81, 0.9);
}

.shop-btn {
  background: #eab308;
  color: #000;
  font-size: 1.3rem;
}

.legend-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  border: 0;
  border-radius: 14px;
  padding: 8px 12px;
  font-size: 1.1rem;
  cursor: pointer;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

/* ---- perk badges ---- */
.badge-row {
  position: absolute;
  top: 78px;
  left: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 132px;
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  color: #fff;
}

.badge-speed { background: rgba(37, 99, 235, 0.85); }
.badge-autoPick { background: rgba(147, 51, 234, 0.85); }
.badge-pickRange { background: rgba(22, 163, 74, 0.85); }
.badge-luck { background: rgba(202, 138, 4, 0.85); color: #000; }
.badge-poisonResist { background: rgba(220, 38, 38, 0.85); }
.badge-tripBoost { background: rgba(219, 39, 119, 0.85); }
.badge-magnet { background: rgba(8, 145, 178, 0.85); }
.badge-doubleCoins { background: rgba(234, 179, 8, 0.9); color: #000; }

/* ---- toast ---- */
.toast {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  padding: 8px 20px;
  border-radius: 9999px;
  font-size: 1.05rem;
  font-weight: 800;
  white-space: nowrap;
  z-index: 20;
}

/* ---- legend ---- */
.legend-panel {
  position: absolute;
  top: 56px;
  right: 12px;
  width: 196px;
  max-height: 70vh;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(4px);
  border-radius: 14px;
  padding: 14px;
  font-size: 0.78rem;
  z-index: 30;
  pointer-events: auto;
}

.legend-title {
  font-weight: 800;
  color: #facc15;
  margin-bottom: 6px;
}

.legend-head {
  font-weight: 800;
  margin-top: 6px;
}

.legend-row {
  line-height: 1.5;
}

.g-edible { color: #4ade80; }
.g-rare { color: #60a5fa; }
.g-legendary { color: #facc15; }
.g-poison { color: #f87171; }

.legend-foot {
  margin-top: 8px;
  opacity: 0.6;
}

/* ---- shop ---- */
.shop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.shop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #111827;
}

.shop-h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: #facc15;
}

.shop-coins {
  font-size: 1.1rem;
  font-weight: 800;
  color: #facc15;
  margin-left: auto;
  margin-right: 8px;
}

.shop-close {
  border: 0;
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  background: #dc2626;
  cursor: pointer;
}

.shop-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.shop-list {
  max-width: 384px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.perk-card {
  background: #1f2937;
  border-radius: 14px;
  padding: 12px;
}

.perk-max {
  background: rgba(20, 83, 45, 0.5);
}

.perk-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.perk-name {
  font-weight: 800;
}

.perk-desc {
  font-size: 0.8rem;
  opacity: 0.6;
  text-align: right;
}

.perk-dots {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}

.dot {
  height: 8px;
  flex: 1;
  border-radius: 4px;
  background: #4b5563;
}

.dot-on {
  background: #22c55e;
}

.perk-maxed {
  text-align: center;
  color: #4ade80;
  font-weight: 800;
  font-size: 0.85rem;
}

.buy-btn {
  width: 100%;
  border: 0;
  padding: 10px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
}

.buy-on {
  background: #eab308;
  color: #000;
}

.buy-off {
  background: #4b5563;
  color: #9ca3af;
  cursor: not-allowed;
}

.reset-btn {
  display: block;
  margin: 20px auto 8px;
  border: 1px solid rgba(248, 113, 113, 0.5);
  background: transparent;
  color: #f87171;
  border-radius: 10px;
  padding: 8px 18px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.reset-btn:hover {
  background: rgba(248, 113, 113, 0.12);
}

/* ---- pick prompt ---- */
.pick-wrap {
  position: absolute;
  bottom: 160px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
}

.pick-btn {
  border: 0;
  font-weight: 800;
  font-size: 1.05rem;
  padding: 12px 24px;
  border-radius: 9999px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  white-space: nowrap;
}

.pick-good { background: #22c55e; color: #fff; }
.pick-poison { background: #ef4444; color: #fff; }
.pick-legendary { background: #facc15; color: #000; }

.key-hint {
  opacity: 0.6;
}

/* ---- combo streak pill ---- */
.streak {
  position: absolute;
  top: 106px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #f97316, #ef4444);
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 5px 14px;
  border-radius: 9999px;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.5);
  z-index: 22;
  white-space: nowrap;
}

.streak.bump {
  animation: streak-bump 0.3s ease-out;
}

@keyframes streak-bump {
  0% { transform: translateX(-50%) scale(1); }
  40% { transform: translateX(-50%) scale(1.18); }
  100% { transform: translateX(-50%) scale(1); }
}

/* ---- rare compass ---- */
.compass {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  border-radius: 9999px;
  padding: 5px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 18;
  white-space: nowrap;
}

.compass-arrow {
  display: inline-block;
  color: #fcd34d;
  font-size: 1rem;
  line-height: 1;
  will-change: transform;
}

.compass-label {
  opacity: 0.95;
}

/* ---- legend collection counts ---- */
.legend-count {
  color: #fcd34d;
  font-weight: 700;
}

.legend-count-zero {
  color: #6b7280;
  font-weight: 400;
}

/* ---- floating coin popups ---- */
.pop-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 25;
  overflow: hidden;
}

.pop {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: 1.1rem;
  white-space: nowrap;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  animation: pop-rise 1s ease-out forwards;
  will-change: transform, opacity;
}

.pop-good { color: #fde047; }
.pop-rare { color: #93c5fd; font-size: 1.25rem; }
.pop-legendary { color: #fcd34d; font-size: 1.5rem; }
.pop-poison { color: #fca5a5; }

@keyframes pop-rise {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(1); }
}

/* ---- touch joysticks ---- */
.stick {
  position: absolute;
  bottom: 24px;
  width: 112px;
  height: 112px;
  border-radius: 9999px;
  border: 4px solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  touch-action: none;
}

.stick-left { left: 24px; }
.stick-right { right: 24px; }

.knob {
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* ---- keyboard hint ---- */
.kb-hint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  border-radius: 14px;
  padding: 8px 16px;
  font-size: 0.85rem;
  z-index: 20;
}

.kb-hint span {
  opacity: 0.7;
}

/* ---- trip mode ---- */
body.trip .stat-panel,
body.trip .legend-btn {
  animation: trip-pulse 1s ease-in-out infinite;
}

body.trip .toast {
  animation: trip-bounce 0.8s ease-in-out infinite;
}

body.trip .stick {
  border-color: rgba(244, 114, 182, 0.6);
}

body.trip .knob {
  background: linear-gradient(90deg, #f472b6, #22d3ee);
}

@keyframes trip-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes trip-bounce {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -8px); }
}
