/* 커피내기 공통 스타일 — 모든 페이지가 /assets/cb.css + /assets/icons.css 를 쓴다 */
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css");

:root {
  --bg: #fbf7f2;
  --surface: #ffffff;
  --surface-2: #f4ede4;
  --surface-3: #ebe1d5;
  --text: #2b1d14;
  --text-2: #6b5a4e;
  --text-3: #9c8b7e;
  --line: #e7dccf;
  --brand: #ff5a36;
  --brand-2: #ff8a3d;
  --brand-ink: #ffffff;
  --brand-soft: #ffe9e2;
  --coffee: #6f4e37;
  --ok: #12a46b;
  --warn: #f59e0b;
  --danger: #e5383b;
  --draw: #3b82f6;
  --bomb: #ef4444;
  --skill: #10b981;
  --tool: #8b5cf6;
  --shadow-1: 0 1px 2px rgba(43, 29, 20, .06), 0 2px 8px rgba(43, 29, 20, .05);
  --shadow-2: 0 8px 30px rgba(43, 29, 20, .14);
  --r: 16px;
  --r-sm: 10px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15110e; --surface: #201915; --surface-2: #2a211b; --surface-3: #352a22;
    --text: #f5ede4; --text-2: #bcab9c; --text-3: #8a7a6d; --line: #3a2f27;
    --brand-soft: #3a1d14; --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 10px 30px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15110e; --surface: #201915; --surface-2: #2a211b; --surface-3: #352a22;
  --text: #f5ede4; --text-2: #bcab9c; --text-3: #8a7a6d; --line: #3a2f27;
  --brand-soft: #3a1d14; --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 10px 30px rgba(0,0,0,.5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.02em; }
p { margin: 0; }
[hidden] { display: none !important; }

/* ── 아이콘 (Lucide SVG mask) ── */
.ic {
  display: inline-block; width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em;
  background: currentColor; -webkit-mask: var(--ic) center / contain no-repeat; mask: var(--ic) center / contain no-repeat;
}

/* ── 상단 바 ── */
.cb-top {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.cb-top .cb-title { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; min-width: 0; }
.cb-top .cb-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-top .cb-spacer { flex: 1; }
.cb-logo { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 900; font-size: 18px; letter-spacing: -0.03em; }
.cb-logo .cb-logo-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
}

/* ── 버튼 ── */
.cb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-weight: 650; cursor: pointer; text-decoration: none;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, opacity .15s; user-select: none; white-space: nowrap;
}
.cb-btn:hover { background: var(--surface-2); }
.cb-btn:active { transform: scale(.97); }
.cb-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.cb-btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.cb-btn.primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); }
.cb-btn.dark { background: var(--text); border-color: var(--text); color: var(--bg); }
.cb-btn.danger { color: var(--danger); }
.cb-btn.ghost { background: transparent; border-color: transparent; }
.cb-btn.ghost:hover { background: var(--surface-2); }
.cb-btn.icon { width: 40px; padding: 0; }
.cb-btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.cb-btn.sm.icon { width: 32px; padding: 0; }
.cb-btn.lg { min-height: 54px; padding: 0 22px; font-size: 17px; border-radius: 14px; font-weight: 750; }
.cb-btn.xl { min-height: 64px; padding: 0 28px; font-size: 20px; border-radius: 18px; font-weight: 800; }
.cb-btn.block { width: 100%; }
.cb-btn.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }

/* ── 레이아웃 ── */
.cb-main { max-width: 1040px; margin: 0 auto; padding: 16px 16px 48px; }
.cb-main.wide { max-width: 1400px; }
.cb-stack { display: flex; flex-direction: column; gap: 12px; }
.cb-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cb-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.cb-split { display: grid; gap: 16px; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); align-items: start; }
@media (max-width: 820px) { .cb-split { grid-template-columns: minmax(0, 1fr); } }
.cb-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow-1); }
.cb-card.flat { box-shadow: none; }
.cb-card.pad-lg { padding: 22px; }
.cb-label { font-size: 13px; font-weight: 700; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.cb-muted { color: var(--text-2); }
.cb-small { font-size: 13px; }
.cb-center { text-align: center; }
.cb-h1 { font-size: 26px; font-weight: 850; }
.cb-h2 { font-size: 19px; font-weight: 800; }
.cb-divider { height: 1px; background: var(--line); margin: 4px 0; border: 0; }

/* ── 입력 ── */
.cb-input, .cb-select, .cb-textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
.cb-textarea { min-height: 90px; resize: vertical; }
.cb-input:focus, .cb-select:focus, .cb-textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.cb-num { width: 84px; text-align: center; }

/* 세그먼트 (탭형 선택) */
.cb-seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface-2); border-radius: 12px; border: 1px solid var(--line); flex-wrap: wrap; }
.cb-seg button {
  border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; font-weight: 650; cursor: pointer; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 6px; font-size: 14px;
}
.cb-seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* 칩 */
.cb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cb-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 6px 5px 11px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); font-weight: 600; font-size: 14px; max-width: 100%;
}
.cb-chip.static { padding-right: 11px; }
.cb-chip button { border: 0; background: transparent; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; color: var(--text-3); padding: 0; }
.cb-chip button:hover { background: var(--surface-3); color: var(--text); }
.cb-chip.sel { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.cb-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.cb-chip .dot.off { background: var(--text-3); }
.cb-chip.pick { cursor: pointer; padding-right: 11px; }

/* 배지 */
.cb-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--text-2); }
.cb-badge.live { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }

