:root {
  --sol-green: #14F195;
  --sol-purple: #9945FF;
  --bg: #07060d;
  --panel: rgba(18, 16, 32, 0.72);
  --panel-border: rgba(153, 69, 255, 0.35);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: #fff;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

canvas#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: crosshair;
}

.hidden { display: none !important; }

/* ── Lobby ──────────────────────────────────────────────── */
#lobby {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 30% 20%, rgba(153, 69, 255, 0.25), transparent 45%),
    radial-gradient(circle at 75% 75%, rgba(20, 241, 149, 0.18), transparent 45%),
    #07060d;
  z-index: 50;
}

.lobby-card {
  width: min(92vw, 420px);
  max-height: 94vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  padding: 30px 28px;
  backdrop-filter: blur(14px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

/* Lobby: explainer panel beside the join card */
.lobby-row {
  display: flex;
  gap: 18px;
  align-items: stretch;
  justify-content: center;
  width: min(96vw, 800px);
  max-height: 94vh;
}
.lobby-explainer {
  flex: 0 0 auto;
  width: 332px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  padding: 26px 22px;
  backdrop-filter: blur(14px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.exp-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; opacity: 0.6; margin-bottom: 16px; }
.exp-item { display: flex; gap: 11px; margin-bottom: 15px; }
.exp-ic { font-size: 19px; line-height: 1.2; flex: 0 0 auto; }
.exp-item > div > b { display: block; font-size: 13.5px; margin-bottom: 2px; color: #fff; }
.exp-item p { font-size: 12.5px; line-height: 1.5; opacity: 0.72; margin: 0; }
.exp-item p b { color: var(--sol-green); }

.lobby-banner {
  display: block;
  width: 100%;
  border-radius: 14px;
  margin-bottom: 14px;
  box-shadow: 0 10px 30px rgba(153, 69, 255, 0.25);
}

@media (max-width: 780px) {
  .lobby-row { flex-direction: column; align-items: center; max-height: none; width: auto; }
  .lobby-explainer { width: min(92vw, 420px); order: 2; }
  .lobby-card { order: 1; }
}

.rewards-banner {
  text-align: center;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 16px;
  border: 1px solid rgba(20, 241, 149, 0.35);
  background: linear-gradient(180deg, rgba(20,241,149,0.10), rgba(153,69,255,0.08));
}
.rewards-banner .rb-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.7; }
.rewards-banner .rb-total { font-size: 30px; font-weight: 700; margin-top: 2px; }
.rewards-banner .rb-total b {
  background: linear-gradient(90deg, var(--sol-green), var(--sol-purple));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.rewards-banner .rb-sub { font-size: 11px; opacity: 0.55; margin-top: 2px; }

.lobby-logo {
  display: block;
  width: 92px;
  height: 92px;
  margin: 0 auto 8px;
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(153, 69, 255, 0.4);
}

.logo {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  background: linear-gradient(90deg, var(--sol-green), var(--sol-purple));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 18px rgba(153, 69, 255, 0.4));
}
.logo span { -webkit-text-fill-color: #fff; }

.tagline {
  text-align: center;
  font-size: 13.5px;
  opacity: 0.78;
  margin: 10px 0 18px;
  line-height: 1.5;
}
.tagline b { color: var(--sol-green); }

.gate {
  font-size: 12.5px;
  text-align: center;
  padding: 9px 12px;
  border-radius: 12px;
  margin-bottom: 16px;
  border: 1px dashed var(--panel-border);
  background: rgba(153, 69, 255, 0.08);
  opacity: 0.95;
}
.gate.demo { border-color: rgba(20,241,149,0.4); background: rgba(20,241,149,0.07); }

.field { display: block; margin-bottom: 14px; }
.field span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.6;
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus { border-color: var(--sol-green); }

.skins { display: flex; flex-wrap: wrap; gap: 8px; }
.skins .swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s, border-color 0.1s;
}
.skins .swatch:hover { transform: scale(1.12); }
.skins .swatch.sel { border-color: #fff; box-shadow: 0 0 10px currentColor; transform: scale(1.12); }

#playBtn {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
  font-family: inherit;
  cursor: pointer;
  color: #06110b;
  background: linear-gradient(90deg, var(--sol-green), var(--sol-purple));
  box-shadow: 0 10px 30px rgba(20, 241, 149, 0.25);
  transition: transform 0.08s, filter 0.15s;
}
#playBtn:hover { filter: brightness(1.08); }
#playBtn:active { transform: translateY(1px); }
#playBtn:disabled { opacity: 0.6; cursor: wait; }

.error { color: #ff6b81; font-size: 13px; text-align: center; min-height: 18px; margin-top: 10px; }

.how {
  margin-top: 18px;
  display: grid;
  gap: 6px;
  font-size: 12px;
  opacity: 0.65;
  text-align: center;
}
.how b { color: var(--sol-green); }

.winners { margin-top: 18px; border-top: 1px solid rgba(255,255,255,0.08); padding-top: 14px; }
.winners-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.6; margin-bottom: 8px; }
.winners ol { list-style: none; display: grid; gap: 5px; }
.winners li { font-size: 13px; display: flex; justify-content: space-between; opacity: 0.9; }
.winners li .w-name { color: var(--sol-green); }

#recentRounds { display: grid; gap: 10px; max-height: 220px; overflow-y: auto; }
.round-block { border-left: 2px solid var(--panel-border); padding-left: 8px; }
.round-head { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.5; margin-bottom: 3px; }
.round-block ol { list-style: none; display: grid; gap: 3px; }
.round-block li { font-size: 12.5px; display: flex; justify-content: space-between; opacity: 0.9; }
.round-block li .w-name { color: var(--sol-green); }

.footer { margin-top: 20px; font-size: 11px; opacity: 0.4; }

/* ── HUD ────────────────────────────────────────────────── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 20; }

#urgentVignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 22;
  /* Static shadow; opacity is pulsed from the rAF loop (no infinite CSS animation). */
  box-shadow: inset 0 0 130px 24px rgba(255, 77, 109, 0.5);
  will-change: opacity;
}

#topbar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
}
.pill {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 8px 16px;
  text-align: center;
  backdrop-filter: blur(10px);
  min-width: 84px;
}
.pill .label { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.55; }
.conn-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--sol-green);
  box-shadow: 0 0 6px var(--sol-green);
  margin-right: 4px;
  vertical-align: middle;
}
.conn-dot.off { background: #ff4d6d; box-shadow: 0 0 6px #ff4d6d; animation: pulse 1s infinite; }
.pill .value { display: block; font-size: 20px; font-weight: 700; }
#roundPill .value { color: var(--sol-green); }
.icon-pill {
  pointer-events: auto;
  cursor: pointer;
  font-family: inherit;
  font-size: 20px;
  min-width: 0;
  width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.icon-pill.muted { opacity: 0.5; }
#roundPill.urgent .value { color: #ff6b81; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

#leaderboard {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 210px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px;
  backdrop-filter: blur(10px);
}
.lb-title { font-size: 13px; font-weight: 700; margin-bottom: 10px; }
#lbList { list-style: none; display: grid; gap: 5px; }
#lbList li {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  padding: 3px 6px;
  border-radius: 7px;
}
#lbList li .rank { opacity: 0.5; width: 18px; }
#lbList li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0 6px; }
#lbList li .sc { font-weight: 700; }
#lbList li.me { background: rgba(20, 241, 149, 0.14); }
#lbList li.top3 .nm { color: var(--sol-green); }
#myRankRow {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 5px 6px;
  border-top: 1px dashed rgba(255,255,255,0.15);
  font-size: 12.5px;
  background: rgba(20, 241, 149, 0.14);
  border-radius: 0 0 7px 7px;
}
#myRankRow .arrow { color: var(--sol-green); animation: rankBob 1.2s ease-in-out infinite; }
@keyframes rankBob { 50% { transform: translateY(2px); } }
#myRankRow .rank { opacity: 0.6; min-width: 22px; }
#myRankRow .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0 4px; color: var(--sol-green); }
#myRankRow .sc { font-weight: 700; }

