/* =============================================
   誰も知らない6000の結末 — style.css
   ============================================= */

:root {
  --bg-primary: #000000;
  --bg-secondary: #1A1A1A;
  --bg-input: #111111;
  --text-primary: #FFFFFF;
  --text-secondary: #888888;
  --border-default: #333333;
  --border-focus: #FFFFFF;
  --accent-character: #E63946;
  --accent-stage: #7DF9FF;
  --accent-trigger: #FFBF00;
  --transition-speed: 0.5s;
}

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

html, body {
  width: 100%; height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Noto Sans JP', sans-serif;
  overflow-x: hidden;
}

#app {
  width: 100%;
  min-height: 100dvh;
  position: relative;
}

/* ── 画面共通 ─────────────────────────────── */
.screen {
  display: none;
  opacity: 0;
  width: 100%;
  min-height: 100dvh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: opacity var(--transition-speed) ease-in-out;
}
.screen.active {
  display: flex;
  opacity: 1;
}

/* ── アプリコンテナ ─────────────────────── */
.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px 40px;
  gap: 20px;
}

.scroll-container {
  justify-content: flex-start;
  padding-top: 48px;
  overflow-y: auto;
}

@media (min-width: 1024px) {
  body {
    background: radial-gradient(ellipse at center, #1a1a1a 0%, #000 70%);
  }
  .app-container {
    max-width: 420px;
  }
}

/* ── フルスクリーン背景 ──────────────────── */
.fullscreen-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.bg-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

/* ── フォールバックテキスト ─────────────── */
.fallback-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px;
  background: var(--bg-primary);
  text-align: center;
}

.guidance-line {
  font-size: 16px;
  font-weight: 400;
  line-height: 2;
  letter-spacing: 0.08em;
  opacity: 0;
  animation: fadeInUp 0.6s ease forwards;
}
.guidance-line:nth-child(1) { animation-delay: 0.2s; }
.guidance-line:nth-child(2) { animation-delay: 0.7s; }
.guidance-line:nth-child(3) { animation-delay: 1.2s; }

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

/* ── スクリーンフッター（絶対配置ボタン） ─ */
.screen-footer {
  position: absolute;
  bottom: max(40px, env(safe-area-inset-bottom, 40px));
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  z-index: 10;
}

/* ── テキスト系 ─────────────────────────── */
.title-text {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: 0.05em;
  text-align: center;
}
.category-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.card-text  { font-size: 13px; font-weight: 500; }
.story-text {
  font-size: 15px;
  font-weight: 400;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-all;
}
.question-text { font-size: 15px; font-weight: 500; line-height: 1.7; }
.hint-text {
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
}
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

@media (min-width: 1024px) {
  .title-text    { font-size: 26px; }
  .category-label{ font-size: 15px; }
  .card-text     { font-size: 14px; }
  .story-text    { font-size: 16px; line-height: 2; }
  .question-text { font-size: 16px; }
}

/* ── ボタン ─────────────────────────────── */
.btn {
  width: 100%;
  max-width: 300px;
  padding: 14px;
  font-size: 14px;
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--text-primary);
  color: var(--text-primary);
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
  position: relative;
  z-index: 2;
}
.btn:hover, .btn:active {
  background: var(--text-primary);
  color: var(--bg-primary);
}
.btn--character:hover { border-color: var(--accent-character); background: var(--accent-character); color: #fff; }
.btn--stage:hover     { border-color: var(--accent-stage);     background: var(--accent-stage);     color: #000; }
.btn--trigger:hover   { border-color: var(--accent-trigger);   background: var(--accent-trigger);   color: #000; }

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  align-items: center;
}

/* Screen16 専用：リスタートボタンは小さめサブトーン */
.btn--restart {
  font-size: 12px;
  padding: 10px 14px;
  opacity: 0.55;
  letter-spacing: 0.1em;
  border-color: rgba(255,255,255,0.35);
  color: rgba(255,255,255,0.55);
}
.btn--restart:hover, .btn--restart:active {
  opacity: 1;
  background: transparent;
  border-color: var(--text-primary);
  color: var(--text-primary);
}

/* ── カード基本 ─────────────────────────── */
.card {
  border-radius: 12px;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: var(--bg-secondary);
  position: relative;
}
.card img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.card-result {
  width: 70vw;
  max-width: 280px;
}
.card-small {
  width: 28vw;
  max-width: 120px;
  flex-shrink: 0;
}
@media (min-width: 1024px) {
  .card-result { max-width: 240px; }
  .card-small  { width: 140px; max-width: 140px; }
}

.card-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 12px; text-align: center;
  font-size: 12px; line-height: 1.6;
}

/* ── Swiper デッキ ───────────────────────── */
.swiper {
  width: 100%;
  padding: 24px 0 32px !important;
  cursor: grab;
}
.swiper:active { cursor: grabbing; }

.swiper-slide {
  width: 60vw !important;
  max-width: 260px !important;
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-secondary);
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.swiper-slide img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  pointer-events: none; user-select: none;
}
.swiper-slide-active   { transform: scale(1.08) !important; opacity: 1 !important; }
.swiper-slide-prev,
.swiper-slide-next     { transform: scale(0.85) !important; opacity: 0.55 !important; }