/* 토글 스위치 */
.cb-switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.cb-switch input { appearance: none; width: 40px; height: 24px; border-radius: 999px; background: var(--surface-3); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.cb-switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.cb-switch input:checked { background: var(--brand); }
.cb-switch input:checked::after { transform: translateX(16px); }

/* ── 모달 ── */
.cb-backdrop {
  position: fixed; inset: 0; z-index: 1000; background: rgba(20, 12, 8, .55); display: grid; place-items: center;
  padding: 16px; animation: cb-fade .18s ease; backdrop-filter: blur(3px);
}
.cb-modal {
  width: min(480px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border-radius: 22px;
  box-shadow: var(--shadow-2); padding: 22px; animation: cb-pop .26s cubic-bezier(.2, 1.4, .4, 1);
}
.cb-modal.wide { width: min(640px, 100%); }
.cb-modal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.cb-modal-head h3 { font-size: 19px; font-weight: 800; flex: 1; }
.cb-modal-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.cb-modal-actions .cb-btn { flex: 1; }
@keyframes cb-fade { from { opacity: 0; } }
@keyframes cb-pop { from { opacity: 0; transform: scale(.9) translateY(10px); } }

/* 결과 모달 */
.cb-result { text-align: center; }
.cb-result .cb-result-icon { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 20px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-size: 30px; }
.cb-result .cb-result-head { font-size: 15px; font-weight: 700; color: var(--text-2); }
.cb-result .cb-result-names { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 10px 0 6px; }
.cb-result .cb-result-name { font-size: 30px; font-weight: 900; letter-spacing: -0.03em; padding: 4px 16px; border-radius: 14px; background: var(--brand); color: #fff; animation: cb-pop .4s cubic-bezier(.2, 1.6, .4, 1) both; }
.cb-result .cb-result-penalty { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 8px 14px; border-radius: 12px; background: var(--surface-2); font-weight: 750; font-size: 16px; }
.cb-result .cb-result-note { margin-top: 10px; color: var(--text-2); }
.cb-rank { list-style: none; padding: 0; margin: 14px 0 0; text-align: left; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.cb-rank li { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.cb-rank li:last-child { border-bottom: 0; }
.cb-rank li .n { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--surface-2); flex: none; }
.cb-rank li .nm { flex: 1; font-weight: 700; }
.cb-rank li .v { color: var(--text-2); font-variant-numeric: tabular-nums; }
.cb-rank li.hit { background: var(--brand-soft); }
.cb-rank li.hit .n { background: var(--brand); color: #fff; }

/* 토스트 */
.cb-toasts { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.cb-toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 650; box-shadow: var(--shadow-2); animation: cb-pop .25s ease; max-width: calc(100vw - 32px); display: flex; gap: 8px; align-items: center; }

/* 컨페티 캔버스 */
.cb-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 1500; }

/* ── 방 패널 ── */
.cb-room-code { font-size: 44px; font-weight: 900; letter-spacing: .18em; text-align: center; font-variant-numeric: tabular-nums; }
.cb-qr { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 14px; width: fit-content; margin: 0 auto; }
.cb-qr img, .cb-qr canvas { display: block; width: 180px; height: 180px; }
.cb-room-badge { gap: 6px; }
.cb-room-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.cb-room-badge .dot.off { background: var(--warn); box-shadow: none; }

/* 참가자 에디터 */
.cb-players .cb-players-add { display: flex; gap: 6px; }
.cb-players .cb-chips { min-height: 34px; }
.cb-players .cb-players-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* 빈 상태 */
.cb-empty { padding: 24px; text-align: center; color: var(--text-3); border: 1.5px dashed var(--line); border-radius: var(--r); }

/* 무대(게임 화면) */
.cb-stage { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow-1); }

/* 진행 표시 */
@keyframes cb-shake { 0%,100% { transform: translate(0,0) rotate(0); } 20% { transform: translate(-3px,2px) rotate(-2deg); } 40% { transform: translate(3px,-2px) rotate(2deg); } 60% { transform: translate(-2px,-1px) rotate(-1deg); } 80% { transform: translate(2px,1px) rotate(1deg); } }
@keyframes cb-pulse { 50% { transform: scale(1.06); } }
.cb-shake { animation: cb-shake .4s linear infinite; }
.cb-pulse { animation: cb-pulse 1s ease-in-out infinite; }

/* 하단 푸터 */
.cb-foot { max-width: 1040px; margin: 0 auto; padding: 20px 16px 36px; color: var(--text-3); font-size: 12px; text-align: center; }
.cb-foot a { color: var(--text-2); }

@media (max-width: 560px) {
  .cb-room-code { font-size: 36px; }
  .cb-result .cb-result-name { font-size: 26px; }
  .cb-modal { padding: 18px; border-radius: 20px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
