:root {
  --paper: #f3eee2;
  --grid: #e4ddcb;
  --ink: #17140f;
  --white: #fffdf7;
  --muted: #6f6a5c;
  --yellow: #ffd23f;
  --coral: #ff6b4a;
  --NORMAL: #bdb7a5;
  --RARE: #6c9bff;
  --EPIC: #b184f7;
  --LEGEND: #ff8f3d;
  --SSR: #ffd23f;
  --shadow: 6px 6px 0 var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  color: var(--ink);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: break-word;
  line-break: strict;
  min-height: 100vh;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 27px 27px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 27px 27px,
    var(--paper);
}

.wrap { max-width: 480px; margin: 0 auto; padding: 18px 18px calc(40px + env(safe-area-inset-bottom)); }

/* 상단 */
.bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 900; letter-spacing: -0.02em; }
.logo { width: 28px; height: 28px; }
.date { padding: 4px 10px; border: 2.5px solid var(--ink); border-radius: 8px; background: var(--white); font-size: 12px; font-weight: 800; white-space: nowrap; }

.hero { margin-bottom: 8px; }
.eyebrow { display: inline-block; margin: 0 0 14px; padding: 5px 11px; border: 2.5px solid var(--ink); border-radius: 8px; background: var(--coral); color: var(--ink); font-size: 12px; font-weight: 900; letter-spacing: 0.02em; white-space: nowrap; transform: rotate(-2deg); box-shadow: 3px 3px 0 var(--ink); }
h1 { margin: 0; font-size: clamp(29px, 9.2vw, 44px); font-weight: 900; letter-spacing: -0.045em; line-height: 1.18; }
h1 mark { white-space: nowrap; background: linear-gradient(transparent 58%, var(--yellow) 58% 92%, transparent 92%); color: inherit; padding: 0 2px; }

.shared { margin: 24px 0 8px; }
.shared-label { margin: 0 0 14px; font-size: 13px; font-weight: 800; }
.shared-label::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border: 2px solid var(--ink); background: var(--yellow); }

/* 뽑기 무대 */
.stage { margin-top: 10px; }
.slot { min-height: 360px; display: flex; align-items: center; justify-content: center; }
.slot.has-card { min-height: 0; padding: 16px 0 8px; }

.machine { width: 100%; display: grid; justify-items: center; gap: 12px; text-align: center; }
.machine svg { width: 230px; height: auto; overflow: visible; }
.machine-text { margin: 0; color: var(--muted); font-size: 14px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.chips span { padding: 3px 9px; border: 2px solid var(--ink); border-radius: 7px; background: var(--c); font-size: 11px; font-weight: 900; letter-spacing: 0.03em; white-space: nowrap; }

.cap { animation: bob 2.6s ease-in-out infinite; animation-delay: var(--d); }
.knob { transform-origin: 110px 212px; }
.drop { transform: translate(110px, 248px) scale(0); transform-origin: 0 0; }
.machine.shake svg { animation: rattle 0.12s linear infinite; }
.machine.shake .knob { animation: turn 1.1s ease-in-out forwards; }
.machine.dropping svg { animation: none; }
.machine.dropping .drop { animation: fall 0.65s cubic-bezier(0.3, 0, 0.6, 1) forwards; }
.machine.dropping .machine-text, .machine.dropping .chips { opacity: 0.3; }

/* 결과 카드(사원증) */
.card {
  position: relative;
  width: 100%;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--white);
  box-shadow: 8px 8px 0 var(--ink);
  animation: reveal 0.45s cubic-bezier(0.2, 1.2, 0.4, 1);
}
.band {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 26px 18px 14px;
  border-bottom: 3px solid var(--ink);
  border-radius: 15px 15px 0 0;
  background: var(--tier);
}
.card[data-tier="EPIC"] .band { background: radial-gradient(rgba(23, 20, 15, 0.16) 2.2px, transparent 2.6px) 0 0 / 11px 11px, var(--tier); }
.card[data-tier="LEGEND"] .band, .card[data-tier="SSR"] .band { background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.45) 0 7px, transparent 7px 28px), var(--tier); }
.hole { position: absolute; top: 8px; left: 50%; width: 52px; height: 11px; margin-left: -26px; border: 2.5px solid var(--ink); border-radius: 999px; background: var(--paper); }
.tier { font-size: 40px; font-weight: 900; line-height: 1; letter-spacing: 0.02em; white-space: nowrap; }
.chance { padding: 3px 10px; border: 2.5px solid var(--ink); border-radius: 999px; background: var(--white); font-size: 12px; font-weight: 900; white-space: nowrap; }

