/* Kids Truck Builder — Styles */

:root {
  --bg-sky: #e0f2fe;
  --bg-sky-deep: #bae6fd;
  --road-color: #334155;
  --road-line: #f1f5f9;
  --accent-gold: #f59e0b;
  --accent-green: #10b981;
  --accent-blue: #2563eb;
  --card-bg: #ffffff;
  --card-border: #cbd5e1;
  --bay-scale: 1;
}

body {
  background: radial-gradient(circle at 50% 25%, var(--bg-sky) 0%, var(--bg-sky-deep) 100%);
  margin: 0;
  padding: 0;
  color: #1e293b;
  font-family: inherit;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overflow-x: hidden;
}

.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 860px;
  margin: 0 auto;
  padding: 8px 16px 16px;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Hide duplicate shell header stats so status-bar is the sole prominent counter */
.game-header .header-center {
  display: none;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 4px;
}

.score-badge {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 1.1rem;
  font-weight: 800;
  color: #0369a1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.instruction-banner {
  margin: 4px 0 8px;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  color: #0f172a;
}

/* Workshop Stage */
.workshop-stage {
  position: relative;
  width: 100%;
  height: 250px;
  max-width: 640px;
  background: linear-gradient(180deg, #93c5fd 0%, #dbeafe 65%, #64748b 66%, var(--road-color) 100%);
  border: 6px solid #0284c7;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(2, 132, 199, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.stage-sky {
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  height: 60px;
  pointer-events: none;
}

.cloud {
  position: absolute;
  font-size: 1.8rem;
  opacity: 0.85;
}

.cloud-1 {
  top: 6px;
  left: 12%;
  animation: floatCloud 24s infinite linear;
}

.cloud-2 {
  top: 18px;
  right: 15%;
  animation: floatCloud 32s infinite linear reverse;
}

.vehicle-title-badge {
  position: absolute;
  top: 12px;
  background: #0284c7;
  color: #ffffff;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 1.1rem;
  font-weight: 800;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
  z-index: 5;
}

/* Assembly Bay */
.assembly-bay {
  position: relative;
  width: 320px;
  height: 150px;
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(var(--bay-scale));
  transform-origin: center center;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
}

.assembly-bay.is-driving {
  animation: driveOut 2.2s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

.vehicle-silhouette {
  position: relative;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.25);
  border: 3px dashed rgba(2, 132, 199, 0.5);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.3s, background 0.3s;
}

.vehicle-silhouette.completed {
  border-color: transparent;
  background: transparent;
}

/* Parts Layer on Silhouette */
.slot-layer {
  position: absolute;
  inset: 0;
  display: block;
}

/* Vehicle Mounting Blueprint Slots */
.vehicle-slot {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(2, 132, 199, 0.45);
  border-radius: 12px;
  background: rgba(2, 132, 199, 0.08);
  box-sizing: border-box;
  user-select: none;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s, border-color 0.2s;
  z-index: 3;
  outline: none;
}

.vehicle-slot:focus-visible {
  outline: 3px solid #0284c7;
  outline-offset: 2px;
}

.vehicle-slot .slot-ghost-icon {
  font-size: 1.8rem;
  opacity: 0.35;
  filter: grayscale(0.8);
  pointer-events: none;
}

.vehicle-slot.highlight {
  background: rgba(2, 132, 199, 0.25) !important;
  border-color: #0284c7 !important;
  border-style: solid !important;
  transform: scale(1.06);
  box-shadow: 0 0 14px rgba(2, 132, 199, 0.35);
}

.vehicle-slot.wobble {
  animation: slot-wobble 0.4s ease-in-out;
  border-color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.15) !important;
}

.vehicle-slot.is-filled {
  border: none !important;
  background: transparent !important;
  cursor: default;
}

.vehicle-slot.is-filled .slot-ghost-icon {
  display: none !important;
}

.installed-part {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  animation: snapBounce 0.4s ease-out;
}

/* Part Visual Types */
.part-chassis {
  border-radius: 14px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  font-size: 2rem;
}

.part-cabin {
  border-radius: 14px 14px 4px 4px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  font-size: 2.2rem;
}

.part-wheels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  font-size: 2.4rem;
  width: 100%;
  height: 100%;
}

.wheel-spin {
  display: inline-block;
  line-height: 1;
}

.assembly-bay.is-driving .wheel-spin {
  animation: spinWheel 0.6s infinite linear;
}

