/* 我貫神社 — 水面の暗転と和紙。localStorage / sessionStorage は使用しない（メモリのみ）。 */

:root {
  --ink: #1a1510;
  --ink-soft: rgba(26, 21, 16, 0.82);
  --paper: #f4efe6;
  --accent-muted: #8b3a2e;
  --gold: #e0c060;
  --debug-faint: rgba(0, 255, 200, 0.12);
  --font-serif: "Noto Serif JP", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --ease-slow: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-bg: 4.2s;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-serif);
  color: var(--ink-soft);
  background: #0a0f24;
  overflow-x: hidden;
}

/* 水面グラデーション — data-step で段階暗転 */
.app {
  min-height: 100vh;
  padding: clamp(1rem, 4vw, 2.5rem);
  padding-bottom: 4rem;
  transition:
    background var(--duration-bg) var(--ease-slow),
    color 2.8s var(--ease-slow);
  background:
    radial-gradient(120% 80% at 50% 100%, rgba(255, 200, 160, 0.35) 0%, transparent 55%),
    linear-gradient(180deg, #e8a574 0%, #c97d5c 28%, #6b5a52 62%, #2c3038 100%);
  background-color: #c97d5c;
}

.app[data-step="1"] {
  background:
    radial-gradient(ellipse 140% 70% at 50% 108%, rgba(255, 220, 190, 0.45) 0%, transparent 50%),
    linear-gradient(185deg, #f0c09a 0%, #d9996e 35%, #8a6a58 78%, #4a4540 100%);
  background-color: #d9996e;
  color: var(--ink-soft);
}

.app[data-step="2"] {
  background:
    radial-gradient(ellipse 120% 60% at 50% 100%, rgba(180, 140, 120, 0.2) 0%, transparent 55%),
    linear-gradient(185deg, #9a7a68 0%, #5c524c 45%, #353840 100%);
  background-color: #5c524c;
  color: rgba(244, 239, 230, 0.9);
}

.app[data-step="3"] {
  background:
    radial-gradient(ellipse 100% 50% at 50% 100%, rgba(80, 90, 110, 0.35) 0%, transparent 60%),
    linear-gradient(185deg, #3d3f48 0%, #282b34 55%, #1a1e28 100%);
  background-color: #282b34;
  color: rgba(236, 232, 224, 0.88);
}

.app[data-step="4"] {
  background:
    radial-gradient(ellipse 90% 45% at 50% 100%, rgba(40, 50, 80, 0.5) 0%, transparent 65%),
    linear-gradient(185deg, #222632 0%, #151a26 70%, #0f1320 100%);
  background-color: #151a26;
  color: rgba(230, 226, 218, 0.85);
}

.app[data-step="5"] {
  background:
    radial-gradient(ellipse 80% 40% at 50% 100%, rgba(20, 40, 90, 0.4) 0%, transparent 70%),
    linear-gradient(185deg, #0f1428 0%, #0a0f24 45%, #050812 100%);
  background-color: #0a0f24;
  color: rgba(220, 218, 210, 0.82);
}

.site-header {
  text-align: center;
  margin-bottom: clamp(1.5rem, 5vw, 2.5rem);
}

.site-mark {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  letter-spacing: 0.2em;
  font-weight: 700;
}

.site-mark .wabi {
  display: inline-block;
}

/* サブタイトル（現在地） */
.page-subtitle {
  margin: 0.35rem 0 0;
  font-family: var(--font-serif);
  font-size: 0.85rem;
  letter-spacing: 0.25em;
  font-weight: 500;
  transition: color 0.5s var(--ease-slow);
}

.app[data-step="1"] .page-subtitle {
  color: transparent; /* これで完全に背景と同化（透明化）します */
}

.app[data-step="intermission"] .page-subtitle {
  color: #ffcf71;
}

.app[data-step="2"] .page-subtitle {
  color: #b3e5fc;
}

.app[data-step="3"] .page-subtitle {
  color: #d8b4fe;
}

.app[data-step="4"] .page-subtitle {
  color: #ffb7b2;
}

.app[data-step="5"] .page-subtitle {
  color: #e3e3e3;
}

.step {
  display: none;
  max-width: 36rem;
  margin: 0 auto;
  animation: stepFade 0.9s var(--ease-slow) both;
}

.step--active {
  display: block;
}

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

.step-title {
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  font-weight: 600;
  letter-spacing: 0.28em;
  text-align: center;
  margin: 0 0 1.5rem;
}

/* 和紙 */
.washi-panel {
  position: relative;
  padding: clamp(1.25rem, 4vw, 2rem);
  border-radius: 2px;
  background-color: rgba(252, 248, 240, 0.88);
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E"),
    linear-gradient(165deg, rgba(255, 255, 255, 0.5) 0%, transparent 42%, rgba(0, 0, 0, 0.03) 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 12px 40px rgba(0, 0, 0, 0.12);
  color: var(--ink);
}

.washi-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(60, 45, 35, 0.06);
}

.field-group {
  border: none;
  margin: 0 0 1.25rem;
  padding: 0;
}

.legend {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  margin-bottom: 0.45rem;
  padding: 0;
}

.field-hint {
  font-size: 0.72rem;
  opacity: 0.75;
  margin: 0 0 0.5rem;
  line-height: 1.6;
}

.privacy-note {
  margin: 0.55rem 0 0;
  font-size: 0.7rem;
  line-height: 1.65;
  letter-spacing: 0.02em;
  color: var(--ink);
  opacity: 0.65;
}

.input-washi {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  line-height: 1.65;
  border: none;
  border-bottom: 1px solid rgba(40, 30, 25, 0.22);
  background: rgba(255, 255, 255, 0.35);
  color: var(--ink);
  resize: vertical;
  min-height: 3.5rem;
  transition: border-color 0.3s ease, background 0.3s ease;
}

input.input-washi {
  min-height: auto;
  resize: none;
}

textarea.input-washi {
  min-height: 3.5rem;
}

.input-washi--block {
  margin-top: 0.35rem;
}

.input-washi--block:first-of-type {
  margin-top: 0;
}

.field-micro-label {
  margin: 0.65rem 0 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  opacity: 0.78;
}

.field-group--birth > .birth-date-time-row:first-child {
  margin-top: 0;
}

.birth-date-time-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  column-gap: 15px;
  row-gap: 0.35rem;
  align-items: start;
  margin-top: 0.15rem;
}

.birth-date-time-row__label-date {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  align-self: end;
}

.birth-date-time-row__label-time {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  align-self: end;
  display: block;
}

.birth-date-time-row .birth-ymd {
  grid-column: 1;
  grid-row: 2;
  align-self: start;
  justify-self: start;
}

.birth-date-time-row__time-stack {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  align-self: start;
}

@media (max-width: 520px) {
  .birth-date-time-row {
    grid-template-columns: 1fr;
    row-gap: 0.45rem;
  }

  .birth-date-time-row__label-date {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    opacity: 0.88;
    align-self: start;
  }

  .birth-date-time-row .birth-ymd {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    max-width: 100%;
  }

  .birth-date-time-row .input-washi--year,
  .birth-date-time-row .input-washi--month,
  .birth-date-time-row .input-washi--day {
    min-height: 2.75rem;
    font-size: 1rem;
    box-sizing: border-box;
  }

  .birth-date-time-row__label-time {
    grid-column: 1;
    grid-row: 3;
    margin: 0.85rem 0 0;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    opacity: 0.88;
    align-self: start;
  }

  .birth-date-time-row__time-stack {
    grid-column: 1;
    grid-row: 4;
    width: 100%;
  }

  .birth-date-time-row__time-stack .input-washi--time {
    font-size: 1rem;
    min-height: 2.75rem;
  }

  .birth-place-block {
    margin-top: 0.85rem;
  }

  .birth-place-label {
    margin-top: 0;
    margin-bottom: 0.4rem;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    opacity: 0.88;
  }

  .field-group--birth #birth-place.input-washi--block {
    margin-top: 0;
    font-size: 1rem;
    min-height: 2.75rem;
  }

  .form-section-divider {
    margin-top: 1.15rem;
    margin-bottom: 0.35rem;
  }
}

.birth-ymd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem 0.45rem;
  width: fit-content;
  max-width: 100%;
}

.birth-ymd-unit {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  flex: 0 0 auto;
}

.birth-ymd-unit--year .input-washi--year {
  width: 4.35rem;
  min-width: 4rem;
  max-width: 5rem;
  flex: 0 0 auto;
}

.birth-ymd-unit--md .input-washi--month,
.birth-ymd-unit--md .input-washi--day {
  width: 2.65rem;
  min-width: 2.65rem;
  max-width: 3rem;
  flex: 0 0 auto;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}

.birth-ymd-suffix {
  font-size: 0.8rem;
  color: var(--ink-soft);
  opacity: 0.85;
  white-space: nowrap;
  user-select: none;
}

.input-washi--time {
  margin-top: 0;
  width: 100%;
  min-height: 2.5rem;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}

.input-washi--time:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.label-time-unknown {
  color: var(--ink);
  opacity: 0.88;
}

.label-time-unknown input {
  accent-color: var(--accent-muted);
}

.field-group .input-washi--block:last-of-type {
  margin-top: 0.75rem;
}

.birth-place-block {
  margin-top: 0;
}

.birth-place-label {
  display: block;
  margin: 1.1rem 0 0.35rem;
}

.field-group--birth #birth-place.input-washi--block {
  margin-top: 0;
}

.form-section-divider {
  border: none;
  border-top: 1px solid rgba(40, 30, 25, 0.14);
  margin: 1.15rem 0 0.65rem;
  padding: 0;
  height: 0;
}

.input-washi:focus {
  outline: none;
  border-bottom-color: var(--accent-muted);
  background: rgba(255, 255, 255, 0.55);
}

.input-washi::placeholder {
  color: rgba(26, 21, 16, 0.35);
}

.offering-block {
  margin: 1.5rem 0 1.25rem;
  padding: 0.85rem 0;
  border-top: 1px solid rgba(40, 30, 25, 0.12);
  border-bottom: 1px solid rgba(40, 30, 25, 0.12);
}

.offering-title {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
}

.offering-body {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.75;
  opacity: 0.88;
}

.btn-primary,
.btn-secondary {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  font-family: var(--font-serif);
  font-size: 0.88rem;
  letter-spacing: 0.18em;
  cursor: pointer;
  border: none;
  background: var(--ink);
  color: var(--paper);
  transition: opacity 0.25s ease, transform 0.2s ease;
}

.btn-primary:hover,
.btn-secondary:hover {
  opacity: 0.88;
}

.btn-primary:active,
.btn-secondary:active {
  transform: scale(0.99);
}

.btn-secondary {
  margin-top: 1.75rem;
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
  opacity: 0.85;
}

.app[data-step="1"] .btn-secondary {
  border-color: var(--ink);
  color: var(--ink);
}

.step-inner {
  text-align: center;
}

.step-inner--narrow {
  max-width: 22rem;
  margin: 0 auto;
}

.step-inner--stage {
  max-width: min(500px, 100%);
  width: 100%;
  margin: 0 auto;
  padding: 0 clamp(0.25rem, 2vw, 0.75rem);
}

.step-title--minimal {
  margin-bottom: 0.65rem;
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  letter-spacing: 0.35em;
  opacity: 0.72;
}

.step-footer--stage {
  max-width: 100%;
}

.step-footer {
  margin-top: 1.75rem;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  gap: 16px;
  align-items: stretch;
  max-width: 40rem;
  margin-left: auto;
  margin-right: auto;
}

.step-inner:not(.step-inner--narrow):not(.step-inner--final) .step-footer {
  max-width: 40rem;
}

.step-footer .btn-back,
.step-footer .btn-secondary {
  flex: 1;
  margin: 0;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  border-radius: 4px;
  transition: all 0.3s ease;
  box-sizing: border-box;
}

/* 進むボタン（メインアクション） */
.step-footer .btn-secondary {
  background: rgba(138, 127, 166, 0.15);
  border: 1px solid #8a7fa6;
  color: #e3e3e3;
}

.step-footer .btn-secondary:hover {
  background: rgba(138, 127, 166, 0.35);
  box-shadow: 0 0 15px rgba(138, 127, 166, 0.4);
  color: #fff;
  transform: translateY(-2px);
}

/* 戻るボタン（サブアクション） */
.step-footer .btn-back {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(227, 227, 227, 0.25);
  color: rgba(227, 227, 227, 0.7);
}

.step-footer .btn-back:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(227, 227, 227, 0.5);
  color: #e3e3e3;
  transform: translateY(-2px);
}

.step-footer .btn-back:focus-visible,
.step-footer .btn-secondary:focus-visible {
  outline: 2px solid rgba(227, 227, 227, 0.6);
  outline-offset: 2px;
}

.step-footer--final {
  flex-direction: column;
  max-width: 22rem;
  margin-top: 2rem;
}

.step-footer--final .btn-cta {
  margin: 0;
}

.step-footer--final .btn-reset {
  margin-top: 0.35rem;
}

@media (max-width: 600px) {
  .step-footer {
    flex-direction: column;
    gap: 12px;
  }

  .step-footer .btn-back,
  .step-footer .btn-secondary {
    width: 100%;
  }

  /* 長いタイトル（ハウス名など）が枠からはみ出さないように折り返す */
  .planet-message-modal__title {
    font-size: 1rem;
    word-break: break-all;
    overflow-wrap: break-word;
  }
}

/* ホロスコープ（Step 2 舞台） */
.horoscope-wrap {
  position: relative;
  width: min(100%, 500px, 85vh);
  max-width: 500px;
  aspect-ratio: 1;
  max-height: min(500px, 85vh);
  height: auto;
  margin: 0 auto 1rem;
  box-sizing: border-box;
}

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

.horoscope-ring {
  stroke: currentColor;
  stroke-width: 0.6;
  opacity: 0.35;
}

.house-lines line {
  stroke: currentColor;
  stroke-width: 0.3;
  opacity: 0.18;
}

.zodiac-signs text {
  font-family: var(--font-serif);
  font-size: 8px;
  fill: currentColor;
  opacity: 0.5;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.house-numbers text {
  font-family: var(--font-mono);
  font-size: 6px;
  fill: currentColor;
  opacity: 0.3;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.star-field {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  z-index: 2;
}

.star {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  transform: translate(var(--sx), var(--sy));
  transition: transform 0.3s var(--ease-slow);
  opacity: 0.88;
  -webkit-tap-highlight-color: transparent;
}

.star:hover {
  transform: translate(var(--sx), calc(var(--sy) - 8px)) scale(1.05) !important;
  z-index: 10;
}

.star.star--instant {
  transform: translate(var(--sx), var(--sy));
  opacity: 0.88;
  animation: none;
}

.star__dot {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 3px;
  background: rgba(15, 20, 35, 0.82);
  border: 1px solid currentColor;
  color: rgba(220, 230, 220, 0.82);
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
  pointer-events: none;
  transition:
    transform 0.26s var(--ease-slow),
    box-shadow 0.26s ease,
    color 0.26s ease,
    text-shadow 0.26s ease,
    filter 0.26s ease,
    border-color 0.26s ease;
}

.star:hover .star__dot,
.star:focus-visible .star__dot {
  transform: scale(1.25);
  color: #fff;
  border-color: rgba(255, 250, 245, 0.95);
  box-shadow:
    0 0 10px 2px rgba(255, 255, 255, 0.28),
    0 0 22px 5px rgba(200, 185, 255, 0.35),
    0 0 36px 10px rgba(160, 210, 255, 0.12);
  text-shadow:
    0 0 6px rgba(255, 255, 255, 0.95),
    0 0 14px rgba(210, 190, 255, 0.65),
    0 0 22px rgba(180, 160, 255, 0.35);
  filter: brightness(1.08);
}

.star:active .star__dot {
  transform: scale(1.12);
}

.star:focus-visible {
  outline: 2px solid rgba(120, 220, 200, 0.55);
  outline-offset: 2px;
}

.star.star--enter {
  animation: fallAndSettle 1.8s ease-out forwards;
}

@keyframes fallAndSettle {
  0% {
    transform: translate(var(--sx), -200px);
    opacity: 0;
  }
  100% {
    transform: translate(var(--sx), var(--sy));
    opacity: 0.88;
  }
}

.star.star--glow .star__dot {
  animation: starGlow 3.2s ease-in-out infinite;
}

.star.star--glow {
  z-index: 3;
}

@keyframes starGlow {
  0%,
  100% {
    color: rgba(220, 230, 220, 0.82);
    border-color: rgba(220, 230, 220, 0.55);
    box-shadow: none;
    text-shadow: none;
    filter: brightness(1);
    transform: scale(1);
  }
  45% {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow:
      0 0 12px 3px rgba(255, 255, 255, 0.35),
      0 0 26px 8px rgba(200, 185, 255, 0.45),
      0 0 42px 12px rgba(170, 200, 255, 0.2);
    text-shadow:
      0 0 8px rgba(255, 255, 255, 1),
      0 0 18px rgba(220, 200, 255, 0.75),
      0 0 28px rgba(190, 170, 255, 0.45);
    filter: brightness(1.12);
    transform: scale(1.22);
  }
}

/* 待合（Step 1.5）— 受信ドット */
.intermission-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 2rem;
}

.intermission-loading__label {
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  opacity: 0.8;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0.45;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
  animation: intermissionTypingDot 1.35s ease-in-out infinite;
}

.intermission-loading .typing-dot:nth-child(2) {
  animation-delay: 0s;
}

.intermission-loading .typing-dot:nth-child(3) {
  animation-delay: 0.2s;
}

.intermission-loading .typing-dot:nth-child(4) {
  animation-delay: 0.4s;
}

@keyframes intermissionTypingDot {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  40% {
    transform: translateY(-5px);
    opacity: 0.85;
  }
}

/* 天体メッセージモーダル（和風サイバーパンク） */
.planet-message-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 1.75rem);
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity 0.4s var(--ease-slow),
    visibility 0.4s;
}

