:root {
  --bg-sky-top: #e8f5ff;
  --bg-sky-mid: #f7fbff;
  --bg-cream: #fffdf7;
  --ink-main: #3f342c;
  --ink-soft: #78695c;
  --accent-coral: #ff7e6b;
  --accent-peach: #ffb673;
  --accent-sun: #ffd86b;
  --accent-mint: #79c99e;
  --accent-sky: #74b9ff;
  --border-soft: rgba(120, 105, 92, 0.14);
  --shadow-card: 0 14px 36px rgba(90, 72, 52, 0.12);
  --shadow-soft: 0 8px 20px rgba(90, 72, 52, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-pill: 999px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "Hiragino Sans GB", "Rounded Mplus 1c", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink-main);
  background: linear-gradient(180deg, #dff1ff 0%, #f5f9ff 48%, #e4f5d5 100%);
}

#farmCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  display: block;
}

/* Top Birthday Header */
.top-header {
  position: fixed;
  top: 16px;
  left: 24px;
  right: 24px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.brand-banner {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 253, 247, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 2px solid rgba(255, 214, 153, 0.75);
  border-radius: var(--radius-pill);
  padding: 8px 22px 8px 10px;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.brand-banner:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}

.crown-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffe28a 0%, #ffb969 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 -2px 6px rgba(217, 130, 43, 0.25);
  flex-shrink: 0;
}

.title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.main-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--ink-main);
  line-height: 1.15;
}

.sub-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.status-pills {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 253, 247, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-main);
  box-shadow: var(--shadow-soft);
}

.pill-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #62c58a;
  box-shadow: 0 0 0 4px rgba(98, 197, 138, 0.22);
}

.pill-dot.idle {
  background: #d3c5b4;
  box-shadow: none;
}

/* Main Photo Stage (upper center ~54% height, leaves plenty of grassy pen below) */
.photo-stage-wrap {
  position: fixed;
  top: 78px;
  left: 0;
  right: 0;
  height: 52vh;
  min-height: 280px;
  max-height: 540px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 0 240px;
}

.photo-frame {
  pointer-events: auto;
  position: relative;
  width: 100%;
  max-width: 780px;
  height: 100%;
  background: var(--bg-cream);
  border-radius: var(--radius-xl);
  padding: 14px 14px 36px 14px;
  box-shadow:
    0 20px 50px rgba(82, 65, 47, 0.16),
    0 0 0 4px rgba(255, 255, 255, 0.85),
    0 0 0 7px rgba(255, 214, 153, 0.45);
  display: flex;
  flex-direction: column;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
}

.photo-frame.drag-over {
  transform: scale(1.02);
  box-shadow:
    0 24px 56px rgba(255, 126, 107, 0.28),
    0 0 0 4px var(--accent-coral);
}

.photo-viewport {
  position: relative;
  flex: 1;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(135deg, #fff6e8 0%, #fef0f3 50%, #edf7ff 100%);
}

.photo-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.9s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-slide.active {
  opacity: 1;
}

.photo-slide img.bg-blur {
  position: absolute;
  inset: -12%;
  width: 124%;
  height: 124%;
  object-fit: cover;
  filter: blur(22px) brightness(1.06) saturate(1.12);
  opacity: 0.42;
}

.photo-slide img.main-photo {
  position: relative;
  z-index: 2;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: kenBurns 12s ease-in-out infinite alternate;
}

@keyframes kenBurns {
  0% { transform: scale(1.0) translate(0, 0); }
  100% { transform: scale(1.045) translate(0, -4px); }
}

.photo-empty-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px;
  text-align: center;
}

.photo-empty-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink-main);
}

.photo-empty-desc {
  font-size: 14px;
  color: var(--ink-soft);
  max-width: 440px;
  line-height: 1.65;
}

.photo-empty-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.photo-footer {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 7px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}

.photo-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.photo-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(120, 105, 92, 0.22);
  transition: all 0.25s ease;
}

.photo-dot.active {
  width: 20px;
  border-radius: 999px;
  background: var(--accent-coral);
}

/* Corner Floating Cards: Left = Camera Auto-Capture, Right = Phone QR */
.side-widget {
  position: fixed;
  top: 88px;
  z-index: 12;
  width: 204px;
  background: rgba(255, 253, 247, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 22px;
  padding: 12px;
  box-shadow: var(--shadow-card);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.side-widget.left {
  left: 22px;
}

.side-widget.right {
  right: 22px;
}

.side-widget.collapsed {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px) scale(0.96);
}

.widget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.widget-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.widget-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: #fff0e5;
  color: #d96b38;
}

.widget-badge.live {
  background: #e3f7eb;
  color: #218852;
}

.camera-box {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  overflow: hidden;
  background: #f2ece3;
  border: 1.5px solid var(--border-soft);
}

