:root {
  --bg: #0c0c14;
  --bg-grad-end: #141420;
  --text: #c4c0b0;
  --text-dim: #5a5748;
  --text-bright: #e0dcc8;
  --accent: #7a9aaa;
  --accent-dim: #4a6a7a;
  --paper-text: #1e1e1e;
  --border: rgba(122, 154, 170, 0.12);
}

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

body {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-grad-end) 100%);
  color: var(--text);
  font-family: 'Shippori Mincho', 'Yu Mincho', 'Hiragino Mincho ProN', serif;
  font-weight: 400;
  line-height: 2.1;
  font-size: 16px;
  min-height: 100vh;
  letter-spacing: 0.02em;
}

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

@keyframes paperFloat {
  0% { transform: translateY(40px) rotate(-0.5deg); opacity: 0; }
  100% { transform: translateY(0) rotate(0deg); opacity: 1; }
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 80px 20px 120px;
}

/* ===== ヘッダー ===== */
header {
  text-align: center;
  margin-bottom: 80px;
  animation: fadeIn 1.2s ease-out;
}

header h1 {
  font-family: 'Shippori Mincho', serif;
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: 0.35em;
  margin-bottom: 14px;
  color: var(--text-bright);
}

header .subtitle {
  font-size: 0.9rem;
  color: var(--text-dim);
  letter-spacing: 0.18em;
  font-weight: 400;
}

/* ===== 導入文 ===== */
.intro {
  margin-bottom: 72px;
  padding: 36px 32px;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  animation: fadeIn 1.4s ease-out 0.2s both;
}

.intro p {
  margin-bottom: 1.4em;
  text-align: justify;
}

.intro p:last-child { margin-bottom: 0; }

/* ===== 装飾 ===== */
.deco-line {
  width: 1px;
  height: 60px;
  background: linear-gradient(180deg, transparent, var(--accent-dim), transparent);
  margin: 56px auto;
  opacity: 0.4;
}

/* ===== 入力フォーム ===== */
.form-section {
  margin-bottom: 80px;
  animation: fadeIn 1.4s ease-out 0.4s both;
}

.form-section h2 {
  font-family: 'Shippori Mincho', serif;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.25em;
  margin-bottom: 52px;
  text-align: center;
  color: var(--text-dim);
}

.question {
  margin-bottom: 52px;
}

.question-label {
  display: block;
  font-size: 1rem;
  margin-bottom: 22px;
  letter-spacing: 0.06em;
  color: var(--text-bright);
}

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.option-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 14px 26px;
  font-family: 'Shippori Mincho', serif;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.5s ease;
  letter-spacing: 0.04em;
}

.option-btn:hover {
  border-color: var(--accent-dim);
  color: var(--text);
}

.option-btn.selected {
  border-color: var(--accent);
  color: var(--text-bright);
  background: rgba(122, 154, 170, 0.06);
}

.name-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-bright);
  font-family: 'Shippori Mincho', serif;
  font-size: 1rem;
  padding: 14px 4px;
  outline: none;
  transition: border-color 0.4s;
  letter-spacing: 0.04em;
}

.name-input:focus {
  border-color: var(--accent-dim);
}

.name-input::placeholder {
  color: var(--text-dim);
  opacity: 0.4;
}

.submit-btn {
  display: block;
  margin: 64px auto 0;
  background: transparent;
  border: 1px solid var(--accent-dim);
  color: var(--text-bright);
  padding: 18px 64px;
  font-family: 'Shippori Mincho', serif;
  font-size: 1rem;
  letter-spacing: 0.25em;
  cursor: pointer;
  transition: all 0.5s ease;
}

.submit-btn:hover {
  background: rgba(122, 154, 170, 0.1);
  border-color: var(--accent);
}

.submit-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* ===== 結果画面 ===== */
.result {
  display: none;
  animation: fadeIn 1s ease-out;
}

.result.active {
  display: block;
}

.scene-text {
  font-size: 0.92rem;
  color: var(--text-dim);
  margin-bottom: 48px;
  padding: 20px 24px;
  border-left: 2px solid var(--border);
  line-height: 2.2;
}

/* ===== 3D 紙めくり ===== */
.flip-scene {
  perspective: 1400px;
  margin-bottom: 36px;
}

/* 高さは表の中身から決める。
   両面とも absolute にすると親が中身の高さを知れず、紙が下の要素へ重なる
   （改修前は 1280px で 49px、320px では 457px 重なっていた） */
