/* 오늘의 캡슐 - 파스텔 문구점 + 가챠 머신 테마 */
:root {
  --bg: #FFF8F0;
  --paper: #FFFFFF;
  --ink: #5A3D5C;
  --ink-soft: #8C7290;
  --pink: #FFB5C8;
  --pink-deep: #FF8FAE;
  --lav: #C9B6FF;
  --mint: #BDEFD8;
  --lemon: #FFE59E;
  --line: #F1DCE4;
  --shadow: 0 6px 0 #F3D3DE;
  --dot: rgba(255, 181, 200, .35);
  color-scheme: light;
  --font: "Gowun Dodum", "M PLUS Rounded 1c", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-head: "Jua", "M PLUS Rounded 1c", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
:root:lang(ja) { --font: "M PLUS Rounded 1c", "Gowun Dodum", system-ui, sans-serif; --font-head: "M PLUS Rounded 1c", system-ui, sans-serif; }
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #23203A;
    --paper: #2F2B4A;
    --ink: #FBEFF5;
    --ink-soft: #C6B8D8;
    --line: #463F68;
    --shadow: 0 6px 0 #1A1830;
    --dot: rgba(201, 182, 255, .18);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  background-color: var(--bg);
  background-image:
    radial-gradient(var(--dot) 2px, transparent 2.5px),
    radial-gradient(var(--dot) 2px, transparent 2.5px);
  background-size: 28px 28px;
  background-position: 0 0, 14px 14px;
  padding: env(safe-area-inset-top, 0px) 16px env(safe-area-inset-bottom, 0px);
}
[hidden] { display: none !important; }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: .6em 1.4em;
  font: inherit; font-family: var(--font-head); font-size: 1rem;
  color: #5A3D5C;
  background: var(--paper);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { cursor: default; opacity: .65; transform: none; box-shadow: 0 4px 0 var(--ink); }
