:root {
  --bg: #e7e4d6;
  --paper: #f8f6ed;
  --ink: #1d2618;
  --muted: #6a7060;
  --line: #d2cdb9;
  --olive: #34421f;
  --olive-2: #566a3a;
  --accent: #d4511b;
  --good: #2f7d4a;
  --bad: #b3372b;
  --gold: #c9941a;
  --r-n: #8a8f94; --r-r: #3a7bd5; --r-sr: #8e44ad; --r-ssr: #d4a017;
  --font: 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
  --display: 'Black Han Sans', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.55; }
body { min-height: 100vh; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 1px 0 rgba(0,0,0,.03); }

/* ---------- 버튼 ---------- */
.btn { border: 1px solid #b9b49e; background: #fbfaf4; color: var(--ink); border-radius: 8px; padding: 9px 16px; font-size: 14px; font-weight: 500; transition: transform .08s, background .15s, box-shadow .15s; }
.btn:hover { background: #fff; box-shadow: 0 2px 0 rgba(0,0,0,.08); }
.btn:active { transform: translateY(1px); }
.btn.big { padding: 13px 22px; font-size: 16px; font-weight: 700; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.primary { background: var(--olive); color: #f1efe0; border-color: var(--olive); }
.btn.primary:hover { background: #425529; }
.btn.active { background: var(--olive); color: #f1efe0; border-color: var(--olive); }
.btn.toggle:not(.active) { opacity: .75; }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(212,81,27,.5); } 50% { box-shadow: 0 0 0 10px rgba(212,81,27,0); } }

/* ---------- 타이틀 ---------- */
.screen { min-height: 100vh; }
.title-wrap { max-width: 1040px; margin: 0 auto; padding: 36px 20px 60px; display: grid; grid-template-columns: 1.05fr 1fr; gap: 36px; align-items: center; min-height: 100vh; }
.title-art { border: 4px solid var(--olive); border-radius: 12px; overflow: hidden; box-shadow: 8px 8px 0 rgba(52,66,31,.2); background: #000; }
.title-art canvas, .stage canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; aspect-ratio: 16 / 9; }
.eyebrow { font-size: 13px; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
h1 { font-family: var(--display); font-size: clamp(54px, 9vw, 92px); line-height: 1.02; letter-spacing: -.01em; color: var(--ink); }
h1 span { color: var(--accent); }
.lead { margin: 14px 0 22px; font-size: 17px; color: #3b4433; }
.title-form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.title-form input { width: 100%; max-width: 320px; padding: 11px 14px; border: 1px solid #b9b49e; border-radius: 8px; font-size: 16px; font-family: inherit; background: #fff; margin-bottom: 14px; }
.title-btns { display: flex; flex-wrap: wrap; gap: 10px; }
.notes { margin: 26px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.notes li { margin-bottom: 4px; }

/* ---------- 게임 상단 ---------- */
.topbar { background: var(--olive); color: #eef0df; padding: 10px 20px 0; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.top-row { max-width: 1120px; margin: 0 auto; display: flex; align-items: center; gap: 22px; padding-bottom: 8px; }
.brand { font-family: var(--display); font-size: 22px; white-space: nowrap; }
.brand span { color: #ff9a5a; }
.dday { display: flex; align-items: baseline; gap: 8px; }
.dday small { font-size: 12px; opacity: .75; }
.dday b { font-family: var(--display); font-size: 40px; line-height: 1; color: #ffb27a; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.top-meta { margin-left: auto; text-align: right; display: flex; flex-direction: column; font-size: 13px; opacity: .92; }
.top-meta b { font-size: 16px; }
.progress { position: relative; height: 5px; background: rgba(255,255,255,.18); max-width: 1120px; margin: 0 auto; border-radius: 3px 3px 0 0; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #ff9a5a, #ffd076); transition: width .6s ease; border-radius: 3px 3px 0 0; }
.progress em { position: absolute; top: -2px; width: 2px; height: 9px; background: rgba(255,255,255,.55); }

.controls { max-width: 1120px; margin: 12px auto 0; padding: 0 20px; display: flex; flex-wrap: wrap; gap: 8px; }

.layout { max-width: 1120px; margin: 14px auto 60px; padding: 0 20px; display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 90px; }

/* ---------- 신분증 ---------- */
.idcard { overflow: hidden; }
.id-head { display: flex; justify-content: space-between; background: var(--olive); color: #e8ebd6; font-size: 12px; padding: 7px 12px; font-weight: 700; letter-spacing: .05em; }
.id-body { display: flex; gap: 12px; padding: 12px; }
.id-body canvas { width: 72px; height: 88px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 4px; flex: none; }
.id-info { min-width: 0; flex: 1; }
.id-info h2 { font-size: 20px; margin-bottom: 4px; font-weight: 900; }
.id-info dl { display: grid; grid-template-columns: 34px 1fr; gap: 2px 8px; margin: 0; font-size: 12px; }
.id-info dt { color: var(--muted); }
.id-info dd { margin: 0; font-weight: 500; word-break: keep-all; }
.id-tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 12px; }
.g-chip { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: color-mix(in srgb, var(--c) 12%, #fff); color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 45%, #fff); }

/* ---------- 상태 ---------- */
.stats { padding: 14px 14px 12px; }
.stats h3 { font-size: 15px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: baseline; }
.stats h3 small { color: var(--muted); font-weight: 400; font-size: 12px; }
.bar { display: grid; grid-template-columns: 38px 1fr 26px; gap: 8px; align-items: center; margin: 7px 0; font-size: 13px; border-radius: 6px; }
.b-name { font-weight: 700; }
.b-track { height: 10px; background: #e5e1cf; border-radius: 6px; overflow: hidden; }
.b-track i { display: block; height: 100%; width: 0; border-radius: 6px; transition: width .5s ease; }
.b-val { text-align: right; font-variant-numeric: tabular-nums; }
.bar.up { animation: flashUp .9s; } .bar.down { animation: flashDown .9s; }
@keyframes flashUp { 0% { background: rgba(47,125,74,.28); } 100% { background: transparent; } }
@keyframes flashDown { 0% { background: rgba(179,55,43,.25); } 100% { background: transparent; } }
.wallet { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.wallet div { display: flex; flex-direction: column; }
.wallet small { font-size: 11px; color: var(--muted); }
.wallet b { font-size: 15px; font-variant-numeric: tabular-nums; }

/* ---------- 메인 ---------- */
.main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.stage { overflow: hidden; border: 3px solid var(--olive); border-radius: 10px; }
.caption { padding: 8px 14px; background: #fbfaf4; border-top: 1px solid var(--line); font-size: 13px; color: #3d4634; }

.stage canvas { aspect-ratio: 2 / 1; object-fit: cover; object-position: 50% 88%; }
.focus { padding: 18px 20px; border-left: 5px solid var(--olive-2); scroll-margin-top: 118px; scroll-margin-bottom: 24px; }
.focus.k-choice { border-left-color: var(--accent); }
.focus.k-result { border-left-color: var(--good); }
.focus.flash { animation: cardIn .35s ease; }
@keyframes cardIn { from { transform: translateY(6px); opacity: .3; } to { transform: none; opacity: 1; } }
.f-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.tag { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--olive); color: #eef0df; letter-spacing: .04em; }
.k-choice .tag { background: var(--accent); }
.k-result .tag { background: var(--good); }
.f-head h3 { font-size: 19px; font-weight: 900; }
.f-text { color: #2e3629; font-size: 15px; word-break: keep-all; }
.f-result { margin-top: 10px; padding: 10px 14px; background: #eef4e4; border-radius: 8px; color: #25361b; font-weight: 500; word-break: keep-all; }
.f-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.f-chips:empty { display: none; }
.chip { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.chip.pos { background: #dff0e3; color: #1f6a3a; }
.chip.neg { background: #f6dcd8; color: #a22f24; }
.choices { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.choices:empty { display: none; }
.choice { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; padding: 12px 16px; border: 1px solid #b9b49e; border-radius: 9px; background: #fff; font-size: 15px; transition: transform .08s, border-color .15s, background .15s; }
.choice:hover { border-color: var(--olive); background: #f3f6e8; transform: translateX(3px); }
.choice small { font-size: 11px; font-weight: 700; color: var(--accent); border: 1px dashed var(--accent); border-radius: 999px; padding: 1px 8px; flex: none; }
.choice.danger { border-color: #b3372b; }
.choice.danger:hover { border-color: #b3372b; background: #fbefee; }
.choice small.dg { color: #b3372b; border-color: #b3372b; }
.choice.cont { justify-content: center; background: var(--olive); color: #eef0df; border-color: var(--olive); font-weight: 700; }
.choice.cont:hover { background: #425529; transform: none; }

.logcard { padding: 14px 18px 8px; }
.log-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.log-head h3 { font-size: 15px; }
.log-head small { color: var(--muted); }
#log { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
#log li { padding: 8px 0; border-top: 1px solid #e8e4d3; font-size: 14px; word-break: keep-all; }
#log li:first-child { border-top: 0; }
#log li.hl { font-weight: 700; }
#log .lw { display: inline-block; min-width: 76px; margin-right: 8px; font-size: 11px; font-weight: 700; color: var(--muted); }

/* ---------- 뽑기 오버레이 ---------- */
.overlay { position: fixed; inset: 0; background: rgba(14,20,10,.82); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; overflow: auto; }
.gacha-card { width: min(520px, 100%); background: #f8f6ed; border-radius: 16px; padding: 26px 24px 22px; text-align: center; border: 4px solid #3d4a2b; box-shadow: 0 20px 60px rgba(0,0,0,.45); position: relative; }
.g-step { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .08em; padding: 3px 12px; border-radius: 999px; background: var(--olive); color: #eef0df; }
.g-head h2 { font-family: var(--display); font-size: 34px; margin-top: 10px; font-weight: 400; }
.g-head p { color: var(--muted); font-size: 14px; margin-top: 4px; min-height: 21px; word-break: keep-all; }
.g-reel { margin: 20px 0 6px; height: 92px; display: flex; align-items: center; justify-content: center; background: #fff; border: 2px solid #3d4a2b; border-radius: 12px; overflow: hidden; box-shadow: inset 0 4px 12px rgba(0,0,0,.12); padding: 0 12px; }
#g-reel-text { font-family: var(--display); font-size: 34px; line-height: 1.15; word-break: keep-all; }
.g-reel.landed #g-reel-text { animation: land .35s ease; color: var(--accent); }
@keyframes land { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
.g-result { margin-top: 16px; animation: cardIn .4s ease; }
.rv-rar { display: inline-block; font-family: var(--display); font-size: 22px; letter-spacing: .1em; padding: 2px 16px; border-radius: 8px; color: #fff; background: var(--r-n); }
.rv-name { font-family: var(--display); font-size: 36px; margin: 8px 0 2px; line-height: 1.12; word-break: keep-all; }
.rv-sub { font-size: 14px; color: var(--muted); }
.rv-prob { margin-top: 10px; font-size: 14px; color: #3b4433; }
.rv-prob b { font-size: 20px; color: var(--accent); }
.rv-grade { margin-top: 6px; font-size: 14px; }
.rv-grade .stars { color: #e1a920; letter-spacing: 2px; font-size: 16px; }
.rv-blurb { margin-top: 12px; font-size: 14px; color: #2e3629; word-break: keep-all; }
.rv-note { margin-top: 8px; font-size: 13px; font-weight: 700; color: var(--olive-2); word-break: keep-all; }
.g-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }

.gacha-card.rar-n { border-color: var(--r-n); } .gacha-card.rar-n .rv-rar { background: var(--r-n); }
.gacha-card.rar-r { border-color: var(--r-r); } .gacha-card.rar-r .rv-rar { background: var(--r-r); }
.gacha-card.rar-sr { border-color: var(--r-sr); box-shadow: 0 0 40px rgba(142,68,173,.55); } .gacha-card.rar-sr .rv-rar { background: var(--r-sr); }
.gacha-card.rar-ssr { border-color: var(--r-ssr); box-shadow: 0 0 60px rgba(244,190,40,.7); } .gacha-card.rar-ssr .rv-rar { background: linear-gradient(90deg, #c9941a, #f5cf4a, #c9941a); color: #3a2a00; }
.gacha-card.rar-ur { border-color: transparent; background: linear-gradient(#f8f6ed, #f8f6ed) padding-box, linear-gradient(120deg, #ff5f6d, #ffc371, #47e891, #4facfe, #b06cf5, #ff5f6d) border-box; background-size: 100% 100%, 300% 300%; animation: rainbow 4s linear infinite; box-shadow: 0 0 70px rgba(176,108,245,.6); }
.gacha-card.rar-ur .rv-rar { background: linear-gradient(90deg, #ff5f6d, #ffc371, #47e891, #4facfe, #b06cf5); }
@keyframes rainbow { 0% { background-position: 0 0, 0% 50%; } 100% { background-position: 0 0, 300% 50%; } }
.gacha-card.bad { animation: shake .5s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-9px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }

#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 110; }
#confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(720deg); } }

/* ---------- 도감 ---------- */
.dex-card { width: min(780px, 100%); background: var(--paper); border-radius: 14px; padding: 20px 22px 26px; max-height: 90vh; overflow: auto; }
.dex-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.dex-head h2 { font-family: var(--display); font-size: 28px; font-weight: 400; }
.dex-sum { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.dex-card h4 { margin: 18px 0 8px; font-size: 15px; }
.dex-card h4 small { color: var(--muted); font-weight: 400; }
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.dex-item { border: 1px dashed #c4bfa9; border-radius: 8px; padding: 8px 10px; background: #f1efe3; color: #9a9784; display: flex; flex-direction: column; font-size: 13px; }
.dex-item small { font-size: 11px; }
.dex-item.ok { color: var(--ink); background: #fff; border: 2px solid var(--r-n); }
.dex-item.ok.rar-r { border-color: var(--r-r); } .dex-item.ok.rar-sr { border-color: var(--r-sr); }
.dex-item.ok.rar-ssr { border-color: var(--r-ssr); background: #fffaf0; }
.dex-item.ok.rar-ur { border-color: #b06cf5; background: #f9f3ff; }

/* ---------- 엔딩 ---------- */
.end-wrap { max-width: 760px; margin: 0 auto; padding: 32px 18px 70px; display: flex; flex-direction: column; gap: 14px; }
.cert { background: #fffdf3; border: 3px double #8a7a45; outline: 6px solid #fffdf3; box-shadow: 0 0 0 7px #8a7a45; border-radius: 4px; padding: 34px 26px 30px; text-align: center; position: relative; margin: 10px 8px 14px; }
.cert-head { font-family: var(--display); font-size: 40px; letter-spacing: .5em; color: #4a4020; }
.cert-name { font-family: var(--display); font-size: 46px; margin: 12px 0 6px; }
.cert-line { font-size: 14px; color: #5a5230; font-weight: 700; }
.cert-text { margin-top: 16px; color: #3a3520; word-break: keep-all; }
.cert-sub { margin-top: 12px; font-weight: 700; color: var(--accent); }
.cert-stamp { position: absolute; right: 28px; bottom: 24px; width: 82px; height: 82px; border: 4px solid #c0392b; color: #c0392b; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--display); font-size: 28px; transform: rotate(-14deg); opacity: .85; animation: stamp .5s ease .3s both; }
@keyframes stamp { from { transform: rotate(-14deg) scale(2.2); opacity: 0; } to { transform: rotate(-14deg) scale(1); opacity: .85; } }
.cert-ur { display: inline-block; padding: 2px 14px; margin-bottom: 8px; border-radius: 8px; color: #fff; font-family: var(--display); background: linear-gradient(90deg, #ff5f6d, #ffc371, #47e891, #4facfe, #b06cf5); }
.cert.exempt .cert-head { letter-spacing: .3em; }
.end-grid { display: grid; grid-template-columns: 150px 1fr; gap: 14px; }
.grade-box { text-align: center; padding: 16px 10px; display: flex; flex-direction: column; justify-content: center; }
.grade-box small, .title-box small { color: var(--muted); font-size: 12px; }
.grade-box b { font-family: var(--display); font-size: 74px; line-height: 1; }
.gr-S { color: #c9941a; } .gr-A { color: #2f7d4a; } .gr-B { color: #3a7bd5; } .gr-C { color: #6b7280; } .gr-D { color: #b3372b; }
.grade-box span { color: var(--muted); font-size: 13px; }
.title-box { padding: 16px 20px; display: flex; flex-direction: column; justify-content: center; }
.title-box h2 { font-family: var(--display); font-weight: 400; font-size: 30px; margin: 4px 0; color: var(--accent); word-break: keep-all; }
.title-box p { color: #3b4433; font-size: 14px; word-break: keep-all; }
.end-stats, .draw-box, .end-wrap .card { padding: 16px 20px; }
.end-wrap h3 { font-size: 15px; margin-bottom: 8px; }
.draws { width: 100%; border-collapse: collapse; font-size: 14px; }
.draws td { padding: 7px 4px; border-top: 1px solid #e6e2d0; }
.draws tr:first-child td { border-top: 0; }
.draws td:first-child { color: var(--muted); width: 72px; }
.draws td.r { text-align: right; font-weight: 700; color: var(--accent); width: 70px; }
.onein { margin-top: 12px; padding: 10px 14px; background: #f3efdc; border-radius: 8px; text-align: center; font-size: 14px; }
.onein b { font-size: 18px; color: var(--accent); }
.onein.sub { margin-top: 8px; padding: 4px 8px; background: transparent; color: var(--muted); font-size: 13px; }
.cert.early .cert-head { letter-spacing: .3em; }
.plain { margin: 0; padding-left: 18px; font-size: 14px; }
.plain li { margin: 4px 0; word-break: keep-all; }
.quote { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 13px; font-style: italic; }
.end-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }

.site-foot { max-width: 1120px; margin: 0 auto; padding: 18px 20px 44px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; line-height: 1.7; text-align: center; }
.site-foot p { margin: 2px 0; word-break: keep-all; }
.site-foot a { color: var(--olive-2); text-decoration: underline; text-underline-offset: 2px; }
.site-foot b { color: #4a5239; }
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: #1d2618; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,.3); }

/* ---------- 반응형 ---------- */
@media (max-width: 900px) {
  .title-wrap { grid-template-columns: 1fr; padding-top: 22px; min-height: 0; }
  .layout { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
  .main, .side { display: contents; }
  .stage { order: 1; } .focus { order: 2; } .stats { order: 3; } .idcard { order: 4; } .logcard { order: 5; }
  #log { max-height: 280px; }
  .top-row { gap: 12px; }
  .dday b { font-size: 32px; }
  .brand { font-size: 18px; }
}
@media (max-width: 520px) {
  .top-meta { display: none; }
  .brand { display: none; }
  .end-grid { grid-template-columns: 1fr; }
  .cert-head { font-size: 30px; letter-spacing: .3em; }
  .cert-name { font-size: 36px; }
  .cert-stamp { width: 62px; height: 62px; font-size: 22px; right: 14px; bottom: 12px; }
  .g-head h2 { font-size: 28px; } #g-reel-text { font-size: 28px; } .rv-name { font-size: 30px; }
  .controls { padding: 0 14px; } .layout { padding: 0 14px; }
}