.flip-object {
  position: relative;
  width: 100%;
  transform-style: preserve-3d;
  transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

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

.flip-face {
  width: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* 表は通常フロー。これが親の高さを決める */
.flip-face-front {
  position: relative;
}

/* 裏は表にぴったり重ねる。高さは親＝表に従う */
.flip-face-back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
}

/* 見えていない面はクリックを拾わせない。
   表のめくり角と裏の戻る角は画面上でぴったり重なるので（z-index も同じ 10）、
   これが無いとどちらが当たるか不定になり、裏から戻れないことがある */
.flip-face-back { pointer-events: none; }
.flip-object.flipped .flip-face-back { pointer-events: auto; }
.flip-object.flipped .flip-face-front { pointer-events: none; }

.flip-face-back > .back-paper {
  height: 100%;
}

/* ===== 手紙（表） ===== */
.letter-paper {
  color: var(--paper-text);
  padding: 56px 40px 80px;
  box-shadow:
    0 8px 48px rgba(0,0,0,0.35),
    0 2px 8px rgba(0,0,0,0.15);
  animation: paperFloat 1.4s ease-out;
  position: relative;
  overflow: hidden;
  min-height: 580px;
  background-size: cover;
  background-position: center;
}

/* 横線オーバーレイ */
.letter-paper::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    transparent,
    transparent 33px,
    rgba(0,0,0,0.015) 33px,
    rgba(0,0,0,0.015) 34px
  );
  pointer-events: none;
  z-index: 1;
}

/* ===== 紙画像 ===== */
.paper-wet    { background-image: url('assets/paper-wet.webp'); }
.paper-sun    { background-image: url('assets/paper-sunburned.webp'); }
.paper-folded { background-image: url('assets/paper-folded.webp'); }
.paper-bleed  { background-image: url('assets/paper-bleeding.webp'); }
.paper-env    { background-image: url('assets/paper-envelope.webp'); }

/* ===== 紙の状態よる文字効果 ===== */
.paper-wet .letter-body p:last-child {
  filter: blur(0.25px);
  opacity: 0.92;
}

.paper-bleed .letter-body p:nth-child(2) {
  filter: blur(0.35px);
  opacity: 0.88;
}

.paper-folded {
  transform: rotate(0.4deg);
}

.paper-env {
  transform: rotate(-0.6deg) translateY(3px);
}

/* ===== めくる角 ===== */
.corner-peel {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 68px;
  height: 68px;
  cursor: pointer;
  z-index: 10;
}

.corner-peel::before {
  content: "";
  position: absolute;
  bottom: 0; right: 0;
  width: 0; height: 0;
  border-style: solid;
  border-width: 0 0 56px 56px;
  border-color: transparent transparent rgba(160,155,140,0.4) transparent;
  transition: all 0.35s ease;
}

.corner-peel::after {
  content: "◢";
  position: absolute;
  bottom: 11px;
  right: 13px;
  font-size: 0.72rem;
  color: rgba(60,60,60,0.4);
  transition: all 0.35s ease;
}

.corner-peel:hover::before {
  border-width: 0 0 64px 64px;
  border-color: transparent transparent rgba(160,155,140,0.55) transparent;
}

.corner-peel:hover::after {
  color: rgba(60,60,60,0.6);
  transform: translate(-2px, -2px);
}

.corner-hint {
  position: absolute;
  bottom: 72px;
  right: 10px;
  font-size: 0.7rem;
  color: rgba(60,60,60,0.35);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
  z-index: 10;
  font-family: 'Shippori Mincho', serif;
}

.corner-peel:hover + .corner-hint,
.corner-peel:hover ~ .corner-hint {
  opacity: 1;
}

/* ===== 裏面 ===== */
.back-paper {
  background-image: url('assets/paper-backside.webp');
  background-size: cover;
  background-position: center;
  color: var(--paper-text);
  padding: 56px 40px;
  box-shadow: 0 8px 48px rgba(0,0,0,0.35);
  min-height: 580px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.back-paper::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 40px,
    rgba(0,0,0,0.012) 40px,
    rgba(0,0,0,0.012) 41px
  );
  pointer-events: none;
}

.back-label-top {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: rgba(60,60,60,0.35);
  letter-spacing: 0.2em;
  font-family: 'Shippori Mincho', serif;
}

