:root {
  --bg: #07070f;
  --surface: #0d0d1f;
  --border: #1e1e40;
  --text: #dde0ff;
  --muted: #5050a0;
  --accent: #7f5af0;
  --accent2: #2cb67d;
  --red: #ff3366;
  --blue: #3399ff;
  --glow-accent: rgba(127,90,240,0.5);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', Courier, monospace;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  user-select: none;
}

/* ── SCREENS ── */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }

/* ── LOBBY ── */
.lobby-wrap { width: 960px; max-width: 96vw; }

.game-title {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 900;
  letter-spacing: .35em;
  text-align: center;
  margin-bottom: 2.5rem;
  color: #fff;
  text-shadow: 0 0 20px var(--accent), 0 0 60px var(--glow-accent);
}
.game-title span { color: var(--accent); }

.lobby-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mode-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 16px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  position: relative;
}
.mode-card:hover:not(.locked) { border-color: var(--accent); box-shadow: 0 0 12px var(--glow-accent); }
.mode-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 18px var(--glow-accent), inset 0 0 20px rgba(127,90,240,.08);
}
.mode-card.locked { opacity: .35; cursor: default; }
.mode-icon { font-size: 1.6rem; margin-bottom: 6px; }
.mode-name { font-size: .75rem; font-weight: 700; letter-spacing: .12em; color: #fff; margin-bottom: 4px; }
.mode-desc { font-size: .68rem; color: var(--muted); }

.lobby-right { display: flex; flex-direction: column; gap: 16px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.panel-label {
  font-size: .65rem;
  letter-spacing: .15em;
  color: var(--muted);
  margin-bottom: 10px;
}
.muted { color: var(--muted); }

.color-row { display: flex; gap: 10px; flex-wrap: wrap; }
.color-dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--c);
  cursor: pointer;
  border: 2px solid transparent;
  box-shadow: 0 0 8px var(--c);
  transition: transform .1s, border-color .1s;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.selected { border-color: #fff; transform: scale(1.2); }

.room-list { display: flex; flex-direction: column; gap: 6px; }
.room-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  background: rgba(255,255,255,.03);
  border-radius: 4px;
  cursor: pointer;
  transition: background .1s;
}
.room-row:hover { background: rgba(127,90,240,.15); }
.room-name { font-size: .75rem; }
.room-info { font-size: .65rem; color: var(--muted); }

/* ── LOBBY INPUTS ── */
.lobby-input {
  width: 100%;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: .8rem;
  letter-spacing: .08em;
  outline: none;
  transition: border-color .15s;
}
.lobby-input:focus { border-color: var(--accent); }
.lobby-input::placeholder { color: var(--muted); }

.code-input { text-transform: uppercase; letter-spacing: .2em; }

.join-row {
  display: flex;
  gap: 8px;
}
.join-row .lobby-input { flex: 1; }

.lobby-error {
  font-size: .7rem;
  color: var(--red);
  padding: 6px 0;
  letter-spacing: .05em;
}

/* ── WAITING ROOM ── */
.lobby-waiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 20px 0;
}

.room-code-box {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 16px 28px;
  box-shadow: 0 0 20px var(--glow-accent);
}
.room-code-label {
  font-size: .65rem;
  letter-spacing: .2em;
  color: var(--muted);
}
.room-code-val {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: .35em;
  color: #fff;
  text-shadow: 0 0 16px var(--accent);
}

.waiting-player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 360px;
}
.waiting-player-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
}
.wp-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.wp-name {
  flex: 1;
  font-size: .78rem;
  color: var(--text);
}
.wp-status {
  font-size: .65rem;
  letter-spacing: .12em;
  color: var(--muted);
}
.wp-status.ready { color: var(--accent2); }

.waiting-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.waiting-hint {
  font-size: .65rem;
  color: var(--muted);
  letter-spacing: .06em;
  text-align: center;
}

/* ── EQUIPMENT ── */
.equip-wrap { width: 860px; max-width: 96vw; }

.screen-title {
  font-size: 1.6rem;
  letter-spacing: .25em;
  text-align: center;
  margin-bottom: 2rem;
  color: #fff;
  text-shadow: 0 0 20px var(--accent);
}