.planet-message-modal.is-open {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

/* 待合室モーダル — 深いトワイライト（紫〜墨）とゴールド */
#intermission-modal.planet-message-modal {
  z-index: 9500;
  background: rgba(20, 15, 30, 0.95);
}

#intermission-modal .planet-message-modal__backdrop {
  background: linear-gradient(
    165deg,
    rgba(55, 38, 72, 0.55) 0%,
    rgba(22, 16, 34, 0.82) 45%,
    rgba(12, 10, 22, 0.9) 100%
  );
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: default;
}

#intermission-modal .planet-message-modal__panel {
  background: rgba(26, 20, 38, 0.97);
  border: 1px solid rgba(224, 192, 96, 0.28);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35) inset,
    0 20px 48px rgba(0, 0, 0, 0.5),
    0 0 36px rgba(120, 90, 140, 0.12),
    0 0 24px rgba(224, 192, 96, 0.06);
  color: rgba(238, 236, 244, 0.92);
}

#intermission-modal .intermission-loading__label {
  color: rgba(245, 232, 210, 0.88);
}

#intermission-modal .intermission-loading .typing-dot {
  background: var(--gold);
  box-shadow:
    0 0 0 1px rgba(224, 192, 96, 0.45),
    0 0 10px rgba(224, 192, 96, 0.55),
    0 0 20px rgba(224, 192, 96, 0.25);
}

