@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css");

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --line: #e7e9ee;
  --line-strong: #d5d9e1;
  --ink: #101218;
  --ink-2: #474d5c;
  --muted: #8b91a0;
  --accent: #5b5bf0;
  --accent-hover: #4a4ae0;
  --accent-soft: #eeeffe;
  --accent-ink: #4040c8;
  --amber-soft: #fff3e0;
  --amber-ink: #b25b00;
  --yes: #0f9d58;
  --yes-soft: #e6f6ed;
  --no: #e5484d;
  --no-soft: #fdecec;
  --unk-soft: #f0f1f4;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 30px rgba(16, 24, 40, .06);
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  word-break: keep-all;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent); outline-offset: 2px; }
[hidden] { display: none !important; }
a { color: var(--accent-ink); text-underline-offset: 3px; }
svg { flex: none; }

/* ── 상단 바 ── */
.bar { max-width: 720px; margin: 0 auto; padding: 18px 20px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -0.02em; }
.mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #6d6df7, #4a4ae0);
  color: #fff; font-size: 13px; letter-spacing: 0; font-weight: 800;
  box-shadow: 0 4px 12px rgba(91, 91, 240, .3);
}
.bar-right { display: flex; align-items: center; gap: 8px; }

.queue {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.conn { display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 999px; background: var(--no-soft); color: var(--no); font-size: 13px; font-weight: 700; }
.queue .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.queue.has { color: var(--accent-ink); background: var(--accent-soft); border-color: transparent; }
.queue.has .dot { background: var(--accent); box-shadow: 0 0 0 0 rgba(91, 91, 240, .5); animation: ping 1.6s ease-out infinite; }
.queue.hot { animation: bump .5s ease-out; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  cursor: pointer; transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ── 카드 ── */
.wrap { max-width: 720px; margin: 0 auto; padding: 16px 20px 40px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: 28px; }
@media (max-width: 520px) {
  .bar { padding: 14px 14px 0; }
  .wrap { padding: 12px 12px 32px; }
  .card { padding: 20px 16px; border-radius: 20px; }
}

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 12px;
  border: 1px solid transparent; background: none;
  font-size: 15px; font-weight: 600; white-space: nowrap;
  cursor: pointer; transition: background-color .15s, border-color .15s, color .15s, transform .08s, box-shadow .15s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 4px 12px rgba(91, 91, 240, .25); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); box-shadow: var(--shadow-sm); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { color: var(--muted); height: 34px; padding: 0 10px; font-size: 13px; font-weight: 500; }
.btn-ghost:hover:not(:disabled) { color: var(--ink); background: var(--surface-2); }
.btn-lg { height: 52px; padding: 0 28px; font-size: 16px; border-radius: 14px; }
.btn-block { width: 100%; }

/* ── 입력 ── */
.field { display: block; margin: 0 0 16px; }
.label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
.label .count { font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.input {
  width: 100%; height: 48px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--surface); font-size: 16px;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: #a8adba; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b91a0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.help { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.error { color: var(--no); font-size: 14px; font-weight: 500; margin: 12px 0 0; }

/* 스위치 */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; cursor: pointer; font-weight: 500; }
.switch input { appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--line-strong); position: relative; cursor: pointer; transition: background-color .2s; margin: 0; flex: none; }
.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, .2); transition: transform .2s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }

