@import url('https://fonts.googleapis.com/css2?family=Gloock&family=Noto+Serif+SC:wght@400;600&display=swap');

:root {
  --paper: #f2eadc;
  --paper-soft: #fbf6ec;
  --ink: #201e1b;
  --muted: #766d62;
  --line: rgba(32, 30, 27, .12);
  --accent: #9d7042;
  --accent-soft: #d9bf97;
  --deep: #171512;
  --green: #66724f;
  --danger: #9d4d39;
  font-family: 'Noto Serif SC', serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: #d7c9b7; color: var(--ink); }
html { height: 100%; }
body { min-height: 100%; overflow: hidden; }
button, textarea { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; }
.hidden { display: none !important; }

#app {
  position: relative;
  width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 18%, rgba(255,255,255,.72), transparent 28%),
    linear-gradient(160deg, #fbf5e9 0%, #eee3d2 48%, #e0cfba 100%);
}
#app.decor-off {
  --paper: #181614;
  --paper-soft: #2b2521;
  --ink: #f7ead6;
  --muted: #c8b9a7;
  --line: rgba(247,234,214,.18);
  --accent: #f1bc78;
  --accent-soft: #8b6944;
  --deep: #f5ddbd;
  background:
    radial-gradient(circle at 50% 14%, rgba(240,189,120,.13), transparent 30%),
    linear-gradient(160deg, #1b1815 0%, #28221d 55%, #120f0d 100%);
  color: var(--ink);
}
#app.decor-on::before {
  content: '';
  position: absolute;
  inset: -18% -20%;
  background:
    radial-gradient(circle at 30% 20%, rgba(157,112,66,.13), transparent 24%),
    radial-gradient(circle at 70% 76%, rgba(32,30,27,.08), transparent 28%);
  pointer-events: none;
}

