:root {
  --bg: #050912;
  --fg: #cbd5e1;
  --accent: #6ee7ff;
  --accent2: #ff79f0;
  --red: #ff5566;
  --blue: #66aaff;
  --yellow: #ffd24a;
  --green: #6efbb0;
  --panel: rgba(8, 14, 28, 0.85);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; width: 100%;
  background: var(--bg); color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: hidden;
  user-select: none;
}

canvas#game {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; image-rendering: pixelated;
  background:
    radial-gradient(ellipse at 30% 20%, #0a1330 0%, #050912 60%),
    radial-gradient(ellipse at 70% 80%, #1a0a2a 0%, transparent 60%);
}

.hidden { display: none !important; }

.overlay {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(5,9,18,0.62) 0%, rgba(0,0,0,0.85) 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
}

.card {
  background: var(--panel);
  border: 1px solid #2a3656;
  border-radius: 8px;
  padding: 24px 32px;
  width: min(560px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 0 60px rgba(110, 231, 255, 0.15);
}

.logo {
  margin: 0 0 4px 0;
  letter-spacing: 8px;
  font-weight: 900;
  font-size: 38px;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(110, 231, 255, 0.6);
  text-align: center;
}
.tagline { color: #889; margin: 0 0 18px; text-align: center; }

label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: #9ab;
}
input[type=text], #nameInput, #chatInput {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: #0a1224;
  border: 1px solid #2a3656;
  border-radius: 4px;
  color: var(--fg);
  font: inherit;
  font-size: 16px;
}
input:focus { outline: 1px solid var(--accent); }

.modeBtn {
  display: block; width: 100%;
  padding: 14px 12px;
  background: linear-gradient(180deg, #11203c, #0a1224);
  border: 1px solid #2a3656;
  border-radius: 4px;
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s, border-color 0.15s;
  margin-bottom: 8px;
}
.modeBtn:hover { border-color: var(--accent); transform: translateY(-1px); }
.modeBtn.tutorial { background: linear-gradient(180deg, #1a2a44, #0e1a2e); border-color: #3a5; }

/* Lobby */
.lobbyHeader {
  display: flex; align-items: center; justify-content: space-between;
  margin: 14px 0 8px;
}
.lobbyHeader h3 { margin: 0; font-size: 14px; color: #9ab; letter-spacing: 1px; }
.primaryBtn {
  padding: 8px 14px;
  background: linear-gradient(180deg, #1f3a5e, #122541);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--accent);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.15s;
}
.primaryBtn:hover { transform: translateY(-1px); box-shadow: 0 0 12px rgba(110,231,255,0.35); }

.gameList {
  max-height: 220px; overflow-y: auto;
  border: 1px solid #2a3656; border-radius: 4px;
  background: #0a1224;
  margin-bottom: 12px;
}
.gameList .empty {
  padding: 18px 12px; text-align: center;
  color: #667; font-size: 13px;
}
.gameRow {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px; align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid #1a2540;
  cursor: pointer;
  transition: background 0.1s;
}
.gameRow:last-child { border-bottom: none; }
.gameRow:hover { background: rgba(110,231,255,0.06); }
.gameRow .name   { color: var(--fg); font-weight: 600; font-size: 14px; }
.gameRow .meta   { color: #889; font-size: 11px; margin-top: 2px; letter-spacing: 0.5px; }
.gameRow .mode   { color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: 1px; }
.gameRow .count  { color: var(--yellow); font-size: 12px; font-variant-numeric: tabular-nums; }

#createForm {
  background: #0a1224; border: 1px solid #2a3656;
  border-radius: 4px; padding: 12px 14px; margin-bottom: 12px;
}
#createForm label { margin-bottom: 10px; }
#createForm select {
  width: 100%; margin-top: 6px;
  padding: 8px 10px;
  background: #050912; color: var(--fg);
  border: 1px solid #2a3656; border-radius: 4px;
  font: inherit; font-size: 14px;
}
#createForm .checkbox {
  display: flex; align-items: center; gap: 8px;
  color: var(--fg); font-size: 13px; margin-bottom: 12px;
}
#createForm .checkbox input { width: auto; margin: 0; }
.formButtons {
  display: flex; justify-content: flex-end; gap: 8px;
}
.formButtons button {
  padding: 8px 14px;
  background: #11203c; border: 1px solid #2a3656;
  border-radius: 4px; color: var(--fg);
  font: inherit; font-size: 13px; cursor: pointer;
}
.formButtons button.primaryBtn { background: linear-gradient(180deg, #1f3a5e, #122541); border-color: var(--accent); color: var(--accent); }

/* Store */
.store { margin-top: 14px; font-size: 13px; color: #aab; }
.storeHeader { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.storeHeader h3 { margin: 0; font-size: 14px; color: #9ab; letter-spacing: 1px; }
.loadoutPreview {
  display: flex; gap: 6px; align-items: center;
}
.loadoutPreview .slot {
  width: 36px; height: 36px;
  background: #060a16;
  border: 1px solid #2a3656;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
}
.loadoutPreview .slot.empty { opacity: 0.35; font-size: 18px; color: #556; }
.loadoutPreview canvas { display: block; width: 32px; height: 32px; }

.storeTabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid #2a3656;
  margin-bottom: 8px;
}
.storeTabs .tab {
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #889;
  font: inherit; font-size: 13px; cursor: pointer;
  transition: color 0.1s, border-color 0.1s;
}
.storeTabs .tab:hover { color: var(--fg); }
.storeTabs .tab.active { color: var(--accent); border-bottom-color: var(--accent); }

#storeGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 8px;
  max-height: 300px; overflow-y: auto;
}
.storeItem {
  background: #0a1224; border: 1px solid #2a3656; border-radius: 4px;
  padding: 8px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.storeItem canvas { background: #060a16; border-radius: 3px; }
.storeItem .name { font-size: 11px; color: var(--fg); text-align: center; line-height: 1.2; }
.storeItem .cost { font-size: 12px; color: var(--yellow); display: flex; align-items: center; gap: 4px; }
.storeItem button {
  width: 100%;
  padding: 5px 6px;
  background: #11203c; border: 1px solid #2a3656;
  border-radius: 3px; color: var(--fg);
  font: inherit; font-size: 11px; cursor: pointer;
}
.storeItem button.buy { border-color: var(--yellow); color: var(--yellow); }
.storeItem button.buy:disabled { opacity: 0.4; cursor: not-allowed; }
.storeItem button.equipped { border-color: var(--green); color: var(--green); }
.storeItem button:hover:not(:disabled) { background: #182b4a; }
.storeItem.equippedItem { border-color: var(--green); }
.storeNote { font-size: 11px; color: #667; margin-top: 6px; text-align: right; }

.instructions { font-size: 13px; color: #aab; }
.instructions summary { cursor: pointer; padding: 6px 0; color: var(--accent); }
.instructions ul { padding-left: 18px; line-height: 1.7; }
.instructions b { color: var(--yellow); }
.instructions .hint { color: #8a9; font-size: 12px; }

.credit {
  margin: 18px 0 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: #667;
}

#hud {
  position: absolute; inset: 0; pointer-events: none; z-index: 10;
}
#topbar {
  position: absolute; top: 8px; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 16px;
  font-size: 14px;
}
#modeLabel { color: var(--accent); font-weight: 700; letter-spacing: 2px; }
#scoreboardTop { background: var(--panel); padding: 6px 14px; border-radius: 4px; border: 1px solid #2a3656; }
#scoreboardTop .red { color: var(--red); font-weight: bold; }
#scoreboardTop .blue { color: var(--blue); font-weight: bold; }
#timer { background: var(--panel); padding: 6px 12px; border-radius: 4px; border: 1px solid #2a3656; min-width: 70px; text-align: center; }

#topbarRight { display: flex; align-items: center; gap: 10px; pointer-events: auto; }
#volumeControl {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel); padding: 4px 10px; border-radius: 4px;
  border: 1px solid #2a3656;
}
#volumeIcon {
  background: none; border: none; padding: 0; margin: 0;
  color: var(--fg); font-size: 14px; cursor: pointer; line-height: 1;
}
#volumeIcon:hover { color: var(--accent); }
#volumeSlider {
  -webkit-appearance: none; appearance: none;
  width: 90px; height: 4px;
  background: #2a3656; border-radius: 2px;
  cursor: pointer;
}
#volumeSlider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: none; cursor: pointer;
  box-shadow: 0 0 6px rgba(110, 231, 255, 0.6);
}
#volumeSlider::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: none; cursor: pointer;
  box-shadow: 0 0 6px rgba(110, 231, 255, 0.6);
}

#healthBarWrap {
  position: absolute; bottom: 16px; left: 16px;
  width: 240px; height: 22px;
  background: rgba(0,0,0,0.6); border: 1px solid #2a3656; border-radius: 3px;
  overflow: hidden;
}
#healthBar {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--green), var(--yellow));
  transition: width 0.15s, background 0.15s;
}
#healthText {
  position: absolute; inset: 0; line-height: 22px;
  text-align: center; font-size: 12px; color: #fff; text-shadow: 0 0 4px #000;
}

#upgradePanel {
  position: absolute; bottom: 46px; left: 16px;
  background: var(--panel); padding: 6px 10px; border-radius: 4px;
  border: 1px solid #2a3656;
  font-size: 11px;
  max-width: 240px;
}
#upgradePanel .row { display: flex; justify-content: space-between; gap: 12px; }
#upgradePanel .lvl { color: var(--accent); }

#centerMsg {
  position: absolute; top: 30%; left: 0; right: 0; text-align: center;
  font-size: 24px; color: var(--yellow);
  text-shadow: 0 0 16px rgba(255, 210, 74, 0.6);
  pointer-events: none;
  font-weight: bold; letter-spacing: 2px;
}

#killfeed {
  position: absolute; top: 50px; right: 16px;
  width: 260px;
  font-size: 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.killfeed-item {
  background: var(--panel); padding: 4px 8px; border-radius: 3px;
  border-left: 3px solid var(--accent);
}
.killfeed-item.red { border-left-color: var(--red); }
.killfeed-item.blue { border-left-color: var(--blue); }

#chatBox {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  width: 380px; pointer-events: auto;
}
#chatInput { font-size: 13px; }

#scoreboard {
  position: absolute; top: 80px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid #2a3656;
  padding: 16px 24px; border-radius: 6px;
  min-width: 380px;
  font-size: 13px;
  pointer-events: auto;
}
#scoreboard h3 { margin: 0 0 8px; color: var(--accent); letter-spacing: 2px; font-size: 14px; }
#scoreboard table { width: 100%; border-collapse: collapse; }
#scoreboard td, #scoreboard th { padding: 4px 8px; text-align: left; }
#scoreboard th { color: #99a; font-weight: normal; border-bottom: 1px solid #2a3656; }
#scoreboard .red { color: var(--red); }
#scoreboard .blue { color: var(--blue); }