.btn-pink { background: var(--pink); }
.btn-lav { background: var(--lav); }
.btn-mint { background: var(--mint); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-big { font-size: 1.25rem; padding: .75em 2em; }

/* ---------- 성인 확인 경고창 ---------- */
.gate {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(90, 61, 92, .55);
  backdrop-filter: blur(6px);
}
.gate-card {
  width: min(440px, 100%);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 28px;
  padding: 28px 24px 22px;
  text-align: center;
  box-shadow: 0 10px 0 var(--ink);
  animation: bounce-in .5s cubic-bezier(.2, 1.4, .4, 1);
}
.gate-card p { margin: .35em 0; }
.gate-title { font-family: var(--font-head); font-size: 1.6rem; }
.gate-question { font-family: var(--font-head); font-size: 1.45rem; color: var(--pink-deep); margin-top: .8em !important; }
.gate-note { font-size: .9rem; color: var(--ink-soft); }
.gate-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.gate-capsule {
  width: 64px; height: 64px; margin: 0 auto 10px;
  border-radius: 50%; border: 3px solid var(--ink);
  background: linear-gradient(var(--pink) 50%, #fff 50%);
  position: relative; overflow: hidden;
  animation: wobble 2.4s ease-in-out infinite;
}
.gate-capsule span { position: absolute; left: 0; right: 0; top: calc(50% - 1.5px); height: 3px; background: var(--ink); }
.lang-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 18px; }
.lang-row button {
  border: 2px solid var(--line); background: transparent; color: var(--ink);
  border-radius: 999px; padding: 2px 12px; font: inherit; font-size: .85rem; cursor: pointer;
}
.lang-row button.on { border-color: var(--ink); background: var(--lemon); color: #5A3D5C; }

/* ---------- 레이아웃 ---------- */
.app { max-width: 880px; margin: 0 auto; padding-block: 20px 40px; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.logo { font-family: var(--font-head); font-weight: 400; font-size: clamp(1.8rem, 6vw, 2.6rem); margin: 0; display: flex; align-items: center; gap: 10px; line-height: 1.2; }
.logo-dot { width: .8em; height: .8em; border-radius: 50%; border: 3px solid var(--ink); background: linear-gradient(var(--lav) 50%, #fff 50%); flex: none; }
.tagline { margin: 2px 0 0; color: var(--ink-soft); }
.lang-select select, .pill-select select {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 2.5px solid var(--ink); border-radius: 999px; padding: .35em 1em; cursor: pointer;
}

.panel {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 32px;
  padding: clamp(18px, 4vw, 32px);
  margin-bottom: 26px;
  box-shadow: 0 8px 0 var(--ink);
}
.panel-title { font-family: var(--font-head); font-weight: 400; font-size: 1.6rem; margin: 0 0 14px; }
.panel-title .star { color: var(--pink-deep); }
.bday .panel-title .star { color: #A38BF0; }
.desc { margin-top: 0; }
.hint { font-size: .88rem; color: var(--ink-soft); margin: .6em 0 0; }
.hint.strong { color: var(--ink); font-weight: 700; }

/* ---------- 필터 ---------- */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.chips { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chips legend { float: left; margin-right: 6px; font-family: var(--font-head); }
.chips label { cursor: pointer; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span {
  display: inline-block; padding: .3em 1em; border-radius: 999px;
  border: 2.5px dashed var(--line); transition: all .15s;
}
.chips input:checked + span { border: 2.5px solid var(--ink); background: var(--pink); color: #5A3D5C; transform: rotate(-2deg); }
.chips input:focus-visible + span { outline: 3px solid var(--lav); outline-offset: 2px; }
.chips.small span { font-size: .9rem; }
.toggles { display: flex; flex-wrap: wrap; gap: 10px 20px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; }
.switch .track {
  width: 46px; height: 26px; border-radius: 999px; border: 2.5px solid var(--ink);
  background: var(--line); position: relative; transition: background .2s; flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px;
  border-radius: 50%; background: #fff; border: 2px solid var(--ink); transition: transform .2s cubic-bezier(.3, 1.6, .5, 1);
}
.switch input:checked + .track { background: var(--mint); }
.switch input:checked + .track::after { transform: translateX(19px); }
.switch input:focus-visible + .track { outline: 3px solid var(--lav); outline-offset: 2px; }
.switch input:disabled ~ * { opacity: .5; cursor: not-allowed; }

/* ---------- 가챠 머신 ---------- */
.stage { display: flex; justify-content: center; align-items: center; gap: 28px; flex-wrap: wrap; margin: 26px 0 10px; min-height: 280px; }
.machine { position: relative; width: 190px; flex: none; }
.dome {
  height: 160px; border: 3px solid var(--ink); border-radius: 50% 50% 18px 18px / 60% 60% 18px 18px;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,.9) 0 12%, transparent 13%), rgba(255, 255, 255, .55);
  position: relative; overflow: hidden;
}
.dome i {
  position: absolute; left: var(--x); top: var(--y); width: 38px; height: 38px; border-radius: 50%;
  border: 2.5px solid var(--ink); background: linear-gradient(var(--c) 50%, #fff 50%);
}
/* 돔 안 캡슐 7개의 색과 위치 (HTML의 style 속성 대신 여기서 지정: CSP 때문) */
.dome i:nth-child(1) { --c: #FFB5C8; --x: 18%; --y: 58%; }
.dome i:nth-child(2) { --c: #C9B6FF; --x: 46%; --y: 66%; }
.dome i:nth-child(3) { --c: #BDEFD8; --x: 70%; --y: 55%; }
.dome i:nth-child(4) { --c: #FFE59E; --x: 32%; --y: 36%; }
.dome i:nth-child(5) { --c: #FFB5C8; --x: 60%; --y: 30%; }
.dome i:nth-child(6) { --c: #C9B6FF; --x: 12%; --y: 28%; }
.dome i:nth-child(7) { --c: #BDEFD8; --x: 80%; --y: 24%; }
.body {
  height: 110px; margin-top: -3px; border: 3px solid var(--ink); border-radius: 0 0 26px 26px;
  background: var(--pink); position: relative;
}
.knob {
  position: absolute; left: 50%; top: 18px; width: 54px; height: 54px; margin-left: -27px;
  border-radius: 50%; border: 3px solid var(--ink); background: var(--lemon);
}
.knob span { position: absolute; left: 50%; top: 6px; bottom: 6px; width: 10px; margin-left: -5px; border-radius: 6px; background: var(--ink); }
.slot { position: absolute; right: 16px; bottom: 12px; width: 46px; height: 30px; border: 3px solid var(--ink); border-radius: 10px; background: #5A3D5C; }
.drop-capsule { position: absolute; right: 20px; bottom: 18px; width: 38px; height: 38px; opacity: 0; }
.drop-capsule span { position: absolute; left: 0; right: 0; height: 50%; border: 2.5px solid var(--ink); }
.drop-capsule .top-half { top: 0; border-radius: 40px 40px 0 0; background: var(--lav); }
.drop-capsule .bottom-half { bottom: 0; border-radius: 0 0 40px 40px; background: #fff; border-top: 0; }

.machine.spinning .knob { animation: turn 1.2s cubic-bezier(.4, 0, .3, 1) infinite; }
.machine.spinning .dome i { animation: shake .25s ease-in-out infinite alternate; }
.machine.opened .drop-capsule { opacity: 1; transform: translate(60px, 40px) rotate(360deg); animation: drop .9s ease-in; }
.machine.opened .drop-capsule .top-half { transform: translateY(-14px) rotate(-25deg); transition: transform .4s .1s cubic-bezier(.3, 1.6, .5, 1); }

/* ---------- 결과 카드 ---------- */
.result { flex: 1 1 300px; max-width: 520px; }
.result.pop .card { animation: bounce-in .6s cubic-bezier(.2, 1.4, .4, 1); }
.card {
  display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 18px; align-items: start;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 24px; padding: 16px;
  box-shadow: 6px 6px 0 var(--lav); transform: rotate(-1deg);
}
.cover {
  position: relative; border-radius: 16px; overflow: hidden; border: 2.5px solid var(--ink);
  background: var(--lemon); aspect-ratio: 4 / 3; max-width: 100%;
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: filter .25s, transform .25s; }
/* 기본은 블러. 가장자리가 비치지 않도록 살짝 확대한다 */
.cover.mosaic img { filter: blur(18px) saturate(1.1); transform: scale(1.2); }
.cover.mosaic { cursor: pointer; }
.cover.peek img { filter: none; transform: none; }
.cover.broken img { visibility: hidden; }
.cover.broken::after { content: "✿"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 3rem; color: var(--pink-deep); }
.peek-hint {
  position: absolute; left: 8px; bottom: 8px; font-size: .75rem; padding: 2px 10px;
  border-radius: 999px; background: rgba(255,255,255,.9); color: #5A3D5C; border: 2px solid #5A3D5C;
}
.cover.peek .peek-hint { display: none; }
.card.error-card { display: block; margin: 0; text-align: center; }
.info { min-width: 0; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: .8rem; padding: 1px 12px; border-radius: 999px; border: 2px solid var(--ink); background: var(--mint); color: #5A3D5C; font-family: var(--font-head); }
.badge.age { background: var(--lemon); }
.badge.age.a3 { background: var(--pink); }
.title { font-family: var(--font-head); font-weight: 400; font-size: 1.25rem; line-height: 1.4; margin: 8px 0 4px; overflow-wrap: anywhere; }
.meta { margin: 0 0 12px; color: var(--ink-soft); font-size: .9rem; }

.draw-row { text-align: center; margin-top: 14px; }
.status { min-height: 1.6em; margin: 12px 0 0; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ---------- 생일 ---------- */
.bday-form { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 14px 0 4px; }
.pill-select { display: inline-flex; align-items: center; gap: 6px; }
#bday-status { margin-top: 18px; }
.mini-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px; margin-top: 12px;
}
.mini {
  display: flex; flex-direction: column; gap: 6px;
  text-decoration: none; color: var(--ink);
  background: var(--paper); border: 2.5px solid var(--ink); border-radius: 18px; padding: 10px;
  box-shadow: 4px 4px 0 var(--pink); transition: transform .12s;
}
.mini:nth-child(3n+2) { box-shadow: 4px 4px 0 var(--lav); }
.mini:nth-child(3n) { box-shadow: 4px 4px 0 var(--mint); }
.mini:hover { transform: translateY(-3px) rotate(-1.5deg); }
.mini .cover { border-radius: 12px; border-width: 2px; cursor: pointer; }
.mini .badge { font-size: .7rem; padding: 0 8px; }
.mini-title {
  margin: 0; font-size: .85rem; line-height: 1.4; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mini-date { margin: 0; font-size: .75rem; color: var(--ink-soft); }

/* ---------- 약관 페이지 ---------- */
.terms .terms-h2 { font-family: var(--font-head); font-weight: 400; font-size: 1.35rem; margin: 28px 0 4px; padding-top: 14px; border-top: 2.5px dashed var(--line); }
.terms .terms-h2:first-of-type { border-top: 0; padding-top: 0; }
.terms .terms-h3 { font-size: 1.02rem; margin: 18px 0 4px; }
.terms ul { margin: 0; padding-left: 1.2em; }
.terms li { margin: .25em 0; }
.top .lang-row { margin-top: 0; }

/* ---------- 하단 ---------- */
.foot { text-align: center; font-size: .8rem; color: var(--ink-soft); padding: 8px 0 24px; }
.foot p { margin: .3em 0; }
.foot a { color: inherit; }

/* ---------- 애니메이션 ---------- */
@keyframes bounce-in { from { transform: scale(.6) rotate(-6deg); opacity: 0; } to { transform: scale(1) rotate(-1deg); opacity: 1; } }
@keyframes wobble { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
@keyframes turn { to { transform: rotate(360deg); } }
@keyframes shake { from { transform: translate(-3px, 2px); } to { transform: translate(3px, -3px); } }
@keyframes drop {
  0% { opacity: 0; transform: translate(0, -20px); }
  30% { opacity: 1; transform: translate(0, 0); }
  70% { transform: translate(40px, 40px) rotate(180deg); }
  100% { opacity: 1; transform: translate(60px, 40px) rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- 모바일 ---------- */
@media (max-width: 560px) {
  .card { grid-template-columns: 1fr; transform: none; }
  /* 폰에서는 생일 작품을 2열로, 버튼 글씨는 한 줄에 들어가게 */
  .mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .mini { padding: 8px; border-radius: 14px; }
  .mini-title { font-size: .8rem; }
  .btn-big { font-size: 1.05rem; padding: .7em 1.3em; max-width: 100%; }
  .stage { min-height: 0; }
  .machine { transform: scale(.85); margin: -12px 0; }
  .gate-question { font-size: 1.3rem; }
}
