/* 안개 너머 /world/ — 다크 기본, 390 폭 우선 */
:root {
  --w-bg: #0e1116;
  --w-surface: #161a21;
  --w-surface-2: #1d222b;
  --w-line: #2a313c;
  --w-text: #e6e8ec;
  --w-muted: #8d95a3;
  --w-accent: #8fb8c9;
  --w-accent-strong: #a9cfdf;
  --w-accent-ink: #0b1519;
  --w-danger: #e58a8a;
  --w-ok: #8ccf9f;
  --w-radius: 12px;
  --w-topbar-h: 52px;
  --w-fade: 220ms;
  --w-font: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --w-safe-t: env(safe-area-inset-top, 0px);
  --w-safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
.w-body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--w-bg);
  color: var(--w-text);
  font: 15px/1.6 var(--w-font);
  -webkit-font-smoothing: antialiased;
}
.w-body a { color: var(--w-accent); text-decoration: none; }
.w-body a:hover { color: var(--w-accent-strong); }
[hidden] { display: none !important; }

/* ---------- 공통 조각 ---------- */
.w-card {
  background: var(--w-surface);
  border: 1px solid var(--w-line);
  border-radius: var(--w-radius);
  padding: 22px 20px;
}
.w-eyebrow { margin: 0 0 6px; font-size: 12px; letter-spacing: .08em; color: var(--w-accent); }
.w-title { margin: 0 0 12px; font-size: 22px; line-height: 1.3; font-weight: 700; }
.w-text { margin: 0 0 18px; color: var(--w-muted); }

.w-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 0 18px;
  border: 1px solid var(--w-line); border-radius: 10px;
  background: var(--w-surface-2); color: var(--w-text);
  font: inherit; font-weight: 600; cursor: pointer;
  transition: background-color .15s, border-color .15s, opacity .15s;
}
.w-btn:hover { border-color: var(--w-muted); }
.w-btn:focus-visible, .w-iconbtn:focus-visible, .w-field input:focus-visible { outline: 2px solid var(--w-accent); outline-offset: 2px; }
.w-btn-primary { background: var(--w-accent); border-color: var(--w-accent); color: var(--w-accent-ink); }
.w-btn-primary:hover { background: var(--w-accent-strong); border-color: var(--w-accent-strong); }
.w-btn-block { width: 100%; }
.w-btn[disabled] { opacity: .45; cursor: not-allowed; }

.w-form { display: flex; flex-direction: column; gap: 14px; }
.w-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--w-muted); }
.w-field input {
  width: 100%; min-height: 46px; padding: 0 14px;
  background: var(--w-bg); color: var(--w-text);
  border: 1px solid var(--w-line); border-radius: 10px;
  font: inherit; font-size: 16px; /* iOS 확대 방지 */
}
.w-field input:focus { border-color: var(--w-accent); outline: none; }
.w-check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--w-muted); }
.w-check input { width: 18px; height: 18px; accent-color: var(--w-accent); }
.w-inline-msg { margin: 0; font-size: 13px; color: var(--w-danger); }
.w-inline-note { color: var(--w-muted); }

/* ---------- 로그인·가입 ---------- */
.w-auth {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: calc(24px + var(--w-safe-t)) 16px calc(24px + var(--w-safe-b));
}
.w-auth-card { width: 100%; max-width: 380px; }
.w-auth-sub { margin: 18px 0 0; font-size: 13px; color: var(--w-muted); text-align: center; }

