/* Our Story — デザイン仕様 v1（Claude Design / Design.pdf）に準拠 */
:root {
  /* color */
  --bg: #0b0f2a;
  --bg-2: #121838;
  --card: #151a3f;
  --line: #262c58;
  --text: #f1ece0;
  --sub: #9ea3c4;
  --gold: #e6cd8f;
  --accent: #e07a5f;
  /* shape / type */
  --radius: 14px;
  --font: "Zen Kaku Gothic New", system-ui, "Hiragino Sans", sans-serif;
  /* 追加変数 */
  --sub-2: #6d729a;
  --line-2: #3a4278;
  --font-serif: "Shippori Mincho", serif;
  --font-latin: "Cormorant Garamond", serif;
  --pad: 24px;
  --gap: 32px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }

/* hidden 属性は常に最優先（.screen 側の display 指定に負けないように） */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.8;
  min-height: 100dvh;
}

/* 背景の星レイヤー（1枚、opacity がゆっくり揺れるだけ） */
.stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, rgba(241, 236, 224, .9) 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 8%, rgba(241, 236, 224, .7) 50%, transparent 51%),
    radial-gradient(1px 1px at 34% 32%, rgba(230, 205, 143, .8) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 88% 38%, rgba(241, 236, 224, .6) 50%, transparent 51%),
    radial-gradient(1px 1px at 58% 14%, rgba(241, 236, 224, .8) 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 52%, rgba(241, 236, 224, .5) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 66% 58%, rgba(230, 205, 143, .5) 50%, transparent 51%),
    radial-gradient(1px 1px at 44% 74%, rgba(241, 236, 224, .45) 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 80%, rgba(241, 236, 224, .5) 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 86%, rgba(241, 236, 224, .4) 50%, transparent 51%);
  animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: .7; } to { opacity: 1; } }

.app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
}

/* 画面遷移：opacity のみ */
.screen { animation: screen-in .4s var(--ease); }
@keyframes screen-in { from { opacity: 0; } to { opacity: 1; } }

/* タイトル要素の登場（初回のみ、80ms ずらし） */
.rise { animation: rise .6s var(--ease) both; }
.rise:nth-child(2) { animation-delay: .08s; }
.rise:nth-child(3) { animation-delay: .16s; }
.rise:nth-child(4) { animation-delay: .24s; }
.rise:nth-child(5) { animation-delay: .32s; }
.rise:nth-child(6) { animation-delay: .4s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- タイトル画面 ---------- */
#screen-title {
  padding: max(72px, calc(env(safe-area-inset-top) + 48px)) var(--pad) 48px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
#screen-title h1 {
  font-family: var(--font-latin);
  font-style: italic;
  font-weight: 400;
  font-size: 44px;
  line-height: 1.1;
  text-align: center;
  margin: 0;
}
#date-range {
  text-align: center;
  color: var(--sub);
  font-family: var(--font-latin);
  font-size: 17px;
  letter-spacing: .16em;
  margin: -18px 0 0;
}
#countdown {
  text-align: center;
  margin: 0;
  font-size: 15px;
}
#countdown .cd-num {
  font-family: var(--font-latin);
  font-style: italic;
  font-size: 40px;
  line-height: 1;
  margin: 0 .1em;
  vertical-align: -4px;
}

/* 今日のメッセージカード */
.msg-card {
  background: var(--card);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 5px var(--card), inset 0 0 0 6px rgba(230, 205, 143, .25);
  padding: 28px 22px 24px;
  animation: card-glow .8s var(--ease) both;
}
@keyframes card-glow {
  from { box-shadow: inset 0 0 0 5px var(--card), inset 0 0 0 6px rgba(230, 205, 143, .25), 0 0 0 rgba(230, 205, 143, 0); }
  to { box-shadow: inset 0 0 0 5px var(--card), inset 0 0 0 6px rgba(230, 205, 143, .25), 0 0 24px rgba(230, 205, 143, .12); }
}
.daily-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: .16em;
  margin-bottom: 14px;
}
.daily-label .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}
.daily-text {
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.9;
}
.daily-text.is-empty { color: var(--sub); font-family: var(--font); font-size: 15px; }

