* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100vh;
  color: #15110b;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Hiragino Mincho Pro", serif;
  background: #d7ad53;
}
button { font: inherit; }
[hidden] { display: none !important; }

.landing {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: #f5efe3; color: #3c3024;
}
.landing-panel { width: min(100%, 560px); text-align: center; padding: 40px 28px; background: #fff; border-radius: 18px; }
.mini-brand { letter-spacing: .12em; font-size: 13px; }

.app-shell { min-height: 100vh; }
.screen {
  min-height: 100svh;
  width: 100%;
  background-size: cover;
  background-position: center top;
}
.screen-main { background-image: var(--bg-main); }
.screen-result { background-image: var(--bg-result); }

/* Common safe area: content follows the portrait artwork width, not browser width. */
.screen-content {
  width: min(82vw, 390px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(56px, env(safe-area-inset-top)) 0 max(54px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.brand-label { margin: 0 0 12px; font-size: 15px; letter-spacing: .20em; font-weight: 700; }
.start-title, .choice-title, .loading-title {
  margin: 0; white-space: pre-line; font-weight: 700; letter-spacing: .06em; line-height: 1.55;
  text-shadow: 0 1px rgba(255,255,255,.4);
}
.start-title { font-size: clamp(30px, 8vw, 45px); }
.choice-title, .loading-title { font-size: clamp(27px, 7vw, 39px); }
.start-lead, .choice-lead, .loading-message { white-space: pre-line; font-size: 17px; line-height: 1.9; font-weight: 600; }
.start-lead { margin: 22px 0 28px; }
.choice-lead { margin: 18px 0 26px; }
.loading-message { margin-top: 18px; }

.primary-button, .secondary-button {
  width: min(100%, 430px);
  max-width: 100%;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 700;
  padding: 17px 18px;
  box-shadow: 0 5px 15px rgba(90,38,20,.18);
}
.primary-button { background: #d63324; color: #fff; }
.primary-button:disabled { opacity: .56; cursor: wait; }
.secondary-button { margin-top: 26px; background: #c72f24; color: #fff; }
.daily-note { font-size: 13px; margin: 14px 0 0; font-weight: 700; }
.error-message { color: #8c1d14; background: rgba(255,255,255,.72); padding: 9px 12px; border-radius: 8px; }

/* Three-card choice: vertical-only floating motion with staggered timing. */
.card-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin: 0 auto;
}
.back-card {
  border: 0;
  padding: 0;
  width: 30%;
  max-width: 112px;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 6px 8px rgba(79,45,12,.25));
  transform-origin: 50% 50%;
  animation: cardVerticalFloat 2.35s ease-in-out infinite;
  will-change: transform, opacity, width;
  transition: width .34s ease, max-width .34s ease, opacity .28s ease, transform .34s ease, margin .34s ease;
}
.back-card:nth-child(1) { animation-delay: 0s; }
.back-card:nth-child(2) { animation-delay: -.38s; }
.back-card:nth-child(3) { animation-delay: -.76s; }
.back-card img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform .18s ease, filter .18s ease;
}
.back-card:hover img { transform: scale(1.035); filter: brightness(1.035); }
.back-card:active img { transform: translateY(3px) scale(.985); }
.back-card:disabled { cursor: default; }
.back-card.is-preparing { cursor: pointer; opacity: 1; }

/* After tapping, the two unselected cards disappear and the chosen one moves to center. */
.card-row.is-selecting .back-card { animation: none; }
.card-row.is-selecting .back-card.is-not-selected {
  width: 0;
  max-width: 0;
  margin: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateY(0) scale(.88);
}
.card-row.is-selecting .back-card.is-selected {
  width: 38%;
  max-width: 142px;
  opacity: 1;
  transform: translateY(-8px) scale(1.06);
}

@keyframes cardVerticalFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

/* Loading: keep the chosen card visible between the two dragons. */
.loading-content { position: relative; }
.loading-visual {
  position: relative;
  width: min(62vw, 280px);
  aspect-ratio: 1 / 1;
  margin: 0 auto 18px;
  animation: floatDragon 1.8s ease-in-out infinite;
}
.loading-selected-card {
  position: absolute;
  left: 50%;
  top: 53%;
  width: 30%;
  height: auto;
  transform: translate(-50%, -50%);
  z-index: 1;
  border-radius: 5px;
  filter: drop-shadow(0 7px 10px rgba(73,42,14,.28));
}
.loading-image {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  margin: 0;
  pointer-events: none;
}
@keyframes floatDragon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}

/* Fallback result layout for clients that use one fixed background image. */
.result-wrap {
  width: min(64vw, 300px);
  margin: 0 auto;
  padding: max(62px, env(safe-area-inset-top)) 0 max(78px, env(safe-area-inset-bottom));
}
.result-card-image { display: block; width: 90%; max-width: 440px; height: auto; margin: 0 auto 24px; border-radius: 14px; filter: drop-shadow(0 10px 16px rgba(72,40,12,.28)); }
.result-item-title { text-align: center; margin: 6px 0 22px; font-size: clamp(18px, 4.5vw, 22px); line-height: 1.5; }
.result-section { margin: 0 0 20px; }
.result-section h3 { margin: 0 0 6px; font-size: clamp(12px, 3.3vw, 14px); line-height: 1.6; }
.result-text {
  width: 100%;
  white-space: pre-line;
  font-size: clamp(12px, 3.3vw, 14px);
  line-height: 1.85;
  font-weight: 600;
  text-align: left;
  line-break: strict;
  overflow-wrap: break-word;
}
.same-day-note { text-align: center; margin: 24px 0 0; font-size: 12px; }
.line-save-message { margin: 12px 0 0; text-align: center; font-size: 12px; line-height: 1.7; }

/* ===== Reusable stretchable result frame =====
   Seam-safe construction:
   - top keeps the dragons through their full tails and fades naturally into the rail
   - middle is a true 1px stripe repeated vertically (never stretched)
   - bottom begins with the same stripe and gradually brings back the lower ornament
   The content can start before the top artwork ends, so the frame stays decorative
   without forcing a large blank area above the result.
*/
.df-stretch-result-frame .screen-result {
  background-image: none;
  background-color: #d7ad53;
  min-height: 100svh;
  padding: 0 0 max(18px, env(safe-area-inset-bottom));
}
.df-stretch-result-frame .result-wrap {
  position: relative;
  isolation: isolate;
  width: min(100%, 520px);
  margin: 0 auto;
  padding-top: clamp(155px, 31vw, 180px);
  padding-right: 8.5%;
  padding-bottom: clamp(165px, 32vw, 190px);
  padding-left: 8.5%;
  background-image: var(--result-frame-mid);
  background-repeat: repeat-y;
  background-position: center top;
  background-size: 100% 1px;
  overflow: hidden;
}
.df-stretch-result-frame .result-wrap::before,
.df-stretch-result-frame .result-wrap::after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 0;
  z-index: 0;
  pointer-events: none;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
}
.df-stretch-result-frame .result-wrap::before {
  top: 0;
  /* 941 x 881 */
  padding-top: 93.62%;
  background-image: var(--result-frame-top);
}
.df-stretch-result-frame .result-wrap::after {
  bottom: 0;
  /* 941 x 512 */
  padding-top: 54.41%;
  background-image: var(--result-frame-bottom);
}
.df-stretch-result-frame .result-wrap > * {
  position: relative;
  z-index: 1;
}
.df-stretch-result-frame .result-card-image {
  width: 100%;
  max-width: 440px;
  margin: 0 auto 28px;
  border-radius: 14px;
  filter: drop-shadow(0 12px 18px rgba(72,40,12,.30));
}
.df-stretch-result-frame .result-item-title,
.df-stretch-result-frame .result-section,
.df-stretch-result-frame .same-day-note,
.df-stretch-result-frame .secondary-button,
.df-stretch-result-frame #conciergeArea {
  display: block;
  width: 100%;
  max-width: none;
}
.df-stretch-result-frame .result-item-title {
  margin: 0 0 24px;
  padding: 0 1%;
  text-align: center;
  font-size: clamp(19px, 5vw, 25px);
  line-height: 1.55;
}
.df-stretch-result-frame .result-section {
  margin: 0 0 24px;
}
.df-stretch-result-frame .result-section h3 {
  margin: 0 0 7px;
  font-size: clamp(13px, 3.5vw, 16px);
  line-height: 1.55;
  text-align: left;
}
.df-stretch-result-frame .result-text {
  width: 100%;
  max-width: none;
  font-size: clamp(13px, 3.5vw, 16px);
  line-height: 1.9;
  text-align: left;
}
.df-stretch-result-frame .secondary-button {
  margin-top: 22px;
}
.df-stretch-result-frame .same-day-note { margin-top: 24px; }

@media (max-width: 430px) {
  .result-wrap { width: 64vw; }
  .df-stretch-result-frame .result-wrap { width: 100%; }
}

@media (min-width: 700px) {
  .screen-main {
    background-size: auto 100%;
    background-repeat: no-repeat;
    background-color: #d6ab50;
  }
  .screen-content { width: min(46svh, 390px); }
  .result-wrap { width: min(40svh, 300px); }
  .df-stretch-result-frame .result-wrap { width: min(100%, 520px); }
}

@media (prefers-reduced-motion: reduce) {
  .back-card, .loading-image { animation: none !important; }
  html { scroll-behavior: auto; }
}

/* ===== Phase 4.1: reusable concierge ===== */
.screen-concierge {
  min-height: 100svh;
  background: linear-gradient(180deg, #f8f1df 0%, #efe0b9 100%);
  padding: max(34px, env(safe-area-inset-top)) 20px max(38px, env(safe-area-inset-bottom));
}
.concierge-shell {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 28px 22px;
  background: rgba(255,255,255,.88);
  border: 1px solid rgba(128,92,38,.16);
  border-radius: 18px;
  box-shadow: 0 10px 32px rgba(88,58,20,.12);
  text-align: center;
}
.concierge-title {
  margin: 0;
  font-size: clamp(25px, 7vw, 34px);
  line-height: 1.5;
}
.concierge-lead {
  margin: 14px 0 24px;
  font-size: 15px;
  line-height: 1.9;
}
.concierge-choices {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
}
.concierge-choice-button,
.concierge-sub-button {
  width: 100%;
  border: 1px solid rgba(122,80,30,.24);
  border-radius: 10px;
  padding: 14px 15px;
  background: #fffaf0;
  color: #2d2419;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.6;
}
.concierge-answer,
.concierge-service {
  margin: 18px 0;
  padding: 18px;
  border-radius: 12px;
  background: rgba(255,250,240,.9);
  text-align: left;
}
.concierge-answer p,
.concierge-service p {
  margin: 0;
  white-space: pre-line;
  font-size: 15px;
  line-height: 1.9;
}
.concierge-service h3 {
  margin: 0 0 8px;
  font-size: 18px;
}
.concierge-service-link {
  display: block;
  margin-top: 14px;
  padding: 13px 16px;
  border-radius: 9px;
  background: #c72f24;
  color: #fff;
  text-decoration: none;
  text-align: center;
  font-weight: 700;
}
.concierge-empty {
  margin: 20px 0;
  font-size: 14px;
  line-height: 1.8;
}
.concierge-sub-button { margin-top: 18px; }
.concierge-back-link {
  display: inline-block;
  margin-top: 24px;
  color: #5b4630;
  font-size: 14px;
  text-underline-offset: 4px;
}
