:root {
  --bg: #0d1a3a;
  --panel: #14224a;
  --line: #2c3f7a;
  --text: #f3f1e6;
  --muted: #a9b0c9;
  --red: #e8382f;
  --red-2: #ff6b61;
  --yellow: #ffd23f;
  --green: #4fbf3c;
  --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% -10%, rgba(92, 148, 252, 0.45), transparent 60%),
    linear-gradient(180deg, #16296a 0%, var(--bg) 45%);
  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(20, 34, 74, 0.9);
  border: 1px solid var(--line);
  padding: 28px 32px;
  box-shadow: 0 0 0 4px #081027, 0 20px 60px rgba(0, 0, 0, 0.5);
}
.screen.wide { max-width: 1240px; padding: 16px; }
.hidden, [hidden] { display: none !important; }

h1.logo {
  font-family: var(--font-pixel);
  font-size: 44px;
  margin: 8px 0 20px;
  text-align: center;
  line-height: 1.3;
  letter-spacing: 4px;
}
h1.logo .l1 { color: var(--red-2); text-shadow: 4px 4px 0 #5a0f0a; display: block; }
h1.logo .l2 { color: var(--yellow); text-shadow: 4px 4px 0 #6b4a00; display: block; }
h2 {
  font-family: var(--font-pixel);
  font-size: 16px;
  color: var(--yellow);
  margin: 0 0 20px;
  line-height: 1.6;
}
.tagline { text-align: center; font-size: 24px; margin: 0 0 24px; }
.summary { font-size: 22px; 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; }

.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: #22366e;
  border: 2px solid #3f5aa8;
  padding: 14px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  line-height: 1;
  transition: transform 0.05s, background 0.1s;
}
.btn:hover { background: #2c458a; }
.btn:active { transform: translateY(2px); }
.btn.primary { background: var(--red); border-color: #ff8a80; color: #fff; box-shadow: 0 0 16px rgba(232, 56, 47, 0.45); }
.btn.primary:hover { background: #ff4b40; }
.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; }
input[type="text"], select {
  font-family: var(--font-mono);
  font-size: 22px;
  color: var(--text);
  background: #081027;
  border: 2px solid var(--line);
  padding: 8px 10px;
  width: 100%;
}
input[type="text"]:focus, select:focus { outline: none; border-color: var(--yellow); }

/* ---------- game screen ---------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.status { color: var(--yellow); 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%;
  background: #000;
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
}
#stage canvas {
  display: block;
  background: #000;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
}
#stage:fullscreen { border: 0; background: #000; }

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(8, 16, 39, 0.82);
  padding: 24px;
  text-align: center;
}
#overlay-text { font-size: 24px; line-height: 1.4; }
#overlay-text code {
  font-family: var(--font-mono);
  color: var(--yellow);
  background: #000;
  padding: 4px 8px;
  user-select: all;
  word-break: break-all;
}
#overlay-buttons { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.lobby {
  margin-top: 12px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.lobby code {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--yellow);
  background: #000;
  padding: 4px 8px;
  user-select: all;
  word-break: break-all;
}

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

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

@media (max-width: 640px) {
  html, body { font-size: 18px; }
  .screen { padding: 20px; }
  h1.logo { font-size: 28px; }
}
