/* Doodle Alive: Monster Maker — Stylesheet */

:root {
  --d-bg: #f8fafc;
  --d-primary: #3b82f6;
  --d-accent: #10b981;
  --d-gold: #f59e0b;
  --d-pink: #ec4899;
  --d-purple: #8b5cf6;
  --d-card-bg: rgba(255, 255, 255, 0.95);
  --d-border: #cbd5e1;
  --d-easel-size: min(58vh, 50vw, 480px);
  --d-avatar-size: min(240px, 46vh, 68vw);
}

body {
  background: radial-gradient(circle at 50% 20%, #e0f2fe 0%, #f1f5f9 100%);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overflow: hidden;
  color: #1e293b;
}

.doodle-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  padding: 4px 12px 10px;
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
}

/* ========================================================
   MODE 1: STUDIO VIEW
   ======================================================== */
.studio-view {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  height: 100%;
  max-width: 1060px;
  min-height: 0;
}

/* Easel Frame */
.easel-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.easel-frame {
  position: relative;
  background: #ffffff;
  padding: 10px;
  border-radius: 24px;
  box-shadow: 0 10px 28px rgba(100, 116, 139, 0.2), 0 2px 6px rgba(0, 0, 0, 0.05);
  border: 4px solid #f1f5f9;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.canvas-wrapper {
  position: relative;
  width: var(--d-easel-size);
  height: var(--d-easel-size);
  background: #fafafa;
  border-radius: 18px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  touch-action: none;
  cursor: crosshair;
}

.body-canvas,
.sparkle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.sparkle-canvas {
  pointer-events: none;
  z-index: 5;
}

.features-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}

/* Interactive Placed Features in Studio */
.placed-feature {
  position: absolute;
  pointer-events: auto;
  cursor: grab;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
}

.placed-feature:active {
  cursor: grabbing;
}

/* Easel Action Strip */
.easel-actions-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 2px;
}

.mini-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #f1f5f9;
  border: 2px solid transparent;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.15s ease;
  touch-action: manipulation;
}

.mini-tool-btn:hover {
  background: #e2e8f0;
  transform: translateY(-1px);
}

.mini-tool-btn:active {
  transform: scale(0.92);
}

.mini-tool-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.brush-size-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  padding: 3px 8px;
  border-radius: 20px;
}

.size-dot-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  touch-action: manipulation;
}

.size-dot-btn .dot {
  background: #475569;
  border-radius: 50%;
  display: block;
}

.dot.sm { width: 8px; height: 8px; }
.dot.md { width: 15px; height: 15px; }
.dot.lg { width: 22px; height: 22px; }

.size-dot-btn.active {
  background: #ffffff;
  border-color: var(--d-primary);
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

/* Studio Dock */
.studio-dock {
  display: flex;
  flex-direction: column;
  background: var(--d-card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 2px solid #e2e8f0;
  border-radius: 24px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
  width: 330px;
  height: min(68vh, 580px);
  overflow: hidden;
  box-sizing: border-box;
  min-height: 0;
}

.dock-nav {
  display: flex;
  background: #f1f5f9;
  border-bottom: 2px solid #e2e8f0;
  padding: 4px;
  gap: 3px;
  flex-shrink: 0;
}

.dock-tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 2px;
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 48px;
  touch-action: manipulation;
}

.dock-tab-btn .tab-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.dock-tab-btn .tab-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #64748b;
  margin-top: 3px;
}

.dock-tab-btn.active {
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.dock-tab-btn.active .tab-label {
  color: var(--d-primary);
}

/* Dock Content Panel */
.dock-panel {
  flex: 1 1 auto;
  padding: 10px;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
}

.dock-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 6px;
}

/* Color Swatches Grid */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.color-swatch-item {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
  touch-action: manipulation;
  justify-self: center;
}

.color-swatch-item:hover {
  transform: scale(1.12);
}

.color-swatch-item.active {
  transform: scale(1.15);
  box-shadow: 0 0 0 3px var(--d-primary), 0 4px 10px rgba(0, 0, 0, 0.2);
}