.sticker {
  position: absolute;
  top: 72px;
  right: 14px;
  padding: 5px 12px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 17px;
  font-weight: 900;
  white-space: nowrap;
  transform: rotate(7deg);
  animation: slap 0.4s cubic-bezier(0.2, 1.4, 0.4, 1) 0.35s backwards;
}

.body { padding: 40px 18px 16px; }
.tag { display: inline-block; margin-bottom: 12px; padding: 2px 9px; border: 2px solid var(--ink); border-radius: 6px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.tag.official { background: var(--yellow); }
.situation { margin: 0 0 22px; font-size: 21px; font-weight: 800; line-height: 1.48; letter-spacing: -0.025em; }

.hp { margin-bottom: 18px; }
.hp-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
.hp-head b { color: var(--ink); font-size: 24px; font-weight: 900; letter-spacing: -0.03em; }
.hp-head small { font-size: 14px; font-weight: 900; }
.hp-cells { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.hp-cells i { height: 18px; border: 2px solid var(--ink); border-radius: 4px; background: var(--white); }
.hp-cells i.on { background: var(--tier); animation: cell 0.3s cubic-bezier(0.2, 1.4, 0.4, 1) backwards; }
.hp-cells i.on:nth-child(1) { animation-delay: 0.30s; } .hp-cells i.on:nth-child(2) { animation-delay: 0.35s; }
.hp-cells i.on:nth-child(3) { animation-delay: 0.40s; } .hp-cells i.on:nth-child(4) { animation-delay: 0.45s; }
.hp-cells i.on:nth-child(5) { animation-delay: 0.50s; } .hp-cells i.on:nth-child(6) { animation-delay: 0.55s; }
.hp-cells i.on:nth-child(7) { animation-delay: 0.60s; } .hp-cells i.on:nth-child(8) { animation-delay: 0.65s; }
.hp-cells i.on:nth-child(9) { animation-delay: 0.70s; } .hp-cells i.on:nth-child(10) { animation-delay: 0.75s; }

dl { margin: 0; display: grid; gap: 12px; }
.info { padding: 12px 14px 13px; border: 2.5px solid var(--ink); border-radius: 12px; background: var(--white); box-shadow: 4px 4px 0 var(--ink); }
.info dt { display: inline-block; margin-bottom: 7px; padding: 2px 8px; border-radius: 5px; background: var(--ink); color: var(--white); font-size: 11px; font-weight: 900; letter-spacing: 0.04em; }
.info dd { margin: 0; font-size: 16px; font-weight: 800; line-height: 1.5; letter-spacing: -0.02em; }

.stamp { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; padding-top: 14px; border-top: 2px dashed var(--ink); font-size: 12px; font-weight: 900; letter-spacing: 0.1em; white-space: nowrap; }
.barcode { flex: 1; height: 26px; max-width: 150px; background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 4px, var(--ink) 4px 5px, transparent 5px 8px, var(--ink) 8px 11px, transparent 11px 13px, var(--ink) 13px 14px, transparent 14px 17px); }

/* 버튼 */
.pull {
  width: 100%;
  margin-top: 22px;
  padding: 18px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--yellow);
  box-shadow: var(--shadow);
  color: var(--ink);
  font: inherit;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.02em;
  cursor: pointer;
  transition: transform 0.07s, box-shadow 0.07s;
}
.pull:not(:disabled):hover { background: #ffdb62; }
.pull:not(:disabled):active { transform: translate(6px, 6px); box-shadow: 0 0 0 var(--ink); }
.pull:disabled { background: #e6dfc9; cursor: default; }
.note { min-height: 20px; margin: 14px 0 0; color: var(--muted); font-size: 13px; font-weight: 600; text-align: center; }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px; }
.actions button {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 12px 6px 11px;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  background: var(--white);
  box-shadow: 4px 4px 0 var(--ink);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.07s, box-shadow 0.07s;
}
.actions button:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.actions svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* 확률표 */
.odds { margin-top: 34px; padding: 14px 16px; border: 2.5px solid var(--ink); border-radius: 12px; background: var(--white); font-size: 14px; }
.odds summary { cursor: pointer; font-weight: 900; }
.odds-list { margin-top: 14px; display: grid; gap: 10px; }
.odds-row { display: grid; grid-template-columns: 62px 1fr 34px 44px; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; }
.odds-row b { justify-self: start; padding: 1px 7px; border: 2px solid var(--ink); border-radius: 5px; background: var(--c); font-size: 12px; font-weight: 900; }
.odds-bar { height: 12px; border: 2px solid var(--ink); border-radius: 3px; background: var(--white); overflow: hidden; }
.odds-bar i { display: block; height: 100%; background: var(--ink); }
.odds-n { text-align: right; color: var(--muted); }
.odds-p { text-align: right; font-weight: 900; }
.odds-note { margin: 14px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; font-weight: 500; }

.foot { margin-top: 28px; color: var(--muted); font-size: 12px; font-weight: 500; text-align: center; }
.foot p { margin: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 11px 18px;
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  background: var(--yellow);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  z-index: 30;
}

/* 터지는 순간: 등급 색 면이 한 번 덮고 색종이가 튄다 */
.flash { position: fixed; inset: 0; pointer-events: none; z-index: 20; opacity: 0; }
.flash::before { content: ""; position: absolute; inset: 0; background: var(--tier); }
.flash.go { animation: flash 0.7s ease-out forwards; }
.flash span { position: absolute; left: 50%; top: 46%; width: var(--w); height: calc(var(--w) * 0.6); margin: calc(var(--w) / -2); border: 2px solid var(--ink); opacity: 0; }
.flash.go span { animation: burst 0.9s cubic-bezier(0.1, 0.7, 0.3, 1) forwards; }

@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -4px; } }
@keyframes rattle { 0% { transform: translate(-2px, 0) rotate(-1deg); } 50% { transform: translate(2px, 1px) rotate(1deg); } 100% { transform: translate(-2px, 0) rotate(-1deg); } }
@keyframes turn { to { transform: rotate(360deg); } }
@keyframes fall { 0% { transform: translate(110px, 248px) scale(0.2); } 40% { transform: translate(110px, 262px) scale(1); } 100% { transform: translate(110px, 330px) scale(2.4); } }
@keyframes flash { 0% { opacity: 0; } 22% { opacity: 1; } 100% { opacity: 0; } }
@keyframes burst { 0% { opacity: 1; transform: rotate(var(--r)) translate(0, 0); } 100% { opacity: 0; transform: rotate(calc(var(--r) + 220deg)) translate(var(--d)) rotate(var(--a)); } }
@keyframes reveal { 0% { opacity: 0; transform: translateY(24px) rotate(-2deg) scale(0.94); } 100% { opacity: 1; transform: none; } }
@keyframes slap { 0% { opacity: 0; transform: rotate(7deg) scale(2); } 100% { opacity: 1; transform: rotate(7deg) scale(1); } }
@keyframes cell { from { transform: scale(0); } to { transform: none; } }

/* 한글은 어절 단위로 줄바꿈하고, 줄 길이를 고르게 맞춰 마지막 줄에 한두 글자만 남지 않게 한다. */
.situation, .info dd, .note, .foot p, .odds-note, .machine-text, .shared-label, h1 { text-wrap: balance; }

@media (prefers-reduced-motion: reduce) {
  .card, .sticker, .cap, .hp-cells i.on, .machine svg { animation: none !important; }
  .flash { display: none; }
}