/* ── 히어로 (대기 · 결과) ── */
.hero { text-align: center; padding: 20px 0 8px; }
.orb {
  width: 96px; height: 96px; margin: 0 auto 20px;
  border-radius: 28px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 44px; font-weight: 800; line-height: 1;
}
.orb.thinking { animation: breathe 1.3s ease-in-out infinite; }
.orb.reveal { width: 132px; height: 132px; border-radius: 40px; font-family: var(--emoji); font-size: 76px; font-weight: 400; animation: pop .55s cubic-bezier(.2, .9, .3, 1.25); }
.hero.win .orb { background: var(--yes-soft); }
.hero.lose .orb { background: var(--no-soft); }
.hero.skip .orb { background: var(--unk-soft); color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 700; margin: 0 0 10px; }
.badge.win { background: var(--yes-soft); color: var(--yes); }
.badge.lose { background: var(--no-soft); color: var(--no); }
.badge.skip { background: var(--unk-soft); color: var(--ink-2); }
.title { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.25; overflow-wrap: anywhere; }
.hero.win .title, .hero.lose .title { font-size: clamp(30px, 8vw, 40px); animation: rise .4s ease-out .15s both; }
.sub { margin: 8px auto 0; max-width: 420px; color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.stat { display: inline-flex; gap: 6px; height: 32px; align-items: center; padding: 0 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.stat b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.share { display: flex; align-items: center; gap: 8px; max-width: 460px; margin: 22px auto 0; padding: 6px 6px 6px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.share-url { flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 24px; }

/* ── 게임 머리 ── */
.game-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-weight: 800; font-size: 16px; flex: none; }
.who-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.who-name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 14px; }
.progress { display: flex; align-items: center; gap: 12px; margin: 20px 0 8px; }
.segs { flex: 1; display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.seg { height: 8px; border-radius: 999px; background: var(--line); transition: background-color .3s; }
.seg.used { background: var(--accent); }
.seg.guess { background: #f5a524; }
.seg.next { background: color-mix(in srgb, var(--accent) 30%, var(--line)); animation: blink 1.2s ease-in-out infinite; }
.progress-label { font-size: 13px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }

/* ── 로그 ── */
.log { list-style: none; margin: 12px 0 0; padding: 0; max-height: min(46vh, 460px); overflow-y: auto; overscroll-behavior: contain; }
.log:empty { display: none; }
.log, dialog { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.row { display: grid; grid-template-columns: 26px auto minmax(0, 1fr) auto; column-gap: 12px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row.new { animation: rise .25s ease-out; }
.row .num { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.tag { font-family: var(--mono); font-size: 11.5px; font-weight: 600; padding: 3px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-ink); letter-spacing: 0; }
.tag.guess { background: var(--amber-soft); color: var(--amber-ink); }
.row .txt { font-weight: 500; overflow-wrap: anywhere; }
.ans { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.ans.yes { background: var(--yes-soft); color: var(--yes); }
.ans.no { background: var(--no-soft); color: var(--no); }
.ans.unk { background: var(--unk-soft); color: var(--ink-2); }
.ans.wait { background: var(--unk-soft); gap: 4px; padding: 0 12px; }
.ans.wait i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: bounce 1s ease-in-out infinite; }
.ans.wait i:nth-child(2) { animation-delay: .15s; }
.ans.wait i:nth-child(3) { animation-delay: .3s; }

/* ── 입력창 ── */
.composer { display: flex; gap: 8px; margin-top: 16px; padding: 6px; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent); }
.composer input { flex: 1; min-width: 0; border: 0; background: none; padding: 0 10px; font-size: 16px; height: 44px; }
.composer input:focus { outline: none; }
.composer input::placeholder { color: #a8adba; }
.composer .btns { display: flex; gap: 6px; }
@media (max-width: 520px) {
  .composer { flex-wrap: wrap; }
  .composer input { flex-basis: 100%; }
  .composer .btns { flex: 1; }
  .composer .btns .btn { flex: 1; }
}
.game-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--muted); }
.hint kbd { font-family: var(--font); font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink-2); }
@media (hover: none) { .hint { display: none; } }

/* ── 토스트 ── */
.toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: 14px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 12px 32px rgba(16, 24, 40, .22);
  animation: toast .3s cubic-bezier(.2, .9, .3, 1.2);
  z-index: 50;
}
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #7dffb0; }

/* ── 설정 대화상자 ── */
dialog { border: 0; border-radius: 22px; background: var(--surface); color: var(--ink); padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 24px 64px rgba(16, 24, 40, .25); }
dialog::backdrop { background: rgba(16, 18, 24, .4); backdrop-filter: blur(3px); }
.dlg { padding: 24px; }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.dlg-head h2 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.dlg-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.group { background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.group-title { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em; margin: 0 0 12px; }
.group .field:last-child { margin-bottom: 0; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline .input { flex: 1; min-width: 0; }
.mono { font-family: var(--mono); font-size: 13px; letter-spacing: 0; }
.note { background: var(--amber-soft); color: var(--amber-ink); border-radius: 12px; padding: 10px 14px; font-size: 13px; margin: 0 0 12px; }
.ok { color: var(--yes); font-size: 13px; font-weight: 600; }
.divider { height: 1px; background: var(--line); margin: 6px 0; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.5); opacity: 0; } 70% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); } }
@keyframes breathe { 50% { transform: scale(.92); opacity: .7; } }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-3px); opacity: 1; } }
@keyframes blink { 50% { opacity: .45; } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(91, 91, 240, .45); } 100% { box-shadow: 0 0 0 8px rgba(91, 91, 240, 0); } }
@keyframes bump { 30% { transform: scale(1.1); } }
@keyframes toast { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
