:root {
  --bg: #101318;
  --card: rgba(22, 26, 32, .84);
  --line: rgba(255, 255, 255, .09);
  --text: #f2efe9;
  --muted: #a9a49b;
  --accent: #f4a261;
  --stop: #e76f51;
  --green: #52b788;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: "Noto Sans KR", system-ui, -apple-system, sans-serif; overflow: hidden; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }

.topbar { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; pointer-events: none; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: -.2px; text-shadow: 0 1px 8px rgba(0,0,0,.6); }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
.online { background: var(--card); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; font-size: 13px; backdrop-filter: blur(8px); }
.online i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 6px; box-shadow: 0 0 8px var(--green); }

.hint { position: fixed; top: 66px; left: 50%; transform: translateX(-50%); font-size: 12px; color: var(--muted); background: var(--card); padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); pointer-events: none; transition: opacity .5s; white-space: nowrap; }

.hud { position: fixed; left: 16px; bottom: 16px; width: 330px; display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; backdrop-filter: blur(10px); }
.label { font-size: 12px; color: var(--muted); }
.timer { font-size: 42px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px; margin: 2px 0 4px; line-height: 1.1; }
.sub { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.sub b { color: var(--text); font-weight: 600; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.actions .primary, .actions .wide { grid-column: 1 / -1; }

button { font: inherit; font-size: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--text); padding: 10px 12px; border-radius: 10px; cursor: pointer; transition: background .15s; }
button:hover { background: rgba(255,255,255,.12); }
button:disabled { opacity: .6; cursor: default; }
button.primary { background: var(--accent); color: #1a1410; border-color: transparent; font-weight: 700; }
button.primary:hover { background: #f7b27c; }
button.primary.stop { background: var(--stop); color: #fff; }
button.primary.stop:hover { background: #ef8268; }

.ch-title { font-weight: 700; font-size: 16px; margin: 4px 0 6px; line-height: 1.35; }
.ch-note { font-size: 13px; color: var(--muted); margin-bottom: 8px; white-space: pre-wrap; line-height: 1.45; }
.count { color: var(--green); font-weight: 600; margin-left: 4px; }
.join { display: flex; gap: 8px; margin: 4px 0 10px; }
.join.hidden { display: none; }
.join input { flex: 1; min-width: 0; font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--text); letter-spacing: 2px; }
.join input:focus { outline: 2px solid var(--accent); }
.join .primary { padding: 10px 14px; white-space: nowrap; }
.npc { position: fixed; top: 100px; left: 50%; transform: translateX(-50%); width: min(380px, calc(100% - 32px)); background: #f6efe2; color: #2b2118; border-radius: 16px; padding: 14px 16px; box-shadow: 0 12px 36px rgba(0,0,0,.45); z-index: 6; }
.npc.hidden { display: none; }
.npc-head { font-weight: 700; font-size: 13px; color: #6b4f2a; margin-bottom: 4px; }
.npc p { margin: 0 0 10px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.npc button { background: #2d6a4f; color: #fff; border: none; padding: 8px 12px; font-size: 13px; }
.npc button:hover { background: #3a8a66; }
.bar { height: 8px; background: rgba(255,255,255,.08); border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.bar div { height: 100%; width: 0; background: linear-gradient(90deg, var(--green), #95d5b2); transition: width .4s; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 330px; background: var(--card); border-left: 1px solid var(--line); backdrop-filter: blur(12px); padding: 20px; overflow: auto; transition: transform .3s; }
.drawer.hidden { transform: translateX(105%); }
.drawer h2 { margin: 0 0 4px; font-size: 18px; }
.drawer .close { position: absolute; top: 14px; right: 14px; padding: 6px 10px; font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.rank-row .n { width: 22px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-row .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.rank-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .t { font-variant-numeric: tabular-nums; }
.rank-row.me { color: var(--accent); }

.modal { position: fixed; inset: 0; background: rgba(10, 12, 16, .72); display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px); z-index: 10; }
.modal.hidden { display: none; }
.modal .card { width: min(360px, calc(100% - 32px)); padding: 24px; }
.modal h1 { margin: 0 0 4px; font-size: 22px; }
.modal p { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.modal input { width: 100%; font: inherit; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--text); margin: 6px 0 14px; }
.modal input:focus { outline: 2px solid var(--accent); }
.swatches { display: flex; gap: 10px; margin: 8px 0 18px; }
.swatches span { width: 32px; height: 32px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: transform .15s; }
.swatches span.on { border-color: #fff; transform: scale(1.1); }
.modal .primary { width: 100%; padding: 12px; }

.toast { position: fixed; left: 50%; top: 110px; transform: translateX(-50%) translateY(-10px); background: #f2efe9; color: #1a1410; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; transition: .3s; pointer-events: none; z-index: 20; white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 640px) {
  .hud { left: 10px; right: 10px; bottom: 10px; width: auto; }
  .timer { font-size: 32px; }
  .drawer { width: 100%; }
  .hint { top: 62px; font-size: 11px; }
  .card { padding: 12px 14px; }
}