.back-content {
  font-family: 'Klee One', cursive;
  font-size: 1.05rem;
  line-height: 2.5;
  color: rgba(40,40,40,0.75);
  text-align: center;
  max-width: 420px;
  position: relative;
  z-index: 1;
}

.back-corner-return {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 68px;
  height: 68px;
  cursor: pointer;
  z-index: 10;
}

.back-corner-return::before {
  content: "";
  position: absolute;
  bottom: 0; left: 0;
  width: 0; height: 0;
  border-style: solid;
  border-width: 56px 0 0 56px;
  border-color: transparent transparent transparent rgba(160,155,140,0.4);
  transition: all 0.35s ease;
}

.back-corner-return::after {
  content: "◣";
  position: absolute;
  bottom: 11px;
  left: 13px;
  font-size: 0.72rem;
  color: rgba(60,60,60,0.4);
  transition: all 0.35s ease;
}

.back-corner-return:hover::before {
  border-width: 64px 0 0 64px;
  border-color: transparent transparent transparent rgba(160,155,140,0.55);
}

.back-corner-return:hover::after {
  color: rgba(60,60,60,0.6);
  transform: translate(2px, -2px);
}

/* ===== 手紙内容 ===== */
.letter-content {
  position: relative;
  z-index: 3;
}

.letter-to {
  font-size: 1.15rem;
  margin-bottom: 36px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.letter-body p {
  margin-bottom: 1.8em;
  text-align: justify;
  line-height: 2.2;
}

.letter-from {
  text-align: right;
  margin-top: 48px;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
}

/* ===== めくりヒント ===== */
.flip-hint {
  text-align: center;
  margin-top: 20px;
  font-size: 0.8rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  opacity: 0.7;
  animation: fadeIn 1s ease-out 1.5s both;
}

/* ===== アクション ===== */
.actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 52px;
  flex-wrap: wrap;
  animation: fadeIn 1s ease-out 0.6s both;
}

.action-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 12px 32px;
  font-family: 'Shippori Mincho', serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.4s;
  letter-spacing: 0.12em;
}

.action-btn:hover {
  border-color: var(--accent-dim);
  color: var(--text);
}

/* ===== 記憶 ===== */
.memory {
  margin-top: 80px;
  padding-top: 48px;
  border-top: 1px solid var(--border);
}

.memory h3 {
  font-family: 'Shippori Mincho', serif;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 0.22em;
  margin-bottom: 28px;
}

.memory-item {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 14px;
  padding-left: 18px;
  border-left: 1px solid var(--border);
  line-height: 1.8;
}

/* ===== PRIVACY ===== */
.privacy {
  margin-top: 120px;
  padding-top: 48px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 2.4;
}

.privacy h3 {
  font-family: 'Shippori Mincho', serif;
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  margin-bottom: 18px;
}

/* ===== 記録を消す（PRIVACY の節の中） ===== */
.wipe {
  margin-top: 22px;
}

.wipe button {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 2px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 9px 16px;
  transition: color .4s ease, border-color .4s ease;
}

.wipe button:hover,
.wipe button:focus-visible {
  color: var(--accent);
  border-color: var(--accent-dim);
}

.wipe .ask {
  margin-bottom: 12px;
  line-height: 1.9;
}

.wipe .row {
  display: flex;
  gap: 10px;
}

.wipe .done {
  line-height: 1.9;
}

/* ===== 戻るリンク ===== */
.back-link {
  display: inline-block;
  margin-bottom: 48px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  transition: color 0.3s;
}

.back-link:hover {
  color: var(--accent);
}

/* ===== レスポンシブ ===== */
@media (max-width: 640px) {
  .container { padding: 48px 16px 80px; }
  header h1 { font-size: 2rem; letter-spacing: 0.25em; }
  .letter-paper, .back-paper { padding: 40px 28px 72px; min-height: 480px; }
  .intro { padding: 28px 20px; }
  .options { gap: 8px; }
  .option-btn { padding: 12px 18px; font-size: 0.85rem; }
  /* 高さは中身から決まるので固定しない */
}

@media (max-width: 400px) {
  .letter-paper, .back-paper { padding: 32px 20px 60px; }
  .corner-peel, .back-corner-return { width: 52px; height: 52px; }
  .corner-peel::before { border-width: 0 0 42px 42px; }
  .back-corner-return::before { border-width: 42px 0 0 42px; }
}

/* 足元のコピーライト。ページごとの控えめな色に合わせる（薄くしすぎない） */
.copyright{color:rgba(255,255,255,.42);}