#intermission-modal .dialogue-speaker {
  color: var(--gold);
  opacity: 0.88;
}

#intermission-modal .dialogue-text {
  color: rgba(238, 238, 242, 0.92);
}

/* 待合室モーダル：「神楽殿へ進む」ボタンをゴールドの結界デザインに */
#intermission-modal #btn-proceed-kagura {
  color: #ffcf71;
  border: 1px solid rgba(255, 207, 113, 0.6);
  background: rgba(20, 15, 30, 0.6);
  box-shadow:
    0 0 12px rgba(255, 207, 113, 0.15),
    inset 0 0 5px rgba(255, 207, 113, 0.1);
  text-shadow: 0 0 5px rgba(255, 207, 113, 0.5);
  font-weight: 700;
  transition: all 0.3s ease;
  opacity: 1;
}

#intermission-modal #btn-proceed-kagura:hover,
#intermission-modal #btn-proceed-kagura:focus-visible {
  background: rgba(255, 207, 113, 0.15);
  border-color: #ffcf71;
  box-shadow:
    0 0 20px rgba(255, 207, 113, 0.4),
    inset 0 0 10px rgba(255, 207, 113, 0.2);
  color: #fff;
}

/* 入力エラーモーダル：「戻る」ボタンの視認性向上（エラー色に合わせた赤系） */
#custom-alert-modal #custom-alert-close {
  color: #ffb7b2;
  border: 1px solid rgba(255, 183, 178, 0.5);
  background: transparent;
  font-weight: 600;
  transition: all 0.3s ease;
}

