:root {
  --bg: #151b25;
  --panel: #222b39;
  --border: #3a4554;
  --text: #e5e7eb;
  --text-2: #aab4c4;
  --primary: #eab308;
  --primary-text: #1a1400;
  --accent: #f97316;
  --danger: #f87171;
  --ok: #34d399;
  --sky-top: #080d24;
  --sky-bottom: #293852;
  --ground-top: #577c36;
  --ground-bottom: #263b20;
  --radius: 10px;
  --tap: 44px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--primary); color: var(--primary-text); padding: 8px 12px; border-radius: 6px;
}
.skip-link:focus { top: 8px; }

:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ------------------------------------------------------------ top bar */
#topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 16px; border-bottom: 1px solid var(--border); background: #10151d;
}

.logo, .home-title { font-family: Impact, "Arial Black", "Haettenschweiler", system-ui, sans-serif; letter-spacing: .08em; }
.logo { font-size: 22px; }
.logo-tank { color: #facc15; }
.logo-kaos { color: var(--accent); }

.topbar-status { flex: 1; color: var(--text-2); font-size: 14px; display: flex; gap: 16px; flex-wrap: wrap; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.conn-badge {
  font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel);
}
.conn-badge.is-bad { border-color: var(--danger); color: var(--danger); }
.conn-badge.is-ok { border-color: var(--ok); color: var(--ok); }

main { flex: 1; display: flex; flex-direction: column; padding: 16px; min-width: 0; }
main:focus { outline: none; }

.screen { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }

/* ------------------------------------------------------------ elements */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

.muted { color: var(--text-2); }
.error-text { color: var(--danger); margin: 8px 0 0; }
.fine-print { color: var(--text-2); font-size: 13px; margin: 12px 0 0; }

.btn {
  min-height: var(--tap); min-width: var(--tap);
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: #2c3748; color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover:not(:disabled) { background: #364357; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover:not(:disabled) { background: #f5c518; }
.btn-ghost { background: transparent; }
.btn[aria-pressed="true"] { border-color: var(--ok); color: var(--ok); }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--text-2); }
.field-grow { flex: 1; }

input[type="text"], input[type="number"], select {
  min-height: var(--tap); padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; width: 100%;
}
input:disabled, select:disabled { opacity: .55; }

.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); }
.check input { width: 22px; height: 22px; }

.overlay {
  position: fixed; inset: 0; background: rgba(8, 13, 36, .7); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.overlay-card { width: min(520px, 100%); max-height: 90dvh; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.overlay-actions { display: flex; justify-content: flex-end; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 90;
  background: #0b0f16; border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px; max-width: min(560px, 92vw);
}
.toast.is-error { border-color: var(--danger); }

.splash { position: fixed; inset: 0; background: var(--bg); z-index: 200; display: flex; align-items: center; justify-content: center; }

.noscript { padding: 16px; color: var(--danger); }

.standings { width: 100%; border-collapse: collapse; }
.standings th, .standings td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.standings td.num, .standings th.num { text-align: right; font-variant-numeric: tabular-nums; }

.seat-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; font-size: 13px; font-weight: 700; color: #111;
  flex: none;
}

/* ------------------------------------------------------------ home */
.home-card { width: min(460px, 100%); margin-top: 6vh; display: flex; flex-direction: column; gap: 14px; }
.home-title { font-size: clamp(44px, 12vw, 72px); text-align: center; margin: 0; line-height: 1; }
.slogan { text-align: center; color: var(--text-2); letter-spacing: .2em; font-size: 13px; margin: 0; }
.home-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.join-row { display: flex; gap: 10px; align-items: flex-end; }
#input-code { text-transform: uppercase; letter-spacing: .15em; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
body.reduced-motion * { animation: none !important; transition: none !important; }
