:root {
  color-scheme: light;
  --ink: #3d3552;
  --ink-soft: #7a6f8f;
  --coral: #ff7a6b;
  --coral-deep: #e8604f;
  --gold: #ffd166;
  --cream: #fff8ef;
  --sky: #b9e0f4;
  --peach: #ffe6cf;
  --card: #ffffff;
  --jua: Jua, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --body: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard', 'Malgun Gothic', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #f4e9dc radial-gradient(circle at 1px 1px, rgba(61, 53, 82, 0.08) 1.2px, transparent 0) 0 0 / 22px 22px;
  color: var(--ink);
  font-family: var(--body);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--sky);
  box-shadow: 0 0 0 1px rgba(61, 53, 82, 0.08), 0 20px 60px rgba(61, 53, 82, 0.12);
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}
button:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

[hidden] { display: none !important; }

.screen { position: absolute; inset: 0; }

/* ── 버튼 ─────────────────────────────── */

.cta {
  display: block;
  width: 100%;
  padding: 17px 20px 15px;
  border-radius: 20px;
  background: var(--coral);
  color: #fff;
  font-family: var(--jua);
  font-size: 22px;
  letter-spacing: 0.01em;
  box-shadow: 0 5px 0 var(--coral-deep), 0 10px 22px rgba(232, 96, 79, 0.28);
  transition: transform 0.08s, box-shadow 0.08s;
}
.cta:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--coral-deep), 0 4px 10px rgba(232, 96, 79, 0.25); }

.sub {
  display: block;
  width: 100%;
  padding: 15px 16px 13px;
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  font-family: var(--jua);
  font-size: 18px;
  box-shadow: inset 0 0 0 2px rgba(61, 53, 82, 0.14), 0 4px 0 rgba(61, 53, 82, 0.1);
}
.sub:active { transform: translateY(3px); box-shadow: inset 0 0 0 2px rgba(61, 53, 82, 0.14); }

.chip {
  padding: 8px 14px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  font-family: var(--jua);
  font-size: 14px;
  box-shadow: inset 0 0 0 1.5px rgba(61, 53, 82, 0.16);
}
.chip[aria-pressed='false'] { color: var(--ink-soft); }

.link {
  display: block;
  margin: 0 auto;
  padding: 12px 16px;
  font-family: var(--jua);
  font-size: 16px;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.fine {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-soft);
  text-align: center;
}

.bar {
  height: 12px;
  border-radius: 999px;
  background: rgba(61, 53, 82, 0.1);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--coral));
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.park-next {
  margin: 8px 0 0;
  font-family: var(--jua);
  font-size: 14px;
  color: var(--ink-soft);
}

/* ── 타이틀 ─────────────────────────────── */

.title { pointer-events: none; }
.title > * { pointer-events: auto; }

.title-top {
  position: absolute;
  top: calc(var(--safe-top) + 3.5%);
  left: 16px;
  right: 16px;
  text-align: center;
}
#logo { width: 108px; height: 90px; display: block; margin: 0 auto -4px; }
.title h1 {
  margin: 0;
  font-family: var(--jua);
  font-weight: 400;
  font-size: 46px;
  line-height: 1.1;
  color: var(--ink);
  text-shadow: 0 3px 0 #fff, 0 -2px 0 #fff, 2px 0 0 #fff, -2px 0 0 #fff;
}
.title h1 em { font-style: normal; color: var(--coral); }
.lead {
  margin: 10px 0 0;
  font-family: var(--jua);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
}

.title-bottom {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(var(--safe-bottom) + 16px);
}
.park {
  padding: 14px 18px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 0 rgba(61, 53, 82, 0.08);
  text-align: center;
}
.park-label { margin: 0; font-size: 12.5px; color: var(--ink-soft); }
.park-num { margin: 2px 0 10px; font-family: var(--jua); font-size: 18px; }
.park-num b { font-weight: 400; font-size: 28px; color: var(--coral); }
.title .cta { margin-top: 24px; }
.title-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}
.title-foot .fine { text-align: left; }

