:root {
  --bg: #0b0d14;
  --panel: #151926;
  --panel-alt: #1d2336;
  --border: #38435e;
  --accent: #f59e0b;
  --accent-hot: #ef4444;
  --text: #f1f5f9;
  --muted: #94a3b8;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, "Cascadia Mono", "Fira Code", Menlo, Consolas, monospace;
  overflow: hidden;
  user-select: none;
}

[hidden] {
  display: none !important;
}

/* LOBBY */
.lobby {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 20% 20%, rgba(245, 158, 11, 0.14), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(239, 68, 68, 0.12), transparent 45%),
    var(--bg);
  overflow-y: auto;
}

.lobby-card {
  width: min(980px, 100%);
  background: var(--panel);
  border: 3px solid var(--border);
  box-shadow: 0 0 0 3px #07090f, 0 18px 48px rgba(0, 0, 0, 0.65);
  padding: 20px;
}

.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--accent);
}

.lobby-header h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 1px;
}

.env-badge {
  font-size: 12px;
  padding: 6px 10px;
  border: 2px solid var(--border);
  background: var(--panel-alt);
}

.env-badge.ok {
  border-color: #22c55e;
  color: #86efac;
}

.env-badge.warn {
  border-color: #f59e0b;
  color: #fde047;
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 16px;
}

@media (max-width: 780px) {
  .lobby-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel-alt);
  border: 2px solid var(--border);
  padding: 14px;
}

.field-label {
  display: block;
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.pixel-input {
  width: 100%;
  padding: 9px 10px;
  background: #0d101a;
  color: var(--text);
  border: 2px solid var(--border);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.pixel-input:focus {
  border-color: var(--accent);
}

.class-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.class-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #111522;
  border: 2px solid var(--border);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.class-card:hover {
  border-color: #64748b;
}

.class-card.active {
  border-color: var(--accent);
  background: #1c2033;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.class-sprite {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  background-image: url("/sprites/heroes.png");
  background-size: 192px 192px;
  image-rendering: pixelated;
}

.class-title {
  font-weight: bold;
  font-size: 14px;
}

.class-desc {
  font-size: 11px;
  color: var(--muted);
  margin: 2px 0;
}

.class-stats {
  font-size: 10px;
  color: #cbd5e1;
}

.action-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.pixel-btn {
  flex: 1;
  padding: 12px 14px;
  font-family: inherit;
  font-weight: bold;
  font-size: 14px;
  border: 2px solid #000;
  cursor: pointer;
  letter-spacing: 0.5px;
}

.pixel-btn.primary {
  background: var(--accent);
  color: #141013;
  box-shadow: inset 0 -3px 0 #b45309;
}

.pixel-btn.primary:hover:not(:disabled) {
  background: #fbbf24;
}

.pixel-btn.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pixel-btn.secondary {
  background: #334155;
  color: var(--text);
  box-shadow: inset 0 -3px 0 #1e293b;
}

.pixel-btn.secondary:hover {
  background: #475569;
}

.msg {
  min-height: 18px;
  margin: 10px 0 0;
  font-size: 12px;
  color: #86efac;
}

.msg.error {
  color: #fca5a5;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.side-block {
  border-bottom: 1px solid #2b344d;
  padding-bottom: 10px;
}

.side-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.side-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 6px;
}

.muted {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.stats-line {
  margin: 6px 0 0;
  font-size: 12px;
  color: #fde68a;
}

.auth-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.auth-btns {
  display: flex;
  gap: 6px;
}

.mini-btn {
  padding: 5px 9px;
  background: #273147;
  color: var(--text);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
}

.mini-btn:hover {
  background: #364361;
}

.mini-btn.danger {
  background: #7f1d1d;
  border-color: #ef4444;
}

.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
}

.leaderboard-list li {
  display: flex;
  justify-content: space-between;
  background: #111522;
  padding: 5px 8px;
  border: 1px solid #263047;
}

.controls-box p {
  margin: 3px 0;
  font-size: 11px;
  color: #cbd5e1;
}

/* GAME HUD */
.hud {
  position: relative;
  width: 100%;
  height: 100%;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  cursor: crosshair;
}

.hud-top {
  position: fixed;
  top: 12px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.hud-vitals, .hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(11, 13, 20, 0.82);
  border: 2px solid var(--border);
  padding: 6px 10px;
  pointer-events: auto;
}

.hp-bar {
  width: 120px;
  height: 14px;
  background: #1e293b;
  border: 2px solid #000;
}

.hp-fill {
  height: 100%;
  width: 100%;
  background: #ef4444;
  transition: width 0.1s linear;
}

.pill {
  font-size: 12px;
  padding: 3px 7px;
  background: #1d2336;
  border: 1px solid var(--border);
}

.kill-feed {
  position: fixed;
  top: 64px;
  right: 14px;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
  align-items: flex-end;
}

.kill-feed li {
  background: rgba(11, 13, 20, 0.8);
  border-left: 3px solid var(--accent);
  padding: 4px 8px;
  font-size: 12px;
}

.kill-feed li.good {
  border-left-color: #22c55e;
  color: #bbf7d0;
}

.kill-feed li.bad {
  border-left-color: #ef4444;
  color: #fecaca;
}

.banner {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(11, 13, 20, 0.9);
  border: 3px solid var(--accent);
  padding: 12px 22px;
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 1px;
  color: #fef08a;
  pointer-events: none;
}

.chat-box {
  position: fixed;
  left: 14px;
  bottom: 14px;
  width: 300px;
  background: rgba(11, 13, 20, 0.72);
  border: 2px solid var(--border);
}

.chat-log {
  list-style: none;
  margin: 0;
  padding: 6px 8px;
  max-height: 120px;
  overflow-y: auto;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#chat-input {
  width: 100%;
  padding: 6px 8px;
  background: rgba(21, 25, 38, 0.9);
  border: none;
  border-top: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  outline: none;
}

.scoreboard {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, 92vw);
  background: rgba(15, 20, 32, 0.95);
  border: 3px solid var(--accent);
  padding: 16px;
}

.scoreboard h2 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--accent);
}

.scoreboard table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.scoreboard th, .scoreboard td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid #2b344d;
}

.scoreboard tr.me {
  color: #fde047;
  font-weight: bold;
}
