:root {
  --bg: #FFF9EF;
  --bg-accent: #FDF2DF;
  --surface: #FFFFFF;
  --surface-soft: #FFFDF8;
  --ink: #3E2D20;
  --ink-muted: #7C6654;
  --border: #ECDCC5;
  --primary: #FF7B54;
  --primary-dark: #E05E38;
  --secondary: #4EA8DE;
  --secondary-soft: #E9F6FF;
  --mint: #4AC285;
  --danger: #E55B5B;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-card: 0 10px 28px rgba(102, 71, 38, 0.08);
  --shadow-btn: 0 4px 0 rgba(74, 55, 40, 0.14);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 12% 14%, rgba(255, 214, 153, 0.32), transparent 36%),
    radial-gradient(circle at 88% 8%, rgba(160, 224, 255, 0.28), transparent 38%),
    radial-gradient(circle at 84% 88%, rgba(186, 240, 198, 0.28), transparent 38%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Rounded Mplus 1c", sans-serif;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.app-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}

/* Header */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

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

.brand-icon {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: linear-gradient(135deg, #FFE29A, #FFB07C);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 4px 12px rgba(255, 138, 80, 0.26);
}

.brand-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.mode-tabs {
  display: inline-flex;
  background: var(--surface);
  padding: 5px;
  border-radius: 999px;
  border: 2px solid var(--border);
  box-shadow: 0 4px 12px rgba(102, 71, 38, 0.06);
  gap: 6px;
}

.mode-tab {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 0.98rem;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s ease;
}

.mode-tab:hover {
  color: var(--ink);
  background: var(--bg-accent);
}

.mode-tab.active {
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(255, 123, 84, 0.34);
}

.count-badge {
  background: rgba(255, 255, 255, 0.25);
  color: inherit;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.82rem;
  font-weight: 800;
  min-width: 24px;
  text-align: center;
}

.mode-tab:not(.active) .count-badge {
  background: var(--bg-accent);
  color: var(--primary-dark);
}

/* Views */
.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeSlideIn 0.24s ease;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px solid transparent;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 10px 18px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
  user-select: none;
  font-family: inherit;
}

.btn:active {
  transform: translateY(2px);
}

.btn-sm {
  padding: 7px 13px;
  font-size: 0.86rem;
  border-radius: 11px;
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 4px 0 var(--primary-dark);
}

.btn-primary:hover {
  background: #FF6B40;
}

.btn-cta {
  background: linear-gradient(135deg, #FF8252, #FF5E62);
  color: #FFFFFF;
  padding: 13px 24px;
  font-size: 1.05rem;
  border-radius: 16px;
  box-shadow: 0 5px 0 #CC4145, 0 10px 20px rgba(255, 94, 98, 0.28);
}

.btn-cta:hover {
  filter: brightness(1.03);
}

.btn-secondary {
  background: var(--surface-soft);
  color: var(--ink);
  border-color: var(--border);
  box-shadow: 0 3px 0 var(--border);
}

.btn-secondary:hover {
  background: var(--bg-accent);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--bg-accent);
  color: var(--ink);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border-color: #F6C8C8;
}

.btn-danger-ghost:hover {
  background: #FFF0F0;
}

.btn-chip {
  margin-left: auto;
  border: 2px solid #F2D7B6;
  background: #FFF4E2;
  color: #9C5A21;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.btn-chip:hover {
  background: #FFE7C2;
}

/* Studio Layout */
.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 20px;
  align-items: start;
}

.studio-controls {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.step-header h2 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
}

.step-header p {
  margin: 2px 0 0;
  font-size: 0.84rem;
  color: var(--ink-muted);
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #FFE0B5;
  color: #A14C14;
  font-weight: 900;
  font-size: 0.98rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.editing-pill {
  margin-left: auto;
  background: #E9F6FF;
  color: #2076B5;
  border: 1.5px solid #B5DDF9;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
}

/* Upload Dropzone */
.upload-zone {
  border: 2.5px dashed #E1C7A4;
  background: #FFFDF8;
  border-radius: var(--radius-md);
  padding: 18px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.upload-zone.drag-over {
  border-color: var(--primary);
  background: #FFF3EB;
}

.upload-empty {
  text-align: center;
  padding: 6px 0;
}

.upload-illustration {
  font-size: 36px;
  margin-bottom: 6px;
}

.upload-title {
  margin: 0 0 12px;
  font-size: 0.92rem;
  color: var(--ink-muted);
}

.upload-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.upload-preview-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.fabric-thumb {
  width: 82px;
  height: 82px;
  border-radius: 14px;
  object-fit: cover;
  border: 2px solid var(--border);
  box-shadow: 0 4px 10px rgba(74, 55, 40, 0.1);
  flex-shrink: 0;
}

.fabric-meta {
  flex: 1;
  min-width: 0;
}

.fabric-status {
  font-size: 0.92rem;
  font-weight: 700;
  color: #2F8A59;
  margin-bottom: 8px;
}

.fabric-meta-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Sample Fabrics */
.sample-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.sample-label {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--ink-muted);
  white-space: nowrap;
}

.sample-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sample-swatch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 2px solid var(--border);
  background: var(--surface-soft);
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  transition: all 0.15s ease;
}