#custom-alert-modal #custom-alert-close:hover,
#custom-alert-modal #custom-alert-close:focus-visible {
  background: rgba(255, 183, 178, 0.1);
  border-color: #ffb7b2;
  color: #fff;
  box-shadow: 0 0 15px rgba(255, 183, 178, 0.2);
}

.planet-message-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 18, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.planet-message-modal__panel {
  position: relative;
  z-index: 1;
  width: min(100%, 26rem);
  max-height: min(70dvh, 32rem);
  overflow: auto;
  padding: 1.35rem 1.25rem 1.25rem;
  box-sizing: border-box;
  background: rgba(15, 20, 35, 0.95);
  border: 1px solid rgba(100, 200, 190, 0.22);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35) inset,
    0 20px 50px rgba(0, 0, 0, 0.55),
    0 0 40px rgba(60, 140, 130, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(232, 238, 236, 0.92);
  text-align: left;
}

/* モーダルタイトルエリアのスタイル定義 */
.planet-message-modal__title-area {
  border-bottom: 1px solid rgba(150, 100, 255, 0.3);
  margin-bottom: 1.5rem;
  padding-bottom: 15px;
  text-align: left;
}

.planet-message-modal__subtitle {
  font-size: 0.75rem;
  color: #ffcf71;
  letter-spacing: 0.1em;
  display: block;
}

