/* Tree Ball Rescue — Park Storybook Stylesheet
   Rich cartoon park aesthetic, crystal clear intuitive controls, zero viewport occlusion */

:root {
  --park-green: #2d7a36;
  --park-grass-bright: #48bb78;
  --park-leaf-dark: #1b4332;
  --sun-gold: #f6ad55;
  --sun-yellow: #fef08a;
  --sky-blue: #70c4f4;
  --accent-blue: #2563eb;
  --accent-red: #dc2626;
  --card-bg: rgba(255, 255, 255, 0.95);
  --card-dark: rgba(14, 28, 18, 0.92);
  --text-dark: #1a202c;
  --text-light: #ffffff;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #68c5f7;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  color: var(--text-dark);
  user-select: none;
}

.game-viewport-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.stage-container {
  position: relative;
  width: 100%;
  height: 100%;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
  cursor: pointer;
}

/* Confetti canvas */
.confetti-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

/* Top Navigation Bar */
.top-bar {
  position: absolute;
  top: 14px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 30;
}

.top-bar > * {
  pointer-events: auto;
}

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

.nav-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #ffffff;
  border: 2px solid #2d7a36;
  border-radius: 999px;
  color: #1b4332;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  transition: transform 0.18s ease, background 0.18s ease;
}

.nav-back-btn:hover {
  transform: translateY(-2px);
  background: #edfdf2;
}

.home-icon {
  font-size: 15px;
}

.game-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #38a169;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.badge-icon {
  font-size: 20px;
}

.badge-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: #1b4332;
  line-height: 1;
}

/* Center Story Stepper */
.story-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #cbd5e0;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.step-dot {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #edf2f7;
  color: #718096;
  font-size: 11px;
  font-weight: 800;
  transition: all 0.25s ease;
}

.step-num {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #cbd5e0;
  color: #2d3748;
  font-size: 10px;
}

.step-dot.active {
  background: #2e8540;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(46, 133, 64, 0.35);
}

.step-dot.active .step-num {
  background: #ffffff;
  color: #1b4332;
  font-weight: 900;
}

.step-dot.completed {
  background: #c6f6d5;
  color: #22543d;
}

.step-dot.completed .step-num {
  background: #38a169;
  color: #ffffff;
}

.step-line {
  width: 10px;
  height: 2px;
  background: #cbd5e0;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #ffffff;
  border: 2px solid #cbd5e0;
  border-radius: 999px;
  color: #2d3748;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: #f7fafc;
  transform: translateY(-2px);
}

/* Floating 3D Speech Bubbles */
.speech-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 25;
}

.speech-bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  margin-top: -24px;
  background: #ffffff;
  color: #1a202c;
  border-radius: 18px;
  padding: 10px 18px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25), 0 3px 6px rgba(0, 0, 0, 0.1);
  border: 2.5px solid #2e8540;
  max-width: 270px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.bubble-header {
  margin-bottom: 4px;
}