.sample-swatch:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.sample-swatch.active {
  border-color: var(--primary);
  background: #FFF1E8;
  color: var(--primary-dark);
}

.sample-swatch img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

/* Animal Picker Grid */
.animal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.animal-option {
  border: 2px solid var(--border);
  background: var(--surface-soft);
  border-radius: 16px;
  padding: 10px 6px 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.16s ease;
  font-family: inherit;
  color: var(--ink);
}

.animal-option:hover {
  border-color: #F4B38A;
  transform: translateY(-2px);
  background: #FFF8EE;
}

.animal-option.active {
  border-color: var(--primary);
  background: #FFF0E6;
  box-shadow: 0 5px 14px rgba(255, 123, 84, 0.2);
}

.animal-option-emoji {
  font-size: 28px;
  line-height: 1.1;
}

.animal-option-name {
  font-size: 0.92rem;
  font-weight: 800;
}

.animal-option-outfit {
  font-size: 0.74rem;
  color: var(--ink-muted);
}

/* Live Dressing Mirror */
.stage-card {
  position: sticky;
  top: 16px;
}

.dressing-mirror {
  position: relative;
  border-radius: 20px;
  background: linear-gradient(180deg, #FFF7E6 0%, #FFEED4 62%, #E8F4D9 62%, #D7ECBF 100%);
  border: 2px solid var(--border);
  height: 350px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  cursor: grab;
}

.dressing-mirror:active {
  cursor: grabbing;
}

.mirror-backdrop {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 24%, rgba(255, 255, 255, 0.7) 0 28px, transparent 29px),
    radial-gradient(circle at 82% 20%, rgba(255, 255, 255, 0.6) 0 22px, transparent 23px);
  pointer-events: none;
}

.animal-preview-slot {
  width: 300px;
  height: 325px;
  position: relative;
  z-index: 1;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.animal-preview-slot.pop {
  animation: animalPop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes animalPop {
  0% { transform: scale(0.9); }
  55% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.animal-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.drag-hint {
  position: absolute;
  bottom: 10px;
  right: 12px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  pointer-events: none;
}

/* Pattern Sliders */
.pattern-controls {
  margin-top: 14px;
  background: var(--surface-soft);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-row {
  display: grid;
  grid-template-columns: 98px 1fr 48px;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
  font-weight: 700;
}

.slider-row input[type="range"] {
  accent-color: var(--primary);
  cursor: pointer;
}

.slider-val {
  text-align: right;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.pattern-reset-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
}

/* Save Box */
.save-box {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.name-input-wrap label {
  display: block;
  font-size: 0.86rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.name-input-wrap input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--surface-soft);
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease;
}

.name-input-wrap input:focus {
  border-color: var(--primary);
  background: #FFFFFF;
}

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

.save-actions .btn-cta {
  flex: 1;
}

/* ================= VIEW 2: SCENE STAGE ================= */
.scene-picker-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  margin-bottom: 14px;
}

.scene-picker-title {
  font-weight: 800;
  font-size: 0.94rem;
  white-space: nowrap;
}

.scene-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.scene-pill {
  border: 2px solid var(--border);
  background: var(--surface-soft);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  font-family: inherit;
}

.scene-pill:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
}

.scene-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(255, 123, 84, 0.3);
}

.stage-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.scene-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 26px;
  overflow: hidden;
  border: 3px solid var(--border);
  box-shadow: 0 18px 42px rgba(74, 55, 40, 0.14);
  background: #CFEFFF;
  user-select: none;
  touch-action: none;
}

.scene-bg-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.scene-bg-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.scene-float-slow {
  animation: driftSlow 8s ease-in-out infinite alternate;
}

@keyframes driftSlow {
  from { transform: translateX(-10px); }
  to { transform: translateX(14px); }
}

