/* 客向け SPA（スマホ縦持ち 360〜430px 基準） */

.app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) var(--gutter) max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.noscript {
  margin: 30vh 0 0;
  text-align: center;
}

[tabindex="-1"]:focus {
  outline: none;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  animation: screen-in 0.6s var(--ease) both;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ================= イントロ ================= */

.intro {
  align-items: center;
  text-align: center;
  padding-top: 2vh;
  animation: none;
}

.intro > * {
  animation: rise 0.9s var(--ease) both;
}

.intro > :nth-child(2) { animation-delay: 0.15s; }
.intro > :nth-child(3) { animation-delay: 0.3s; }
.intro > :nth-child(4) { animation-delay: 0.42s; }
.intro > :nth-child(5) { animation-delay: 0.54s; }
.intro > :nth-child(6) { animation-delay: 0.66s; }
.intro > :nth-child(7) { animation-delay: 0.78s; }
.intro > :nth-child(8) { animation-delay: 0.9s; }
.intro > :nth-child(9) { animation-delay: 1s; }

.intro-logo {
  width: 72px;
  height: auto;
  opacity: 0.92;
}

.intro-title-wrap {
  position: relative;
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  gap: 10px;
  margin: 3.5vh 0 1vh;
}

/* 縦書きの題字。両脇にロゴの器の曲線を細く添える */
.intro-title {
  margin: 0;
  writing-mode: vertical-rl;
  font-size: clamp(2.5rem, min(12vw, 6.4vh), 3.25rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.3em;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.35);
}

.intro-reading {
  margin: 0.4em 0 0;
  writing-mode: vertical-rl;
  font-size: 0.8125rem;
  letter-spacing: 0.5em;
  color: var(--cream-3);
}

.intro-title-wrap::before,
.intro-title-wrap::after {
  content: "";
  position: absolute;
  bottom: -14px;
  width: 30px;
  height: 46%;
  border-bottom: 1px solid var(--line-strong);
}

.intro-title-wrap::before {
  left: -42px;
  border-left: 1px solid var(--line-strong);
  border-bottom-left-radius: 30px 26px;
}

.intro-title-wrap::after {
  right: -42px;
  border-right: 1px solid var(--line-strong);
  border-bottom-right-radius: 30px 26px;
}

/* 再来店のあいさつ */
.intro-welcome {
  margin: 1.6em 0 0;
  padding: 0.9em 1.6em;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.intro-welcome-name {
  margin: 0;
  font-size: 0.875rem;
  color: var(--cream-2);
  letter-spacing: 0.12em;
}

.intro-welcome-who {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--cream);
}

.intro-welcome-text {
  margin: 0.3em 0 0;
  font-size: 0.9375rem;
  letter-spacing: 0.14em;
}

.intro-edit-profile {
  margin-top: 1em;
  padding: 0.6em 1em;
  border: 0;
  background: none;
  color: var(--cream-3);
  font: inherit;
  font-size: 0.8125rem;
  letter-spacing: 0.1em;
  text-decoration: underline;
  text-underline-offset: 0.3em;
  cursor: pointer;
}

.intro-lead {
  margin: 1.8em 0 0.8em;
  font-size: 1.0625rem;
  letter-spacing: 0.2em;
}

.intro-weather {
  margin: 0 0 1.6em;
}

.intro-note {
  margin: 0 0 1.6em;
  font-size: 0.875rem;
  line-height: 2.1;
  color: var(--cream-3);
}

.intro-time {
  display: block;
  margin-top: 0.8em;
  font-size: 0.75rem;
  letter-spacing: 0.3em;
}

.btn-start {
  width: min(100%, 280px);
}

.intro-error {
  width: 100%;
  padding: 1em;
  border: 1px solid var(--line);
  color: var(--danger);
}

.intro-error p {
  margin: 0 0 1em;
}

.intro-foot {
  margin: auto 0 0;
  padding-top: 2em;
  font-size: 0.6875rem;
  color: var(--cream-4);
  letter-spacing: 0.4em;
}

/* ================= 質問 ================= */

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

.q-back {
  padding-left: 8px;
  letter-spacing: 0.12em;
}

.q-count {
  font-size: 0.75rem;
  color: var(--cream-3);
  padding-right: 8px;
}

.progress {
  display: flex;
  gap: 4px;
  margin: 6px 0 0;
}

.progress-seg {
  flex: 1;
  height: 2px;
  background: var(--line);
  transition: background-color 0.4s var(--ease);
}

.progress-seg.is-done {
  background: var(--cream-3);
}

.progress-seg.is-current {
  background: var(--cream);
}

.q-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-top: 7vh;
}

.q-ordinal {
  margin: 0;
  font-size: 0.8125rem;
  letter-spacing: 0.5em;
  color: var(--cream-3);
}

