/* S003 뽑기판 · 헬베티카 계열 단일 서체, 종이·잉크 톤 */
:root {
  --ink: #16150f;
  --paper: #f2efe7;
  --panel: #fffdf8;
  --muted: #6d675c;
  --line: #ddd5c6;
  --accent: #e2542c;
  --accent-ink: #b23c1b;
  --radius: 16px;
  --font: 'Helvetica Neue', Helvetica, 'Apple SD Gothic Neo', 'Noto Sans KR', Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  word-break: keep-all;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ── 머리 ─────────────────────────────────────────── */
.mast {
  display: flex; align-items: center; gap: 14px;
  padding: 16px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
}
.wordmark {
  font-size: 23px; font-weight: 800; letter-spacing: -.05em;
  text-decoration: none; display: inline-flex; align-items: baseline; gap: 3px;
}
.wordmark span { color: var(--accent); }
.wordmark i { font-style: normal; font-size: 13px; transform: translateY(-6px); }
.edition {
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); border-left: 1px solid var(--line); padding-left: 14px;
}
.lang {
  margin-left: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600;
}
.lang:hover { border-color: var(--ink); }

main { max-width: 1160px; margin: 0 auto; padding: clamp(18px, 3vw, 30px) clamp(16px, 4vw, 40px) 60px; }

/* ── 소개 ─────────────────────────────────────────── */
.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.intro-copy { max-width: 720px; }
.eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: var(--accent-ink); margin-bottom: 10px;
}
h1 {
  font-size: clamp(34px, 5.2vw, 62px); line-height: 1.02; letter-spacing: -.05em;
  font-weight: 800;
}
.lede { margin-top: 14px; font-size: clamp(15px, 1.6vw, 18px); color: #454035; max-width: 620px; }
.stamp {
  border: 1.5px solid var(--ink); border-radius: 12px; padding: 12px 16px;
  display: grid; gap: 4px; transform: rotate(-2deg); background: var(--panel);
  box-shadow: 5px 5px 0 rgba(22,21,15,.08); min-width: 170px;
}
.stamp-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; }
.stamp strong { font-size: 26px; letter-spacing: -.03em; line-height: 1; }
.stamp small { font-size: 11px; color: var(--muted); }

/* ── 작업대 ───────────────────────────────────────── */
.workspace {
  display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 18px; margin-top: clamp(22px, 3vw, 34px); align-items: start;
}
.names-pane, .draw-pane {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px;
}
.pane-head { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.pane-head h2 { font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.step {
  display: inline-grid; place-items: center; width: 22px; height: 22px;
  border-radius: 6px; background: var(--ink); color: var(--paper);
  font-size: 10px; font-weight: 700; letter-spacing: .02em;
}

textarea {
  width: 100%; min-height: 190px; resize: vertical;
  border: 1px solid var(--line); border-radius: 12px; background: #fffefb;
  padding: 12px 13px; font-family: var(--font); font-size: 15px; line-height: 1.75;
  color: var(--ink); word-break: keep-all;
}
textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(226,84,44,.15); }

.names-meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.count-chip {
  display: inline-flex; align-items: baseline; gap: 2px;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px;
  font-size: 12px; font-weight: 700; background: var(--paper);
}
.count-chip strong { font-size: 14px; }
.count-chip span { color: var(--muted); font-weight: 600; margin-left: 1px; }

.switch { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; font-weight: 600; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.hint { font-size: 12px; line-height: 1.55; color: var(--muted); margin-top: 6px; }
.note { margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--accent-ink); }

/* ── 탭 ───────────────────────────────────────────── */
.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 4px;
}
.tab {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; background: transparent; border-radius: 9px; padding: 9px 8px;
  font-size: 14px; font-weight: 700; color: var(--muted);
}
.tab[aria-selected="true"] { background: var(--ink); color: var(--panel); }
.tab:disabled { opacity: .55; cursor: default; }

