/* ============================================================================
   FROSTY SWIRL & THE CRAZY WEASEL - 3D WebGL Stylized Village Simulation
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=JetBrains+Mono:wght@500;700&family=Nunito:wght@600;700;800&display=swap');

:root {
  --bg-glass: rgba(18, 23, 42, 0.72);
  --bg-glass-light: rgba(255, 252, 245, 0.88);
  --border-glass: rgba(255, 255, 255, 0.22);
  --accent-pink: #ff5e97;
  --accent-mint: #2ee5b5;
  --accent-gold: #ffca3a;
  --accent-orange: #ff7f32;
  --accent-purple: #9b5de5;
  --text-light: #fffdf9;
  --text-muted: rgba(255, 253, 249, 0.75);
  --shadow-soft: 0 10px 30px rgba(8, 12, 28, 0.38);
  --shadow-pop: 0 4px 0 rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1f35;
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-light);
}

#canvas-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  cursor: grab;
}

#canvas-container:active {
  cursor: grabbing;
}

/* ----------------------------------------------------------------------------
   3D World Floating Speech / Emote Bubble for the Weasel & Van
   ---------------------------------------------------------------------------- */
#world-labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}

.speech-bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  background: #fffef8;
  color: #231942;
  font-family: 'Fredoka', cursive, sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 6px 13px;
  border-radius: 18px;
  border: 3px solid #231942;
  box-shadow: 0 4px 0 #231942, 0 8px 18px rgba(0,0,0,0.25);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.speech-bubble.visible {
  opacity: 1;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 9px 7px 0;
  border-style: solid;
  border-color: #231942 transparent;
  display: block;
  width: 0;
}

.speech-bubble.weasel-bubble {
  background: #fff3b0;
  color: #5f0f40;
  border-color: #5f0f40;
  box-shadow: 0 4px 0 #5f0f40, 0 8px 18px rgba(0,0,0,0.25);
}

.speech-bubble.weasel-bubble::after {
  border-color: #5f0f40 transparent;
}

/* ----------------------------------------------------------------------------
   HUD Layout Overlay
   ---------------------------------------------------------------------------- */
#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 22px;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.hud-row.bottom {
  align-items: flex-end;
}

.panel {
  pointer-events: auto;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid var(--border-glass);
  border-radius: 20px;
  padding: 14px 18px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.panel:hover {
  border-color: rgba(255, 255, 255, 0.36);
}

/* ----------------------------------------------------------------------------
   Top-Left Title & Stats Badge
   ---------------------------------------------------------------------------- */
.brand-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 390px;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-gold));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.65rem;
  box-shadow: 0 4px 12px rgba(255, 94, 151, 0.45);
  flex-shrink: 0;
  animation: bobble 2.6s ease-in-out infinite;
}

@keyframes bobble {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-4px) rotate(5deg); }
}

.title-text h1 {
  font-family: 'Fredoka', cursive, sans-serif;
  font-size: 1.32rem;
  line-height: 1.1;
  letter-spacing: 0.3px;
  background: linear-gradient(90deg, #ffffff, #ffe6a7, #ff9ebb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.title-text p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.stat-item {
  background: rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 6px 10px;
  text-align: center;
}

.stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  display: block;
}

.stat-value {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--accent-gold);
}

.stat-value.mint {
  color: var(--accent-mint);
}

.stat-value.pink {
  color: var(--accent-pink);
}

/* Madness Meter Bar */
.madness-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.74rem;
}

.madness-label {
  font-weight: 800;
  color: #ffadad;
  white-space: nowrap;
}

.madness-track {
  flex: 1;
  height: 9px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.16);
}

.madness-fill {
  height: 100%;
  width: 68%;
  background: linear-gradient(90deg, #2ee5b5, #ffca3a, #ff5e97, #ff2a55);
  border-radius: 99px;
  transition: width 0.25s ease;
}

.weasel-state-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(255, 94, 151, 0.25);
  border: 1px solid var(--accent-pink);
  color: #ffc2d9;
}

