/* ───────── 미니게임 공통 스타일 ─────────
 * 허브(/game)와 모든 게임 화면이 함께 쓴다. 게임 전용 스타일은 각 게임 폴더에 둔다.
 * 종이 위에 인쇄한 투표용지/점수판 같은 톤.
 * 그라데이션·그림자·발광 효과 없이 잉크색, 얇은 선, 두 가지 안료색(A/B)만 쓴다.
 */
:root {
  --paper:    #F5F2EA;
  --paper-2:  #ECE7DB;
  --surface:  #FFFDF8;
  --ink:      #1D1C1A;
  --ink-2:    #55514A;
  --ink-3:    #8E897F;
  --rule:     #D8D2C4;

  --a:        #B4472E;  /* 선택지 A — 벽돌색 */
  --a-tint:   #F3E4DC;
  --a-ink:    #7A2E1D;
  --b:        #2D5285;  /* 선택지 B — 짙은 청색 */
  --b-tint:   #E0E6EF;
  --b-ink:    #1E3A60;
  --live:     #2E6A46;  /* 생존 */

  --radius:   8px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  word-break: keep-all;
}

button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wordmark {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}

/* 미니게임 / 게임 이름 경로 */
.crumbs { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.crumb-sep { color: var(--ink-3); }
.crumb { font-size: 18px; font-weight: 700; color: var(--ink-2); text-decoration: none; }
.wordmark:hover, .crumb:hover { text-decoration: underline; text-underline-offset: 4px; }

.back-link {
  display: inline-block;
  margin-bottom: 20px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
}
.back-link:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

.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;
}

/* ───────── 공통 ───────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s ease, color .12s ease;
}
.btn:hover { background: var(--paper-2); }
.btn:disabled { opacity: .35; cursor: not-allowed; background: transparent; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: #3A3834; }
.btn-primary:disabled { background: var(--ink); }
.btn-quiet { border-color: var(--rule); color: var(--ink-2); }
.btn-block { width: 100%; }
.btn-lg { min-height: 58px; font-size: 18px; padding: 0 32px; }

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--ink-3);
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:hover { color: var(--a); }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.input {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
  outline: none;
}
.input:focus { border-color: var(--ink); }
.input::placeholder { color: var(--ink-3); font-weight: 400; }
.input-code { font-size: 26px; letter-spacing: .3em; font-variant-numeric: tabular-nums; }

.error-text { color: var(--a); font-size: 14px; font-weight: 600; min-height: 20px; margin: 0; }
.muted { color: var(--ink-3); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  z-index: 100;
}
.toast.show { opacity: 1; }

.eyebrow {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ───────── 랜딩 (/game) ───────── */
.landing {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 16px 64px;
}
.landing h1 {
  margin: 0 0 12px;
  font-size: clamp(34px, 6vw, 52px);
  letter-spacing: -0.04em;
  line-height: 1.15;
}
.landing .lead { margin: 0 0 40px; color: var(--ink-2); font-size: 17px; line-height: 1.65; }
.landing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}
.landing-col { padding: 24px 0 28px; display: flex; flex-direction: column; gap: 14px; }
.landing-col + .landing-col { padding-left: 28px; margin-left: 28px; border-left: 1px solid var(--rule); }
.landing-col h2 { margin: 0; font-size: 20px; }
.landing-col p { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.6; }
.landing-col .grow { flex: 1; }
.rules { margin-top: 36px; }
.rules h3 { margin: 0 0 10px; font-size: 16px; }
.rules ol { margin: 0; padding-left: 20px; color: var(--ink-2); line-height: 1.85; font-size: 15px; }
.rules b { color: var(--ink); }

/* ───────── 허브 (/game) ───────── */
.hub {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 16px 64px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}
.hub-head h1 {
  margin: 0 0 12px;
  font-size: clamp(34px, 6vw, 52px);
  letter-spacing: -0.04em;
  line-height: 1.15;
}
.hub-head .lead { margin: 0; color: var(--ink-2); font-size: 17px; line-height: 1.65; }

.hub-join {
  padding: 22px 0 24px;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}
.hub-join h2 { margin: 0 0 14px; font-size: 18px; }
.hub-join-form { display: flex; gap: 10px; }
.hub-join-form .input { max-width: 220px; }
.hub-join-hint { margin: 12px 0 0; font-size: 14px; line-height: 1.6; }

.hub-section-head { padding-bottom: 12px; border-bottom: 2px solid var(--ink); }
.hub-section-head h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.02em; }
.hub-section-head p { margin: 0; font-size: 15px; line-height: 1.6; }