.q-prompt {
  margin: 0.4em 0 0;
  font-size: clamp(1.5rem, 6.6vw, 1.75rem);
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0.1em;
  word-break: auto-phrase;
  text-wrap: balance;
}

.q-hint,
.q-optional {
  margin: 0.6em 0 0;
  font-size: 0.875rem;
  color: var(--cream-3);
  line-height: 1.8;
}

.q-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  margin-top: 4vh;
}

.q-foot {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: auto calc(var(--gutter) * -1) 0;
  padding: 28px var(--gutter) max(8px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(1, 42, 47, 0), rgba(1, 42, 47, 0.92) 36%);
}

.q-foot .btn-bowl {
  width: min(100%, 300px);
}

.q-error {
  min-height: 1.6em;
  margin: 10px 0 0;
  font-size: 0.875rem;
  color: var(--danger);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.3s, transform 0.3s var(--ease);
}

.q-error.is-shown {
  opacity: 1;
  transform: none;
}

.q-note {
  margin: 14px 0 0;
  font-size: 0.8125rem;
  color: var(--cream-3);
  text-align: right;
  letter-spacing: 0.12em;
}

/* 文字入力: 下線だけの静かな欄 */
.q-field {
  position: relative;
  display: block;
}

.q-input {
  width: 100%;
  min-height: 56px;
  padding: 10px 4.5em 10px 2px;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  font-size: 1.375rem; /* 16px 以上（iOS のズーム防止） */
  letter-spacing: 0.08em;
  transition: border-color 0.3s;
}

.q-type-email .q-input {
  font-size: 1.125rem;
  letter-spacing: 0.02em;
  padding-right: 2px;
}

.q-input::placeholder {
  color: var(--cream-4);
}

.q-input:focus {
  outline: none;
  border-bottom-color: var(--cream);
}

.q-counter {
  position: absolute;
  right: 2px;
  bottom: 16px;
  font-size: 0.75rem;
  color: var(--cream-4);
  letter-spacing: 0.08em;
}

.q-counter.is-over {
  color: var(--danger);
}

/* 選択肢: 罫線で区切った品書きのような並び */
.q-options {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}

.q-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 12px 10px 12px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  transition: background-color 0.25s var(--ease), padding 0.25s var(--ease);
}

.q-option:hover {
  background: var(--wash);
}

.q-option:active {
  background: var(--wash-2);
}

.q-option-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.q-option-label {
  font-size: 1.1875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  line-height: 1.5;
}

.q-option-hint {
  font-size: 0.8125rem;
  color: var(--cream-3);
  letter-spacing: 0.08em;
}

.q-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-family: var(--font-roman);
  font-size: 0.75rem;
  color: var(--ink);
  transition: background-color 0.25s, border-color 0.25s, transform 0.25s var(--ease);
}

.q-option.is-selected {
  background: var(--wash-2);
  padding-left: 12px;
}

.q-option.is-selected .q-mark {
  background: var(--cream);
  border-color: var(--cream);
  transform: scale(1.08);
}

.q-options.is-chosen .q-option:not(.is-selected) {
  opacity: 0.4;
  transition: opacity 0.3s;
}

/* 札: 縦長のカードを 4×2 に */
.q-deck {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.q-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 3 / 4.6;
  min-height: 92px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(243, 238, 226, 0.06), transparent 60%),
    var(--teal-deep);
  box-shadow:
    inset 0 0 0 4px var(--teal-deep),
    inset 0 0 0 5px var(--line),
    0 6px 18px rgba(0, 0, 0, 0.25);
  transition: transform 0.35s var(--ease), background-color 0.3s, box-shadow 0.35s, opacity 0.3s;
}

.q-deck > .q-card:nth-child(odd) { transform: rotate(-1.2deg); }
.q-deck > .q-card:nth-child(even) { transform: rotate(0.9deg); }
.q-deck > .q-card:nth-child(3n) { transform: rotate(-0.4deg) translateY(3px); }

.q-deck > .q-card:hover {
  transform: translateY(-3px) rotate(0deg);
}

.q-card-num {
  position: absolute;
  top: 9px;
  font-size: 0.5625rem;
  color: var(--cream-3);
  letter-spacing: 0.1em;
}

.q-card-label {
  font-size: 1.875rem;
  font-weight: 600;
  line-height: 1;
}

.q-deck > .q-card.is-selected {
  background: var(--cream);
  color: var(--ink);
  box-shadow:
    inset 0 0 0 4px var(--cream),
    inset 0 0 0 5px rgba(1, 42, 47, 0.3),
    0 10px 30px rgba(0, 0, 0, 0.4);
  transform: translateY(-6px) rotate(0deg) scale(1.04);
}