/* ----------------------------------------------------------------------------
   Top-Right Chiptune Music Synthesizer Deck
   ---------------------------------------------------------------------------- */
.music-panel {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 290px;
}

.music-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.music-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--accent-purple);
  color: #fff;
  padding: 3px 7px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.track-name {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.92rem;
  color: #fff;
}

/* 4-Channel Chiptune Visualizer Bars */
.visualizer-box {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: rgba(8, 11, 22, 0.55);
  padding: 7px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
}

.chan-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.chan-bar-wrap {
  width: 100%;
  height: 28px;
  background: rgba(255,255,255,0.06);
  border-radius: 5px;
  display: flex;
  align-items: flex-end;
  padding: 2px;
  overflow: hidden;
}

.chan-bar {
  width: 100%;
  height: 15%;
  border-radius: 3px;
  transition: height 0.06s linear;
}

.chan-bar.lead  { background: linear-gradient(to top, #ff5e97, #ff9ebb); }
.chan-bar.arp   { background: linear-gradient(to top, #2ee5b5, #9bf6ff); }
.chan-bar.bass  { background: linear-gradient(to top, #ffca3a, #ffe6a7); }
.chan-bar.drums { background: linear-gradient(to top, #9b5de5, #d0bfff); }

.chan-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.58rem;
  color: var(--text-muted);
}

.music-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ----------------------------------------------------------------------------
   Buttons & Interactive Controls
   ---------------------------------------------------------------------------- */
.btn {
  appearance: none;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-light);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 7px 12px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-pop);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.28);
}

.btn.active {
  background: linear-gradient(135deg, var(--accent-mint), #17b890);
  color: #09231c;
  border-color: #9bf6ff;
}

.btn.pink {
  background: linear-gradient(135deg, var(--accent-pink), #e03172);
  border-color: #ff9ebb;
}

.btn.gold {
  background: linear-gradient(135deg, var(--accent-gold), #f48c06);
  color: #2b1800;
  border-color: #ffe6a7;
}

.btn.purple {
  background: linear-gradient(135deg, var(--accent-purple), #6930c3);
  border-color: #d0bfff;
}

.btn-sm {
  padding: 5px 9px;
  font-size: 0.74rem;
  border-radius: 9px;
}

/* ----------------------------------------------------------------------------
   Bottom Action Bar & Camera / Mood Selectors
   ---------------------------------------------------------------------------- */
.action-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-heading {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-muted);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-group {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.key-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  background: rgba(0, 0, 0, 0.32);
  color: rgba(255, 255, 255, 0.85);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ----------------------------------------------------------------------------
   Audio Start Prompt Pill (Auto-hides once AudioContext runs)
   ---------------------------------------------------------------------------- */
#audio-unlock-banner {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: linear-gradient(135deg, #ff5e97, #ff9f1c);
  color: #fff;
  font-family: 'Fredoka', sans-serif;
  font-size: 0.95rem;
  padding: 10px 20px;
  border-radius: 99px;
  border: 2px solid #fff;
  box-shadow: 0 8px 25px rgba(255, 94, 151, 0.55);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: pulseBanner 1.6s infinite ease-in-out;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#audio-unlock-banner.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-20px);
}

@keyframes pulseBanner {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.05); }
}

/* Drive Mode Indicator Banner */
#drive-hint {
  position: fixed;
  bottom: 112px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  background: rgba(18, 23, 42, 0.85);
  border: 1.5px solid var(--accent-mint);
  color: var(--text-light);
  padding: 7px 16px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

#drive-hint.visible {
  opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  #hud {
    padding: 10px;
  }
  .brand-panel {
    max-width: 280px;
  }
  .music-panel {
    min-width: 230px;
  }
  .btn {
    padding: 6px 9px;
    font-size: 0.74rem;
  }
}