.scene-ambient-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.ambient-particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.ambient-bubble {
  border: 2px solid rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.18);
  animation: riseBubble var(--dur, 7s) linear infinite;
  animation-delay: var(--delay, 0s);
}

@keyframes riseBubble {
  0% { transform: translateY(105vh) translateX(0); opacity: 0; }
  12% { opacity: 0.85; }
  88% { opacity: 0.8; }
  100% { transform: translateY(-60px) translateX(18px); opacity: 0; }
}

.ambient-sparkle {
  background: #FFF6B0;
  box-shadow: 0 0 10px rgba(255, 240, 150, 0.9);
  animation: twinkle var(--dur, 3s) ease-in-out infinite alternate;
  animation-delay: var(--delay, 0s);
}

@keyframes twinkle {
  from { opacity: 0.25; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1.25); }
}

/* Editable Class Banner */
.scene-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  background: rgba(255, 253, 246, 0.92);
  backdrop-filter: blur(6px);
  border: 2.5px solid #EBD3B0;
  border-radius: 999px;
  padding: 7px 22px;
  box-shadow: 0 6px 18px rgba(74, 55, 40, 0.14);
  max-width: 80%;
}

.scene-banner span {
  font-size: clamp(0.95rem, 1.8vw, 1.35rem);
  font-weight: 900;
  color: var(--ink);
  outline: none;
  letter-spacing: 0.04em;
}

/* Animals in Scene */
.scene-animals-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
}

.stage-animal {
  position: absolute;
  width: 17%;
  min-width: 82px;
  max-width: 240px;
  transform: translate(-50%, -82%);
  cursor: grab;
  touch-action: none;
  transition: filter 0.15s ease;
}

.stage-animal:active,
.stage-animal.dragging {
  cursor: grabbing;
  z-index: 999 !important;
}

.stage-animal.selected .stage-animal-body {
  filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0)) drop-shadow(0 0 12px rgba(255, 123, 84, 0.72));
}

.stage-animal-inner {
  transform: scale(var(--item-scale, 1));
  transform-origin: center bottom;
}

.stage-animal-body {
  animation: idleBounce var(--idle-dur, 3.6s) ease-in-out infinite;
  animation-delay: var(--idle-delay, 0s);
}

.scene-stage[data-motion="float"] .stage-animal-body {
  animation-name: idleFloat;
}

.stage-animal.dragging .stage-animal-body {
  animation: none;
}

.stage-animal.cheering .stage-animal-body {
  animation: cheerJump 0.62s cubic-bezier(0.34, 1.56, 0.64, 1) 2 !important;
}

.stage-animal-flip {
  transform: scaleX(var(--flip, 1));
  transition: transform 0.22s ease;
}

@keyframes idleBounce {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50% { transform: translateY(-6px) scaleY(1.015); }
}

@keyframes idleFloat {
  0%, 100% { transform: translateY(0) rotate(-1.6deg); }
  50% { transform: translateY(-12px) rotate(1.6deg); }
}

@keyframes cheerJump {
  0%, 100% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-28px) scale(1.08) rotate(-3deg); }
  70% { transform: translateY(-10px) scale(1.03) rotate(3deg); }
}

.stage-animal-tag {
  margin: -4px auto 0;
  width: fit-content;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(255, 253, 248, 0.94);
  color: var(--ink);
  border: 2px solid #EBD5B6;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: clamp(0.7rem, 1.05vw, 0.88rem);
  font-weight: 800;
  text-align: center;
  box-shadow: 0 3px 8px rgba(74, 55, 40, 0.14);
}

.scene-stage.hide-names .stage-animal-tag {
  display: none;
}

.cheer-emoji {
  position: absolute;
  top: -16px;
  left: 50%;
  font-size: 24px;
  pointer-events: none;
  animation: floatUpFade 1.1s ease-out forwards;
}

@keyframes floatUpFade {
  0% { opacity: 1; transform: translate(-50%, 0) scale(0.7); }
  100% { opacity: 0; transform: translate(-50%, -48px) scale(1.3); }
}

/* Empty Overlay */
.scene-empty-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(255, 250, 240, 0.56);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.empty-card {
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid var(--border);
  border-radius: 24px;
  padding: 26px 28px;
  text-align: center;
  max-width: 440px;
  box-shadow: 0 14px 36px rgba(74, 55, 40, 0.16);
}

.empty-emoji {
  font-size: 44px;
  margin-bottom: 6px;
}