.game-list { list-style: none; margin: 0; padding: 0; }
.game-item {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 16px;
  row-gap: 4px;
  padding: 18px 4px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  text-decoration: none;
}
.game-item:hover { background: var(--paper-2); }
.game-name { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.game-tagline { grid-column: 1; color: var(--ink-2); font-size: 15px; line-height: 1.6; }
.game-meta { grid-column: 1; color: var(--ink-3); font-size: 14px; font-weight: 600; }
.game-arrow { grid-column: 2; grid-row: 1 / span 3; align-self: center; font-size: 22px; color: var(--ink-2); }

@media (max-width: 640px) {
  .hub { padding-top: 32px; gap: 32px; }
  .hub-join-form .input { max-width: none; flex: 1; }
  .landing { padding-top: 32px; }
  .landing-grid { grid-template-columns: 1fr; }
  .landing-col + .landing-col { padding-left: 0; margin-left: 0; border-left: 0; border-top: 1px solid var(--rule); }
  .landing-col.pc-only { order: 2; }
}

/* ───────── 진행자 화면 (/game/host) ───────── */
.host {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px clamp(16px, 3vw, 48px) 20px;
}
.host-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--ink);
}
.host-header .meta {
  display: flex;
  gap: 20px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.host-header .meta b { color: var(--ink); }
.host-main { flex: 1; display: flex; flex-direction: column; padding-top: 28px; }
.host-footer {
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--ink-3);
}
.stage { flex: 1; display: flex; flex-direction: column; gap: 28px; }