.color-swatch-item.rainbow-swatch {
  background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red) !important;
}

/* Feature Parts Grid */
.parts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.part-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  padding: 6px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
}

.part-btn:hover {
  background: #ffffff;
  border-color: var(--d-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.15);
}

.part-btn:active {
  transform: scale(0.94);
}

.part-btn.active {
  background: #ffffff;
  border-color: var(--d-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
  transform: scale(1.02);
}

.part-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* Dock Footer & Magic Button */
.dock-footer {
  padding: 10px;
  background: #f8fafc;
  border-top: 2px solid #e2e8f0;
  flex-shrink: 0;
}

.btn-alive-action {
  width: 100%;
  min-height: 50px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border: none;
  border-radius: 16px;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
  transition: all 0.15s ease;
  animation: pulse-alive 2.2s infinite ease-in-out;
  touch-action: manipulation;
}

.btn-alive-action:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.5);
}

.btn-alive-action:active {
  transform: scale(0.96);
}

.btn-alive-action:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  animation: none;
}

@keyframes pulse-alive {
  0%, 100% { box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35); }
  50% { box-shadow: 0 8px 28px rgba(16, 185, 129, 0.65); }
}

/* ========================================================
   MONSTER FEATURES (Eyes, Mouth, Limbs, Hats)
   ======================================================== */
.feature-svg {
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.12));
}

/* Eyes Layouts */
.googly-pair,
.anime-eyes {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.googly-single {
  display: flex;
  align-items: center;
  justify-content: center;
}

.googly-trio {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Eye Base */
.eye {
  position: relative;
  width: 42px;
  height: 42px;
  background: #ffffff;
  border: 3.5px solid #0f172a;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 3px 8px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  transition: transform 0.08s ease;
  flex-shrink: 0;
}

.eye.large {
  width: 58px;
  height: 58px;
  border-width: 4px;
}

.eye.medium {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

.eye.small {
  width: 24px;
  height: 24px;
  border-width: 2.5px;
}

.eye.anime {
  width: 40px;
  height: 46px;
  border-radius: 50% 50% 45% 45%;
  border-width: 3.5px;
  background: #ffffff;
}

.eye.blinking {
  transform: scaleY(0.08) !important;
}

/* Pupils */
.pupil {
  position: absolute;
  width: 17px;
  height: 17px;
  background: #0f172a;
  border-radius: 50%;
  pointer-events: none;
  transition: transform 0.05s ease-out;
}

.eye.large .pupil {
  width: 25px;
  height: 25px;
}

.eye.medium .pupil {
  width: 14px;
  height: 14px;
}

.eye.small .pupil {
  width: 10px;
  height: 10px;
}

.eye.anime .pupil {
  width: 22px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(180deg, #0f172a 0%, #312e81 60%, #4f46e5 100%);
}

/* Pupil highlights (shiny reflections) */
.pupil.shiny::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 4px;
  width: 7px;
  height: 7px;
  background: #ffffff;
  border-radius: 50%;
}

.pupil.shiny::after {
  content: '';
  position: absolute;
  bottom: 4px;
  right: 3px;
  width: 4px;
  height: 4px;
  background: #ffffff;
  border-radius: 50%;
}

/* Limbs */
.limbs-pair {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 70px;
  width: 150px;
}

.limb {
  font-size: 2.3rem;
  line-height: 1;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.15));
  user-select: none;
}

/* Hats */
.hat {
  font-size: 2.6rem;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
  user-select: none;
}

/* Placed feature in alive avatar */
.alive-feat {
  pointer-events: none;
}

.feature-limbs, .feat-limbs { z-index: 1; }
.feature-mouth, .feat-mouth { z-index: 2; }
.feature-eyes, .feat-eyes { z-index: 3; }
.feature-hats, .feat-hats { z-index: 4; }

.placed-feature.is-dragging {
  cursor: grabbing !important;
  transform: translate(-50%, -50%) scale(1.1) !important;
  z-index: 10 !important;
}

/* ========================================================
   MODE 2: ALIVE PLAYGROUND VIEW
   ======================================================== */
.alive-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  max-width: 960px;
  gap: 10px;
  min-height: 0;
}