.part-equip,
.part-equipment {
  font-size: 2.2rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.part-siren {
  font-size: 1.8rem;
}

.siren-blink {
  animation: sirenFlash 0.5s infinite alternate ease-in-out;
}

/* Road at Stage Bottom */
.stage-road {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 38px;
  background: var(--road-color);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.road-line {
  width: 100%;
  height: 4px;
  background: repeating-linear-gradient(
    90deg,
    var(--road-line) 0px,
    var(--road-line) 24px,
    transparent 24px,
    transparent 44px
  );
}

/* Smoke Exhaust FX */
.smoke-exhaust {
  position: absolute;
  bottom: 18px;
  left: -12px;
  font-size: 1.6rem;
  pointer-events: none;
  opacity: 0;
  z-index: 1;
}

.assembly-bay.is-driving .smoke-exhaust {
  opacity: 1;
  animation: smokePuff 0.6s infinite ease-out;
}

@keyframes smokePuff {
  0% { transform: translate(0, 0) scale(0.6); opacity: 0.8; }
  100% { transform: translate(-30px, -18px) scale(1.4); opacity: 0; }
}

/* Parts Tray */
.tray-section {
  width: 100%;
  max-width: 640px;
  margin: 6px 0 10px;
}

.parts-tray {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 3px solid #bae6fd;
  border-radius: 20px;
  padding: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.part-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 3px solid #e2e8f0;
  border-radius: 16px;
  padding: 8px 12px;
  min-width: 80px;
  min-height: 80px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  color: #334155;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.part-card:hover:not(:disabled) {
  transform: translateY(-4px) scale(1.05);
  border-color: #0284c7;
  box-shadow: 0 8px 16px rgba(2, 132, 199, 0.2);
}

.part-card:active:not(:disabled) {
  transform: scale(0.96);
}

.part-card.placed {
  opacity: 0.35;
  transform: scale(0.9);
  pointer-events: none;
  filter: grayscale(0.5);
}

.part-card.dragging {
  cursor: grabbing !important;
  opacity: 0.95;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.3);
  transform: scale(1.15) rotate(3deg);
  pointer-events: none;
}

.part-card.selected {
  outline: 4px solid #0284c7;
  outline-offset: 3px;
  transform: translateY(-6px) scale(1.08);
  box-shadow: 0 10px 20px rgba(2, 132, 199, 0.35);
  border-color: #0284c7;
}

.part-card.shake {
  animation: shake 0.4s ease-in-out;
  border-color: #ef4444;
}

@keyframes slot-wobble {
  0%, 100% { transform: scale(1) translateX(0); }
  25% { transform: scale(1.04) translateX(-6px); }
  75% { transform: scale(1.04) translateX(6px); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.part-icon {
  font-size: 2.2rem;
  line-height: 1;
  margin-bottom: 4px;
}

.part-name {
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Action Controls */
.action-bar {
  display: flex;
  justify-content: center;
  min-height: 54px;
  width: 100%;
}

.action-btn {
  border: 3px solid #fff;
  border-radius: 40px;
  color: #fff;
  font-family: inherit;
  font-weight: 800;
  font-size: 1.25rem;
  padding: 12px 36px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s, box-shadow 0.2s;
  animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.drive-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4), 0 3px 0 #047857;
  animation: pulseGlow 1.8s infinite ease-in-out;
}

.next-btn {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.4), 0 3px 0 #b45309;
}

.again-btn {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.4), 0 3px 0 #1d4ed8;
}

.action-btn:hover {
  transform: translateY(-2px) scale(1.05);
}

.action-btn:active {
  transform: translateY(2px) scale(0.97);
}

/* Celebration Particles Overlay */
.fx-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}

.sparkle-particle {
  position: absolute;
  font-size: 1.8rem;
  line-height: 1;
  pointer-events: none;
  animation: sparkleRise 1s forwards ease-out;
}

/* Animations */
@keyframes snapBounce {
  0% { transform: scale(0.4) rotate(-8deg); opacity: 0; }
  70% { transform: scale(1.15) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

@keyframes driveOut {
  0% { transform: scale(var(--bay-scale, 1)) translateX(0); }
  25% { transform: scale(var(--bay-scale, 1)) translateX(-15px); }
  100% { transform: scale(var(--bay-scale, 1)) translateX(450px); }
}

@keyframes spinWheel {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes sirenFlash {
  0% { filter: drop-shadow(0 0 4px #ef4444); transform: scale(1); }
  100% { filter: drop-shadow(0 0 16px #3b82f6); transform: scale(1.2); }
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4); }
  50% { transform: scale(1.05); box-shadow: 0 8px 26px rgba(16, 185, 129, 0.7); }
}

@keyframes popIn {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes sparkleRise {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% - 35px)) scale(1.2); opacity: 0; }
}

@keyframes floatCloud {
  0% { transform: translateX(-40px); }
  100% { transform: translateX(500px); }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .assembly-bay.is-driving, .cloud, .action-btn, .wheel-spin, .siren-blink, .installed-part, .sparkle-particle, .vehicle-slot.wobble, .part-card.shake {
    animation: none !important;
    transition: none !important;
  }
}

/* Mobile responsive */
@media (max-width: 540px) {
  :root {
    --bay-scale: 0.88;
  }

  .workshop-stage {
    height: 220px;
  }

  .parts-tray {
    gap: 8px;
    padding: 8px;
  }

  .part-card {
    min-width: 66px;
    min-height: 66px;
    padding: 6px 8px;
  }

  .part-icon {
    font-size: 1.8rem;
  }

  .part-name {
    font-size: 0.75rem;
  }
}

@media (max-width: 380px) {
  :root {
    --bay-scale: 0.78;
  }

  .part-card {
    min-width: 58px;
    min-height: 58px;
    padding: 4px 6px;
  }

  .part-icon {
    font-size: 1.5rem;
  }

  .part-name {
    font-size: 0.68rem;
  }
}