/* 대기실 */
.lobby {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  flex: 1;
}
.join-panel { padding-right: 40px; border-right: 1px solid var(--rule); display: flex; flex-direction: column; gap: 18px; }
.join-panel h2, .players-panel h2 { margin: 0; font-size: 18px; }
.qr-box {
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1;
  padding: 14px;
  background: #FFFFFF;
  border: 1px solid var(--rule);
}
.qr-box svg { width: 100%; height: 100%; display: block; }
.join-steps { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 15px; line-height: 1.75; }
.join-steps b { color: var(--ink); }
.code-block .eyebrow { margin-bottom: 4px; }
.big-code {
  margin: 0;
  font-size: clamp(64px, 7vw, 96px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: .06em;
  font-variant-numeric: tabular-nums;
}

.players-panel { padding-left: 40px; display: flex; flex-direction: column; gap: 18px; min-height: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.panel-head .count { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.name-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  column-gap: 32px;
  border-top: 1px solid var(--rule);
}
.name-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 12px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 18px;
  font-weight: 600;
}
.name-list .link-btn { opacity: 0; }
.name-list li:hover .link-btn, .name-list .link-btn:focus-visible { opacity: 1; }
@media (hover: none) { .name-list .link-btn { opacity: 1; } }
.empty-hint { color: var(--ink-3); font-size: 16px; line-height: 1.7; margin: 0; }
.lobby-actions { margin-top: auto; display: flex; justify-content: flex-end; align-items: center; gap: 16px; }

.notice-screen { margin: 40px auto; max-width: 440px; display: flex; flex-direction: column; gap: 14px; }
.notice-screen h2 { margin: 0; font-size: 24px; }
.notice-screen p { margin: 0; color: var(--ink-2); line-height: 1.6; }
.notice-screen .btn { align-self: flex-start; }

@media (max-width: 900px) {
  .lobby { grid-template-columns: 1fr; gap: 28px; }
  .join-panel { padding-right: 0; border-right: 0; }
  .players-panel { padding-left: 0; }
}

/* ───────── 참가자 화면 (/game/play) ───────── */
.play {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
.play-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ink);
}
.play-header .wordmark { font-size: 16px; }
.me { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.me .state-live { color: var(--live); }
.me .state-out { color: var(--ink-3); }
.play-main { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px 0; }

.screen { display: flex; flex-direction: column; gap: 18px; }
.screen-title { margin: 0; font-size: 30px; letter-spacing: -0.035em; line-height: 1.3; }
.screen-desc { margin: 0; color: var(--ink-2); font-size: 16px; line-height: 1.6; }
.join-form { display: flex; flex-direction: column; gap: 16px; padding-top: 8px; }
.center { text-align: center; }
.note {
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  text-align: center;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.6;
}
.note b { color: var(--ink); }

/* 진행 화면 아래쪽 버튼 줄 */
.actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

/* ───────── 순위표 (shared/scoreboard.js) ───────── */
.sb-title { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--ink-3); }
.sb-list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.sb-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: 14px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--rule);
  font-variant-numeric: tabular-nums;
  transition: transform .7s cubic-bezier(.2, .9, .3, 1.15);
}
.sb-rank { font-size: 15px; font-weight: 800; color: var(--ink-3); }
.sb-first .sb-rank { color: var(--ink); }
.sb-name { position: relative; justify-self: start; padding-right: 4px; font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.sb-name .stamp { left: 100%; top: -10px; margin-left: 6px; font-size: 15px; }
.sb-cell { font-size: 17px; font-weight: 800; text-align: right; white-space: nowrap; }
.sb-cell small { margin-left: 2px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.sb-me { background: var(--paper-2); }
.sb-up .sb-rank { color: var(--live); }
.sb-down .sb-rank { color: var(--a); }

/* ───────── 시상식 (shared/awards.js) ───────── */
.awards-title { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--ink-3); }
.award-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.award {
  padding: 14px 16px 16px;
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: opacity .35s ease, transform .35s ease;
}
.award-hidden { opacity: 0; transform: translateY(12px) rotate(-1.5deg); }
.award-name { margin: 0; font-size: 14px; font-weight: 700; color: var(--ink-3); }
.award-winners { position: relative; margin: 4px 0 6px; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.award-winners .stamp { right: -4px; top: -16px; font-size: 16px; }
.award-desc { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink-2); }

/* ───────── 진행자 설정 (대기실) ───────── */
.lobby-settings { border-top: 1px solid var(--rule); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.lobby-settings h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink-3); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.setting-label { font-size: 16px; font-weight: 600; }
.setting .input { min-height: 40px; width: auto; font-size: 15px; }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper .btn { min-height: 36px; width: 36px; padding: 0; font-size: 18px; }
.stepper output { min-width: 2.5em; text-align: center; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ───────── 웃음 장치 (shared/fx.js) ───────── */
.sound-toggle {
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: transparent;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}
.sound-toggle[aria-pressed="false"] { color: var(--ink-3); text-decoration: line-through; }

/* 3·2·1 */
.countdown {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  z-index: 50;
  font-size: min(36vw, 280px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.countdown > span { animation: count-pop .7s ease-out; }
.countdown .countdown-wait { font-size: 40px; font-weight: 700; color: var(--ink-2); animation: none; }
@keyframes count-pop { from { transform: scale(1.25); opacity: .2; } to { transform: scale(1); opacity: 1; } }

/* 도장: 비스듬히 쾅 */
.has-stamp { position: relative; }
.stamp {
  position: absolute;
  z-index: 2;
  padding: 0.08em 0.4em;
  border: 0.12em solid currentColor;
  border-radius: 0.18em;
  font-weight: 900;
  font-size: 32px;
  line-height: 1.2;
  letter-spacing: 0.04em;
  white-space: nowrap;
  background: rgba(255, 253, 248, 0.6);
  transform: rotate(-12deg);
  pointer-events: none;
  animation: stamp-in .32s cubic-bezier(.2, 1.6, .4, 1) both;
}
.stamp.still { animation: none; }
.stamp-out { color: var(--a); }
.stamp-live { color: var(--live); }
.stamp-ink { color: var(--ink); }
@keyframes stamp-in {
  0% { transform: rotate(-12deg) scale(2.4); opacity: 0; }
  60% { transform: rotate(-12deg) scale(0.92); opacity: 1; }
  100% { transform: rotate(-12deg) scale(1); opacity: 1; }
}
.thud { animation: thud .25s ease-out; }
@keyframes thud {
  0%, 100% { transform: translate(0, 0); }
  30% { transform: translate(2px, 3px); }
  60% { transform: translate(-2px, -1px); }
}

/* 호외 헤드라인: 신문처럼 위아래 줄, 왼쪽부터 펼쳐짐 */
.headline {
  margin: 0;
  padding: 10px 4px 12px;
  border-top: 4px double var(--ink);
  border-bottom: 1px solid var(--ink);
  text-align: center;
  font-size: clamp(22px, 2.6vw, 34px);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.3;
}
.headline span { display: inline-block; animation: headline-in .6s ease-out both; }
@keyframes headline-in {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}
.play .headline { font-size: 20px; }

/* 이름표 떨어지기: 차례로 툭 떨어져 비뚤게 남는다 */
.falling { display: inline-block; animation: fall .7s cubic-bezier(.5, 0, .7, 1.4) var(--d, 0ms) both; }
@keyframes fall {
  0% { transform: translateY(-14px) rotate(0); opacity: 1; }
  70% { transform: translateY(12px) rotate(var(--r, 10deg)); }
  100% { transform: translateY(8px) rotate(var(--r, 10deg)); opacity: 1; }
}

/* 휴대폰 결과 도장 자리 */
.verdict-stamp { position: relative; height: 96px; display: flex; align-items: center; justify-content: center; }
.verdict-stamp .stamp { position: static; display: inline-block; font-size: 52px; }

@media (prefers-reduced-motion: reduce) {
  .stamp, .headline span, .falling, .thud, .countdown > span { animation: none !important; }
  .falling { transform: rotate(var(--r, 10deg)); }
}