.alive-stage {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  background: radial-gradient(circle at 50% 30%, #fef3c7 0%, #fed7aa 60%, #fdba74 100%);
  border-radius: 28px;
  box-shadow: 0 14px 32px rgba(180, 83, 9, 0.15), inset 0 -24px 36px rgba(194, 65, 12, 0.12);
  border: 4px solid #ffffff;
  overflow: hidden;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Floor illusion */
.alive-stage::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 25%;
  background: linear-gradient(180deg, rgba(217, 119, 6, 0.12) 0%, rgba(180, 83, 9, 0.25) 100%);
  pointer-events: none;
}

.disco-lights {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 2;
}

.disco-lights.active {
  opacity: 1;
  animation: disco-pulse 0.8s infinite alternate ease-in-out;
}

@keyframes disco-pulse {
  0% { background: radial-gradient(circle at 20% 30%, rgba(236, 72, 153, 0.4), transparent 60%); }
  50% { background: radial-gradient(circle at 80% 40%, rgba(59, 130, 246, 0.4), transparent 60%); }
  100% { background: radial-gradient(circle at 50% 80%, rgba(16, 185, 129, 0.4), transparent 60%); }
}

.alive-fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* Living Creature Container */
.alive-creature {
  position: relative;
  z-index: 5;
  cursor: grab;
  touch-action: none;
  transition: transform 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.alive-creature:active {
  cursor: grabbing;
}

.alive-creature.is-dragging {
  transition: none !important;
}

.alive-avatar-body {
  position: relative;
  width: var(--d-avatar-size, 240px);
  height: var(--d-avatar-size, 240px);
  animation: breathe 3.2s infinite ease-in-out;
  transform-origin: center bottom;
}

.alive-drawn-body {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* Animations for Creature */
@keyframes breathe {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(1.03, 0.97) translateY(2px); }
}

.alive-creature.tickled .alive-avatar-body {
  animation: tickle-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes tickle-bounce {
  0% { transform: scale(1.2, 0.7); }
  40% { transform: scale(0.85, 1.25) translateY(-26px); }
  75% { transform: scale(1.08, 0.92) translateY(0); }
  100% { transform: scale(1, 1); }
}

.alive-creature.dancing .alive-avatar-body {
  animation: dance-groove 0.5s infinite alternate ease-in-out;
}

@keyframes dance-groove {
  0% { transform: rotate(-7deg) scale(1.04, 0.96) translateY(-8px); }
  100% { transform: rotate(7deg) scale(0.96, 1.04) translateY(-8px); }
}

.alive-creature.jumping .alive-avatar-body {
  animation: super-jump 0.9s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes super-jump {
  0% { transform: scale(1.3, 0.6); }
  35% { transform: scale(0.85, 1.2) translateY(-120px) rotate(180deg); }
  70% { transform: scale(0.9, 1.1) translateY(-50px) rotate(360deg); }
  90% { transform: scale(1.15, 0.8) translateY(0); }
  100% { transform: scale(1, 1); }
}

/* Interactive Food Treats */
.treats-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
}

.snack-item {
  position: absolute;
  font-size: 2.8rem;
  pointer-events: auto;
  cursor: grab;
  user-select: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.2));
  animation: snack-float 2s infinite ease-in-out;
  transition: transform 0.1s ease;
  touch-action: none;
}

.snack-item:active {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.2);
}

.snack-item.is-dragging {
  cursor: grabbing;
  transition: none !important;
  animation: none !important;
}

@keyframes snack-float {
  0%, 100% { transform: translate(-50%, -50%) translateY(0); }
  50% { transform: translate(-50%, -50%) translateY(-8px); }
}

