/* ==========================================================
   1. CORE RESET & THEME TOKENS
   ========================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang TC", "Microsoft JhengHei", sans-serif;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #03080d;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* 2D Top-Down Canopy Forest Background */
#svg-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* 3D WebGL Canvas */
#webgl-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  touch-action: none;
}

/* UI Layer */
.ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 14px;
}

.interactive {
  pointer-events: auto;
}

/* Floating Glassmorphic UI Card (Night Forest Tint) */
.glass-panel {
  background: rgba(14, 26, 23, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 2px solid rgba(120, 200, 160, 0.35);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), inset 0 1px 3px rgba(255, 255, 255, 0.2);
  color: #e0f2f1;
}

/* Top HUD */
.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 1050px;
  margin: 0 auto;
}

.stat-cluster {
  display: flex;
  gap: 6px;
  align-items: center;
}

.stat-pill {
  padding: 5px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
}

.stat-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #80cbc4;
}

.stat-val {
  font-size: 15px;
  font-weight: 900;
  color: #ffffff;
}

.stat-val-sub {
  font-size: 10px;
  font-weight: 700;
  color: #a7ffeb;
}

/* Action Buttons (SVG inside, No Emojis) */
.btn-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease;
  border: none;
  outline: none;
  color: #e0f2f1;
}

.btn-circle svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.btn-circle:active {
  transform: scale(0.90);
}

/* Mid Screen Rotation Controls */
.rotation-controls {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 16px;
  transform: translateY(-50%);
  pointer-events: none;
}

.btn-orbit {
  width: 48px;
  height: 48px;
  font-size: 20px;
  font-weight: bold;
  color: #e0f2f1;
  background: rgba(14, 26, 23, 0.85);
}

/* Right-Side "Tool vs Cube" Dynamic Card */
#tool-guide-card {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%) translateX(280px);
  width: 215px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  z-index: 15;
}

#tool-guide-card.visible {
  transform: translateY(-50%) translateX(0);
}

#tool-guide-card.collapsed {
  transform: translateY(-50%) translateX(calc(100% - 26px));
}

.guide-toggle-tab {
  position: absolute;
  left: -22px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 44px;
  background: rgba(14, 26, 23, 0.95);
  border: 2px solid rgba(120, 200, 160, 0.4);
  border-right: none;
  border-radius: 10px 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #a7ffeb;
  font-size: 13px;
  font-weight: 900;
  box-shadow: -4px 4px 12px rgba(0, 0, 0, 0.45);
}

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

.guide-tool-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(0, 77, 64, 0.45);
  border: 1px solid rgba(128, 203, 196, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.guide-tool-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.guide-vs-badge {
  font-size: 10px;
  font-weight: 900;
  background: #00897b;
  color: #fff;
  padding: 2px 6px;
  border-radius: 6px;
  align-self: center;
}

.guide-target-box {
  border: 1px dashed rgba(128, 203, 196, 0.4);
  border-radius: 10px;
  padding: 8px;
  background: rgba(10, 22, 18, 0.5);
}

.guide-tip-text {
  font-size: 10.5px;
  line-height: 1.35;
  color: #b2dfdb;
  font-weight: 600;
}

/* -30% Compact Bottom Backpack Hotbar */
.hud-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 0 auto;
  margin-bottom: 4px;
}

.backpack-bar {
  display: flex;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
}

.tool-slot {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(14, 28, 24, 0.7);
  border: 2px solid rgba(120, 200, 160, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.tool-slot:hover {
  transform: translateY(-2px);
}

.tool-slot.active {
  background: rgba(0, 137, 123, 0.55);
  border-color: #64ffda;
  box-shadow: 0 0 16px rgba(100, 255, 218, 0.6);
  transform: scale(1.08) translateY(-3px);
}

.tool-slot.pulse-highlight {
  animation: pulseGlow 0.8s infinite alternate ease-in-out;
}

@keyframes pulseGlow {
  from { box-shadow: 0 0 6px rgba(255, 23, 68, 0.6); transform: scale(1.0); }
  to { box-shadow: 0 0 18px rgba(255, 23, 68, 1.0); transform: scale(1.12); }
}

.tool-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.tool-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.tool-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: #e65100;
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

/* Overlays / Modals */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 9, 15, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 1;
  transition: opacity 0.4s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  padding: 26px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: popIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-title {
  font-size: 26px;
  font-weight: 900;
  color: #64ffda;
  line-height: 1.2;
}

.modal-title.defeat {
  color: #ff5252;
}

.modal-subtitle {
  font-size: 13px;
  color: #b2dfdb;
  font-weight: 500;
}

.btn-main {
  padding: 11px 22px;
  font-size: 16px;
  font-weight: 800;
  border-radius: 24px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #00bfa5, #00897b);
  color: white;
  box-shadow: 0 8px 18px rgba(0, 191, 165, 0.35);
  transition: transform 0.15s ease;
}

.btn-main.defeat {
  background: linear-gradient(135deg, #e53935, #c62828);
  box-shadow: 0 8px 18px rgba(229, 57, 53, 0.4);
}

.btn-main:active {
  transform: scale(0.95);
}

.btn-secondary {
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: 24px;
  border: 2px solid #80cbc4;
  background: transparent;
  color: #e0f2f1;
  cursor: pointer;
}

/* Idle Hint Bubble Anchor */
#idle-hint-tag {
  position: absolute;
  z-index: 25;
  pointer-events: none;
  transform: translate(-50%, -100%);
  transition: opacity 0.35s ease;
  opacity: 0;
  display: none;
}

.hint-bubble {
  background: #ff3d00;
  color: #fff;
  font-weight: 900;
  font-size: 12px;
  padding: 6px 13px;
  border-radius: 16px;
  box-shadow: 0 6px 14px rgba(255, 61, 0, 0.5);
  white-space: nowrap;
  animation: floatBob 0.8s infinite alternate ease-in-out;
}

@keyframes floatBob {
  from { transform: translateY(0); }
  to { transform: translateY(-7px); }
}

/* SVG Vector Star Display */
.star-rating {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.star-icon {
  width: 30px;
  height: 30px;
  fill: #ffd54f;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.star-icon.dim {
  fill: #546e7a;
  opacity: 0.45;
}

@media (max-width: 600px) {
  .stat-pill { min-width: 58px; padding: 4px 6px; }
  .stat-val { font-size: 13px; }
  .stat-label { font-size: 8px; }
  .btn-circle { width: 36px; height: 36px; }
  .tool-slot { width: 40px; height: 40px; }
  .tool-icon { width: 28px; height: 28px; }
  .btn-orbit { width: 42px; height: 42px; font-size: 16px; }
  #tool-guide-card { width: 175px; right: 4px; padding: 10px; }
}