.unlock-screen, .main-app {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(28px, env(safe-area-inset-top)) 22px max(112px, calc(env(safe-area-inset-bottom) + 96px));
}
.unlock-screen { display: grid; place-items: center; align-content: center; gap: 28px; }
.machine { position: relative; width: min(75vw, 318px); aspect-ratio: 1; display: grid; place-items: center; }
.machine-grid {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(from 2deg, rgba(32,30,27,.22) 0 1deg, transparent 1deg 12deg);
  mask: radial-gradient(circle, transparent 0 39%, #000 40% 41%, transparent 42% 58%, #000 59% 60%, transparent 61%);
}
.ring { position: absolute; border-radius: 50%; }
.ring-1 { inset: 2px; border: 1px solid rgba(32,30,27,.38); animation: slowSpin 18s linear infinite; }
.ring-2 { inset: 42px; border: 1px dashed rgba(32,30,27,.34); animation: slowSpin 11s linear reverse infinite; }
.ring-3 { inset: 84px; background: radial-gradient(circle, transparent 54%, rgba(157,112,66,.55) 56%, transparent 58%); animation: pulse 3s ease-in-out infinite; }
.needle { position: absolute; width: 41%; height: 1px; background: var(--accent); transform-origin: left center; transform: translateX(50%) rotate(-32deg); }
.core {
  position: relative;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(251,246,236,.82);
  box-shadow: inset 0 0 0 1px rgba(32,30,27,.18), 0 20px 60px rgba(32,30,27,.12);
  font-family: Gloock, serif;
  font-size: 31px;
  letter-spacing: .04em;
}
.unlock-panel {
  width: min(100%, 382px);
  text-align: center;
  padding: 8px 4px 0;
}
.eyebrow { margin: 0 0 8px; font-size: 12px; letter-spacing: .18em; color: var(--muted); text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 18px; font-size: 25px; line-height: 1.34; font-weight: 600; }
.date-options { display: grid; gap: 10px; }
.date-option {
  padding: 15px 18px;
  border-radius: 999px;
  background: rgba(251, 246, 236, .78);
  box-shadow: inset 0 0 0 1px rgba(32,30,27,.12), 0 10px 30px rgba(32,30,27,.06);
  font-family: Gloock, serif;
  font-size: 18px;
  letter-spacing: .04em;
}
.date-option.correct { background: var(--deep); color: var(--paper); }
.hint, .micro, .tiny { color: var(--muted); }
.hint { min-height: 24px; margin: 14px 0 0; font-size: 13px; }
.micro { margin: 0 0 16px; font-size: 13px; text-align: center; }
.tiny { margin: 10px 0 0; font-size: 12px; }
.shake { animation: shake .34s ease; }
.traveling .ring-1 { animation-duration: .55s; }
.traveling .ring-2 { animation-duration: .45s; }
.traveling .machine { animation: tunnel 1.15s ease forwards; }
.traveling .unlock-panel { animation: fadeSink .8s ease forwards; }

.main-app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; z-index: 5; }
.topbar .eyebrow:empty { display: none; }
.topbar h2 { margin: 0; font-size: 24px; line-height: 1.12; font-weight: 600; }
.top-actions { display: flex; gap: 6px; }
.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(251,246,236,.72);
  box-shadow: inset 0 0 0 1px var(--line), 0 10px 26px rgba(32,30,27,.07);
  font-size: 18px;
}
.song-skip { font-family: Gloock, serif; font-size: 24px; line-height: 1; }
.music-panel {
  position: absolute;
  top: 82px;
  right: 20px;
  width: min(330px, calc(100vw - 40px));
  z-index: 30;
  padding: 16px;
  border-radius: 24px;
  background: rgba(251,246,236,.96);
  box-shadow: 0 22px 80px rgba(32,30,27,.16), inset 0 0 0 1px var(--line);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.panel-head button, .ghost-button {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.26);
  box-shadow: inset 0 0 0 1px var(--line);
}
.song-list { display: grid; gap: 8px; }
.song-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 13px; border-radius: 16px; background: #f8f1e8; box-shadow: inset 0 0 0 1px var(--line); text-align: left; }
.song-item.active { background: #efe0ca; }
.song-item.music-master { background: #25231f; color: #f2eadc; }
.song-item.unavailable { opacity: .58; }
.icon-button.playing { background: #25231f; color: #f2eadc; }
.icon-button.muted { opacity: .42; filter: grayscale(1); }
.icon-button.night { background: #25231f; color: #f2eadc; opacity: 1; filter: none; }
#app.decor-off .icon-button { background: rgba(48,41,35,.88); color: var(--ink); }
#app.decor-off .icon-button.night, #app.decor-off .tab-button.active { background: var(--deep); color: #171512; }
#app.decor-off .music-panel, #app.decor-off .bottom-tabs, #app.decor-off .date-option, #app.decor-off .future-card, #app.decor-off .coupon-card, #app.decor-off .monster-card, #app.decor-off .coupon-form, #app.decor-off .monster-form, #app.decor-off .why, #app.decor-off .close-button { background: rgba(47,40,34,.92); color: var(--ink); }
#app.decor-off .future-card h3, #app.decor-off .coupon-card h3, #app.decor-off .monster-card h3, #app.decor-off .gift-card h2, #app.decor-off .detail-card h2 { color: var(--ink); }
#app.decor-off .future-card p, #app.decor-off .coupon-card p, #app.decor-off .monster-card p, #app.decor-off .gift-card p, #app.decor-off .why, #app.decor-off .monster-meta, #app.decor-off .coupon-card small { color: var(--muted); }
#app.decor-off .song-item { background: #332b25; color: var(--ink); }
#app.decor-off .song-item.active { background: #59422e; color: #fff4e5; }
#app.decor-off .song-item.music-master { background: #f5ddbd; color: #171512; }

.tab-page { display: none; flex: 1; padding: 18px 0 132px; min-height: 0; }
.tab-page.active { display: block; }
.bottom-tabs {
  position: fixed;
  left: 18px;
  right: 18px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(251,246,236,.83);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 70px rgba(32,30,27,.14), inset 0 0 0 1px var(--line);
}
.tab-button { padding: 12px 6px; border-radius: 999px; background: transparent; color: var(--muted); }
.tab-button.active { background: var(--deep); color: var(--paper); }

.memory-hero { min-height: auto; display: grid; align-content: start; overflow: visible; padding-bottom: 18px; }
.memory-book-title { width: min(92vw, 430px); margin: 4px auto 14px; color: rgba(32,30,27,.68); }
.memory-book-title span { display: block; font-family: Gloock, serif; font-size: clamp(36px, 10vw, 46px); line-height: .95; letter-spacing: .01em; }
.memory-book-title em { display: block; margin: 8px 0 0 92px; font-style: normal; font-size: 16px; color: rgba(32,30,27,.48); }
.film-scroller {
  position: relative;
  width: calc(100vw + 44px);
  margin-left: -22px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 6px 0 10px;
  scroll-snap-type: x proximity;
  scroll-behavior: smooth;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.film-scroller::-webkit-scrollbar { display: none; }
.film-track {
  position: relative;
  display: flex;
  align-items: center;
  width: max-content;
  min-height: 262px;
  padding: 45px max(74px, calc((100vw - 286px) / 2));
  background:
    repeating-linear-gradient(90deg, transparent 0 21px, rgba(247,243,224,.9) 21px 40px, transparent 40px 62px) top 14px left / 62px 34px repeat-x,
    repeating-linear-gradient(90deg, transparent 0 21px, rgba(247,243,224,.9) 21px 40px, transparent 40px 62px) bottom 14px left / 62px 34px repeat-x,
    linear-gradient(180deg, #2f2d28 0%, #1f1e1a 100%) center / 100% 218px no-repeat;
  filter: drop-shadow(0 16px 28px rgba(32,30,27,.14));
  z-index: 1;
}
.film-frame-strip {
  position: relative;
  flex: 0 0 auto;
  width: 258px;
  height: 166px;
  margin: 0 10px;
  padding: 0;
  border-radius: 9px 6px 10px 7px / 8px 10px 8px 9px;
  background: transparent;
  overflow: visible;
  scroll-snap-align: center;
  transform: translateY(var(--lift, 0px)) rotate(var(--tilt, 0deg)) scale(.965);
  transition: transform .32s ease, filter .32s ease, opacity .32s ease;
  z-index: 3;
}
.film-frame-strip.is-active { transform: translateY(var(--lift, 0px)) rotate(var(--tilt, 0deg)) scale(1.045); filter: saturate(1.04) contrast(1.02); z-index: 4; }
.film-frame-strip:not(.is-active) { opacity: .72; filter: saturate(.82); }
.film-frame-strip.is-wide { width: 286px; height: 166px; }
.film-frame-strip.is-portrait { width: 178px; height: 206px; }
.film-frame-strip.is-squareish { width: 218px; height: 178px; }
.photo-paper {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 4px;
  background: #fff7df;
  box-shadow: inset 0 0 0 5px #24231f, 0 8px 18px rgba(0,0,0,.18);
  border-radius: inherit;
  overflow: visible;
}
.film-frame-strip img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  background: transparent;
  border-radius: 3px;
  box-shadow: none;
}
.film-frame-strip.is-wide img { width: 100%; height: auto; }
.film-frame-strip.is-portrait img { width: auto; height: 100%; }
.film-frame-strip.is-squareish img { max-width: 100%; max-height: 100%; }
.film-frame-strip.multi::after {
  content: '2';
  position: absolute;
  right: 13px;
  top: 13px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(245,239,229,.88);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-family: Gloock, serif;
  font-size: 13px;
}
.memory-caption {
  width: min(88vw, 430px);
  margin: 4px auto 0;
  min-height: 100px;
  padding: 6px 4px 0;
  display: grid;
  gap: 8px;
  transform: translateY(0);
  opacity: 1;
  transition: opacity .32s ease, transform .32s ease;
}
.memory-caption.is-changing { opacity: 0; transform: translateY(10px); }
.memory-caption span { color: var(--accent); font-family: Gloock, serif; font-size: 17px; }
.memory-caption strong { font-size: clamp(18px, 5.2vw, 22px); line-height: 1.5; font-weight: 600; }

.detail-page { position: fixed; inset: 0; z-index: 60; padding: max(22px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom)); background: var(--paper); overflow-y: auto; }
.close-button { position: sticky; top: 0; z-index: 3; margin-bottom: 18px; padding: 11px 16px; border-radius: 999px; background: rgba(251,246,236,.86); box-shadow: inset 0 0 0 1px var(--line), 0 12px 34px rgba(32,30,27,.08); }
.detail-card, .gift-card { max-width: 520px; margin: 0 auto; min-height: calc(100vh - 108px); display: grid; align-content: center; }
.detail-images { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; }
.detail-images img { width: 100%; min-width: 100%; max-height: 74vh; object-fit: contain; border-radius: 22px; background: #e6d8c6; scroll-snap-align: center; }
.detail-card h2 { margin: 18px 0 0; font-size: 24px; line-height: 1.45; }

.gift-stage { min-height: calc(100vh - 190px); display: grid; justify-items: center; align-content: center; gap: 12px; }
.mystery-box { position: relative; width: 258px; height: 196px; margin: -24px auto -4px; perspective: 900px; }
.gift-glow { position: absolute; left: 42px; right: 42px; bottom: 6px; height: 54px; border-radius: 50%; background: rgba(214,146,91,.2); filter: blur(14px); }
.cake-motion { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 18px 24px rgba(32,30,27,.13)); transform: translateY(-18px); }
.cake-motion.celebrating { animation: cakePop .78s cubic-bezier(.2,.9,.2,1); }
.gift-card-grid { width: min(84vw, 328px); display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; justify-items: center; }
.gift-flip-card { position: relative; width: 58px; height: 70px; padding: 0; background: transparent; perspective: 800px; }
.gift-card-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .46s cubic-bezier(.2,.8,.2,1); }
.gift-flip-card.opened .gift-card-inner, .gift-flip-card.selected .gift-card-inner { transform: rotateY(180deg); }
.gift-card-front, .gift-card-back { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 18px; backface-visibility: hidden; background: rgba(251,246,236,.78); box-shadow: 0 10px 22px rgba(32,30,27,.1), inset 0 0 0 1px rgba(32,30,27,.08); overflow: hidden; }
.gift-card-front img { width: 58px; height: 58px; object-fit: contain; transform: translateY(-1px); }
.gift-card-back { transform: rotateY(180deg); padding: 7px; font-size: 12px; line-height: 1.22; text-align: center; background: linear-gradient(145deg, #fff1d9 0%, #f5d7bd 55%, #eac9ad 100%); color: #5a4030; box-shadow: inset 0 0 0 1px rgba(130,86,57,.14), 0 10px 22px rgba(32,30,27,.08); }
.gift-title-lines { display: grid; gap: 2px; place-items: center; font-weight: 600; letter-spacing: .08em; line-height: 1.18; }
.gift-title-lines span { white-space: nowrap; }
.gift-card { text-align: center; }
.gift-card img { width: min(78vw, 340px); max-height: 44vh; object-fit: contain; margin: 0 auto 18px; border-radius: 30px; }
.gift-card h2 { margin-bottom: 12px; font-size: 30px; }
.gift-card p { line-height: 1.8; }
.why { margin-top: 18px; padding: 16px; border-radius: 20px; display: grid; gap: 8px; text-align: left; background: #fbf5ec; box-shadow: inset 0 0 0 1px var(--line); }

.future-intro h2 { font-size: 25px; margin-bottom: 18px; }
.future-grid { display: grid; gap: 14px; margin-top: 10px; }
.future-grid-two { margin-top: 22px; }
.future-card { width: 100%; text-align: left; padding: 20px; border-radius: 26px; background: rgba(251,246,236,.76); box-shadow: inset 0 0 0 1px var(--line), 0 16px 42px rgba(32,30,27,.07); }
.future-card span { color: var(--accent); font-family: Gloock, serif; }
.future-card h3 { margin: 8px 0; font-size: 23px; }
.future-card p { margin-bottom: 0; color: var(--muted); line-height: 1.65; }
.future-detail-inner { max-width: 520px; margin: 0 auto; }
.future-detail-head { display: grid; gap: 12px; margin-bottom: 18px; }
.future-detail-inner h2 { font-size: 30px; margin-bottom: 0; }
.future-detail-body { display: grid; grid-template-columns: 1fr; gap: 12px; padding-bottom: 40px; }
.monster-add-button, .coupon-add-button { width: 100%; padding: 14px 18px; border-radius: 20px; text-align: center; background: linear-gradient(135deg, rgba(157,112,66,.16), rgba(255,255,255,.28)); color: var(--accent); font-weight: 600; }
.coupon-card, .monster-card, .coupon-form, .monster-form { width: 100%; padding: 16px; border-radius: 22px; background: rgba(251,246,236,.78); box-shadow: inset 0 0 0 1px var(--line), 0 14px 36px rgba(32,30,27,.06); }
.coupon-card.used { opacity: .62; }
.coupon-card small { display: block; margin-top: 8px; color: var(--muted); }
.coupon-count { width: fit-content; margin-top: 10px; padding: 5px 10px; border-radius: 999px; background: rgba(157,112,66,.12); color: var(--accent); font-size: 12px; }
.coupon-card button, .monster-card button, .monster-form button, .victory-note button { margin-top: 10px; padding: 10px 14px; border-radius: 999px; background: transparent; box-shadow: inset 0 0 0 1px rgba(32,30,27,.18); }
.coupon-card button:disabled { opacity: .45; }
.monster-card { position: relative; overflow: hidden; }
.monster-card::before { content: ''; position: absolute; right: -28px; top: -30px; width: 86px; height: 86px; border-radius: 50%; background: rgba(157,112,66,.08); pointer-events: none; }
.monster-card.done { background: rgba(226,232,209,.78); }
.monster-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.monster-type { color: var(--accent); font-size: 12px; }
.monster-status { padding: 4px 9px; border-radius: 999px; background: rgba(157,112,66,.12); color: var(--accent); font-size: 12px; }
.monster-meta { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.coupon-form, .monster-form { display: grid; gap: 10px; }
.coupon-form input, .coupon-form textarea, .monster-form input, .monster-form textarea, .victory-note textarea { width: 100%; resize: vertical; padding: 12px 13px; border: 0; border-radius: 16px; background: #fbf5ec; box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); }
.coupon-form textarea, .monster-form textarea { min-height: 82px; }
.victory-note { display: grid; gap: 8px; margin-top: 12px; }
.victory-note textarea { min-height: 80px; }
#app.decor-off .coupon-form input, #app.decor-off .coupon-form textarea, #app.decor-off .monster-form input, #app.decor-off .monster-form textarea, #app.decor-off .victory-note textarea { background: #3a312a; color: var(--ink); }
#app.decor-off input::placeholder, #app.decor-off textarea::placeholder { color: #8f7d6d; }
#app.decor-off .monster-card.done { background: rgba(72,86,61,.82); }
#app.decor-off .monster-status, #app.decor-off .coupon-count { background: rgba(241,188,120,.16); color: var(--accent); }

@keyframes slowSpin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { transform: scale(.94); opacity: .62; } }
@keyframes shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
@keyframes tunnel { to { transform: scale(4.5) rotate(240deg); opacity: 0; } }
@keyframes fadeSink { to { transform: translateY(20px); opacity: 0; } }
@keyframes boxShake { 20% { transform: rotate(-7deg) translateX(-5px); } 40% { transform: rotate(7deg) translateX(5px); } 60% { transform: rotate(-5deg); } 80% { transform: rotate(4deg); } }
@keyframes openLid { to { transform: translate(-18px, -34px) rotate(-16deg); } }
@keyframes cakePop { 0% { transform: translateY(-18px) scale(1); } 30% { transform: translateY(-34px) scale(1.08) rotate(-3deg); } 58% { transform: translateY(-20px) scale(.98) rotate(2deg); } 100% { transform: translateY(-18px) scale(1); } }

@media (max-height: 740px) {
  .topbar h2 { font-size: 21px; }
  .memory-book-title { margin-bottom: 8px; }
  .memory-book-title span { font-size: 34px; }
  .memory-book-title em { font-size: 13px; margin-left: 64px; }
  .film-scroller { padding-top: 14px; padding-bottom: 16px; }
  .film-track { min-height: 210px; padding-top: 34px; padding-bottom: 34px; }
  .film-frame-strip { transform: translateY(var(--lift, 0px)) rotate(var(--tilt, 0deg)) scale(.9); }
  .film-frame-strip.is-active { transform: translateY(var(--lift, 0px)) rotate(var(--tilt, 0deg)) scale(.98); }
  .memory-caption { min-height: 126px; margin-top: 10px; }
}

@media (min-width: 720px) {
  body { display: grid; place-items: center; }
  #app { width: 430px; min-height: 900px; max-height: 100vh; border-radius: 34px; box-shadow: 0 22px 80px rgba(0,0,0,.18); }
  .bottom-tabs { position: absolute; }
}
