/* LoveDigitalGift — mobile & touch-friendly layout */

@media (max-width: 768px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  /* --- Editor shell (sidebar + preview) --- */
  body.gift-editor-layout {
    flex-direction: column !important;
    height: 100dvh !important;
    max-height: 100dvh;
    overflow: hidden !important;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mobile-editor-switcher {
    display: flex;
    flex-shrink: 0;
    gap: 8px;
    padding: 8px 12px;
    background: #fff;
    border-bottom: 1px solid #fce7f3;
    z-index: 30;
  }

  .mobile-editor-switcher__btn {
    flex: 1;
    border: none;
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
    background: #f9fafb;
    cursor: pointer;
    min-height: 44px;
  }

  .mobile-editor-switcher__btn.is-active {
    color: #fff;
    background: linear-gradient(135deg, #f472b6, #ec4899);
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.25);
  }

  .gift-editor-aside {
    width: 100% !important;
    max-width: none !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    border-right: none !important;
    border-bottom: 1px solid #fce7f3;
  }

  .gift-editor-main {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    width: 100% !important;
    padding: 12px !important;
    overflow: hidden;
  }

  body.gift-editor-layout.mobile-show-edit .gift-editor-main {
    display: none !important;
  }

  body.gift-editor-layout.mobile-show-preview .gift-editor-aside {
    display: none !important;
  }

  .gift-editor-aside > .p-4:first-child,
  .gift-editor-aside > div:first-child {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px !important;
  }

  .gift-editor-aside h1 {
    font-size: 11px !important;
    max-width: 140px;
  }

  #btn-publish,
  #btn-save {
    font-size: 9px !important;
    padding: 8px 10px !important;
    min-height: 36px;
  }

  .paper-editor-main {
    padding: 12px !important;
    min-height: 0 !important;
  }

  .cake-editor-preview,
  .birthday-gift-editor-preview {
    min-height: 55dvh;
    border-radius: 12px !important;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .cake-editor-preview .birthday {
    min-height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .cake-editor-preview .birthday_inner__stage {
    position: relative !important;
    top: auto !important;
    transform: none !important;
  }

  /* --- Shared preview / view windows --- */
  .preview-window {
    aspect-ratio: auto !important;
    min-height: 68dvh;
    max-height: none !important;
    border-radius: 20px !important;
    width: 100% !important;
  }

  .scene {
    padding: 24px 16px !important;
  }

  /* --- Modals & toasts --- */
  .modal__card {
    width: calc(100vw - 24px) !important;
    max-width: 420px;
    margin: 12px;
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    text-align: center;
  }

  /* --- Touch targets --- */
  .touch-friendly button,
  .touch-friendly .start,
  .touch-friendly .mixer,
  .touch-friendly .add,
  .touch-friendly .sa,
  .touch-friendly .giftbox,
  .touch-friendly .item_inner,
  .touch-friendly .envelope-card,
  .touch-friendly #envelopeSeal {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .touch-friendly button,
  .touch-friendly .start,
  .touch-friendly .mixer,
  .touch-friendly .add,
  .touch-friendly .sa {
    min-height: 44px;
  }

  .touch-friendly .item_inner {
    min-width: 48px;
    min-height: 48px;
  }
}

@media (min-width: 769px) {
  .mobile-editor-switcher {
    display: none !important;
  }
}

/* --- Birthday cake experience (view5 + editor preview) --- */
@media (max-width: 768px) {
  body.cake-body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: env(safe-area-inset-top);
  }

  .cake-back,
  .birthday-gift-back {
    top: calc(12px + env(safe-area-inset-top));
    left: 12px;
    font-size: 10px;
    padding: 8px 12px;
  }

  .birthday {
    position: relative;
    min-height: 100dvh;
    padding: 52px 0 32px;
  }

  .birthday_inner {
    position: relative;
    min-height: calc(100dvh - 84px);
  }

  .birthday_inner__stage {
    position: relative !important;
    top: auto !important;
    transform: none !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 8px 12px 32px;
    margin: 0 auto;
  }

  .birthday_inner__modal {
    position: fixed;
    width: calc(100vw - 24px);
    max-width: 400px;
    padding: 32px 24px 88px;
    z-index: 50;
  }

  .birthday_inner__stage h1 {
    font-size: clamp(1.4rem, 6vw, 2rem);
  }

  .birthday_inner__stage h2 {
    font-size: 11px;
    line-height: 1.5;
    padding: 0 4px;
  }

  .birthday_inner__stage .mix {
    margin-top: 40px;
  }

  .birthday_inner__stage .mix_spoon {
    margin-left: 28px;
  }

  .birthday_inner__stage .oven img {
    width: min(260px, 85vw);
    left: 0;
  }

  .birthday_inner__stage .tin img {
    width: 72px;
  }

  .birthday_inner__stage .cakemake {
    margin-top: 120px;
  }

  .birthday_inner__stage .options {
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
  }

  .birthday_inner__stage .options .sponges,
  .birthday_inner__stage .options .fillings {
    float: none;
    width: 100%;
    max-width: 320px;
    margin: 0 !important;
  }

  .birthday_inner__stage .options .item {
    margin-right: 10px;
    margin-bottom: 8px;
  }

  .birthday_inner__stage .startagain {
    position: relative;
    right: auto;
    top: auto;
    margin: 16px auto 0;
    text-align: center;
  }

  .birthday .add,
  .birthday .sa,
  .birthday_inner__stage button.mixer,
  .birthday_inner__stage button.start {
    font-size: 18px;
    padding: 12px 22px;
    max-width: 92vw;
  }

  svg.cake-svg {
    width: min(340px, 92vw) !important;
  }

  .cake-balloons {
    max-width: 100%;
    height: auto;
    min-height: 100px;
    position: relative;
    top: 0;
    left: 0;
    transform: none;
    margin: 0 auto 8px;
  }

  .cake-balloons .balloon > div {
    width: clamp(40px, 11vw, 58px);
    height: clamp(54px, 14vw, 78px);
  }

  .cake-balloons .balloon > div span {
    font-size: clamp(1rem, 4vw, 1.8em) !important;
    padding-bottom: 10px;
  }

  .stage3 .tin.is-touch-target {
    outline: 2px dashed rgba(231, 117, 114, 0.5);
    outline-offset: 6px;
    border-radius: 8px;
  }

  .stage3 .tin.is-touch-target::after {
    content: "Tap to bake";
    display: block;
    font-family: georgia, serif;
    font-size: 10px;
    color: #b9918e;
    margin-top: 6px;
  }
}

/* --- Birthday gift surprise (view4) --- */
@media (max-width: 768px) {
  body.birthday-gift-body {
    overflow: hidden;
    min-height: 100dvh;
    height: 100dvh;
  }

  #birthdayGiftRoot {
    position: fixed;
    inset: 0;
    overflow: hidden;
  }

  .moon {
    right: 6% !important;
    top: 4% !important;
    width: 64px !important;
    height: 64px !important;
  }

  .moon .crater1 { width: 20px; height: 20px; }
  .moon .crater2 { width: 8px; height: 8px; }
  .moon .crater3 { width: 10px; height: 10px; }

  #people {
    width: 90px !important;
    left: 8px !important;
    bottom: 48px !important;
  }

  #beach {
    background-size: 120vw auto !important;
    background-position: bottom right;
  }

  #sea {
    height: 70px;
  }

  .giftbox {
    width: min(260px, 72vw) !important;
    margin-left: calc(min(260px, 72vw) / -2) !important;
    bottom: 28px !important;
    height: 170px !important;
  }

  .giftbox-hint {
    font-size: 20px !important;
  }

  .icons {
    left: 50% !important;
    right: auto !important;
    width: 92% !important;
    transform: translateX(-50%) !important;
    bottom: 200px;
    top: auto;
  }

  .icons .row span {
    font-size: clamp(28px, 8vw, 44px) !important;
  }

  #video {
    right: 50% !important;
    transform: translateX(50%);
    bottom: 100px !important;
    width: min(280px, 88vw);
  }

  #video iframe {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16 / 9;
    max-height: 160px;
  }

  .merrywrap {
    touch-action: manipulation;
  }
}

@media (max-width: 768px) and (max-height: 640px) {
  .icons {
    bottom: 170px;
  }

  .icons .row span {
    font-size: 24px !important;
  }

  #video {
    bottom: 72px !important;
  }
}