.planet-message-modal__title {
  font-size: 1.15rem;
  font-weight: 600;
  color: #b3e5fc;
  letter-spacing: 0.05em;
  margin-top: 4px;
  line-height: 1.3;
}

.planet-message-modal__close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1.35rem;
  line-height: 1;
  color: rgba(200, 220, 215, 0.75);
  background: transparent;
  border: 1px solid rgba(120, 180, 170, 0.25);
  border-radius: 2px;
  cursor: pointer;
  transition:
    color 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease;
}

.planet-message-modal__close:hover {
  color: rgba(240, 252, 248, 0.95);
  border-color: rgba(140, 220, 200, 0.45);
  background: rgba(0, 255, 200, 0.06);
}

.planet-message-modal__close:focus-visible {
  outline: 2px solid rgba(100, 220, 200, 0.5);
  outline-offset: 2px;
}

.planet-message-modal__header {
  margin: 0 2.25rem 0.85rem 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.45;
  color: rgba(220, 245, 238, 0.95);
  font-family: var(--font-serif);
}

.planet-message-modal__typing {
  margin: 0;
  min-height: 4.5rem;
  font-size: 0.82rem;
  line-height: 1.75;
  letter-spacing: 0.03em;
  color: rgba(210, 218, 222, 0.88);
  font-family: var(--font-serif);
  white-space: pre-wrap;
  word-break: break-word;
}