.avatar-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.yuj-tag { background: #2563eb; color: #fff; }
.maya-tag { background: #d97706; color: #fff; }
.leo-tag { background: #16a34a; color: #fff; }
.sam-tag { background: #ea580c; color: #fff; }

.bubble-tail {
  position: absolute;
  bottom: -11px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 11px solid #2e8540;
}

/* Top Story Event Banner */
.story-banner-wrap {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 28;
  pointer-events: none;
  max-width: min(600px, 92vw);
  width: 100%;
}

.story-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.96);
  border: 2.5px solid #38a169;
  border-radius: 20px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.18);
  text-align: left;
}

.banner-status-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.banner-headline {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #1b4332;
  line-height: 1.1;
  margin-bottom: 2px;
}

.banner-desc {
  font-size: 12px;
  color: #4a5568;
  font-weight: 600;
  line-height: 1.3;
}

/* Floating Click/Tap Target Indicator in 3D Scene */
.scene-target-hint {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 22;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.target-ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #ffcc00;
  background: rgba(255, 204, 0, 0.25);
  box-shadow: 0 0 15px #ffcc00;
  display: grid;
  place-items: center;
  font-size: 18px;
}

.target-label {
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  border-radius: 6px;
  white-space: nowrap;
}

/* Sleek Intuitive Story Action Card (Bottom Center) */
.story-action-card-wrapper {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: min(620px, calc(100vw - 32px));
  z-index: 35;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.story-action-card {
  width: 100%;
  background: #ffffff;
  border: 3px solid #2e8540;
  border-radius: 24px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.card-character-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.char-big-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #edfdf2;
  border: 2px solid #38a169;
  display: grid;
  place-items: center;
  font-size: 28px;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.char-text-group {
  display: flex;
  flex-direction: column;
}

.char-name {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #276749;
}

.char-quote {
  font-size: 13px;
  font-weight: 700;
  color: #1a202c;
  line-height: 1.25;
}

/* Primary Story Action Button */
.main-story-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px;
  background: linear-gradient(135deg, #38a169 0%, #22543d 100%);
  border: 2px solid #ffffff;
  border-radius: 18px;
  color: #ffffff;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(34, 84, 61, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.main-story-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(34, 84, 61, 0.45);
  background: linear-gradient(135deg, #48bb78 0%, #276749 100%);
}

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

.main-story-btn .btn-emoji {
  font-size: 24px;
}

/* Secondary Camera & Audio Dock under action card */
.quick-dock-pills {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.quick-pill-btn {
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.9);
  border: 1.5px solid #cbd5e0;
  border-radius: 999px;
  color: #2d3748;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.15s ease;
}

.quick-pill-btn:hover {
  background: #ffffff;
  border-color: #38a169;
  color: #1b4332;
}

.quick-pill-btn.active {
  background: #2563eb;
  border-color: #1d4ed8;
  color: #ffffff;
}

/* Victory Modal (Chapter 6 Clapping) */
.victory-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 20, 14, 0.75);
  display: grid;
  place-items: center;
  z-index: 60;
  padding: 20px;
}

.victory-card {
  background: #ffffff;
  color: #1a202c;
  border-radius: 28px;
  padding: 32px 36px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  border: 4px solid #48bb78;
}

.victory-trophy {
  font-size: 54px;
  margin-bottom: 8px;
}

.victory-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #1b4332;
  line-height: 1;
  margin-bottom: 8px;
}

.victory-subtitle {
  font-size: 14px;
  color: #4a5568;
  line-height: 1.45;
  margin-bottom: 18px;
}

.rescued-inventory {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.item-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  background: #edf2f7;
  border-radius: 14px;
  border: 1px solid #cbd5e0;
}

.item-card.hero-item {
  background: #fefcbf;
  border-color: #ecc94b;
}

.item-emoji {
  font-size: 24px;
  margin-bottom: 4px;
}

.item-name {
  font-size: 11px;
  font-weight: 800;
  color: #2d3748;
}

.item-status {
  font-size: 10px;
  font-weight: 800;
  color: #276749;
}

.item-card.hero-item .item-status {
  color: #b7791f;
}

.clap-mega-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
  border: none;
  border-radius: 16px;
  color: #ffffff;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(47, 133, 90, 0.4);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  margin-bottom: 16px;
}

.clap-mega-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(47, 133, 90, 0.5);
}

.clap-mega-btn:active {
  transform: scale(0.96);
}

.clap-icon {
  font-size: 30px;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.action-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
  border: none;
  transition: all 0.18s ease;
}

.action-btn.primary-glow {
  background: #2563eb;
  color: #ffffff;
}

.action-btn.primary-glow:hover {
  background: #1d4ed8;
}

.action-btn.secondary {
  background: #edf2f7;
  color: #2d3748;
  border: 1px solid #cbd5e0;
}

.action-btn.secondary:hover {
  background: #e2e8f0;
}

.action-btn.home-action-btn {
  background: #1b4332;
  color: #68d391;
  border: 1px solid rgba(72, 187, 120, 0.4);
  text-decoration: none;
}

.action-btn.home-action-btn:hover {
  background: #276749;
  color: #ffffff;
}

/* Mobile Responsiveness */
@media (max-width: 820px) {
  .story-stepper {
    display: none;
  }

  .story-action-card {
    flex-direction: column;
    text-align: center;
    gap: 12px;
    padding: 12px 16px;
  }

  .card-character-info {
    flex-direction: column;
    text-align: center;
  }

  .main-story-btn {
    width: 100%;
    font-size: 20px;
    padding: 12px 18px;
  }

  .story-banner-wrap {
    top: 70px;
  }
}