.camera-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  display: block;
}

.camera-box canvas#camOverlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}

.camera-status {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: center;
  min-height: 18px;
}

.camera-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.qr-box {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  background: #fffdf8;
  border: 1.5px solid var(--border-soft);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-box svg {
  width: 100%;
  height: 100%;
  display: block;
}

.qr-caption {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-main);
  text-align: center;
  line-height: 1.45;
}

.qr-url {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: center;
  word-break: break-all;
}

/* Spotlight Arrival Toast */
.arrival-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.84);
  z-index: 30;
  background: rgba(255, 253, 247, 0.96);
  border: 3px solid #ffd480;
  border-radius: 30px;
  padding: 18px 30px;
  box-shadow: 0 24px 60px rgba(90, 72, 52, 0.22);
  display: flex;
  align-items: center;
  gap: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.arrival-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.arrival-avatar {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #ffb673;
  box-shadow: 0 8px 18px rgba(255, 140, 90, 0.28);
}

.arrival-text h3 {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink-main);
}

.arrival-text p {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-coral);
}

/* Bottom Dock */
.control-dock {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 253, 247, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-pill);
  padding: 8px 12px;
  box-shadow: var(--shadow-card);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.control-dock.hidden {
  opacity: 0;
  transform: translate(-50%, 24px);
  pointer-events: none;
}

.btn {
  border: none;
  outline: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

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

.btn-primary {
  background: linear-gradient(135deg, #ff8f73 0%, #ff6f61 100%);
  color: #fff;
  box-shadow: 0 6px 14px rgba(255, 111, 97, 0.28);
}

.btn-primary:hover {
  filter: brightness(1.04);
}

.btn-warm {
  background: linear-gradient(135deg, #ffd970 0%, #ffb85c 100%);
  color: #543818;
  box-shadow: 0 6px 14px rgba(255, 184, 92, 0.28);
}

.btn-soft {
  background: #f4eee4;
  color: var(--ink-main);
}

.btn-soft:hover {
  background: #ece3d5;
}

.btn-soft.active {
  background: #dff5e8;
  color: #1f7a49;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  flex: 1;
}

.dock-divider {
  width: 1px;
  height: 22px;
  background: var(--border-soft);
  margin: 0 2px;
}

/* Modal for editing birthday child & dress-up */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(63, 52, 44, 0.34);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-cream);
  border-radius: 26px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(63, 52, 44, 0.22);
  border: 2px solid rgba(255, 214, 153, 0.6);
}

.modal-card h2 {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 16px;
}

.form-row {
  margin-bottom: 14px;
}

.form-row label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.form-row input[type="text"],
.form-row input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1.5px solid var(--border-soft);
  background: #fff;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink-main);
  outline: none;
}

.form-row input:focus {
  border-color: var(--accent-coral);
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-soft);
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-main);
  cursor: pointer;
}

.chip.selected {
  background: #fff0e5;
  border-color: var(--accent-coral);
  color: #c94c38;
}

.modal-footer {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 1180px) {
  .photo-stage-wrap {
    padding: 0 210px;
  }
  .side-widget {
    width: 184px;
  }
}

/* iPhone / iPad Landscape AirPlay compact layout */
@media (max-width: 980px), (max-height: 540px) {
  .top-header {
    top: 8px;
    left: 12px;
    right: 12px;
  }
  .brand-banner {
    padding: 5px 14px 5px 6px;
    gap: 8px;
  }
  .crown-badge {
    width: 30px;
    height: 30px;
  }
  .main-title {
    font-size: 15px;
  }
  .sub-title {
    font-size: 10px;
  }
  .pill {
    padding: 5px 10px;
    font-size: 11px;
  }
  .photo-stage-wrap {
    top: 52px;
    height: 49vh;
    min-height: 165px;
    padding: 0 162px;
  }
  .photo-frame {
    padding: 8px 8px 24px 8px;
    border-radius: 18px;
  }
  .photo-empty-title {
    font-size: 15px;
  }
  .photo-empty-desc {
    font-size: 11px;
    line-height: 1.4;
  }
  .photo-footer {
    font-size: 10px;
    bottom: 2px;
  }
  .side-widget {
    top: 54px;
    width: 146px;
    padding: 8px;
    border-radius: 16px;
  }
  .side-widget.left { left: 10px; }
  .side-widget.right { right: 10px; }
  .widget-title { font-size: 11px; }
  .widget-badge { font-size: 9px; padding: 1px 5px; }
  .camera-status, .qr-caption { font-size: 10px; margin-top: 4px; }
  .qr-url { display: none; }
  .control-dock {
    bottom: 8px;
    padding: 5px 8px;
    gap: 5px;
  }
  .btn {
    padding: 6px 10px;
    font-size: 11px;
  }
}