/* ── HUD ─────────────────────────────── */

.hud { position: absolute; inset: 0; pointer-events: none; }

.hud-top {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  left: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.timer, .pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 3px 0 rgba(61, 53, 82, 0.1);
  font-family: var(--jua);
  font-size: 15px;
}
.timer { flex: 1; }
.timer-num { min-width: 22px; font-size: 20px; text-align: center; }
.timer-track { flex: 1; height: 10px; border-radius: 999px; background: rgba(61, 53, 82, 0.1); overflow: hidden; }
.timer-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #8fd3c1;
  transform-origin: left;
}
.timer.hurry .timer-num { color: var(--coral); }
.timer.hurry .timer-track i { background: var(--coral); }
.pill b { font-weight: 400; color: var(--coral); }

.banner {
  position: absolute;
  top: calc(var(--deck-top) * 0.42);
  left: 50%;
  margin: 0;
  padding: 10px 20px 9px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-family: var(--jua);
  font-size: 20px;
  white-space: nowrap;
  transform: translate(-50%, -8px) scale(0.9);
  opacity: 0;
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.banner.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.hint {
  position: absolute;
  top: calc(var(--water-bottom) + 22px);
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-family: var(--jua);
  font-size: 15px;
  color: var(--ink);
  opacity: 0;
  transition: opacity 0.4s;
}
.hint.show { opacity: 1; animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateX(4px); } }