/* ---------- B1: 가입·대기열·초대장 ---------- */
.w-field small { margin-left: 6px; color: var(--w-muted); opacity: .75; font-size: 12px; }
.w-auth-top { align-items: flex-start; }
.w-auth-fine { font-size: 12px; margin-top: 12px; }
.w-subtitle { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.w-sep { border: 0; border-top: 1px solid var(--w-line); margin: 22px 0; }
.w-text-sub { font-size: 13px; margin-top: -10px; }
.w-result { margin-top: 14px; padding: 14px; background: var(--w-bg); border: 1px solid var(--w-line); border-radius: 10px; }
.w-result .w-text { margin-bottom: 10px; color: var(--w-text); }
.w-result .w-text-sub { color: var(--w-muted); margin-top: 0; margin-bottom: 0; }
.w-btn-small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.w-invite-list { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.w-invite-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding: 10px 12px; background: var(--w-bg); border: 1px solid var(--w-line); border-radius: 10px; }
.w-invite-list .w-invite-row { margin-bottom: 0; }
.w-invite-code { flex: 1; min-width: 0; font: 600 16px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; word-break: break-all; user-select: all; }
.w-invite-row.is-used { opacity: .55; }
.w-invite-row.is-used .w-invite-code { text-decoration: line-through; color: var(--w-muted); user-select: none; }
.w-invite-who { font-size: 12px; color: var(--w-muted); white-space: nowrap; }
a.w-btn { text-decoration: none; }
.w-body a.w-btn-primary, .w-body a.w-btn-primary:hover { color: var(--w-accent-ink); }

/* ---------- 앱 셸 ---------- */
.w-app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.w-topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  min-height: calc(var(--w-topbar-h) + var(--w-safe-t));
  padding: var(--w-safe-t) 12px 0 16px;
  background: rgba(14, 17, 22, .92);
  border-bottom: 1px solid var(--w-line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.w-brand { font-weight: 700; color: var(--w-text) !important; letter-spacing: .02em; }
.w-charname { margin-left: auto; font-size: 13px; color: var(--w-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45vw; }
.w-iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 0; border-radius: 10px;
  background: transparent; color: var(--w-text); cursor: pointer;
}
.w-iconbtn:hover { background: var(--w-surface-2); }
.w-menu {
  position: absolute; right: 12px; top: calc(var(--w-topbar-h) + var(--w-safe-t) - 4px);
  min-width: 160px; padding: 6px;
  background: var(--w-surface); border: 1px solid var(--w-line); border-radius: var(--w-radius);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .45);
}
.w-menu a { display: block; padding: 11px 12px; border-radius: 8px; color: var(--w-text); }
.w-menu a:hover { background: var(--w-surface-2); color: var(--w-text); }

/* 패널은 같은 칸에 겹쳐 쌓는다: 새 패널이 올라오는 동안 이전 패널이 빈 화면을 만들지 않는다. */
.w-stage { flex: 1; display: grid; grid-template: 1fr / 1fr; width: 100%; max-width: 640px; margin: 0 auto; padding: 16px 16px calc(24px + var(--w-safe-b)); }
.w-panel {
  grid-area: 1 / 1; min-width: 0; align-self: start;
  opacity: 1; transform: none;
  transition: opacity var(--w-fade) ease, transform var(--w-fade) ease;
}
.w-panel.is-entering { opacity: 0; transform: translateY(8px); }
.w-panel.is-leaving { opacity: 0; transform: translateY(-4px); pointer-events: none; }
.w-empty { text-align: left; }

/* ---------- 로딩(0.3초 뒤에만 켜진다) ---------- */
.w-loading {
  position: fixed; left: 0; top: 0; right: 0; height: 2px; z-index: 50;
  background: linear-gradient(90deg, transparent, var(--w-accent), transparent);
  background-size: 40% 100%; background-repeat: no-repeat;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.w-loading.is-on { opacity: 1; animation: w-slide 1s linear infinite; }
@keyframes w-slide { from { background-position: -40% 0; } to { background-position: 140% 0; } }

/* ---------- 토스트 ---------- */
.w-toasts {
  position: fixed; left: 0; right: 0; bottom: calc(16px + var(--w-safe-b)); z-index: 60;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0 16px; pointer-events: none;
}
.w-toast {
  max-width: 420px; padding: 11px 16px;
  background: var(--w-surface-2); color: var(--w-text);
  border: 1px solid var(--w-line); border-radius: 10px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .45);
  font-size: 14px; pointer-events: auto;
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s;
}
.w-toast.is-on { opacity: 1; transform: none; }
.w-toast-error { border-color: var(--w-danger); }
.w-toast-ok { border-color: var(--w-ok); }

@media (min-width: 640px) {
  .w-stage { padding-top: 28px; }
  .w-card { padding: 28px 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .w-panel, .w-toast, .w-btn { transition: none; }
  .w-loading.is-on { animation: none; background: var(--w-accent); }
}