/* ── 무대 ─────────────────────────────────────────── */
.stage {
  position: relative; margin-top: 12px; border: 1px solid var(--line); border-radius: 14px;
  background:
    radial-gradient(circle at 18% 12%, rgba(226,84,44,.07), transparent 46%),
    repeating-linear-gradient(45deg, #f7f3ea 0 12px, #f4efe4 12px 24px);
  min-height: 320px; overflow: hidden; display: flex;
}
.stage-view { display: block; flex: 1 1 auto; min-width: 0; }
.cards-view { display: flex; align-items: center; justify-content: center; padding: 10px; }
.deck {
  width: 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 7px; align-content: start; max-height: 300px; overflow: auto; padding: 4px;
}
.card { position: relative; aspect-ratio: 4 / 3; perspective: 640px; }
.card-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform .5s cubic-bezier(.3,.7,.2,1);
}
.card.flipped .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  border-radius: 9px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  padding: 5px; text-align: center; overflow: hidden;
}
.card-face.front {
  background: linear-gradient(155deg, #fffefb, #efe8da);
  border: 1px solid #d9d0bf; color: #46402f;
  font-size: 12px; font-weight: 600; line-height: 1.25;
}
.card-face.front span {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-face.back {
  transform: rotateY(180deg); background: var(--ink); color: var(--panel);
  flex-direction: column; gap: 1px; border: 1px solid var(--ink);
}
.card-face.back b { font-size: 19px; line-height: 1; color: #ffc9a8; font-weight: 800; }
.card-face.back span { font-size: 10.5px; font-weight: 600; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card[data-rank="1"] .card-face.back { background: var(--accent); border-color: var(--accent); }
.card[data-rank="1"] .card-face.back b { color: #fff4ea; }
.card.dimmed { opacity: .38; transition: opacity .4s .1s; }
.card.ghost { border: 1.5px dashed #ded6c6; border-radius: 9px; background: rgba(255,255,255,.45); }
.card.more {
  display: grid; place-items: center; border: 1.5px dashed #d9d0bf; border-radius: 9px;
  font-size: 13px; font-weight: 700; color: var(--muted); background: rgba(255,255,255,.6);
}

.wheel-view { display: flex; align-items: center; justify-content: center; padding: 16px 12px; }
.wheel-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; max-width: 100%; }
.wheel-wrap canvas { display: block; max-width: 100%; height: auto !important; filter: drop-shadow(0 8px 18px rgba(22,21,15,.16)); }
.pointer {
  position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; border-left: 11px solid transparent; border-right: 11px solid transparent;
  border-top: 18px solid var(--accent); z-index: 2;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.2));
}

.verdict {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin-top: 12px; padding: 12px 16px; border-radius: 13px;
  background: var(--ink); color: var(--panel);
}
.verdict-label { font-size: 11px; font-weight: 700; letter-spacing: .12em; color: #ffb994; }
.verdict-name { font-size: clamp(24px, 4vw, 44px); font-weight: 800; letter-spacing: -.04em; line-height: 1.1; }
.verdict.pop { animation: pop .34s cubic-bezier(.2,1.3,.4,1); }
@keyframes pop { from { transform: scale(.96); opacity: .5; } to { transform: scale(1); opacity: 1; } }

.caption { margin-top: 8px; font-size: 12.5px; color: var(--muted); min-height: 19px; }

/* ── 조작 ─────────────────────────────────────────── */
.controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: 14px; }
.modes { display: inline-flex; background: var(--paper); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 3px; }
.mode { border: 0; background: transparent; border-radius: 8px; padding: 8px 12px; font-size: 13.5px; font-weight: 700; color: var(--muted); }
.mode[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(22,21,15,.12); }
.mode:disabled { opacity: .55; cursor: default; }

.count-field { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.number-wrap {
  display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line);
  border-radius: 10px; background: #fffefb; padding: 4px 9px;
}
.number-wrap input {
  width: 54px; border: 0; background: transparent; font: inherit; font-weight: 800;
  font-size: 16px; text-align: right; padding: 3px 0; color: var(--ink);
}
.number-wrap input:focus { outline: none; }
.number-wrap span { font-size: 12px; font-weight: 600; color: var(--muted); }

.primary {
  border: 0; border-radius: 12px; padding: 12px 22px;
  background: var(--accent); color: #fff8f3; font-size: 15px; font-weight: 800; letter-spacing: -.01em;
  box-shadow: 0 3px 0 var(--accent-ink);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.primary:hover:not(:disabled) { background: #ef6039; }
.primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-ink); }
.primary:disabled { background: #cfc7b8; color: #7d776b; box-shadow: 0 3px 0 #b9b1a2; cursor: default; }

.status { margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--accent-ink); min-height: 19px; }
.status.error { color: #b3261e; }

/* ── 결과 ─────────────────────────────────────────── */
.results { margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--line); }
.result-list {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 4px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.result-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 8px;
  border-bottom: 1px solid rgba(221,213,198,.7); animation: slideIn .28s ease both;
}
.result-item .rank {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px;
  border-radius: 7px; background: var(--paper); border: 1px solid var(--line);
  font-size: 12px; font-weight: 800; color: var(--muted);
}
.result-item .name { font-size: 16px; font-weight: 700; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-item:nth-child(1) .rank { background: var(--accent); border-color: var(--accent); color: #fff6f0; }
@keyframes slideIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.secondary {
  border: 1px solid var(--ink); background: var(--panel); border-radius: 10px;
  padding: 9px 14px; font-size: 13.5px; font-weight: 700;
}
.secondary:hover { background: var(--ink); color: var(--panel); }
.text-button {
  border: 1px solid transparent; background: transparent; border-radius: 8px;
  padding: 7px 9px; font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: underline;
  text-underline-offset: 3px;
}
.text-button:hover { color: var(--ink); }
.text-button:disabled { opacity: .5; }

/* ── 안내 ─────────────────────────────────────────── */
.guide {
  margin-top: clamp(30px, 4vw, 48px); padding-top: clamp(20px, 3vw, 30px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: clamp(18px, 3vw, 36px);
}
.guide-head h2 { font-size: clamp(22px, 2.6vw, 30px); letter-spacing: -.04em; font-weight: 800; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.steps li { border-left: 2px solid var(--line); padding-left: 12px; }
.steps strong { display: block; font-size: 14.5px; font-weight: 800; margin-bottom: 3px; }
.steps p { font-size: 13px; color: #4c4739; line-height: 1.6; }
.faq { grid-column: 1 / -1; margin-top: 6px; display: grid; gap: 2px; }
.faq h3 { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
details { border-bottom: 1px solid var(--line); padding: 10px 2px; }
summary { cursor: pointer; font-size: 14.5px; font-weight: 700; }
details p { margin-top: 8px; font-size: 13.5px; color: #4c4739; line-height: 1.65; max-width: 760px; }

footer {
  display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center;
  margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
footer a { text-decoration: underline; text-underline-offset: 3px; }

/* ── 발표 화면 ────────────────────────────────────── */
.present {
  position: fixed; inset: 0; z-index: 100; background: #13120e; color: var(--paper);
  display: flex; justify-content: center; padding: clamp(16px, 4vw, 48px);
  overflow: auto;
}
.present-inner { width: min(1000px, 100%); margin: auto; display: flex; flex-direction: column; gap: 14px; }
.present-kicker { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: #ffb994; }
.present h2 { font-size: clamp(22px, 3vw, 34px); letter-spacing: -.04em; font-weight: 800; }
.present-list {
  list-style: none; margin: 0; padding: 0; display: grid; gap: clamp(6px, 1.4vh, 16px);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-content: start; overflow: auto;
}
.present-list li { display: flex; align-items: baseline; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.12); padding-bottom: 8px; }
.present-list .rank { font-size: clamp(14px, 1.6vw, 22px); font-weight: 800; color: var(--accent); min-width: 1.6em; }
.present-list .name { font-size: clamp(26px, 4.4vw, 56px); font-weight: 800; letter-spacing: -.04em; line-height: 1.1; }
.present-hint { font-size: 12px; color: rgba(242,239,231,.55); }
.present-close {
  align-self: flex-start; border: 1px solid rgba(242,239,231,.4); background: transparent;
  color: var(--paper); border-radius: 999px; padding: 9px 20px; font-size: 14px; font-weight: 700;
}
.present-close:hover { background: rgba(242,239,231,.12); }
body.is-presenting { overflow: hidden; }

.noscript { padding: 16px; font-size: 14px; }

/* ── 좁은 화면 ────────────────────────────────────── */
@media (max-width: 880px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .guide { grid-template-columns: minmax(0, 1fr); }
  .stamp { transform: none; }
}

@media (max-width: 560px) {
  .mast { padding: 12px 14px; gap: 10px; }
  .edition { display: none; }
  .wordmark { font-size: 20px; }
  main { padding: 16px 14px 48px; }
  .names-pane, .draw-pane { padding: 14px; }
  textarea { min-height: 140px; font-size: 14px; }
  .stage { min-height: 250px; }
  .deck { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); gap: 6px; max-height: 280px; }
  .stamp { align-self: flex-start; }
  .card-face.front { font-size: 11px; }
  .card-face.back b { font-size: 16px; }
  .controls { gap: 8px; }
  .modes { width: 100%; }
  .mode { flex: 1; }
  .count-field { flex: 1; }
  .primary { flex: 1 1 100%; padding: 13px 18px; }
  .result-list { grid-template-columns: minmax(0, 1fr); }
  .present-list { grid-template-columns: minmax(0, 1fr); }
  .present-list .name { font-size: clamp(24px, 8vw, 40px); }
}

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