:root {
  --bg: #0b0a0a;
  --bg-2: #161212;
  --panel: #1b1616;
  --line: #3a2b2b;
  --text: #e9e2d8;
  --muted: #9b8f88;
  --red: #c8102e;
  --red-2: #ff3b3b;
  --amber: #ffb000;
  --font-pixel: "Press Start 2P", "VT323", "Courier New", monospace;
  --font-mono: "VT323", "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 22px;
  line-height: 1.3;
}

body {
  background:
    radial-gradient(ellipse at 50% -20%, rgba(200, 16, 46, 0.35), transparent 60%),
    linear-gradient(180deg, #120d0d 0%, var(--bg) 40%);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#app {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
}

.screen {
  width: 100%;
  max-width: 640px;
  background: rgba(27, 22, 22, 0.85);
  border: 1px solid var(--line);
  padding: 28px 32px;
  box-shadow: 0 0 0 4px #000, 0 20px 60px rgba(0, 0, 0, 0.6);
}
.screen.wide { max-width: 1000px; padding: 16px; }
.hidden, [hidden] { display: none !important; }

h1.logo {
  font-family: var(--font-pixel);
  font-size: 64px;
  margin: 8px 0 20px;
  text-align: center;
  color: var(--red-2);
  letter-spacing: 6px;
  text-shadow: 0 0 12px rgba(255, 59, 59, 0.6), 4px 4px 0 #3a0000;
}
h2 {
  font-family: var(--font-pixel);
  font-size: 18px;
  color: var(--amber);
  margin: 0 0 20px;
  line-height: 1.6;
}
.tagline { text-align: center; font-size: 24px; margin: 0 0 24px; }
.summary { font-size: 22px; color: var(--text); margin: 0 0 20px; }
.fineprint, .hint { color: var(--muted); font-size: 18px; }
.howto { margin: 24px 0 8px; padding-left: 28px; font-size: 22px; }
.howto li { margin: 6px 0; }
kbd {
  font-family: var(--font-mono);
  border: 1px solid var(--muted);
  border-bottom-width: 3px;
  padding: 0 6px;
  border-radius: 3px;
  background: #000;
}

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: center; margin: 20px 0 8px; }

.btn {
  font-family: var(--font-pixel);
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text);
  background: #2a2222;
  border: 2px solid #4a3a3a;
  padding: 14px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  line-height: 1;
  transition: transform 0.05s, background 0.1s;
}
.btn:hover { background: #3a2c2c; }
.btn:active { transform: translateY(2px); }
.btn.primary { background: var(--red); border-color: #ff5c5c; color: #fff; box-shadow: 0 0 16px rgba(200, 16, 46, 0.5); }
.btn.primary:hover { background: #e01535; }
.btn.big { font-size: 14px; padding: 18px 24px; }
.btn.small { font-size: 10px; padding: 10px 12px; }
.btn.link { background: transparent; border-color: transparent; color: var(--muted); }
.btn.link:hover { color: var(--text); background: transparent; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.form label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-size: 20px; }
.form label small { color: var(--muted); font-size: 16px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form .checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin-bottom: 8px; }
.form .checks label { flex-direction: row; align-items: center; gap: 10px; margin-bottom: 6px; }
.form .checks input { width: 20px; height: 20px; accent-color: var(--red); }
input[type="text"], select {
  font-family: var(--font-mono);
  font-size: 22px;
  color: var(--text);
  background: #000;
  border: 2px solid var(--line);
  padding: 8px 10px;
  width: 100%;
}
input[type="text"]:focus, select:focus { outline: none; border-color: var(--amber); }

/* ---------- game screen ---------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.status { color: var(--amber); font-size: 20px; min-height: 24px; }
.status.error { color: var(--red-2); }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

#stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}
#stage canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  background: #000;
  image-rendering: pixelated;
  outline: none;
}
#stage:fullscreen { border: 0; }
#stage:fullscreen canvas {
  width: auto !important;
  height: 100vh !important;
  aspect-ratio: 4 / 3;
  max-width: 100vw;
}

#loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #000;
}
.loader-title { font-family: var(--font-pixel); color: var(--red-2); font-size: 18px; }
.loader-bar { width: 60%; height: 18px; border: 2px solid var(--line); background: #111; }
#loader-fill { height: 100%; width: 0%; background: var(--red); transition: width 0.2s; }
#loader-text { color: var(--muted); }

.lobby {
  margin-top: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lobby-link { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.lobby-link code {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--amber);
  background: #000;
  padding: 4px 8px;
  user-select: all;
  word-break: break-all;
}
.lobby-players #players { color: var(--text); }
.lobby-hint { margin: 4px 0 0; color: var(--muted); font-size: 18px; }

.controls-help { margin-top: 12px; color: var(--muted); font-size: 18px; }
.controls-help b { color: var(--text); }

.footer { text-align: center; color: #5f5555; font-size: 15px; padding: 12px; }

@media (max-width: 640px) {
  html, body { font-size: 18px; }
  .screen { padding: 20px; }
  h1.logo { font-size: 40px; }
  .form .row, .form .checks { grid-template-columns: 1fr; }
}
