:root {
  --bg: #eef4ef;
  --surface: #ffffff;
  --text: #1d1d1d;
  --muted: #6b7280;
  --line: #d9e2dc;
  --accent: #2f6fd0;
  --accent-soft: #e8f0fc;
  --danger: #c62828;
  --ok: #16a34a;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { margin: 0 0 12px; font-size: 26px; }
h2 { margin: 0 0 12px; font-size: 18px; }
p { margin: 0 0 12px; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.ok { color: var(--ok); }
.error { padding: 8px 10px; border-radius: 6px; background: #fdecec; color: var(--danger); font-size: 14px; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border: 1px solid #b9c4bd; border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-decoration: none;
}
.button:hover { background: #f3f6f4; text-decoration: none; }
.button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.button.primary:hover { background: #2861b8; }
.button.danger { border-color: #e6b3b3; color: var(--danger); }
.button.small { height: 32px; padding: 0 12px; font-size: 14px; }
.button:disabled { opacity: 0.5; cursor: default; }

.topbar {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.logo { font-weight: 700; font-size: 18px; color: var(--text); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a, .user > a:not(.button) {
  padding: 6px 10px; border-radius: 6px; color: var(--text);
}
.nav a:hover, .user > a:not(.button):hover { background: #f1f4f2; text-decoration: none; }
.nav a.active, .user a.active { background: var(--accent-soft); color: var(--accent); }
.user { display: flex; align-items: center; gap: 8px; }
.me { display: flex; align-items: center; gap: 8px; }

.page { max-width: 1040px; margin: 0 auto; padding: 28px 24px 48px; }
.narrow { max-width: 640px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 16px; }
.page-head h1 { margin: 0; }

.card { padding: 20px; margin-bottom: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.block { margin-bottom: 24px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.split { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: start; margin-bottom: 32px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.hero { padding: 8px 0 24px; }
.hero h1 { font-size: 34px; }
.lead { font-size: 18px; color: var(--muted); max-width: 32em; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field .label { font-size: 13px; font-weight: 600; color: #374151; padding: 0; }
.field .hint { font-size: 12px; color: var(--muted); }
input:not([type="radio"]):not([type="checkbox"]), select {
  height: 38px; padding: 0 10px; border: 1px solid #c4cec7; border-radius: 8px;
  background: #fff; font: inherit; color: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 6px; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tab {
  padding: 6px 12px; border: 0; border-radius: 6px; background: transparent;
  color: var(--text); font: inherit; cursor: pointer;
}
.tab:hover { background: #e7ede9; text-decoration: none; }
.tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.toolbar .tabs { margin: 0; }
.search { width: 240px; }

.avatar {
  display: inline-flex; flex: none; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff; font-weight: 700; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.avatar.empty { width: 32px; height: 32px; background: #f1f4f2; border-style: dashed; border-color: #c4cec7; box-shadow: none; }
.avatars { display: flex; }
.avatars .avatar + .avatar { margin-left: -6px; }

.badge { padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.waiting { background: #fff4d6; color: #92600a; }
.badge.playing { background: #dcf3e3; color: #166534; }
.badge.finished { background: #eceff1; color: #4b5563; }
.guest { padding: 1px 6px; border-radius: 8px; background: #f1f1f1; color: var(--muted); font-size: 11px; }
.you { padding: 1px 6px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 12px; }
.lock { margin-left: 8px; padding: 1px 6px; border-radius: 8px; background: #f1f1f1; color: var(--muted); font-size: 11px; font-weight: 400; }

.game-list { margin: 0; padding: 0; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.game-list li + li { border-top: 1px solid var(--line); }
.game-row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; color: inherit; }
.game-row:hover { background: #f7faf8; text-decoration: none; }
.game-main { flex: 1; min-width: 0; }
.game-name { font-weight: 600; }
.seats { width: 36px; text-align: right; color: var(--muted); font-size: 13px; }
.empty-list { padding: 16px; margin: 0; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch input { position: absolute; opacity: 0; }
.swatch span {
  display: block; width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--text); }
.swatch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatch input:disabled + span { opacity: 0.25; cursor: not-allowed; }

.map-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.map-option input { position: absolute; opacity: 0; }
.map-card {
  display: flex; flex-direction: column; padding: 12px; border: 1px solid #c4cec7; border-radius: 8px; cursor: pointer;
}
.map-option input:checked + .map-card { border-color: var(--accent); background: var(--accent-soft); }
.map-option input:focus-visible + .map-card { outline: 2px solid var(--accent); }

.profile-head { display: flex; align-items: center; gap: 16px; }
.profile-head h1 { margin: 0; }
.stats { display: flex; gap: 16px; margin-top: 4px; font-size: 14px; color: var(--muted); }
.stats b { color: var(--text); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.players { margin: 0; padding: 0; list-style: none; }
.player { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.player + .player { border-top: 1px solid #f0f3f1; }
.narrow > .error { margin-bottom: 12px; }


.join-block p { margin-bottom: 10px; }
.join-row { display: flex; gap: 8px; }
.join-form { display: flex; flex-direction: column; gap: 8px; }
.code-input {
  flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 20px !important;
  letter-spacing: 0.15em; text-transform: uppercase;
}
.code-card { text-align: center; }
.code-card .actions { justify-content: center; }
.code {
  margin: 4px 0 8px; font-family: ui-monospace, monospace; font-size: 40px; font-weight: 700;
  letter-spacing: 0.12em; user-select: all;
}
.split > div > .card + .card { margin-top: 16px; }

body.offline::before {
  content: "No connection to the server. Reconnecting...";
  position: fixed; top: 0; left: 0; right: 0; z-index: 5; padding: 6px; text-align: center;
  background: #fde68a; color: #78350f; font-size: 14px;
}
.note { padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); color: #1e3a8a; font-size: 14px; }

@media (max-width: 760px) {
  .topbar { gap: 12px; padding: 0 16px; }
  .me span { display: none; }
  .page { padding: 20px 16px 40px; }
  .split, .grid-2 { grid-template-columns: 1fr; }
  .search { width: 100%; }
  .game-row { flex-wrap: wrap; }
}