#liveLeaderboard {
  position: absolute; top: 230px; right: 12px;
  width: 220px;
  background: var(--panel); border: 1px solid #2a3656;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 12px;
  pointer-events: none;
}
#liveLeaderboard .lbTitle {
  color: var(--accent);
  letter-spacing: 2px;
  font-weight: bold;
  font-size: 11px;
  margin-bottom: 4px;
  text-align: center;
}
#liveLeaderboard table { width: 100%; border-collapse: collapse; }
#liveLeaderboard td { padding: 2px 4px; }
#liveLeaderboard td:first-child { color: #99a; width: 18px; text-align: right; }
#liveLeaderboard td:nth-child(2) { color: var(--fg); }
#liveLeaderboard td:nth-child(3) { color: var(--yellow); text-align: right; width: 32px; }
#liveLeaderboard td:nth-child(4) { color: #889; text-align: right; width: 50px; font-size: 10px; }

#tutorialPanel {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid #3a5;
  padding: 12px 18px; border-radius: 6px;
  font-size: 14px;
  max-width: 480px;
}
#tutorialPanel h4 { margin: 0 0 6px; color: var(--green); }
#tutorialPanel .step { color: var(--yellow); }
#tutorialPanel .check { color: var(--green); }

/* Q currency — geometric Q glyph with two vertical bars overlaid,
   mimicking the way $ has two strokes through its S. */
.qsym {
  position: relative;
  display: inline-block;
  font: 700 1em "Bahnschrift", "Eurostile", "Tahoma", sans-serif;
  color: var(--yellow);
  padding: 0 0.2em;
}
.qsym::before, .qsym::after {
  content: "";
  position: absolute;
  top: -0.04em;
  bottom: 0.04em;
  width: 0.07em;
  background: currentColor;
}
.qsym::before { left: 0.34em; }
.qsym::after  { right: 0.34em; }

#qBalance {
  position: absolute;
  top: 14px;
  right: 18px;
  font-size: 18px;
  color: var(--yellow);
  letter-spacing: 1px;
  text-shadow: 0 0 6px rgba(255, 210, 74, 0.35);
  z-index: 21;
}
#qBalance .amount { margin-left: 4px; }