/* ボタン */
.title-buttons { display: flex; flex-direction: column; gap: 12px; }
.btn {
  display: block;
  width: 100%;
  height: 52px;
  border-radius: var(--radius);
  border: none;
  background: var(--text);
  color: var(--bg);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: transform .2s var(--ease), background .2s var(--ease);
}
.btn:active { transform: scale(.98); background: #d8d3c4; }
.btn--present {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  transition: background .6s var(--ease), border-color .6s var(--ease), color .6s var(--ease), box-shadow .6s var(--ease);
}
.btn--present .diamond { font-size: 12px; }
.btn--present .btn-present-label { flex: 1; text-align: left; }
.btn--present .btn-present-open {
  font-family: var(--font-latin);
  font-size: 11px;
  letter-spacing: .16em;
}
.btn--present.is-sealed {
  background: transparent;
  border: 1px dashed var(--line-2);
  color: var(--sub);
  font-size: 14px;
  cursor: default;
}
.btn--present.is-sealed:active { transform: none; }
.btn--present.is-sealed .diamond { color: var(--gold); }
.btn--present.is-sealed .btn-present-open { color: var(--sub-2); }
.btn--present.is-open {
  background: var(--gold);
  color: var(--bg);
  border: none;
  box-shadow: 0 0 0 4px rgba(230, 205, 143, .15), 0 0 28px rgba(230, 205, 143, .2);
}

/* 手紙一覧（過去分） */
.letters-label {
  font-family: var(--font-latin);
  font-size: 11px;
  letter-spacing: .16em;
  color: var(--sub);
  margin-bottom: 6px;
}
.daily-past {
  display: flex;
  gap: 14px;
  align-items: baseline;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.daily-past-date {
  font-family: var(--font-latin);
  font-size: 15px;
  color: var(--gold);
  min-width: 44px;
  flex: none;
}
.daily-past-text { font-family: var(--font-serif); font-size: 15px; }

/* ---------- アルバム画面 ---------- */
#screen-album { padding: 0 20px 48px; }
.album-header {
  position: sticky;
  top: 0;
  height: 100px;
  display: flex;
  align-items: flex-start;
  padding-top: calc(env(safe-area-inset-top) + 14px);
  background: linear-gradient(180deg, var(--bg) 55%, transparent);
  z-index: 5;
}
.btn-back {
  height: 40px;
  min-width: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(11, 15, 42, .6);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
}
.album-title {
  flex: 1;
  text-align: center;
  font-family: var(--font-latin);
  font-style: italic;
  font-size: 24px;
  line-height: 40px;
}
.album-header-spacer { width: 76px; }

.album-month { margin-bottom: 36px; }
.album-month-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 8px;
}
.album-month-en {
  font-family: var(--font-latin);
  font-style: italic;
  font-size: 26px;
}
.album-month-ja { font-size: 12px; color: var(--sub); }
.album-month.is-locked .album-month-en,
.album-month.is-locked .album-month-ja { color: var(--sub-2); }

.album-item {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 10px 0;
}
.album-item img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 10px;
  flex: none;
}
.album-date {
  font-family: var(--font-latin);
  font-size: 15px;
  color: var(--gold);
}
.album-text { font-size: 15px; margin-top: 2px; }

.coming-soon {
  height: 104px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--sub);
  margin-top: 10px;
}
.coming-soon .diamond { font-size: 6px; color: var(--sub-2); }
.coming-soon .cs-text { font-family: var(--font-latin); font-style: italic; font-size: 18px; }
.coming-soon.is-small { height: 64px; }

/* ---------- プレゼントモード ---------- */
.screen--present {
  position: relative;
  height: 100dvh;
  max-width: none;
  overflow: hidden;
  background: var(--bg);
}
.progress {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  z-index: 10;
}
.progress .bar {
  flex: 1;
  height: 2px;
  border-radius: 1px;
  background: rgba(241, 236, 224, .25);
  overflow: hidden;
}
.progress .bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--text);
}
.progress .bar.is-done > i { width: 100%; }
.progress .bar.is-active > i { animation: bar-fill 4.5s linear forwards; }
.progress.is-paused .bar.is-active > i { animation-play-state: paused; }
@keyframes bar-fill { from { width: 0; } to { width: 100%; } }

.btn-close {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 24px);
  left: 8px;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 22px;
  z-index: 10;
  cursor: pointer;
}
#present-stage { position: absolute; inset: 0; }
#present-stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  animation: present-photo 4.5s var(--ease) forwards;
}
@keyframes present-photo {
  from { opacity: 0; transform: scale(1); }
  18% { opacity: 1; }
  to { opacity: 1; transform: scale(1.04); }
}
#present-stage::before,
#present-stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  pointer-events: none;
}
#present-stage::before { top: 0; height: 140px; background: linear-gradient(180deg, rgba(11, 15, 42, .55), transparent); }
#present-stage::after { bottom: 0; height: 260px; background: linear-gradient(0deg, rgba(11, 15, 42, .72), transparent); }
#present-caption {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: calc(env(safe-area-inset-bottom) + 40px);
  z-index: 5;
  transition: opacity .3s var(--ease);
}
#present-caption.is-dim { opacity: .4; }
.present-date {
  font-family: var(--font-latin);
  font-size: 15px;
  letter-spacing: .08em;
  color: var(--gold);
}
.present-text {
  font-family: var(--font-serif);
  font-size: 20px;
  line-height: 1.7;
  margin-top: 4px;
}

/* クライマックス */
#present-climax {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 32px;
}
#present-climax[hidden] { display: none; }
.climax-frame {
  background: var(--card);
  border: 1px solid var(--gold);
  padding: 10px;
  width: 100%;
  max-width: 311px;
  animation: climax-photo 1.2s var(--ease) both;
}
.climax-frame img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  display: block;
}
@keyframes climax-photo { from { opacity: 0; } to { opacity: 1; } }
.climax-texts { text-align: center; margin-top: 36px; animation: rise .8s var(--ease) .9s both; }
.climax-heading { font-family: var(--font-serif); font-size: 24px; font-weight: 500; }
.climax-sub {
  font-family: var(--font-latin);
  font-style: italic;
  font-size: 16px;
  color: var(--gold);
  margin-top: 6px;
}
.climax-again { margin-top: 36px; width: auto; padding: 0 28px; animation: rise .8s var(--ease) 3s both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