/* Alive Toolbar */
.alive-action-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  flex-shrink: 0;
}

.alive-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 6px 16px;
  border-radius: 16px;
  border: 2px solid transparent;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.15s ease;
  color: #ffffff;
  touch-action: manipulation;
}

.alive-btn .btn-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.alive-btn:hover {
  transform: translateY(-2px) scale(1.02);
}

.alive-btn:active {
  transform: scale(0.94);
}

.btn-snack { background: linear-gradient(135deg, #f59e0b, #d97706); }
.btn-dance { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.btn-jump  { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.btn-photo { background: linear-gradient(135deg, #ec4899, #db2777); }
.btn-new   { background: linear-gradient(135deg, #10b981, #059669); }

.btn-dance.active {
  animation: pulse-dance 1s infinite alternate ease-in-out;
  border-color: #facc15;
}

@keyframes pulse-dance {
  from { box-shadow: 0 0 10px rgba(139, 92, 246, 0.5); }
  to { box-shadow: 0 0 20px rgba(250, 204, 21, 0.9); }
}

/* Accessibility Focus */
.alive-creature:focus-visible,
.size-dot-btn:focus-visible,
.color-swatch-item:focus-visible,
.part-btn:focus-visible,
.dock-tab-btn:focus-visible,
.mini-tool-btn:focus-visible,
.alive-btn:focus-visible,
.btn-alive-action:focus-visible {
  outline: 3px solid var(--d-primary);
  outline-offset: 2px;
}

/* ========================================================
   RESPONSIVE DESIGN
   ======================================================== */
@media (max-width: 820px) and (orientation: portrait) {
  :root {
    --d-easel-size: min(34vh, 76vw, 290px);
    --d-avatar-size: min(200px, 38vh, 60vw);
  }

  .studio-view {
    flex-direction: column;
    gap: 8px;
  }

  .easel-frame {
    padding: 6px;
    border-radius: 18px;
    gap: 6px;
  }

  .mini-tool-btn {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .size-dot-btn {
    width: 28px;
    height: 28px;
  }

  .studio-dock {
    width: 100%;
    max-width: 400px;
    flex: 1 1 auto;
    min-height: 0;
    border-radius: 18px;
  }

  .dock-nav {
    padding: 2px;
    gap: 2px;
  }

  .dock-tab-btn {
    min-height: 42px;
    padding: 3px 2px;
  }

  .dock-tab-btn .tab-icon {
    font-size: 1.1rem;
  }

  .dock-tab-btn .tab-label {
    font-size: 0.65rem;
  }

  .btn-alive-action {
    min-height: 44px;
    font-size: 1rem;
  }

  .alive-action-bar {
    gap: 6px;
  }

  .alive-btn {
    min-height: 42px;
    padding: 6px 10px;
    font-size: 0.85rem;
  }

  .alive-btn .btn-label {
    display: none;
  }
}

@media (max-height: 520px) {
  :root {
    --d-easel-size: min(65vh, 44vw, 270px);
    --d-avatar-size: min(180px, 58vh, 40vw);
  }

  .doodle-field {
    padding: 2px 8px 6px;
  }

  .studio-view {
    flex-direction: row;
    gap: 10px;
  }

  .easel-frame {
    padding: 6px;
    gap: 4px;
  }

  .mini-tool-btn {
    width: 34px;
    height: 34px;
  }

  .size-dot-btn {
    width: 26px;
    height: 26px;
  }

  .studio-dock {
    width: min(46vw, 320px);
    height: 100%;
    border-radius: 18px;
  }

  .dock-tab-btn {
    min-height: 38px;
    padding: 2px;
  }

  .dock-tab-btn .tab-icon {
    font-size: 1rem;
  }

  .dock-tab-btn .tab-label {
    font-size: 0.62rem;
  }

  .btn-alive-action {
    min-height: 40px;
    font-size: 0.95rem;
  }

  .alive-btn {
    min-height: 40px;
    padding: 4px 10px;
  }
}
