:root {
  --bg: #0f1126; --panel: #171a36; --panel-2: #1f2347; --border: #2c3160;
  --text: #e8ebf7; --muted: #9aa3c7; --accent: #3fa9f5; --accent-2: #f26b1d;
  --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
img { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; margin: 0 0 14px; }

/* Navigation */
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--border); }
.nav .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); }
.nav .brand img { width: 36px; height: 36px; border-radius: 9px; }
.nav .nav-links { display: flex; gap: 16px; }
.nav .spacer { flex: 1; }
.nav form { margin: 0; }

.container { max-width: 1040px; margin: 0 auto; padding: 20px 16px 48px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.card h2, .card h3 { margin-top: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-actions h1 { margin: 0; }
.grid { display: grid; gap: 14px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--panel-2); border-radius: 10px; padding: 14px 16px; }
.stat .n { font-size: 28px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; }

/* Forms */
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; padding: 10px 12px; background: #0b0d1f; border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 16px;
}
textarea { min-height: 70px; }
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--accent-2); background: var(--accent-2); color: #140d05; font-weight: 600; cursor: pointer; font-size: 14px; line-height: 1.2; text-align: center; }
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn.secondary { background: transparent; border-color: var(--accent); color: var(--accent); }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.small { padding: 6px 11px; font-size: 13px; }
td .btn { white-space: nowrap; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; }
.flash.ok { border-color: var(--ok); background: rgba(34,197,94,.08); }
.flash.bad { border-color: var(--bad); background: rgba(239,68,68,.08); }
.errors { color: var(--bad); font-size: 13px; margin: 6px 0 0; padding-left: 18px; }

/* Tables scroll sideways on small screens instead of squeezing */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -18px; padding: 0 18px; }
.table-wrap table { min-width: 620px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: rgba(34,197,94,.15); color: var(--ok); }
.pill.warn { background: rgba(245,158,11,.15); color: var(--warn); }
.pill.bad { background: rgba(239,68,68,.15); color: var(--bad); }
.pill.muted { background: rgba(154,163,199,.15); color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code { background: #0b0d1f; padding: 1px 5px; border-radius: 4px; font-size: 13px; word-break: break-all; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }
.checklist { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; background: #0b0d1f; }
.checklist label { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; color: var(--text); font-size: 14px; }

/* Numbered list on the welcome page */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: step; padding: 12px 0 12px 44px; position: relative; border-bottom: 1px solid var(--border); }
.steps li:last-child { border-bottom: 0; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 12px; width: 30px; height: 30px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-weight: 700; }

/* Welcome and login */
.hero { text-align: center; padding: 40px 16px 20px; }
.hero-logo { width: 120px; height: 120px; border-radius: 28px; }
.hero h1 { font-size: 34px; margin: 14px 0 8px; }
.auth-card { max-width: 420px; margin: 24px auto; }
.auth-brand { text-align: center; margin-bottom: 16px; }
.auth-brand img { width: 84px; height: 84px; border-radius: 20px; }
.auth-brand h1 { margin: 10px 0 2px; font-size: 24px; }
.auth-brand p { margin: 0; }
.divider { text-align: center; margin: 14px 0; font-size: 13px; }

/* Player page: one step per card, each with the service's logo */
.player-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.player-head h1 { margin: 0; }
.order-box { text-align: right; }
.step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.step-no { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.step.done .step-no { background: rgba(34,197,94,.2); border-color: var(--ok); color: var(--ok); }
.step-logo { flex: none; width: 48px; height: 48px; border-radius: 10px; object-fit: contain; background: #0b0d1f; }
.step-logo.light { background: #fff; padding: 5px; }
.step-head h2 { margin: 0; font-size: 20px; flex: 1; }
.step-body > p:first-child { margin-top: 0; }
.step-body > p:last-child { margin-bottom: 0; }
.invites { display: grid; gap: 10px; }
.invite { background: var(--panel-2); border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; }
.invite strong { font-size: 15px; }

/* Phones */
@media (max-width: 640px) {
  .nav { padding: 10px 12px; gap: 8px 12px; }
  .nav .user-name { display: none; }
  .nav .nav-links { order: 3; width: 100%; gap: 14px; }
  .container { padding: 16px 12px 40px; }
  .card { padding: 14px; border-radius: 10px; }
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
  h1 { font-size: 22px; }
  .hero { padding: 24px 8px 12px; }
  .hero h1 { font-size: 28px; }
  .order-box { text-align: left; }
  .row > .btn, .row > form { flex: 1 1 100%; }
  .row > form > .btn { width: 100%; }
  .step-logo { width: 42px; height: 42px; }
  .step-head h2 { font-size: 18px; }
}

/* Per-game results on the admin tournament page */
details.game { margin-top: 12px; }
details.game summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
details.game .table-wrap { margin-top: 6px; }
