:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b0f0d;
  color: #f3f2ea;
  font-synthesis: none;
  --ink: #f3f2ea;
  --muted: #9ea69f;
  --panel: #131a16;
  --panel-2: #18211b;
  --line: #2c3831;
  --accent: #c9e567;
  --accent-ink: #12170f;
  --danger: #ff766f;
  --warning: #f4c76a;
  --blue: #76b8ff;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 80% 0, #1c2a1d 0, #0b0f0d 35rem); }
button, input, select { font: inherit; }
button { cursor: pointer; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 410px); padding: 36px; border: 1px solid var(--line); border-radius: 24px; background: rgba(19, 26, 22, .94); box-shadow: 0 30px 80px #0008; }
.brand { font-family: Georgia, serif; letter-spacing: .23em; font-size: 16px; }
.eyebrow { color: var(--accent); letter-spacing: .18em; text-transform: uppercase; font-size: 12px; font-weight: 800; }
h1, h2, h3, p { margin-top: 0; }
.login-card h1 { font-family: Georgia, serif; font-size: 42px; margin: 42px 0 8px; font-weight: 500; }
.muted { color: var(--muted); }
.field { display: grid; gap: 8px; margin-top: 18px; }
.field label { color: #c6cbc7; font-size: 13px; font-weight: 700; }
input, select { width: 100%; border: 1px solid var(--line); background: #0d120f; color: var(--ink); border-radius: 12px; padding: 13px 14px; outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #c9e56720; }
.primary, .secondary, .danger, .ghost { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 800; }
.primary { color: var(--accent-ink); background: var(--accent); }
.secondary { color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); }
.ghost { color: var(--muted); background: transparent; }
.danger { color: #250807; background: var(--danger); }
.wide { width: 100%; margin-top: 24px; }
.error { min-height: 20px; color: var(--danger); margin: 14px 0 0; font-size: 14px; }

.shell { min-height: 100vh; }
.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 32px; border-bottom: 1px solid var(--line); background: #0b0f0de8; backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 10; }
.topbar .brand small { font-family: Inter, sans-serif; letter-spacing: normal; color: var(--muted); margin-left: 14px; }
.user { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.user-badge { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 900; }
.content { width: min(1440px, 100%); margin: 0 auto; padding: 36px 32px 80px; }
.title-row { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.title-row h1 { font-family: Georgia, serif; font-weight: 500; font-size: clamp(36px, 5vw, 58px); margin-bottom: 4px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
.stat { padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.stat strong { display: block; font-family: Georgia, serif; font-size: 32px; font-weight: 500; }
.stat span { color: var(--muted); font-size: 13px; }
.toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) 190px auto; gap: 12px; margin-bottom: 16px; }

.table-wrap { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .09em; padding: 13px 16px; background: #101612; }
td { padding: 17px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: #1a231d; }
.game-link { color: var(--ink); font-weight: 800; background: none; border: 0; padding: 0; text-align: left; }
.game-id { display: block; color: var(--muted); font-size: 11px; font-family: ui-monospace, monospace; margin-top: 5px; }
.status { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 6px 10px; background: #222b25; font-size: 12px; font-weight: 800; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status.active::before { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.status.lobby::before { background: var(--warning); }
.status.resolved::before { background: var(--blue); }
.status.closed::before { background: var(--danger); }
.activity { color: var(--muted); font-size: 13px; }
.empty { text-align: center; padding: 70px 24px; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid #ffffff20; border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: #000a; backdrop-filter: blur(8px); }
.modal { width: min(100%, 560px); max-height: calc(100vh - 40px); overflow: auto; border: 1px solid var(--line); border-radius: 22px; background: #111713; box-shadow: 0 30px 90px #000b; }
.modal.large { width: min(100%, 850px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #111713f5; backdrop-filter: blur(12px); z-index: 2; }
.modal-head h2 { margin-bottom: 5px; }
.close { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--ink); font-size: 22px; }
.modal-body { padding: 24px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 24px; border-top: 1px solid var(--line); }
.detail-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 24px; }
.detail-stat { background: #0b100d; border-radius: 12px; padding: 14px; }
.detail-stat strong { display: block; font-size: 22px; }
.detail-stat span { color: var(--muted); font-size: 11px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 28px 0 12px; }
.member { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; padding: 14px; background: #0d120f; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 9px; }
.seat { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--panel-2); color: var(--accent); font-weight: 900; }
.member small { display: block; color: var(--muted); margin-top: 4px; }
.member-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.member-code { display: flex; align-items: center; gap: 4px; padding: 5px 6px 5px 11px; border: 1px solid #52612e; border-radius: 10px; background: #1d2717; }
.member-code span { font: 800 13px ui-monospace, SFMono-Regular, monospace; color: var(--accent); }
.member-code .ghost { padding: 6px 8px; font-size: 11px; }
.legacy-code { color: var(--warning); font-size: 11px; max-width: 130px; }
.code-grid { display: grid; gap: 10px; }
.code-card { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 16px; border-radius: 14px; border: 1px solid #52612e; background: #1d2717; }
.code { font: 800 20px ui-monospace, SFMono-Regular, monospace; letter-spacing: .04em; }
.notice { color: var(--warning); background: #302716; border-radius: 12px; padding: 12px 14px; font-size: 13px; }
.danger-zone { border: 1px solid #6b312f; background: #251311; padding: 18px; border-radius: 14px; margin-top: 28px; }
.danger-zone p { color: #d7a5a2; font-size: 13px; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; background: #edf7ca; color: #151a11; padding: 12px 18px; border-radius: 999px; font-weight: 800; transition: .2s ease; box-shadow: 0 10px 40px #0008; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 820px) {
  .topbar { padding: 0 18px; }
  .topbar .brand small, .user span { display: none; }
  .content { padding: 26px 16px 70px; }
  .title-row { align-items: flex-start; flex-direction: column; }
  .title-row .primary { width: 100%; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .toolbar { grid-template-columns: 1fr; }
  .table-wrap { border: 0; background: transparent; overflow: visible; }
  table, tbody { display: block; }
  thead { display: none; }
  tr { display: grid; grid-template-columns: 1fr auto; gap: 12px; margin-bottom: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); }
  td { display: block; border: 0; padding: 0; }
  td:nth-child(3), td:nth-child(4), td:nth-child(5) { color: var(--muted); font-size: 13px; }
  .detail-stats { grid-template-columns: repeat(2, 1fr); }
  .member { grid-template-columns: 44px 1fr; }
  .member-actions { grid-column: 1 / -1; justify-content: stretch; }
  .member-actions .secondary { flex: 1; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button { width: 100%; }
}
