:root {
  color-scheme: light;
  --background: #f4f6fa;
  --surface: #fff;
  --border: #dce2ed;
  --text: #182339;
  --muted: #52617b;
  --accent: #3e4bd3;
  --accent-hover: #313db6;
  --accent-light: #edf0ff;
  --sidebar: #151d34;
  --sidebar-text: #bdc8e1;
  --radius: 14px;
  --gutter: clamp(20px, 3.3vw, 48px);
  font: 14px/1.55 "Inter", "Segoe UI", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  color: var(--text);
  background: var(--background);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid #6476ed; outline-offset: 3px; }
.workspace:focus { outline: none; }

.skip-link {
  position: fixed;
  inset: 12px auto auto 12px;
  transform: translateY(-160%);
  z-index: 30;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 8px;
}
.skip-link:focus { transform: none; }

body:has(.workspace) {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  padding: 28px 16px;
  color: var(--sidebar-text);
  background: var(--sidebar);
}
.brand {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 11px;
  color: white;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -.04em;
  text-decoration: none;
}
.sidebar .brand { margin: 0 0 38px 10px; }
.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid #8d9aff;
  border-radius: 10px;
  background: #5666ec;
}
.brand-mark::before {
  content: "";
  width: 16px;
  height: 13px;
  border: 2px solid white;
  border-radius: 4px;
  background: radial-gradient(circle at 32% 50%, #fff 1px, transparent 1.6px),
              radial-gradient(circle at 68% 50%, #fff 1px, transparent 1.6px);
}
.brand-mark::after {
  content: "";
  position: absolute;
  top: 7px;
  left: 15px;
  width: 2px;
  height: 4px;
  border-radius: 2px;
  background: white;
}
.primary-nav { display: grid; gap: 5px; }
.primary-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 600;
}
.primary-nav a:hover { background: #212b47; color: white; }
.primary-nav a.current { background: #29365b; color: white; }
.primary-nav a.current::before {
  content: "";
  position: absolute;
  inset: 11px auto 11px 0;
  width: 3px;
  border-radius: 4px;
  background: #a7b1ff;
}
.nav-icon { position: relative; flex: 0 0 16px; height: 16px; }
.nav-icon.config {
  background: linear-gradient(currentColor, currentColor) 0 3px / 16px 1.5px no-repeat,
              linear-gradient(currentColor, currentColor) 0 8px / 16px 1.5px no-repeat,
              linear-gradient(currentColor, currentColor) 0 13px / 16px 1.5px no-repeat;
}
.nav-icon.config::before {
  content: "";
  position: absolute;
  width: 3px;
  height: 5px;
  top: 1px;
  left: 4px;
  border-radius: 1px;
  background: currentColor;
  box-shadow: 6px 5px currentColor, 0 10px currentColor;
}
.nav-icon.rooms {
  background: linear-gradient(currentColor, currentColor) 1px 1px / 6px 6px no-repeat,
              linear-gradient(currentColor, currentColor) 9px 1px / 6px 6px no-repeat,
              linear-gradient(currentColor, currentColor) 1px 9px / 6px 6px no-repeat,
              linear-gradient(currentColor, currentColor) 9px 9px / 6px 6px no-repeat;
}
.nav-icon.players::before, .nav-icon.players::after, .nav-icon.bets::before {
  content: "";
  position: absolute;
  border: 1.5px solid currentColor;
}
.nav-icon.players::before { inset: 1px 5px 9px; border-radius: 50%; }
.nav-icon.players::after { inset: 8px 2px 1px; border-radius: 6px 6px 2px 2px; }
.nav-icon.bets::before { inset: 0 2px; border-radius: 2px; }
.nav-icon.bets::after {
  content: "";
  position: absolute;
  inset: 5px 5px auto;
  height: 1px;
  background: currentColor;
  box-shadow: 0 3px currentColor, 0 6px currentColor;
}

.workspace { min-width: 0; }
.workspace-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.local { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.local i { width: 7px; height: 7px; border-radius: 50%; background: #239771; }
.workspace-content {
  width: 100%;
  max-width: 1540px;
  margin: 0 auto;
  padding: 35px var(--gutter) 44px;
}
.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 0 0 24px;
}
h1 { font-size: clamp(25px, 3vw, 36px); letter-spacing: -.035em; line-height: 1.2; }
.page-heading p { margin-top: 9px; color: var(--muted); }
.page-heading > button { flex: none; }
h2 { font-size: 18px; line-height: 1.4; font-weight: 720; }
h3 { font-size: 15px; }

.sub {
  display: flex;
  gap: 20px;
  margin: 0 0 18px;
  padding: 0 2px;
  border-bottom: 1px solid var(--border);
}
.sub a {
  position: relative;
  display: block;
  padding: 9px 3px 11px;
  color: var(--muted);
  font-weight: 650;
  text-decoration: none;
}
.sub a:hover, .sub .current { color: var(--accent); }
.sub .current::after {
  content: "";
  position: absolute;
  inset: auto 0 -1px;
  height: 3px;
  border-radius: 4px 4px 0 0;
  background: var(--accent);
}

.panel, .hall {
  min-width: 0;
  margin: 0 0 16px;
  padding: 23px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.panel > h2 { margin: 0 0 16px; }
.panel-heading, .hall-heading, .dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.panel-heading, .hall-heading { margin: 0 0 16px; }
.lead { margin: 0 0 12px; color: var(--muted); }
.count { color: var(--accent); font-weight: 700; }
.notice {
  margin: 0 0 16px;
  padding: 11px 14px;
  border: 1px solid #d5dcf6;
  border-radius: 8px;
  background: #f1f4ff;
  color: #3346a2;
  overflow-wrap: anywhere;
}
.notice.ok { border-color: #bce5d2; background: #eefaf4; color: #176447; }
.bad { color: #a62a42; }
.notice.bad { border-color: #f1c8d0; background: #fff2f4; }
.notice:empty, .lead:empty { display: none; }
.empty { padding: 24px; color: var(--muted); }
.empty.bad { color: #a62a42; }

.config-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 172px;
  align-items: start;
  gap: 22px;
}
.section-nav {
  position: sticky;
  top: 24px;
  grid-column: 2;
  grid-row: 1;
  display: grid;
  gap: 3px;
  padding: 4px 0 4px 12px;
  border-left: 1px solid var(--border);
}
.section-nav a {
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 550;
}
.section-nav a:hover { color: var(--accent); background: var(--accent-light); }
.config-layout > form { grid-column: 1; grid-row: 1; min-width: 0; }
.config-layout section { scroll-margin-top: 22px; }
.config-layout section:target { border-color: #a5aef6; }
.config-shortcuts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.config-shortcuts a {
  position: relative;
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 12px 28px 12px 14px;
  border: 1px solid #dce2fb;
  border-radius: 10px;
  background: #eef1fc;
  color: #3341ae;
  text-decoration: none;
}
.config-shortcuts a:hover { border-color: #a7b2f7; background: #e9edff; }
.config-shortcuts a::after { content: "›"; position: absolute; top: 8px; right: 14px; font-size: 21px; }
.config-shortcuts span { color: #535f7b; font-size: 12px; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 242px), 1fr));
  gap: 16px 18px;
}
.field-wide { grid-column: 1 / -1; }
label { display: block; min-width: 0; }
label > span, legend { display: block; margin: 0 0 6px; color: #3a4963; font-size: 13px; font-weight: 600; }
label small { display: block; margin: 5px 0 0; color: var(--muted); overflow-wrap: anywhere; }
input:not([type=checkbox]), select, textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 39px;
  padding: 8px 10px;
  border: 1px solid #cbd4e5;
  border-radius: 7px;
  background: #fbfcff;
  color: var(--text);
}
input[type=hidden] { display: none; }
select { padding-right: 26px; }
textarea { resize: vertical; font-family: "IBM Plex Mono", Consolas, monospace; }
.checks { margin: 0; padding: 0; border: 0; min-width: 0; }
.checks > div { display: flex; flex-wrap: wrap; gap: 7px; }
.checks label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fbfcff;
  cursor: pointer;
}
.checks label:has(input:checked) { color: #2e3cae; border-color: #cbd3fc; background: var(--accent-light); }
.checks input { margin: 0; accent-color: var(--accent); width: 14px; height: 14px; }

button, .action, a.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 39px;
  padding: 7px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
button:hover, .action:hover { background: var(--accent-hover); }
.secondary, a.secondary { border-color: #d7deed; background: #f7f9fd; color: #35445f; }
.secondary:hover, a.secondary:hover { border-color: #c7d0f4; background: #edf1ff; color: #2d39a4; }
button:disabled { opacity: .62; cursor: wait; }
.small { min-height: 30px; padding: 4px 8px; font-size: 12px; }
.danger { color: #992e44; }
.danger:hover { border-color: #f1c8d0; background: #fff2f4; color: #992e44; }
.form-actions, .tools, .ops, .ops form, .inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.form-actions { justify-content: flex-end; margin-top: 16px; }
.form-actions p { margin-right: auto; color: var(--muted); font-size: 13px; }
.inline-form { align-items: flex-end; gap: 10px; margin-top: 15px; }
.inline-form label { width: 112px; }
#add-progress { margin: 13px 0 0; }
progress { width: min(100%, 360px); margin: 6px 0 0; accent-color: var(--accent); }

.table-panel { padding: 0; overflow: clip; }
.table-panel > h2, .table-panel > .panel-heading { padding: 16px 20px; margin: 0; }
.table-panel > .notice { margin: 0 20px 12px; }
.table-scroll { overflow-x: auto; }
.table-scroll:focus-visible { outline-offset: -3px; }
.table-hint { display: none; padding: 0 20px 8px; color: var(--muted); font-size: 12px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
th, td { padding: 10px 13px; text-align: left; }
th {
  border-block: 1px solid var(--border);
  background: #f5f7fc;
  color: #455571;
  font-size: 12px;
  font-weight: 700;
}
td { border-bottom: 1px solid #e7ebf3; }
tbody tr:nth-child(even) td { background: #fbfcff; }
tbody tr:hover td { background: #f0f3fc; }
tbody tr:last-child td { border-bottom: 0; }
.players-table th, .players-table td { padding-inline: 9px; }
.players-table :is(th, td):first-child { padding-left: 20px; }
.players-table :is(th, td):last-child { padding-right: 20px; }
.players-table [data-field=nickname] { font-weight: 650; }
.players-table .ops, .players-table .ops form { flex-wrap: nowrap; gap: 4px; }
.rooms-table :is(th, td):first-child { padding-left: 20px; }
.rooms-table [data-room] { font-weight: 650; }
.picked, .status-pill {
  display: inline-block;
  border-radius: 5px;
  padding: 2px 7px;
  background: #e9f8f0;
  color: #176347;
  font-size: 12px;
  font-weight: 650;
}
.picked { margin-left: 4px; }
.status-muted { background: #edf0f6; color: #4d5a73; }
.table-description { padding: 16px 20px; color: var(--muted); overflow-wrap: anywhere; }
.pages { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 14px 20px; border-top: 1px solid var(--border); }
.pages a, .pages span { display: grid; place-items: center; min-width: 33px; min-height: 33px; padding: 3px 6px; }
.pages a { border: 1px solid var(--border); border-radius: 7px; color: var(--muted); font-weight: 650; text-decoration: none; }
.pages a:hover, .pages a.current { border-color: #c7d0fa; background: var(--accent-light); color: var(--accent); }

body:has(.mask:not([hidden])) { overflow: hidden; }
.mask {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: start;
  overflow: auto;
  padding: 30px 16px;
  background: #0e173b94;
}
.dialog {
  width: min(1080px, 100%);
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: clip;
  background: var(--surface);
  box-shadow: 0 18px 60px #10183d40;
}
.dialog-heading {
  position: sticky;
  z-index: 1;
  top: 0;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
#bet-body > p:not([class]) { padding: 18px 20px; }

.access-layout { display: grid; grid-template-columns: minmax(300px, 40%) minmax(0, 1fr); min-height: 100vh; }
.access-brand {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: clamp(24px, 4vw, 56px);
  background: linear-gradient(145deg, #141e37, #253566);
  color: #d6dfff;
}
.access-brand .local { margin-top: 32px; }
.access-brand .local i { background: #68d9ab; }
.access-art {
  position: absolute;
  z-index: -1;
  inset: 25% 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle, #9aaaf63c 1px, transparent 1.3px) 50% 50% / 22px 22px;
  mask-image: radial-gradient(ellipse, #000 20%, transparent 75%);
}
.access-art i {
  width: min(33%, 150px);
  aspect-ratio: 1;
  transform: rotate(-18deg);
  border: 1px solid #a6b5ff70;
  border-radius: 30%;
  background: linear-gradient(140deg, #788bf961, #374da33a);
  box-shadow: 0 0 0 24px #7c90ff13, 0 0 0 52px #7c90ff0c, 0 0 65px #7589ff50;
}
.access-content { display: grid; align-items: center; justify-items: center; padding: 32px 24px; }
.access-form { width: min(100%, 430px); }
.access-form h1 { margin-bottom: 8px; }
.access-form form, .access-form > .notice { margin-top: 20px; }
.access-form form { display: grid; gap: 14px; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.access-form button { margin-top: 3px; }

@media (max-width: 1100px) {
  body:has(.workspace) { grid-template-columns: 178px minmax(0, 1fr); }
  .config-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .section-nav { position: static; grid-column: 1; grid-row: auto; display: flex; flex-wrap: wrap; border-left: 0; padding: 0; }
  .section-nav a { padding: 6px 9px; border: 1px solid var(--border); background: var(--surface); }
  .config-layout > form { grid-row: auto; }
  .table-hint { display: block; }
}

@media (max-width: 720px) {
  body:has(.workspace) { display: block; }
  .sidebar { position: static; min-height: auto; padding: 13px var(--gutter) 10px; }
  .sidebar .brand { margin: 0 0 10px; font-size: 20px; }
  .sidebar .brand-mark { width: 30px; height: 30px; }
  .sidebar .brand-mark::after { top: 5px; left: 13px; }
  .primary-nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .primary-nav a { min-height: 38px; padding: 5px 8px; gap: 5px; font-size: 12px; }
  .primary-nav a.current::before { display: none; }
  .primary-nav i { display: none; }
  .workspace-bar { min-height: 42px; }
  .workspace-content { padding-top: 23px; }
  .page-heading { align-items: flex-start; margin-bottom: 16px; }
  .panel, .hall { padding: 16px; }
  .table-panel { padding: 0; }
  .table-panel > h2, .table-panel > .panel-heading, .table-description, .table-hint { padding-inline: 14px; }
  .tools { gap: 6px; }
  .tools :is(button, a) { padding-inline: 8px; font-size: 12px; }
  .mask { padding: 12px; }
  .dialog-heading, .pages { padding-inline: 14px; }
  .access-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .access-brand { flex-direction: row; align-items: center; gap: 10px; padding: 16px 20px; }
  .access-brand .local { margin: 0; }
  .access-art { display: none; }
  .access-content { align-items: start; padding-top: 48px; }
}

@media (max-width: 400px) {
  :root { --gutter: 15px; }
  .page-heading { flex-wrap: wrap; }
  .config-shortcuts { gap: 8px; }
  .config-shortcuts a { padding-left: 10px; }
}
