* { box-sizing: border-box; }
:root { --ink: #1b1b24; --muted: #6c6f80; --line: #2f3346; --accent: #ffd60a; --bad: #e53935; --bg: #12131c; --panel: #1d1f2c; }
html, body { margin: 0; color: #f2f2f7; background: var(--bg); font-family: Pretendard, "Noto Sans KR", system-ui, "Malgun Gothic", sans-serif; }
body { min-height: 100vh; }
button { font: inherit; cursor: pointer; color: inherit; }
[hidden] { display: none !important; }

.bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; background: #0b0c12; border-bottom: 1px solid var(--line); }
.bar a { color: #f2f2f7; text-decoration: none; font-weight: 800; white-space: nowrap; }
.bar-actions { display: flex; gap: 6px; }
.bar button { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 6px 12px; white-space: nowrap; }

.shell { max-width: 860px; margin: 0 auto; padding: 12px 16px 40px; }
h1 { margin: 6px 0 2px; font-size: clamp(22px, 5vw, 30px); }
h1 small { font-size: .6em; color: var(--accent); margin-left: 6px; }
.progress { margin: 0 0 10px; color: #b9bccb; font-weight: 700; }

.stage-wrap { position: relative; }
#stage { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 16px; border: 3px solid var(--line); background: #000; touch-action: manipulation; }

.card { margin: 12px auto 0; max-width: 560px; padding: 16px 18px; border-radius: 18px; background: #fff; color: var(--ink); text-align: center; box-shadow: 0 20px 50px #000a; animation: pop .3s ease-out; }
.card.fail { border: 4px solid var(--bad); }
.card.ending { border: 4px solid var(--accent); }
.card-tag { margin: 0; font-weight: 900; color: var(--muted); }
.card h2 { margin: 4px 0 8px; font-size: 24px; }
.card p { line-height: 1.6; margin: 6px 0; }
.card-new { font-weight: 900; color: #7b2cbf; min-height: 0; }
.card-new:empty { display: none; }
.card-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.card-actions button { border: 1px solid #d8d9e2; background: #fff; border-radius: 12px; padding: 10px 14px; font-weight: 800; }
.primary { border: 0 !important; background: linear-gradient(135deg, #ffb703, #fb8500) !important; color: #1b1b24 !important; font-weight: 900; }

.timer { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; font-weight: 900; color: var(--accent); animation: blink .4s infinite alternate; }
.timer .track { flex: 1; height: 12px; border-radius: 99px; background: #2b2e40; overflow: hidden; }
.timer i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--bad), var(--accent)); }

.story { min-height: 3.2em; margin: 12px 0; padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); line-height: 1.6; font-size: 17px; }
.story:empty { display: none; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.choices.one { grid-template-columns: 1fr; }
.choice { position: relative; display: grid; justify-items: center; gap: 6px; padding: 14px 10px; border: 2px solid var(--line); border-radius: 16px; background: var(--panel); font-weight: 800; line-height: 1.35; animation: rise .25s ease-out both; transition: transform .1s, border-color .15s; }
.choice:hover, .choice:focus-visible { border-color: var(--accent); transform: translateY(-3px); outline: none; }
.choice .icon { font-size: 40px; line-height: 1; }
.choices.one .choice { padding: 20px; font-size: 22px; background: #3a1d1d; border-color: var(--bad); }
.choice kbd { position: absolute; left: 8px; top: 6px; font: 700 12px system-ui; color: #8b8fa3; }
.help { color: #8b8fa3; font-size: 14px; text-align: center; margin-top: 16px; }

.dialog { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .6); z-index: 20; }
.dialog-card { width: 100%; max-width: 520px; max-height: 88vh; overflow: auto; padding: 18px; border-radius: 18px; background: #fff; color: var(--ink); }
.dialog-card h2 { margin: 0 0 10px; }
.collection { list-style: none; margin: 0 0 12px; padding: 0; }
.collection li { padding: 9px 10px; border-radius: 10px; margin: 4px 0; background: #f4f4f8; display: grid; gap: 2px; }
.collection li.head { background: none; font-weight: 900; padding: 10px 0 2px; }
.collection li.locked { color: #9a9cab; }
.collection small { color: var(--muted); line-height: 1.5; }
.dialog-card .primary { width: 100%; border-radius: 12px; padding: 12px; }

@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes blink { to { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .card, .choice, .timer { animation: none; } }
@media (max-width: 560px) {
  .choices { grid-template-columns: 1fr 1fr; }
  .choice { padding: 10px 6px; font-size: 14px; }
  .choice .icon { font-size: 30px; }
  .story { font-size: 15px; }
}