.lb-note { margin-top: 10px; font-size: 10.5px; opacity: 0.5; line-height: 1.4; }

#settingsPanel {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px 14px;
  backdrop-filter: blur(10px);
  min-width: 190px;
}
.set-title { font-size: 12px; font-weight: 700; opacity: 0.7; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px; }
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px;
  font-size: 14px;
  cursor: pointer;
}
.set-row input { width: 18px; height: 18px; accent-color: var(--sol-green); cursor: pointer; }

#minimapWrap {
  position: absolute;
  bottom: 14px;
  right: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 6px;
  backdrop-filter: blur(10px);
}
#minimap { display: block; border-radius: 8px; }

#killFeed {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 260px;
}
.kill-item {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.08);
  border-left: 3px solid var(--sol-purple);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
  backdrop-filter: blur(8px);
  animation: killIn 0.25s ease;
  transition: opacity 0.5s;
}
.kill-item.you-killed { border-left-color: var(--sol-green); }
.kill-item.you-died { border-left-color: #ff4d6d; }
.kill-item .k { color: var(--sol-green); font-weight: 700; }
.kill-item .v { color: #ff8fa3; font-weight: 700; }
.kill-item.fading { opacity: 0; }
@keyframes killIn { from { transform: translateX(-12px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

#boostBtn {
  position: absolute;
  bottom: 26px;
  left: 26px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 2px solid var(--sol-green);
  background: rgba(20, 241, 149, 0.12);
  color: var(--sol-green);
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: transform 0.08s, background 0.12s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}
#boostBtn.active {
  background: var(--sol-green);
  color: #06110b;
  transform: scale(0.92);
  box-shadow: 0 0 30px rgba(20, 241, 149, 0.6);
}
#boostBtn.disabled { opacity: 0.35; border-color: rgba(255,255,255,0.25); color: rgba(255,255,255,0.5); }

/* Boost button is mainly for touch; hide on wide non-touch screens. */
@media (hover: hover) and (min-width: 760px) {
  #boostBtn { opacity: 0.5; width: 76px; height: 76px; font-size: 12px; }
}

#playerBadge {
  position: absolute;
  left: 14px;
  bottom: 132px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 8px 12px;
  backdrop-filter: blur(10px);
  font-size: 12.5px;
  max-width: 250px;
}
#playerBadge .pb-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
  flex: none;
}
#pbName { font-weight: 700; white-space: nowrap; }
#pbWallet { opacity: 0.55; font-family: ui-monospace, monospace; font-size: 11px; }
#pbLen { color: var(--sol-green); font-weight: 700; margin-left: 4px; }
#pbLen::before { content: '· '; color: rgba(255,255,255,0.4); }

#multiKill {
  position: absolute;
  top: 28%;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 2px;
  text-align: center;
  white-space: nowrap;
  background: linear-gradient(90deg, #FFD166, #FF4D6D, #9945FF);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 18px rgba(255, 77, 109, 0.5));
  animation: mkPop 0.4s cubic-bezier(0.2, 1.4, 0.5, 1);
}
@keyframes mkPop { from { transform: translateX(-50%) scale(0.5); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

#toast {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  border: 1px solid var(--panel-border);
  padding: 12px 22px;
  border-radius: 14px;
  font-size: 15px;
  opacity: 0;
  transition: opacity 0.3s;
  text-align: center;
  max-width: 80vw;
}
#toast.show { opacity: 1; }

/* ── Death screen ───────────────────────────────────────── */
#roundWinOverlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.rw-card {
  background: rgba(18, 16, 32, 0.45); /* more see-through than the standard panel — game shows through */
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  padding: 26px 34px;
  text-align: center;
  backdrop-filter: blur(10px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 40px rgba(153, 69, 255, 0.3);
  animation: rwPop 0.4s cubic-bezier(0.2, 1.3, 0.5, 1);
}
@keyframes rwPop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.rw-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
  background: linear-gradient(90deg, var(--sol-green), var(--sol-purple));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
#rwPodium { list-style: none; display: grid; gap: 8px; min-width: 240px; }
#rwPodium li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
}
#rwPodium li .medal { font-size: 20px; }
#rwPodium li .rw-name { flex: 1; text-align: left; font-weight: 600; }
#rwPodium li .rw-score { color: var(--sol-green); font-weight: 700; }
#rwPodium li.rank1 { background: rgba(255, 209, 102, 0.14); border: 1px solid rgba(255, 209, 102, 0.35); }
.rw-sub { margin-top: 14px; font-size: 12px; opacity: 0.6; }

#spectateBar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 10px 14px;
  backdrop-filter: blur(10px);
  font-size: 14px;
}
#spectateBar .spec-eye { font-size: 16px; }
#spectateBar b { color: var(--sol-green); }
#spectateBar button {
  border: none;
  border-radius: 9px;
  padding: 8px 16px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  color: #06110b;
  background: linear-gradient(90deg, var(--sol-green), var(--sol-purple));
}
#specNextBtn {
  background: transparent;
  color: #fff;
  border: 1px solid var(--panel-border);
}

#deathScreen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 6, 13, 0.78);
  backdrop-filter: blur(6px);
  z-index: 40;
}
.death-card {
  width: min(90vw, 360px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 28px;
  text-align: center;
}
.death-card h2 { font-size: 30px; color: #ff6b81; margin-bottom: 6px; }
.death-card p { opacity: 0.7; font-size: 14px; margin-bottom: 14px; }
.death-score { font-size: 16px; margin-bottom: 20px; }
.death-score b { color: var(--sol-green); font-size: 24px; }
.death-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 6px 0 22px;
}
.death-stats .stat {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.death-stats .s-val { font-size: 22px; font-weight: 700; color: var(--sol-green); }
.death-stats .s-lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.55; }
.death-card button {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 10px;
  color: #06110b;
  background: linear-gradient(90deg, var(--sol-green), var(--sol-purple));
}
.death-card button.ghost {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
}

@media (max-width: 560px) {
  #leaderboard { width: 150px; padding: 10px; }
  .pill { min-width: 66px; padding: 6px 10px; }
  .pill .value { font-size: 16px; }
  #minimapWrap { transform: scale(0.8); transform-origin: bottom right; }
}