.q-card.is-selected .q-card-num {
  color: rgba(1, 42, 47, 0.5);
}

.q-deck.is-chosen .q-card:not(.is-selected) {
  opacity: 0.3;
}

/* 同意チェック */
.q-check {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 44px;
  margin-top: 18px;
  padding: 10px 0;
  font-size: 0.9375rem;
  line-height: 1.7;
  cursor: pointer;
}

.q-check-input {
  position: absolute;
  opacity: 0;
  width: 24px;
  height: 24px;
  margin: 0;
}

.q-check-box {
  flex: none;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  display: grid;
  place-items: center;
  transition: background-color 0.2s;
}

.q-check-box::after {
  content: "";
  width: 6px;
  height: 11px;
  margin-top: -3px;
  border: solid var(--ink);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.2s var(--ease);
}

.q-check-input:checked + .q-check-box {
  background: var(--cream);
  border-color: var(--cream);
}

.q-check-input:checked + .q-check-box::after {
  transform: rotate(45deg) scale(1);
}

.q-check-input:focus-visible + .q-check-box {
  outline: 2px solid var(--cream-2);
  outline-offset: 3px;
}

.q-privacy {
  margin: 10px 0 0;
  padding-left: 36px;
  font-size: 0.75rem;
  color: var(--cream-3);
  line-height: 1.8;
}

/* ================= 占い中 ================= */

.fortune {
  position: relative;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  min-height: 80vh;
}

.fortune-stage {
  width: 200px;
  height: 170px;
}

.fortune-bowl {
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  stroke: var(--cream);
  stroke-linecap: round;
}

.fortune-bowl .bowl {
  stroke-width: 5;
}

.fortune-bowl .steam {
  stroke-width: 2.4;
  stroke-dasharray: 120;
  stroke-dashoffset: 120;
  opacity: 0;
  animation: steam 3.2s ease-in-out infinite;
}

.fortune-bowl .steam-2 { animation-delay: 0.9s; }
.fortune-bowl .steam-3 { animation-delay: 1.7s; }

@keyframes steam {
  0% {
    stroke-dashoffset: 120;
    opacity: 0;
    transform: translateY(8px);
  }
  30% {
    opacity: 0.75;
  }
  70% {
    opacity: 0.35;
  }
  100% {
    stroke-dashoffset: 0;
    opacity: 0;
    transform: translateY(-14px);
  }
}

.fortune-leaves {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* 舞う茶葉: 細い葉の形を、揺れながら落とす */
.leaf {
  position: absolute;
  top: -20px;
  left: var(--x);
  width: 9px;
  height: 18px;
  border-radius: 0 100% 0 100%;
  background: linear-gradient(135deg, #7d9a5a, #3f6038);
  opacity: 0;
  animation: leaf-fall 6s linear infinite;
  animation-delay: var(--d);
  transform: rotate(var(--r));
}

@keyframes leaf-fall {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(var(--r));
  }
  10% {
    opacity: 0.7;
  }
  50% {
    transform: translate3d(24px, 45vh, 0) rotate(calc(var(--r) + 160deg));
  }
  90% {
    opacity: 0.5;
  }
  100% {
    opacity: 0;
    transform: translate3d(-12px, 90vh, 0) rotate(calc(var(--r) + 320deg));
  }
}

.fortune-title {
  position: relative;
  margin: 28px 0 6px;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: 0.3em;
}

.fortune-dots i {
  font-style: normal;
  display: inline-block;
  animation: dot 1.4s ease-in-out infinite;
}

.fortune-dots i:nth-child(2) { animation-delay: 0.2s; }
.fortune-dots i:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot {
  0%,
  100% {
    opacity: 0.2;
  }
  50% {
    opacity: 1;
  }
}

.fortune-for {
  margin: 0;
  font-size: 0.875rem;
  color: var(--cream-2);
  letter-spacing: 0.16em;
}

.fortune-line {
  position: relative;
  min-height: 1.8em;
  margin: 26px 0 0;
  font-size: 0.875rem;
  color: var(--cream-3);
  letter-spacing: 0.3em;
}

.fortune-line.is-in {
  animation: rise 0.6s var(--ease) both;
}

/* ================= エラー ================= */

.error-screen {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
}

.error-mark {
  margin: 0;
  writing-mode: vertical-rl;
  font-size: 1.25rem;
  letter-spacing: 0.6em;
  color: var(--cream-4);
}

.error-title {
  margin: 16px 0 0;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.error-message {
  max-width: 22em;
  margin: 8px 0 28px;
  color: var(--cream-2);
  font-size: 0.9375rem;
}

.error-screen .btn-bowl {
  width: min(100%, 280px);
}
