/* 겨울서버 관리 페이지. 외부 폰트 안씀 (CSP 때매 self 만 허용) */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --line: #e3e8ec;
  --text: #1c2630;
  --muted: #677684;
  --brand: #2f6f5e;
  --brand-ink: #ffffff;
  --brand-soft: #e4f0ec;
  --accent: #c2413a;
  --accent-soft: #fbe9e7;
  --ok: #2f8a57;
  --ok-soft: #e3f4ea;
  --warn: #b7791f;
  --warn-soft: #fbf1df;
  --ring: rgba(47, 111, 94, .28);
  --shadow: 0 1px 2px rgba(20, 32, 44, .05), 0 4px 16px rgba(20, 32, 44, .06);
  --radius: 12px;
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418;
    --surface: #161d22;
    --surface-2: #1b242a;
    --line: #26323a;
    --text: #e6edf1;
    --muted: #8b9aa6;
    --brand: #5fb39b;
    --brand-ink: #0c1512;
    --brand-soft: #18302a;
    --accent: #ef7b72;
    --accent-soft: #3a1f1d;
    --ok: #5cc48a;
    --ok-soft: #173023;
    --warn: #e2a84b;
    --warn-soft: #33281a;
    --ring: rgba(95, 179, 155, .35);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 17px; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; }
.right { text-align: right; }
svg { width: 16px; height: 16px; fill: currentColor; flex: none; }

/* ---------- 버튼 / 입력 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand); filter: brightness(1.07); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-danger { color: var(--accent); }
.btn-danger:hover { background: var(--accent-soft); border-color: transparent; }
.btn-danger-solid { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger-solid:hover { background: var(--accent); filter: brightness(1.07); }
.danger-text { color: var(--accent); }

input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--text); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--brand); }
input::placeholder { color: var(--muted); opacity: .8; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; }
.field small { color: var(--muted); font-size: 12px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }

.notice {
  padding: 10px 12px; border-radius: 9px;
  background: var(--warn-soft); color: var(--warn); font-size: 13px; font-weight: 600;
}

/* ---------- 브랜드 ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16 7v18M8.2 11.5l15.6 9M8.2 20.5l15.6-9M16 7l-2.5 2.5M16 7l2.5 2.5M16 25l-2.5-2.5M16 25l2.5-2.5' stroke='%23fff' stroke-width='2' stroke-linecap='round' fill='none'/%3E%3C/svg%3E") center/22px no-repeat,
    linear-gradient(135deg, #2f6f5e, #1f4f63);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.brand-title { font-weight: 750; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.brand-lg .brand-mark { width: 44px; height: 44px; border-radius: 13px; background-size: 28px, auto; }
.brand-lg .brand-title { font-size: 18px; }

/* ---------- 테섭/라이브 표시 ---------- */
.env-badge {
  display: inline-flex; align-items: center; margin-top: 4px;
  height: 20px; padding: 0 8px; border-radius: 999px;
  font-size: 11px; font-weight: 750; letter-spacing: .03em; white-space: nowrap;
}
.env-test { background: var(--brand-soft); color: var(--brand); }
.env-live { background: var(--accent); color: #fff; }
/* 라이브면 화면 맨위에 빨간줄 */
[data-stage="live"] body { box-shadow: inset 0 3px 0 var(--accent); }
[data-stage="live"] .side { border-top: 3px solid var(--accent); }
.stage-switch { font-size: 12.5px; color: var(--muted); text-decoration: none; font-weight: 600; }
.stage-switch:hover { color: var(--text); text-decoration: underline; }

/* ---------- 로그인 화면 ---------- */
.auth {
  position: relative; min-height: 100%;
  display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(47,111,94,.22), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(194,65,58,.14), transparent 60%),
    var(--bg);
  overflow: hidden;
}
.auth-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 380px;
  padding: 28px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: grid; gap: 24px;
}
/* 눈 내리는거. 그냥 css 로만 */
.snow, .snow::before, .snow::after {
  position: absolute; inset: -100% 0 0 0; pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 20px 30px, rgba(255,255,255,.9), transparent 60%),
    radial-gradient(2px 2px at 140px 80px, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(3px 3px at 260px 160px, rgba(255,255,255,.8), transparent 60%),
    radial-gradient(2px 2px at 80px 220px, rgba(255,255,255,.6), transparent 60%),
    radial-gradient(3px 3px at 200px 280px, rgba(255,255,255,.7), transparent 60%);
  background-size: 300px 300px;
  animation: snow 18s linear infinite;
}
.snow::before { content: ""; background-size: 220px 220px; animation-duration: 26s; opacity: .7; }
.snow::after { content: ""; background-size: 380px 380px; animation-duration: 34s; opacity: .5; }
@media (prefers-color-scheme: light) {
  .snow, .snow::before, .snow::after { filter: drop-shadow(0 0 1px rgba(47,111,94,.5)); }
}
@keyframes snow { to { transform: translateY(50%); } }
@media (prefers-reduced-motion: reduce) { .snow, .snow::before, .snow::after { animation: none; } }