.planet-message-modal__typing::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 1em;
  margin-left: 1px;
  vertical-align: -0.12em;
  background: rgba(120, 220, 190, 0.65);
  animation: planetCursorBlink 1s step-end infinite;
}

.planet-message-modal.is-typing-done .planet-message-modal__typing::after {
  display: none;
}

@keyframes planetCursorBlink {
  0%,
  50% {
    opacity: 1;
  }
  51%,
  100% {
    opacity: 0;
  }
}

#planet-message-modal #btn-return-stage {
  transition:
    background 0.25s ease,
    border-color 0.25s ease,
    color 0.25s ease,
    box-shadow 0.25s ease,
    opacity 0.25s ease;
}

#btn-return-stage:hover,
#btn-return-stage:focus-visible {
  background: rgba(150, 100, 255, 0.15);
  border-color: #d8b4fe;
  color: #fff;
  box-shadow: 0 0 15px rgba(150, 100, 255, 0.3);
  opacity: 1;
}

.dialogue-block {
  text-align: left;
  max-width: 32rem;
  margin: 0 auto 0.5rem;
  line-height: 1.85;
}

.dialogue-speaker {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  opacity: 0.65;
  margin: 0 0 0.5rem;
}

.dialogue-text {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
}

.dialogue-text--dim {
  opacity: 0.78;
  font-size: 0.82rem;
}

.dialogue-text--accent {
  opacity: 0.92;
}

.type-soft {
  animation: typeReveal 0.02s step-end forwards;
}

@keyframes typeReveal {
  from {
    opacity: 0.6;
  }
  to {
    opacity: 1;
  }
}

/* 絵馬 + サーチライト */
.ema-scene {
  position: relative;
  perspective: 1200px;
  margin: 0 auto 2rem;
  width: min(500px, 90vw);
  overflow: visible;
}

.ema-scene::before {
  content: "";
  position: absolute;
  left: -30%;
  top: -35%;
  width: 160%;
  height: 170%;
  pointer-events: none;
  background: radial-gradient(
    ellipse 42% 36% at 50% 48%,
    rgba(255, 248, 230, 0.16) 0%,
    rgba(255, 248, 230, 0.05) 38%,
    transparent 72%
  );
  transform: translate(-8%, -6%);
  animation: searchSweep 8s ease-in-out infinite;
  z-index: 0;
}

@keyframes searchSweep {
  0%,
  100% {
    transform: translate(-14%, -10%);
    opacity: 0.85;
  }
  50% {
    transform: translate(12%, 8%);
    opacity: 1;
  }
}

.ema-flip {
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: 1.6;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  cursor: pointer;
  transition: transform 1.1s var(--ease-slow);
}

.ema-flip.is-flipped {
  transform: rotateY(180deg);
}

.ema-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  clip-path: polygon(15% 0, 85% 0, 100% 25%, 100% 100%, 0 100%, 0 25%);
  box-shadow: none;
  color: var(--ink);
  filter: drop-shadow(0 15px 25px rgba(0, 0, 0, 0.4));
}

.ema-face--front {
  transform: rotateY(0deg);
  z-index: 2;
  background: linear-gradient(145deg, rgba(232, 220, 200, 0.92) 0%, rgba(200, 180, 155, 0.85) 100%);
  opacity: 1;
  transition: opacity 0.3s ease;
}

.ema-front-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-start;
  padding: 4.5rem 2rem 1.5rem;
  box-sizing: border-box;
  overflow-y: auto;
}

.ema-face--back {
  transform: rotateY(180deg);
  z-index: 1;
  background: linear-gradient(155deg, #182038 0%, #0f1423 100%);
  color: #e3e3e3;
  padding: 0;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.ema-face--back .ema-kanji-bg {
  color: #ffcf71;
  opacity: 0.08;
}

/* 絵馬が裏返った（.is-flipped）時の強制上書き */
.ema-flip.is-flipped .ema-face--front {
  opacity: 0;
  pointer-events: none;
}

.ema-flip.is-flipped .ema-face--back {
  opacity: 1;
  pointer-events: auto;
}

.ema-kanji-bg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10rem;
  font-weight: 700;
  color: var(--ink);
  opacity: 0.05;
  z-index: 0;
  pointer-events: none;
}

/* 表面の巨大な「我」の漢字の基本指定 */
.ema-face--front .ema-kanji-bg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10rem;
  font-weight: 700;
  color: var(--ink);
  opacity: 0.05;
  z-index: 0;
  pointer-events: none;
  transition: all 1s ease;
}

/* 「我」の呪術点滅（アニメーションあり）：タイピング完了かつ未タップ時 */
.ema-face--front.is-ema-prayer-done:not(.is-ema-interaction-done) .ema-kanji-bg {
  color: #ff3333;
  opacity: 0.25;
  text-shadow: 0 0 10px rgba(255, 51, 51, 0.4);
  animation: emaKanjiBreathe 3s ease-in-out infinite;
  transition: opacity 1s ease, color 1s ease;
}