.equip-body { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.equip-col { display: flex; flex-direction: column; gap: 10px; }
.equip-label {
  font-size: .65rem;
  letter-spacing: .18em;
  color: var(--muted);
  margin-bottom: 4px;
}

.weapon-cards, .ability-cards { display: flex; flex-direction: column; gap: 8px; }

.wcard, .acard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.wcard:hover, .acard:hover { border-color: var(--accent); }
.wcard.selected, .acard.selected {
  border-color: var(--accent);
  box-shadow: 0 0 14px var(--glow-accent);
}

.wcard-name, .acard-name {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: #fff;
  margin-bottom: 8px;
}
.wcard-desc, .acard-desc { font-size: .65rem; color: var(--muted); margin-top: 6px; }

.wcard-bars { display: flex; flex-direction: column; gap: 4px; }
.wbar-row { display: flex; align-items: center; gap: 8px; font-size: .6rem; color: var(--muted); }
.wbar-row span { width: 42px; }
.wbar { flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.wbar div { height: 100%; background: var(--accent); border-radius: 2px; }

.acard { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 4px 8px; }
.acard-name { font-size: .8rem; font-weight: 700; letter-spacing: .1em; color: #fff; }
.acard-cd { font-size: .65rem; color: var(--accent2); text-align: right; align-self: start; }
.acard-desc { font-size: .65rem; color: var(--muted); grid-column: 1 / -1; }

.equip-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* ── BUTTONS ── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 12px 28px;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .15em;
  cursor: pointer;
  box-shadow: 0 0 16px var(--glow-accent);
  transition: box-shadow .15s, transform .1s;
}
.btn-primary:hover { box-shadow: 0 0 28px var(--glow-accent); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 28px;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .15em;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.btn-secondary:hover { color: var(--text); border-color: var(--muted); }

.btn-small {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: .65rem;
  letter-spacing: .1em;
  cursor: pointer;
  transition: color .15s;
}
.btn-small:hover { color: var(--text); }

/* ── GAME SCREEN ── */
#screen-game { background: #000; }
#game-canvas { display: block; }

/* ── HUD ── */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 16px;
  pointer-events: none;
}

#hud-tl {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(7,7,15,.75);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
}
.hud-hp-label { font-size: .65rem; letter-spacing: .15em; color: var(--muted); }
.hud-hp-bar-wrap {
  width: 100px; height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
#hud-hp-bar {
  height: 100%;
  width: 100%;
  background: var(--accent2);
  border-radius: 3px;
  transition: width .1s, background .2s;
}
#hud-hp-val { font-size: .7rem; color: #fff; min-width: 28px; }

#hud-score {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(7,7,15,.75);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 20px;
}
.score-val { font-size: 1.6rem; font-weight: 900; letter-spacing: .05em; }
.score-red { color: var(--red); text-shadow: 0 0 12px var(--red); }
.score-blue { color: var(--blue); text-shadow: 0 0 12px var(--blue); }
.score-sep { font-size: 1.2rem; color: var(--muted); }

#hud-tr {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  background: rgba(7,7,15,.75);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
}
#hud-weapon-name { font-size: .7rem; font-weight: 700; letter-spacing: .12em; color: #fff; }
#hud-ability-slot { display: flex; align-items: center; gap: 6px; }
#hud-ability-key {
  width: 20px; height: 20px;
  background: var(--accent);
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: .6rem; font-weight: 700;
}
#hud-ability-name { font-size: .65rem; color: var(--muted); }
#hud-ability-cd { font-size: .65rem; color: var(--accent2); min-width: 24px; text-align: right; }

/* ── MESSAGES ── */
#game-msgs {
  position: absolute;
  bottom: 60px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.game-msg {
  background: rgba(7,7,15,.85);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 14px;
  font-size: .7rem;
  letter-spacing: .08em;
  color: #fff;
  animation: msg-fade 3s forwards;
}
@keyframes msg-fade {
  0% { opacity: 0; transform: translateY(8px); }
  15% { opacity: 1; transform: translateY(0); }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

/* ── MENU BUTTON ── */
#btn-menu {
  position: absolute;
  bottom: 16px;
  right: 16px;
}

/* ── GAME OVER ── */
#game-over {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.8);
  display: flex;
  align-items: center;
  justify-content: center;
}
#game-over.hidden { display: none; }
.gameover-box {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 40px 60px;
  text-align: center;
  box-shadow: 0 0 40px var(--glow-accent);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#gameover-text {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: .2em;
  color: #fff;
  text-shadow: 0 0 20px var(--accent);
}