/* 필름 한 롤 — 눌러도 화면으로 통과한다. 엄지로 밀어 조준하고 톡 쳐서 찍는 자리. */
.reel {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(var(--safe-bottom) + 14px);
  padding: 10px 12px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 4px 0 rgba(61, 53, 82, 0.08);
}
.reel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 2px 8px;
  font-family: var(--jua);
  font-size: 14px;
  color: var(--ink-soft);
}
.reel-head b { font-weight: 400; font-size: 18px; color: var(--ink); margin-right: 1px; }
.reel-frames {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
/* 아래 공간이 좁은 화면은 한 줄 */
.compact .reel-frames { grid-template-columns: repeat(10, 1fr); gap: 4px; }
.compact .reel { padding: 8px 10px 10px; }
.compact .reel-head { margin-bottom: 6px; }
.reel-frames li {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: 8px;
  background: rgba(61, 53, 82, 0.05);
  box-shadow: inset 0 0 0 1.5px rgba(61, 53, 82, 0.16);
}
.reel-frames li:not(.shot)::after {
  content: attr(data-n);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--jua);
  font-size: 12px;
  color: rgba(61, 53, 82, 0.28);
}
.reel-frames li.next { box-shadow: inset 0 0 0 2px var(--coral); }
.reel-frames canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}
.reel-frames li.shot { box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(61, 53, 82, 0.18); animation: pop 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }
.reel-frames .g {
  position: absolute;
  right: -4px;
  top: -5px;
  min-width: 18px;
  padding: 1px 4px 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-family: var(--jua);
  font-size: 11px;
  line-height: 16px;
  text-align: center;
}
.compact .reel-frames .g { font-size: 9px; line-height: 13px; min-width: 14px; right: -3px; top: -4px; }
.reel-frames .g[data-g='S'] { background: #ffb703; }
.reel-frames .g[data-g='A'] { background: var(--coral); }
.reel-frames .g[data-g='B'] { background: #5fb8cf; }
.reel-frames .g[data-g='F'] { background: #b3a9c2; }
@keyframes pop { from { transform: scale(0.6); } }

/* 셔터 — 키보드로 포커스했을 때만 보인다 */
.sr-shutter {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.sr-shutter:focus-visible {
  pointer-events: auto;
  width: auto;
  height: auto;
  clip-path: none;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 200px);
  transform: translateX(-50%);
  padding: 10px 18px 9px;
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  font-family: var(--jua);
  font-size: 16px;
}

.icon-btn {
  pointer-events: auto;
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(61, 53, 82, 0.1);
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(61, 53, 82, 0.1); }

/* 멈춤 */
.pause {
  pointer-events: auto;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(61, 53, 82, 0.35);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.pause-card {
  width: 100%;
  max-width: 320px;
  padding: 26px 22px 20px;
  border-radius: 24px;
  background: var(--cream);
  text-align: center;
  box-shadow: 0 16px 40px rgba(61, 53, 82, 0.25);
  animation: drop 0.3s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.pause-title { margin: 0; font-family: var(--jua); font-size: 24px; }
.pause-text { margin: 10px 0 0; font-size: 14px; line-height: 1.6; color: var(--ink-soft); }
.pause .cta { margin-top: 24px; font-size: 20px; }
.pause .sub { margin-top: 10px; }

/* ── 결과 ─────────────────────────────── */

.result {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(255, 248, 239, 0.94);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  -webkit-user-select: auto;
  user-select: auto;
}
.result-inner {
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 32px);
  text-align: center;
}
.eyebrow {
  margin: 0 0 14px;
  font-family: var(--jua);
  font-size: 22px;
}
.polaroid canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(61, 53, 82, 0.16);
  animation: drop 0.5s cubic-bezier(0.3, 1.4, 0.5, 1);
}
@keyframes drop { from { transform: translateY(-16px) rotate(-3deg); opacity: 0; } }
.polaroid .empty {
  padding: 48px 20px;
  border-radius: 20px;
  background: #fff;
  font-family: var(--jua);
  font-size: 18px;
  line-height: 1.6;
}

.actions {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 10px;
  margin-top: 24px;
}
.actions .cta { font-size: 19px; }

.gain {
  margin-top: 32px;
  padding: 20px 18px 18px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 4px 0 rgba(61, 53, 82, 0.07);
}
.gain-label { margin: 0; font-size: 13px; color: var(--ink-soft); }
.gain-num { margin: 4px 0 2px; font-family: var(--jua); font-size: 22px; }
.gain-num b { font-weight: 400; font-size: 40px; color: var(--coral); }
.gain-total { margin: 0 0 14px; font-family: var(--jua); font-size: 15px; }
.gain-total b { font-weight: 400; }

.unlocks { list-style: none; margin: 0; padding: 0; }
.unlocks li {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #fff6e0;
  text-align: left;
  animation: drop 0.45s cubic-bezier(0.3, 1.4, 0.5, 1) both;
}
.unlocks li.big { background: linear-gradient(90deg, #ffe9a8, #ffd1c8); }
.unlocks .badge {
  flex: none;
  padding: 4px 9px 3px;
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  font-family: var(--jua);
  font-size: 12px;
}
.unlocks strong { display: block; font-family: var(--jua); font-weight: 400; font-size: 17px; }
.unlocks span { font-size: 13px; color: var(--ink-soft); }

.roll-label { margin: 32px 0 10px; font-family: var(--jua); font-size: 16px; }
.roll {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.roll figure { margin: 0; position: relative; }
.roll canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(61, 53, 82, 0.18);
}
.roll figcaption {
  position: absolute;
  right: -4px;
  top: -6px;
  min-width: 22px;
  padding: 2px 5px 1px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-family: var(--jua);
  font-size: 12px;
}
.roll figcaption[data-g='S'] { background: #ffb703; }
.roll figcaption[data-g='A'] { background: var(--coral); }
.roll figcaption[data-g='B'] { background: #5fb8cf; }
.roll figcaption[data-g='F'] { background: #b3a9c2; }

.again { margin: 36px 0 12px; }
.result .fine { margin-top: 16px; }

/* ── 토스트 ─────────────────────────────── */

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 120px);
  padding: 11px 18px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-family: var(--jua);
  font-size: 15px;
  white-space: nowrap;
  transform: translate(-50%, 10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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