:root {
  --bg: #fff4ec;
  --paper: #ffffff;
  --ink: #4a3b3b;
  --soft: #8c7a78;
  --pink: #ff8fab;
  --pink-soft: #ffe0ea;
  --lilac: #b89ad6;
  --lilac-soft: #f1e8fb;
  --mint: #bfe8d4;
  --sky-day1: #cdeeff;
  --sky-day2: #fff1d6;
  --grass: #c8eab0;
  --night1: #2e2a5c;
  --night2: #5b4a8f;
  --gold: #ffcf3f;
  --shadow: 0 6px 18px rgba(120, 80, 70, 0.12);
  --radius: 18px;
  font-family: 'Gowun Dodum', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); overflow-x: hidden; word-break: keep-all; overflow-wrap: anywhere; }
h1, h2, .ending-card p, .pocket-text { text-wrap: balance; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

.app { max-width: 480px; margin: 0 auto; min-height: 100%; position: relative; }
.screen { min-height: 100dvh; }
h1, h2, .phase, .kicker, .big-btn, .party-kicker, .pick-title, .banner { font-family: 'Jua', 'Gowun Dodum', sans-serif; font-weight: 400; }

/* 첫 화면 */
.start { padding: 28px 16px 40px; text-align: center; background: radial-gradient(circle at 50% 0, #ffe3ec 0, var(--bg) 60%); }
.kicker { margin: 0; color: var(--pink); font-size: 16px; }
.start h1 { margin: 6px 0 4px; font-size: 44px; line-height: 1.05; color: var(--ink); letter-spacing: 1px; }
.lineup { display: flex; justify-content: center; gap: 2px; margin: 10px 0 6px; flex-wrap: wrap; }
.lineup .mini { width: 52px; height: 52px; animation: hop 1.8s ease-in-out infinite; }
.lineup .mini:nth-child(2n) { animation-delay: .3s; }
.lineup .mini:nth-child(3n) { animation-delay: .6s; }
.rules { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; text-align: left; font-size: 15px; line-height: 1.55; }
.rules p { margin: 6px 0; }
.pick-title { margin: 22px 0 10px; font-size: 22px; }
.game-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.game-card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 10px; text-align: center; transition: transform .15s; }
.game-card:active { transform: scale(.96); }
.game-card .num { font-family: 'Jua', sans-serif; font-size: 22px; color: var(--pink); }
.game-card .sub { font-size: 13px; color: var(--soft); margin-top: 4px; }
.foot { margin-top: 18px; font-size: 12px; color: var(--soft); }

/* 관전 화면 */
.play { display: flex; flex-direction: column; height: 100dvh; }
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--paper); box-shadow: 0 2px 10px rgba(0,0,0,.05); z-index: 3; }
.icon-btn { font-size: 20px; width: 36px; height: 36px; border-radius: 50%; background: var(--bg); }
.phase-wrap { flex: 1; min-width: 0; }
.phase { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gauge { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.gauge-track { flex: 1; height: 7px; background: var(--pink-soft); border-radius: 9px; overflow: hidden; }
.gauge-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--pink), var(--gold)); border-radius: 9px; transition: width .8s; }
.spy-btn { font-size: 13px; padding: 7px 10px; border-radius: 999px; background: var(--bg); white-space: nowrap; }
.spy-btn[aria-pressed='true'] { background: var(--lilac); color: #fff; }

.stage { position: relative; height: 38dvh; min-height: 240px; max-height: 330px; overflow: hidden; transition: background 1s; flex-shrink: 0; }
.stage.day { background: linear-gradient(var(--sky-day1), var(--sky-day2) 55%, var(--grass) 56%); }
.stage.night { background: linear-gradient(var(--night1), var(--night2) 55%, #6f8f73 56%); }
.stage.party { background: linear-gradient(#ffd6e5, #fff1c9 55%, var(--grass) 56%); }
.sky { position: absolute; inset: 0; pointer-events: none; }
.sun { position: absolute; right: 14px; top: 8px; font-size: 26px; }
.moon { position: absolute; right: 14px; top: 8px; font-size: 24px; display: none; }
.star { position: absolute; color: #fff7c2; display: none; animation: twinkle 2s infinite; }
.s1 { left: 10%; top: 10%; } .s2 { left: 30%; top: 22%; animation-delay: .5s; } .s3 { left: 62%; top: 8%; animation-delay: 1s; } .s4 { left: 80%; top: 30%; animation-delay: 1.4s; }
.stage.night .star, .stage.night .moon { display: block; }
.stage.night .sun { display: none; }
.blanket-mat { position: absolute; left: 50%; top: 60%; width: 62%; height: 34%; transform: translate(-50%, -50%); border-radius: 50%;
  background: repeating-conic-gradient(from 45deg, #ffd1dc 0 25%, #fff 0 50%) 0 0 / 22px 22px; opacity: .85; box-shadow: inset 0 0 0 4px rgba(255,255,255,.7); }

.seat { position: absolute; width: 74px; transform: translate(-50%, -50%); text-align: center; transition: opacity .5s, filter .5s; }
.seat .av { width: 64px; height: 64px; margin: 0 auto; transition: transform .2s; }
.seat .name { display: inline-block; margin-top: -2px; font-size: 12px; background: rgba(255,255,255,.9); padding: 1px 8px; border-radius: 999px; }
.stage.night .seat .name { background: rgba(255,255,255,.75); }
.seat.talking .av { animation: talk .5s ease-in-out infinite alternate; }
.seat.talking::before { content: '💬'; position: absolute; top: -10px; right: 2px; font-size: 18px; animation: hop .8s infinite; }
.seat.nap { opacity: .85; }
.seat.nap::after { content: 'z z'; position: absolute; top: -4px; right: 0; font-family: 'Jua', sans-serif; color: #7d6bc4; font-size: 15px; animation: zz 2s infinite; }
.seat.bench, .seat.backstage { opacity: .5; filter: grayscale(.4); }
.seat .tag { display: block; font-size: 10px; color: var(--soft); }
.stage.night .seat .tag { color: #eee; }
.seat .role { display: none; position: absolute; left: -2px; top: -2px; font-size: 15px; background: #fff; border-radius: 50%; width: 22px; height: 22px; line-height: 22px; box-shadow: var(--shadow); }
body.spy .seat .role { display: block; }
.seat .votes { position: absolute; right: -2px; top: 18px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--pink); color: #fff; font-size: 13px; line-height: 22px; display: none; font-family: 'Jua', sans-serif; }
.seat .votes.on { display: block; animation: pop .3s; }

.banner { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.8); background: rgba(255,255,255,.95); padding: 8px 18px; border-radius: 999px; font-size: 20px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; white-space: nowrap; }
.banner.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.feed { flex: 1; overflow-y: auto; padding: 12px 12px 18px; scroll-behavior: smooth; }
.item { margin: 8px 0; animation: rise .35s ease-out; }
.divider { text-align: center; font-family: 'Jua', sans-serif; color: var(--soft); font-size: 14px; margin: 16px 0 8px; }
.divider span { background: var(--paper); padding: 4px 12px; border-radius: 999px; box-shadow: var(--shadow); }
.row { display: flex; gap: 8px; align-items: flex-start; }
.row .av { width: 42px; height: 42px; flex-shrink: 0; }
.bubble { background: var(--paper); border-radius: 4px var(--radius) var(--radius) var(--radius); padding: 8px 12px; box-shadow: var(--shadow); max-width: 82%; }
.bubble .who { font-size: 12px; color: var(--soft); margin-bottom: 2px; }
.bubble .who .hand { margin-left: 4px; }
.bubble .txt { font-size: 15px; line-height: 1.45; word-break: keep-all; overflow-wrap: anywhere; }
.inner { display: none; margin-top: 5px; font-size: 12.5px; color: #7d5fb0; background: var(--lilac-soft); border-radius: 10px; padding: 4px 8px; }
body.spy .inner { display: block; }
.owl .bubble { background: #fff8e6; border: 2px solid #ffe2a8; }
.kind { display: inline-block; font-size: 10.5px; padding: 0 6px; border-radius: 6px; background: var(--pink-soft); color: #c45a7a; margin-left: 4px; }
.secret { display: none; }
body.spy .secret { display: block; }
.secret-card { border: 2px dashed var(--lilac); background: var(--lilac-soft); border-radius: var(--radius); padding: 8px 12px; font-size: 14px; color: #5d4590; }
.secret-card b { color: #4b347c; }
.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; }
.card h3 { margin: 0 0 6px; font-family: 'Jua', sans-serif; font-weight: 400; font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--bg); border-radius: 999px; padding: 4px 10px; font-size: 13.5px; }
.clue-head { font-size: 14px; margin: 0 0 8px; line-height: 1.45; }
.vote-line { font-size: 14px; padding: 3px 0; border-bottom: 1px dashed #f0e2dc; }
.vote-line:last-of-type { border-bottom: 0; }
.vote-result { margin-top: 6px; font-family: 'Jua', sans-serif; color: var(--pink); }

.controls { display: flex; align-items: center; gap: 8px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: var(--paper); box-shadow: 0 -2px 10px rgba(0,0,0,.05); }
.ctrl { background: var(--bg); border-radius: 999px; padding: 8px 12px; font-size: 14px; white-space: nowrap; }
.ctrl.main { width: 44px; height: 44px; padding: 0; font-size: 18px; background: var(--pink); color: #fff; }
.progress { flex: 1; height: 6px; background: var(--pink-soft); border-radius: 9px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--pink); transition: width .3s; }

/* 주머니 열기 · 파티 */
.overlay { position: fixed; inset: 0; background: rgba(74, 59, 59, .35); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.pocket-card { background: var(--paper); border-radius: 24px; padding: 20px 22px; text-align: center; width: min(320px, 100%); animation: pop .4s; box-shadow: var(--shadow); }
.pocket-avatar { width: 120px; height: 120px; margin: 0 auto; }
.pocket-name { font-family: 'Jua', sans-serif; font-size: 20px; margin: 4px 0; }
.pocket-text { font-size: 17px; margin: 6px 0 0; line-height: 1.5; }
.party { background: rgba(255, 228, 238, .92); overflow-y: auto; align-items: flex-start; }
.party-card { position: relative; z-index: 1; background: var(--paper); border-radius: 26px; padding: 20px 16px; width: min(440px, 100%); text-align: center; box-shadow: var(--shadow); margin: auto 0; animation: pop .5s; }
.party-kicker { margin: 0; color: var(--pink); font-size: 18px; }
.party-card h2 { margin: 4px 0 10px; font-size: 24px; }
.party-cast { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.party-cast .pc { position: relative; }
.party-cast .pc .av { width: 76px; height: 76px; margin: 0 auto; animation: hop 1.2s ease-in-out infinite; }
.party-cast .pc:nth-child(2n) .av { animation-delay: .25s; }
.party-cast .pc .hat { position: absolute; left: 50%; top: -8px; transform: translateX(-50%) rotate(-12deg); font-size: 22px; }
.party-cast .pc .nm { font-size: 13px; }
.party-cast .pc .rl { font-size: 11px; color: var(--soft); }
.party-roles { font-size: 13px; color: var(--soft); margin: 6px 0; }
.ending-card { margin: 14px 4px 6px; background: linear-gradient(135deg, #fff0f5, #fff8e1); border: 2px solid #ffc2d4; border-radius: 20px; padding: 16px 14px; box-shadow: var(--shadow); }
.ending-card .heart { font-size: 30px; display: block; animation: hop 1.5s infinite; }
.ending-card p { margin: 6px 0 0; font-family: 'Jua', sans-serif; font-size: 21px; line-height: 1.45; color: #c2456d; word-break: keep-all; }
.party-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.big-btn { background: var(--pink); color: #fff; border-radius: 999px; padding: 12px 16px; font-size: 18px; box-shadow: var(--shadow); }
.ghost-btn { color: var(--soft); font-size: 14px; padding: 6px; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 3px; animation: fall linear infinite; }

@keyframes hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes talk { from { transform: translateY(0) scale(1); } to { transform: translateY(-4px) scale(1.05); } }
@keyframes zz { 0% { opacity: 0; transform: translate(0, 4px); } 50% { opacity: 1; } 100% { opacity: 0; transform: translate(6px, -8px); } }
@keyframes twinkle { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

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