.empty-card h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.empty-card p {
  margin: 0 0 18px;
  color: var(--ink-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.empty-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Selected Animal Inspector */
.animal-inspector {
  background: #FFFDF8;
  border: 2px solid #F3C49E;
  border-radius: 18px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 8px 20px rgba(255, 123, 84, 0.12);
}

.inspector-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inspector-fabric {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid var(--border);
}

.inspector-meta {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.inspector-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Scene Toolbar */
.scene-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface-soft);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.toggle-pill input {
  accent-color: var(--primary);
  margin: 0;
}

/* Fullscreen Support */
.fullscreen-hud {
  display: none;
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: rgba(255, 253, 248, 0.88);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(235, 211, 176, 0.9);
  border-radius: 999px;
  padding: 6px 12px;
  gap: 8px;
  align-items: center;
  max-width: 94vw;
  flex-wrap: wrap;
  justify-content: center;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.2);
}

.fs-scene-pills {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.fs-scene-btn {
  border: none;
  background: transparent;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
}

.fs-scene-btn.active {
  background: var(--primary);
  color: #FFFFFF;
}

.scene-stage:fullscreen,
.scene-stage:-webkit-full-screen {
  border-radius: 0;
  border: none;
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
}

.scene-stage:fullscreen .fullscreen-hud,
.scene-stage:-webkit-full-screen .fullscreen-hud {
  display: flex;
}

/* Roster Gallery */
.roster-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.roster-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.roster-header p {
  margin: 3px 0 0;
}

.roster-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.roster-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 12px;
}

.roster-item {
  border: 2px solid var(--border);
  background: var(--surface-soft);
  border-radius: 16px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.roster-item:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.roster-item.selected {
  border-color: var(--primary);
  background: #FFF2E9;
}

.roster-svg-wrap {
  width: 96px;
  height: 104px;
}

.roster-name {
  font-weight: 800;
  font-size: 0.92rem;
  text-align: center;
}

.roster-sub {
  font-size: 0.76rem;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.roster-fabric-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--border);
}

.roster-item-btns {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.roster-mini-btn {
  border: 1.5px solid var(--border);
  background: #FFFFFF;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
}

.roster-mini-btn:hover {
  background: var(--bg-accent);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(45, 31, 20, 0.48);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-card {
  background: var(--surface);
  border: 2.5px solid var(--border);
  border-radius: 26px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(45, 31, 20, 0.25);
  position: relative;
  overflow: hidden;
  animation: modalPop 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.celebration-card {
  text-align: center;
}

.modal-badge {
  display: inline-block;
  background: #FFF1CC;
  color: #A65E00;
  font-weight: 900;
  font-size: 0.9rem;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.saved-preview-slot {
  width: 210px;
  height: 225px;
  margin: 0 auto 6px;
}

.celebration-card h3 {
  margin: 0 0 6px;
  font-size: 1.25rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.modal-actions .btn {
  flex: 1;
  min-width: 165px;
}

.confetti-burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  animation: confettiFall 1.3s ease-out forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(320px) rotate(420deg); opacity: 0; }
}

/* Doodle Modal */
.doodle-card {
  max-width: 520px;
}

.modal-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.modal-top h3 {
  margin: 0;
}

.modal-top p {
  margin: 3px 0 0;
}

.icon-close {
  border: 2px solid var(--border);
  background: var(--surface-soft);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-weight: 800;
  color: var(--ink-muted);
}

.doodle-palette {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.color-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  transition: transform 0.12s ease;
}

.color-dot.active {
  transform: scale(1.18);
  border-color: var(--ink);
}

.doodle-canvas-wrap {
  border: 2.5px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  background: #FFFDF7;
  touch-action: none;
}

#doodle-canvas {
  width: 100%;
  height: auto;
  display: block;
  cursor: crosshair;
}

.doodle-footer {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.doodle-tools {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brush-size-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
}

.brush-size-label input {
  width: 84px;
  accent-color: var(--primary);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  background: #3E2D20;
  color: #FFFDF8;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
}

/* Responsive */
@media (max-width: 960px) {
  .studio-grid {
    grid-template-columns: 1fr;
  }
  .stage-card {
    position: static;
  }
}

@media (max-width: 600px) {
  .app-shell {
    padding: 12px 12px 32px;
  }
  .animal-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
  }
  .animal-option {
    padding: 8px 4px;
  }
  .animal-option-outfit {
    display: none;
  }
  .dressing-mirror {
    height: 300px;
  }
  .animal-preview-slot {
    width: 255px;
    height: 275px;
  }
  .scene-stage {
    aspect-ratio: 4 / 3;
    border-radius: 18px;
  }
  .stage-animal {
    width: 22%;
  }
}