/* 「我」の固定表示（アニメーションなし）：タップ後 */
.ema-face--front.is-ema-interaction-done .ema-kanji-bg {
  color: #ff3333;
  opacity: 0.25;
  text-shadow: 0 0 10px rgba(255, 51, 51, 0.4);
  animation: none;
}

/* 「我」の呼吸（明滅）アニメーション */
@keyframes emaKanjiBreathe {
  0%,
  100% {
    text-shadow: 0 0 10px rgba(255, 51, 51, 0.4);
  }
  50% {
    text-shadow: 0 0 25px rgba(255, 51, 51, 0.9), 0 0 40px rgba(255, 51, 51, 0.6);
  }
}

.ema-prayer-typing {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--ink);
  text-align: left;
  font-family: var(--font-serif);
  white-space: pre-wrap;
  word-break: break-word;
}

.ema-prayer-typing::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.12em;
  background: rgba(26, 21, 16, 0.6);
  animation: planetCursorBlink 1s step-end infinite;
}

.is-ema-typing-done .ema-prayer-typing::after,
.is-ema-prayer-typing-done .ema-prayer-typing::after {
  display: none;
}

.ema-back-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-start;
  padding: 4.5rem 2rem 1.5rem;
  box-sizing: border-box;
  overflow-y: auto;
  text-align: left;
}

.ema-prayer-typing {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--ink);
  text-align: left;
  font-family: var(--font-serif);
  white-space: pre-wrap;
  word-break: break-word;
}

.ema-prayer-typing::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.12em;
  background: rgba(26, 21, 16, 0.6);
  animation: planetCursorBlink 1s step-end infinite;
}

.ema-analysis-typing {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.8;
  text-align: left;
  font-family: var(--font-serif);
  white-space: pre-wrap;
  word-break: break-word;
  color: #e3e3e3;
}

.ema-analysis-typing::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.12em;
  background: rgba(227, 227, 227, 0.7);
  animation: planetCursorBlink 1s step-end infinite;
}

.is-ema-analysis-typing-done .ema-analysis-typing::after {
  display: none;
}

/* スクロールバー全体の幅 */
.ema-front-inner::-webkit-scrollbar,
.ema-back-inner::-webkit-scrollbar {
  width: 7px;
}

/* スクロールバーの軌道（トラック） */
.ema-front-inner::-webkit-scrollbar-track,
.ema-back-inner::-webkit-scrollbar-track {
  background: rgba(26, 21, 16, 0.05);
  border-radius: 4px;
}

/* スクロールバーの持ち手（サム） */
.ema-front-inner::-webkit-scrollbar-thumb,
.ema-back-inner::-webkit-scrollbar-thumb {
  background: rgba(26, 21, 16, 0.5);
  border-radius: 4px;
  border: 1px solid rgba(224, 192, 96, 0.2);
}

/* ホバー時の持ち手 */
.ema-front-inner::-webkit-scrollbar-thumb:hover,
.ema-back-inner::-webkit-scrollbar-thumb:hover {
  background: rgba(138, 122, 70, 0.8);
  box-shadow: 0 0 5px rgba(224, 192, 96, 0.3);
}

.step-hint {
  font-size: 0.72rem;
  opacity: 0.55;
  margin: 0 0 0.5rem;
  letter-spacing: 0.08em;
}

/* 神様のセリフエリア */
.tarot-dialogue-box {
  min-height: 5rem;
  margin-bottom: 2rem;
  text-align: left;
}

.tarot-typing-text {
  font-size: 0.9rem;
  line-height: 1.8;
  color: #e3e3e3;
  margin: 0;
}

.tarot-typing-text::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.12em;
  background: rgba(227, 227, 227, 0.7);
  animation: planetCursorBlink 1s step-end infinite;
}

.is-god-typing-done .tarot-typing-text::after {
  display: none;
}

