:root {
  --accent: #ffcb05;
  --panel: rgba(13, 20, 32, 0.82);
}

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

html, body {
  height: 100%;
  background: #06070a;
  color: #fff;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
}

#game-wrap {
  position: fixed;
  inset: 0;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #0d2738;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 12px 16px;
  pointer-events: none;
}
.hud-row { display: flex; gap: 12px; align-items: center; }
.hud-item {
  background: var(--panel);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 1px;
  color: #aeb8d0;
}
.hud-item span { color: var(--accent); margin-left: 6px; }
.icon-btn {
  pointer-events: auto;
  background: var(--panel);
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  box-shadow: none;
}
.icon-btn:hover { transform: none; }

#leaderboard {
  margin-top: 10px;
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  background: var(--panel);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  min-width: 160px;
}
.lb-row { display: flex; justify-content: space-between; gap: 14px; }
.lb-row.me { color: var(--accent); font-weight: bold; }
.lb-row .rank { color: #6b7a94; }

/* ---------- Health ---------- */
#healthbar {
  position: absolute;
  bottom: 18px; left: 50%;
  transform: translateX(-50%);
  width: 220px; height: 14px;
  background: var(--panel);
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #2b3550;
}
#healthfill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #ff4d4d, #ffcb05 55%, #4dff88);
  transition: width 0.12s ease;
}

#respawn {
  position: absolute;
  top: 42%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel);
  padding: 14px 26px;
  border-radius: 10px;
  font-size: 20px;
  font-weight: bold;
}

/* ---------- Share bar ---------- */
#share-bar {
  position: absolute;
  bottom: 16px; left: 16px;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}
#share-link {
  width: 220px;
  background: #0a0f18;
  border: 1px solid #2b3550;
  color: #cfe0ff;
  padding: 6px 8px;
  border-radius: 5px;
  font-size: 12px;
}
#copy-btn { padding: 6px 14px; font-size: 13px; box-shadow: 0 3px 0 #c79e00; }

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  padding: 24px;
  background: radial-gradient(circle at center, rgba(18, 34, 52, 0.86), rgba(6, 10, 16, 0.95));
  backdrop-filter: blur(2px);
}
.overlay h1 { font-size: clamp(42px, 9vw, 80px); letter-spacing: 4px; text-shadow: 0 5px 0 rgba(0,0,0,.35); }
.overlay h1 span { color: var(--accent); }
.overlay h2 { font-size: 40px; letter-spacing: 3px; }
.tagline { color: #9db0cc; max-width: 460px; line-height: 1.5; }
.muted { color: #8194b0; font-size: 14px; }

#name-input {
  background: #0a0f18;
  border: 2px solid #2b3550;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 18px;
  text-align: center;
  width: 240px;
}
#name-input:focus { outline: none; border-color: var(--accent); }

.btn-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.controls { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; color: #c4cde2; font-size: 14px; margin-top: 6px; }

kbd {
  display: inline-block;
  background: #2b3550;
  border-radius: 4px;
  padding: 1px 7px;
  margin: 0 1px;
  font-family: monospace;
  border-bottom: 2px solid #1a2034;
}

#final-board { list-style: none; display: flex; flex-direction: column; gap: 6px; min-width: 260px; }
#final-board li { display: flex; justify-content: space-between; background: var(--panel); padding: 8px 16px; border-radius: 6px; }
#final-board li.me { color: var(--accent); }

button {
  background: var(--accent);
  color: #14181f;
  border: none;
  padding: 14px 34px;
  font-size: 17px;
  font-weight: bold;
  letter-spacing: 2px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.2s ease;
  box-shadow: 0 6px 0 #c79e00;
}
button:hover { transform: translateY(-2px); }
button:active { transform: translateY(4px); box-shadow: 0 2px 0 #c79e00; }
button.secondary { background: #2b3550; color: #fff; box-shadow: 0 6px 0 #1a2034; }

/* ---------- Kill feed ---------- */
#killfeed {
  position: absolute;
  top: 12px; right: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-end;
  pointer-events: none;
  max-width: 50vw;
}
.kill-msg {
  background: var(--panel);
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: bold;
  color: #e6edf7;
  animation: killIn 0.2s ease;
}
.kill-msg.mine { color: var(--accent); box-shadow: 0 0 0 1px rgba(255,203,5,0.4); }
.kill-msg .vic { color: #ff8080; }
@keyframes killIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Touch controls ---------- */
#touch-controls { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.tbtn {
  position: absolute;
  pointer-events: auto;
  border: none;
  border-radius: 50%;
  font-weight: bold;
  color: #fff;
  background: rgba(43, 53, 80, 0.6);
  border: 2px solid rgba(255,255,255,0.25);
  box-shadow: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.tbtn:active { transform: scale(0.94); }
.tbtn.fire {
  right: 22px; bottom: 28px;
  width: 96px; height: 96px;
  font-size: 18px;
  background: rgba(255, 90, 70, 0.55);
  border-color: rgba(255,150,130,0.6);
}
.tbtn.boost {
  right: 130px; bottom: 46px;
  width: 74px; height: 74px;
  font-size: 13px;
  background: rgba(255, 200, 80, 0.5);
  border-color: rgba(255,220,140,0.6);
}
.tbtn.arrow {
  bottom: 36px;
  width: 80px; height: 80px;
  font-size: 30px;
}
#left-btn { left: 22px; }
#right-btn { left: 116px; }
.tbtn.recenter {
  left: 26px; bottom: 140px;
  width: 54px; height: 54px;
  font-size: 22px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #c4cde2;
  font-size: 15px;
  cursor: pointer;
}
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

.hidden { display: none !important; }