/* ── 結果表示 ────────────────────────────── */
.result-card-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.result-label {
  text-align: center;
  max-width: 280px;
  line-height: 1.7;
}
.fade-in-child {
  opacity: 0;
  animation: fadeIn 0.6s 0.1s ease forwards;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── めくりモーション ────────────────────── */
.flip-screen { justify-content: center; }

.motion-wrap {
  width: 60vw;
  max-width: 260px;
  aspect-ratio: 2 / 3;
  position: relative;
}
.motion-video {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}

/* CSSフリップ */
.card-flip {
  width: 100%; height: 100%;
  perspective: 1000px;
}
.card-flip-inner {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.8s ease-in-out;
}
.card-flip-inner.flipped { transform: rotateY(180deg); }

.card-front, .card-back {
  position: absolute;
  width: 100%; height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-secondary);
}
.card-back { transform: rotateY(180deg); }
.card-front img, .card-back img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}

/* ── 3枚並び ─────────────────────────────── */
.three-cards-row {
  display: flex;
  flex-direction: row;
  gap: 8px;
  justify-content: center;
}
.three-cards-row.mini { gap: 6px; margin-bottom: 4px; }
.three-cards-row.mini .card-small { width: 22vw; max-width: 90px; }

.three-cards-labels {
  display: flex;
  flex-direction: row;
  gap: 8px;
  justify-content: center;
  text-align: center;
}
.three-card-label-item {
  width: 28vw;
  max-width: 120px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.5;
  word-break: break-all;
  flex-shrink: 0;
}
@media (min-width: 1024px) {
  .three-card-label-item { width: 140px; max-width: 140px; }
}

/* ── テキストエリア ──────────────────────── */
.textarea {
  width: 100%;
  min-height: 130px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.8;
  border-radius: 8px;
  padding: 14px;
  resize: vertical;
}
.textarea:focus {
  border-color: var(--border-focus);
  outline: none;
}
.char-counter {
  align-self: flex-end;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: -10px;
}

/* ── ストーリーボックス ──────────────────── */
.story-box {
  width: 100%;
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 20px;
}
.story-preview-box {
  width: 100%;
  max-height: 180px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 16px;
}

/* ── ユーザー結末表示 ────────────────────── */
.user-ending-box {
  width: 100%;
  padding: 16px;
  border-left: 3px solid var(--text-primary);
  background: var(--bg-input);
  border-radius: 0 8px 8px 0;
}
.user-ending-text { font-size: 14px; line-height: 1.8; }

/* ── 区切り線 ────────────────────────────── */
.divider {
  width: 40%;
  height: 1px;
  background: var(--text-primary);
  opacity: 0.3;
}

/* ── AIオチ表示 ─────────────────────────── */
.ai-endings-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.ai-ending-item {
  width: 100%;
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 16px;
  opacity: 0;
  animation: fadeIn 0.6s ease forwards;
}
.ai-ending-body {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.9;
  white-space: pre-wrap;
  margin-bottom: 10px;
}
.ai-ending-pattern {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.ai-ending-desc {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
  line-height: 1.6;
}

/* ── ローディング ────────────────────────── */
.loading-text {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
}
.dot-anim {
  display: inline-block;
  animation: dotPulse 1.2s steps(4, end) infinite;
  overflow: hidden;
  width: 24px;
  vertical-align: bottom;
}
@keyframes dotPulse { 0%{width:0} 100%{width:24px} }

/* ── フェードオーバーレイ ───────────────── */
.fade-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 100;
}
.fade-overlay.visible { opacity: 1; pointer-events: all; }
