:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --border: #dbe3ee;
  --success: #15803d;
  --danger: #b91c1c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a { color: inherit; text-decoration: none; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 16px;
}

.brand {
  font-size: 24px;
  font-weight: 700;
}

.subbrand,
.muted-text {
  color: var(--muted);
  font-size: 14px;
}

.topbar-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

.center-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.center-card {
  max-width: 460px;
  margin: 24px auto 0;
}

.stack {
  display: block;
}

.stack > * + * {
  margin-top: 14px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 14px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}

.btn {
  display: inline-block;
  padding: 12px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.btn:hover { background: var(--accent-dark); }
.btn.secondary {
  background: #eef2f7;
  color: var(--text);
}
.btn.small {
  padding: 10px 12px;
  font-size: 14px;
}

.error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 12px;
}

.pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  background: #eef2ff;
  color: #334155;
}

.pill.muted { background: #f3f4f6; }
.pill.pending { background: #fef3c7; }
.pill.accepted { background: #dcfce7; }
.pill.declined,
.pill.expired { background: #fee2e2; }

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.panel-header {
  display: block;
}

.panel-header > * + * {
  margin-top: 10px;
}

.game-list,
.cards,
.participants,
.select-list {
  display: block;
}

.game-list > *,
.cards > *,
.participants > *,
.select-list > * {
  margin-top: 10px;
}

.game-list > *:first-child,
.cards > *:first-child,
.participants > *:first-child,
.select-list > *:first-child {
  margin-top: 0;
}

.game-card,
.check-row,
.participant-row,
.card {
  display: block;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.game-card input { margin-right: 8px; }
.game-card.selected {
  border-color: var(--accent);
  background: #eff6ff;
}

.participant-row {
  overflow: hidden;
}

.status {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  text-transform: uppercase;
}

.status.online { color: var(--success); }
.status.offline { color: var(--muted); }

.card-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.spacer-top { margin-top: 14px; }

.game-layout {
  max-width: 760px;
  margin: 0 auto;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 16px 0 12px;
}

.score-pill {
  padding: 12px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.score-pill strong {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.score-pill span {
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
}

.game-status {
  margin: 16px 0;
  padding: 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--muted);
}

.game-actions {
  margin: 0 0 16px;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.cell {
  min-height: 88px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font-size: 42px;
  font-weight: 700;
  text-align: center;
  vertical-align: middle;
  -webkit-appearance: none;
  appearance: none;
}

.cell:disabled {
  opacity: 1;
  background: #f8fafc;
}

@media (min-width: 960px) {
  .topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .topbar-actions {
    margin-top: 0;
    justify-content: flex-end;
  }

  .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .panel-header > * + * {
    margin-top: 0;
  }

  .lobby-grid {
    grid-template-columns: 280px minmax(0, 1fr) 280px;
    align-items: start;
  }

  .participant-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }
}

@media (max-width: 640px) {
  .page { padding: 12px; }
  .topbar { padding: 14px 12px; }
  .brand { font-size: 22px; }
  .cell { min-height: 74px; font-size: 34px; }
}
