:root {
  --bg: #14161a;
  --panel: #1b1f26;
  --panel-2: #21262e;
  --line: #2b313b;
  --text: #e8ebf2;
  --muted: #9aa1ad;
  --accent: #3e63dd;
  --accent-hi: #5b7cec;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

#app { height: 100%; }

.screen { height: 100%; width: 100%; }
.screen-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
}

.card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.card-wide { width: min(560px, 100%); }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 1.75rem;
  letter-spacing: 0.01em;
  font-weight: 650;
}
.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(62, 99, 221, 0.18), 0 0 18px rgba(62, 99, 221, 0.5);
  flex: none;
}

.muted { color: var(--muted); margin: 0 0 18px; }
.small { font-size: 0.85rem; }
.eyebrow {
  margin: 0 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.h2 { font-size: 1rem; margin: 22px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.error { color: #ff8a8d; margin: 0 0 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 18px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
  text-decoration: none;
  touch-action: manipulation;
}
.btn:hover { background: #28303a; border-color: #3a424f; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn-small { min-height: 34px; padding: 6px 12px; font-size: 0.86rem; }

:focus-visible { outline: 2px solid #9db1ff; outline-offset: 2px; }

.row { display: flex; gap: 8px; align-items: stretch; }
.row > input { flex: 1 1 auto; min-width: 0; }

input[type="text"] {
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #12151a;
  color: var(--text);
  font: inherit;
  letter-spacing: 0.08em;
}
input[type="text"]::placeholder { color: #6b7280; letter-spacing: 0.08em; }
input[type="text"]:focus { outline: 2px solid #9db1ff; outline-offset: 1px; border-color: transparent; }

.join-form { margin-top: 20px; display: block; }
.join-form .eyebrow { display: block; margin-bottom: 8px; }
#btn-create { width: 100%; }

.dev-login { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--line); }
.dev-login .eyebrow { margin-bottom: 8px; }

.code-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(2rem, 7vw, 3rem);
  letter-spacing: 0.18em;
  color: var(--text);
  text-transform: uppercase;
}

.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.players li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.players .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.players .who { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: 999px;
  flex: none;
}

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }

/* ---- game ---- */
.screen-game { position: relative; overflow: hidden; background: var(--bg); }
#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.hud {
  position: absolute;
  inset: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-row { display: flex; gap: 8px; flex-wrap: wrap; }
.stat {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 7px 11px;
  background: rgba(20, 22, 26, 0.82);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-weight: 650;
}
.stat-label { font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stat-room { color: var(--muted); font-weight: 500; letter-spacing: 0.08em; }

.hud-buy { order: 3; }
.legend {
  order: 2;
  list-style: none;
  margin: 0;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(20, 22, 26, 0.78);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 0.82rem;
}
.legend li { display: flex; align-items: center; gap: 7px; color: #cfd5df; }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.legend .dead { text-decoration: line-through; opacity: 0.45; }
.legend .me { font-weight: 650; }

.help {
  order: 4;
  margin: auto 0 0;
  max-width: 100%;
  padding: 6px 10px;
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(20, 22, 26, 0.6);
  border-radius: 8px;
  pointer-events: none;
}

.banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  padding: 9px 16px;
  background: #3a2410;
  border: 1px solid #7a4a12;
  color: #ffd9a0;
  border-radius: 999px;
  font-size: 0.86rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.banner-sub { color: #d9b487; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 50;
  padding: 10px 16px;
  background: #2a1215;
  border: 1px solid #7f2a2e;
  color: #ffb9bb;
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  max-width: min(92vw, 460px);
}

.over {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 15, 0.62);
  padding: 24px;
}
.over-card {
  width: min(380px, 100%);
  padding: 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  text-align: center;
}
.over-title { margin: 0 0 6px; font-size: 1.6rem; }
.over-card .actions { justify-content: center; margin-top: 20px; }

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

@media (max-width: 700px) {
  .card { padding: 20px; }
  .hud { padding: 8px; gap: 6px; }
  .help { display: none; }
  .legend { font-size: 0.75rem; padding: 6px 8px; }
  .stat { padding: 5px 8px; }
  .btn { min-height: 40px; padding: 8px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