/* 3枚のカードデッキコンテナ */
.tarot-deck {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  align-items: center;
  min-height: 350px;
  perspective: 1000px;
  transition: gap 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.tarot-deck.has-selected {
  gap: 0;
}

/* 個別のカードラップ */
.tarot-card-wrap {
  width: min(100px, 28vw);
  aspect-ratio: 3 / 4;
  cursor: pointer;
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ホバーで少し浮き上がる */
.tarot-card-wrap:hover:not(.is-selected):not(.is-discarded) {
  transform: translateY(-10px) scale(1.05);
}

/* 選ばれなかったカード（スゥッと消える） */
.tarot-card-wrap.is-discarded {
  opacity: 0;
  width: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  transform: scale(0.5);
  pointer-events: none;
}

/* 選ばれたカード（中央で巨大化） */
.tarot-card-wrap.is-selected {
  width: min(280px, 75vw);
  pointer-events: none;
}

/* 3Dフリップ構造 */
.tarot-card-3d {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 1s var(--ease-slow);
}

.tarot-card-3d.is-flipped {
  transform: rotateY(180deg);
}

/* 面の共通スタイル */
.tarot-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 4px;
}

/* 裏面（和風の柄を想定した黒金グラデ） */
.tarot-card-back {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 1px solid rgba(224, 192, 96, 0.3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tarot-card-back::after {
  content: "我貫";
  color: rgba(224, 192, 96, 0.15);
  font-size: 2rem;
  font-weight: bold;
  font-family: var(--font-serif);
}

/* 表面（画像を入れる側） */
.tarot-card-front {
  transform: rotateY(180deg);
  background: transparent;
}

/* 透過画像対応の最強ドロップシャドウ発光 */
.tarot-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.5));
  transition: filter 0.4s ease;
}

/* めくられた後の発光とクリック可能化 */
.tarot-card-wrap.is-revealed {
  pointer-events: auto;
}

.tarot-card-wrap.is-revealed:not(.is-read):hover {
  transform: translateY(-8px) scale(1.03);
}

/* まだ詳細を読んでいない（未タップの）カードのみ発光・呼吸させる */
.tarot-card-wrap.is-revealed:not(.is-read) .tarot-img {
  animation: tarotImageBreathe 3.5s ease-in-out infinite;
}

.tarot-card-wrap.is-revealed:not(.is-read):hover .tarot-img {
  filter: drop-shadow(0 0 25px rgba(150, 100, 255, 0.8));
}

/* 一度詳細を読んだ（タップした）後は、静かな影で固定（発光停止） */
.tarot-card-wrap.is-revealed.is-read .tarot-img {
  filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.5));
  animation: none;
}

@keyframes tarotImageBreathe {
  0%,
  100% {
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 0 rgba(150, 100, 255, 0));
  }
  50% {
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 20px rgba(150, 100, 255, 0.5));
  }
}

/* タロットモーダルのタイピングカーソル制御 */
.is-tarot-typing-done #tarot-typing-area::after {
  display: none;
}

/* 御朱印 */
.goshuin-stage {
  position: relative;
  width: min(260px, 75vw);
  margin: 0 auto 1.75rem;
  min-height: 200px;
}

.goshuin-book {
  margin: 0 auto;
  width: 88%;
  aspect-ratio: 3 / 4;
  background: linear-gradient(90deg, #2a2420 0%, #3d3530 8%, #e8dfd4 12%, #f5f0e8 50%, #e8dfd4 88%, #3d3530 92%, #2a2420 100%);
  border-radius: 2px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.goshuin-book-inner {
  text-align: center;
  color: var(--ink);
}

.goshuin-book-title {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: 0.35em;
  font-weight: 700;
}

.goshuin-book-sub {
  margin: 0.35rem 0 0;
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  opacity: 0.7;
}

.stamp-layer {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
  opacity: 0;
}

.stamp-layer.stamp--bang {
  animation: stampBang 0.85s var(--ease-slow) forwards;
}

@keyframes stampBang {
  0% {
    transform: translate(-50%, -50%) scale(2.2) rotate(-8deg);
    opacity: 0;
  }
  55% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05) rotate(2deg);
  }
  72% {
    transform: translate(-50%, -50%) scale(0.98) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    opacity: 1;
  }
}

.stamp-seal {
  width: 88px;
  height: 88px;
  border: 3px solid rgba(180, 40, 40, 0.92);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(200, 50, 50, 0.95);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 0 1px rgba(255, 100, 100, 0.15) inset;
}

.stamp-char {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0;
}

.dialogue-block--final .dialogue-text {
  font-size: 0.84rem;
}

.btn-cta {
  display: block;
  width: 100%;
  max-width: 22rem;
  margin: 2rem auto 0;
  padding: 1rem 1.25rem;
  text-align: center;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: #f0ebe3;
  background: linear-gradient(180deg, rgba(120, 40, 45, 0.95) 0%, rgba(70, 20, 28, 0.98) 100%);
  text-decoration: none;
  border-radius: 2px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.btn-cta:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-cta:focus-visible {
  outline: 2px solid rgba(255, 200, 180, 0.5);
  outline-offset: 3px;
}

.btn-reset {
  display: block;
  margin: 1.25rem auto 0;
  padding: 0.35rem 0.75rem;
  font-family: var(--font-serif);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: inherit;
  opacity: 0.45;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-reset:hover {
  opacity: 0.75;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .star.star--enter,
  .star.star--instant {
    animation: none;
    transform: translate(var(--sx), var(--sy));
    opacity: 0.88;
  }
}