/* ---------- 레이아웃 ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100%; }
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 24px;
  padding: 20px 14px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.side .brand { padding: 0 6px; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-weight: 600;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.side-foot {
  margin-top: auto; padding: 12px 6px 0; border-top: 1px solid var(--line);
  display: grid; gap: 10px;
}
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who-text { display: grid; min-width: 0; }
.who-text b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-text span { font-size: 12px; color: var(--muted); }

.main { padding: 32px 36px 64px; max-width: 1180px; width: 100%; }
.main > section { display: grid; gap: 20px; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }

/* ---------- 카드 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; display: grid; gap: 16px; align-content: start;
}
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; display: grid; gap: 2px;
}
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--muted); min-height: 1.4em; }
.stat-value.good { color: var(--ok); }
.stat-value.bad { color: var(--accent); }
.stat-value.mid { color: var(--warn); }

/* ---------- 테이블 ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 650; color: var(--muted);
  padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .actions { display: flex; gap: 4px; justify-content: flex-end; }
.member { display: flex; align-items: center; gap: 10px; }
.member b { font-weight: 650; }

.avatar {
  width: 28px; height: 28px; border-radius: 7px; flex: none;
  background: var(--surface-2); image-rendering: pixelated;
  box-shadow: inset 0 0 0 1px var(--line);
}
.avatar-lg { width: 48px; height: 48px; border-radius: 10px; }
.avatar-ph {
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--muted);
}

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 650; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-brand::before { display: none; }
.chip {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px;
  padding: 2px 7px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line);
}

/* ---------- 플레이어 ---------- */
.players { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.players li {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
}
.players li span { font-weight: 600; }
.players li small { margin-left: auto; color: var(--muted); font-size: 11.5px; }
.empty {
  display: grid; justify-items: center; gap: 8px; padding: 28px 0;
  color: var(--muted); font-size: 13px;
}
.empty svg { width: 28px; height: 28px; opacity: .5; }

.mc-current { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 10px; background: var(--surface-2); }
.mc-name { font-weight: 700; font-size: 16px; }

/* ---------- 더보기 메뉴 ---------- */
.btn-icon { width: 30px; padding: 0; }
.menu {
  position: absolute; z-index: 40; min-width: 160px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.14); display: grid; animation: pop .12s ease-out;
}
.menu-item {
  text-align: left; padding: 8px 10px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger-text { color: var(--accent); }

/* ---------- 모달 / 토스트 ---------- */
.modal {
  width: min(420px, calc(100% - 32px)); padding: 24px;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal::backdrop { background: rgba(10, 16, 22, .45); backdrop-filter: blur(2px); }
.modal[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; }
.toast {
  min-width: 220px; max-width: 360px; padding: 11px 14px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 13.5px;
  box-shadow: var(--shadow); animation: toast .2s ease-out;
}
.toast.err { background: var(--accent); color: #fff; }
@keyframes toast { from { opacity: 0; transform: translateY(8px); } }

/* ---------- 모바일 ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side {
    position: sticky; top: 0; z-index: 10; height: auto;
    flex-direction: row; align-items: center; gap: 12px; padding: 10px 16px;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .side .brand > div, .who-text, #whoAvatar, .stage-switch { display: none; }
  .side .brand { padding: 0; flex: none; }
  .side-foot .btn { white-space: nowrap; }
  .nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
  .nav a { padding: 7px 10px; font-size: 13px; white-space: nowrap; }
  .nav a svg { display: none; }
  .side-foot { margin: 0; padding: 0; border: 0; flex: none; }
  .main { padding: 20px 16px 48px; }
  h1 { font-size: 20px; }
  .table th, .table td { padding: 10px 12px; }
}
