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

/* Theme palettes. "natural" is the default; [data-theme="neon"] restores the
   original neon look. --game-* vars are read by game.js for canvas drawing. */
:root {
  color-scheme: dark;
  --bg: #2c3827;
  --text: #efe8d5;
  --panel-bg: rgba(40, 48, 34, 0.78);
  --panel-border: rgba(170, 145, 100, 0.45);
  --panel-glow: rgba(0, 0, 0, 0.35);
  --hover-bg: rgba(217, 138, 61, 0.15);
  --accent: #d98a3d;
  --accent-glow: rgba(217, 138, 61, 0.5);
  --accent-hover: #e8a95e;
  --key-bg: rgba(217, 138, 61, 0.08);
  --key-border: rgba(217, 138, 61, 0.5);
  --key-text: #e0bf8f;
  --fart-fill: #7c944b;
  --fart-ready: #9db56a;
  --fart-glow: rgba(124, 148, 75, 0.5);
  --dodge-fill: #5d7d8c;
  --dodge-ready: #8aa7b3;
  --dodge-glow: rgba(93, 125, 140, 0.5);
  --gold: #cfa64e;
  --gold-glow: rgba(207, 166, 78, 0.8);
  --lime: #8ba45a;
  --lime-glow: rgba(139, 164, 90, 0.85);
  --success: #7d9455;
  --reload-fill: #a3573b;
  --reload-glow: rgba(163, 87, 59, 0.5);
  --reload-loaded-glow: rgba(125, 148, 85, 0.5);
  --reload-text: #ded5bd;
  --help: #b9b39e;
  --danger: #cf7a52;
  --danger-bg: rgba(120, 40, 20, 0.28);
  --danger-glow: rgba(0, 0, 0, 0.6);
  --restart-bg: #3c4433;
  --restart-hover: #474f3c;
  --restart-glow: rgba(0, 0, 0, 0.3);
  --restart-hover-glow: rgba(0, 0, 0, 0.45);
  --feed-bg: rgba(30, 36, 26, 0.7);
  --screen-bg: rgba(30, 36, 26, 0.94);
  --input-bg: #37402f;
  --input-border: rgba(170, 145, 100, 0.5);
  --game-bg: #2c3827;
  --game-grid: rgba(20, 28, 16, 0.35);
  --game-border: rgba(146, 109, 63, 0.9);
  --game-border-glow: #926d3f;
  --game-wood-fill: #8a5c30;
  --game-wood-stroke: #5e3c1e;
  --game-wood-cross: rgba(94, 60, 30, 0.5);
  --game-wood-cracks: #402a16;
  --game-rock-fill: #6f6b5e;
  --game-rock-stroke: #524f45;
  --game-rock-highlight: rgba(255, 255, 255, 0.1);
  --game-accent: #d98a3d;
  --game-accent-rgb: 217, 138, 61;
  --game-bush-fill: rgba(26, 42, 22, 0.95);
  --game-bush-highlight: rgba(120, 150, 80, 0.7);
  --game-bush-glow: #2f4526;
  --game-ghost: #cbbf9a;
  --game-barrel: #2c2018;
  --game-self-body: #efe8d5;
  --game-self-name: #e0bf8f;
  --game-name: rgba(240, 235, 220, 0.88);
  --game-danger: rgba(150, 60, 25, 0.9);
  --game-protect-rgb: 225, 215, 185;
}

:root[data-theme="neon"] {
  --bg: #05060f;
  --text: #eaffff;
  --panel-bg: rgba(5, 8, 22, 0.75);
  --panel-border: rgba(0, 240, 255, 0.35);
  --panel-glow: rgba(0, 240, 255, 0.12);
  --hover-bg: rgba(0, 240, 255, 0.12);
  --accent: #00f0ff;
  --accent-glow: rgba(0, 240, 255, 0.8);
  --accent-hover: #7ff7ff;
  --key-bg: rgba(0, 240, 255, 0.08);
  --key-border: rgba(0, 240, 255, 0.5);
  --key-text: #9ff7ff;
  --fart-fill: #9dff00;
  --fart-ready: #ccff33;
  --fart-glow: rgba(157, 255, 0, 0.6);
  --dodge-fill: #009dff;
  --dodge-ready: #7df9ff;
  --dodge-glow: rgba(0, 157, 255, 0.6);
  --gold: #ffe600;
  --gold-glow: rgba(255, 230, 0, 0.8);
  --lime: #b6ff2e;
  --lime-glow: rgba(182, 255, 46, 0.85);
  --success: #39ff88;
  --reload-fill: #ff1f6b;
  --reload-glow: rgba(255, 31, 107, 0.7);
  --reload-loaded-glow: rgba(57, 255, 136, 0.7);
  --reload-text: #bff6ff;
  --help: #8fd7ff;
  --danger: #ff4dd2;
  --danger-bg: rgba(255, 0, 90, 0.14);
  --danger-glow: rgba(255, 46, 136, 0.9);
  --restart-bg: #08210f;
  --restart-hover: #103a1c;
  --restart-glow: rgba(57, 255, 136, 0.25);
  --restart-hover-glow: rgba(57, 255, 136, 0.45);
  --feed-bg: rgba(3, 6, 18, 0.65);
  --screen-bg: rgba(3, 6, 16, 0.94);
  --input-bg: #0a0f22;
  --input-border: rgba(0, 240, 255, 0.4);
  --game-bg: #05060f;
  --game-grid: rgba(0, 240, 255, 0.07);
  --game-border: rgba(255, 47, 214, 0.75);
  --game-border-glow: #ff2fd0;
  --game-wood-fill: #241033;
  --game-wood-stroke: #ff8a00;
  --game-wood-cross: rgba(255, 138, 0, 0.35);
  --game-wood-cracks: #ffd166;
  --game-rock-fill: #0f1a33;
  --game-rock-stroke: #00e5ff;
  --game-rock-highlight: rgba(0, 229, 255, 0.14);
  --game-accent: #00f0ff;
  --game-accent-rgb: 0, 240, 255;
  --game-bush-fill: rgba(8, 60, 32, 0.9);
  --game-bush-highlight: rgba(80, 255, 150, 0.55);
  --game-bush-glow: #39ff88;
  --game-ghost: #7df9ff;
  --game-barrel: #1a1030;
  --game-self-body: #eaffff;
  --game-self-name: #9ff7ff;
  --game-name: rgba(210, 255, 255, 0.88);
  --game-danger: rgba(255, 46, 136, 0.9);
  --game-protect-rgb: 180, 255, 255;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  user-select: none;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  color: var(--text);
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 14px;
  box-shadow: 0 0 14px var(--panel-glow);
}

#topbar {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

#scorePanel {
  font-size: 22px;
  font-weight: 700;
}

#scoreVal {
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-glow);
}

.sub {
  display: block;
  font-size: 12px;
  font-weight: 400;
  opacity: 0.75;
}

#fartPanel {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.key {
  background: var(--key-bg);
  border: 1px solid var(--key-border);
  border-radius: 4px;
  padding: 0 5px;
  font-size: 11px;
  color: var(--key-text);
}

#fartBar {
  width: 180px;
  height: 10px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 5px;
  margin-top: 5px;
  overflow: hidden;
}

#fartFill {
  height: 100%;
  width: 0%;
  background: var(--fart-fill);
  box-shadow: 0 0 8px var(--fart-glow);
  transition: background 0.2s;
}

#fartBar.ready #fartFill {
  background: var(--fart-ready);
}

#dodgeBar {
  width: 120px;
  height: 10px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 5px;
  margin-top: 5px;
  overflow: hidden;
}

#dodgeFill {
  height: 100%;
  width: 0%;
  background: var(--dodge-fill);
  box-shadow: 0 0 8px var(--dodge-glow);
  transition: background 0.2s;
}

#dodgeBar.ready #dodgeFill {
  background: var(--dodge-ready);
}

#muteBtn, #themeSelect {
  pointer-events: auto;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 14px;
  box-shadow: 0 0 14px var(--panel-glow);
}

#muteBtn:hover, #themeSelect:hover {
  background: var(--hover-bg);
}

#buffPanel {
  position: absolute;
  top: 92px;
  left: 12px;
  display: none;
  min-width: 150px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

#buffList .buff {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 0;
}

#buffList .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

#buffList .t {
  opacity: 0.7;
  font-weight: 400;
}

#rightCol {
  position: absolute;
  top: 92px;
  right: 12px;
  width: 300px;
  max-height: calc(100% - 104px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#titlesPanel {
  min-width: 0;
  font-size: 13px;
  max-height: 40vh;
  overflow-y: auto;
}

.panelTitle {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.7;
  margin-bottom: 6px;
}

#titlesList {
  margin: 0;
  padding-left: 20px;
}

#titlesList li {
  padding: 2px 0;
  color: var(--gold);
  font-weight: 600;
  text-shadow: 0 0 8px var(--gold-glow);
}

#reloadWrap {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  text-align: center;
}

#reloadBar {
  width: 100%;
  height: 12px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  overflow: hidden;
}

#reloadFill {
  height: 100%;
  width: 100%;
  background: var(--reload-fill);
  box-shadow: 0 0 9px var(--reload-glow);
  transition: width 0.05s linear;
}

#reloadFill.loaded {
  background: var(--success);
  box-shadow: 0 0 9px var(--reload-loaded-glow);
}

#reloadText {
  margin-top: 4px;
  font-size: 12px;
  color: var(--reload-text);
  opacity: 0.85;
}

#killfeed {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
  font-size: 13px;
  min-height: 0;
  overflow-y: auto;
}

#killfeed .line {
  background: var(--feed-bg);
  border-radius: 4px;
  padding: 3px 8px;
}

#killfeed .you {
  color: var(--accent);
  font-weight: 700;
  text-shadow: 0 0 8px var(--accent-glow);
}

#help {
  position: absolute;
  bottom: 70px;
  left: 12px;
  max-width: calc(100% - 340px);
  font-size: 12px;
  color: var(--help);
  opacity: 0.6;
}

#respawnOverlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: var(--danger-bg);
  font-size: 42px;
  font-weight: 800;
  color: var(--danger);
  text-shadow: 0 0 18px var(--danger-glow), 0 2px 8px #000;
}

#respawnOverlay .sub2 {
  font-size: 18px;
  font-weight: 400;
  margin-top: 10px;
}

#announce {
  position: absolute;
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}

#announce.show {
  opacity: 1;
}

#announce .label {
  font-size: 20px;
  letter-spacing: 3px;
  color: var(--lime);
  text-shadow: 0 0 14px var(--lime-glow), 0 2px 6px #000;
}

#announce .title {
  font-size: 46px;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 0 22px var(--gold-glow), 0 3px 12px #000;
  margin-top: 8px;
}

#announce .hint {
  font-size: 13px;
  opacity: 0.75;
  margin-top: 10px;
}

#endScreen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: var(--screen-bg);
  text-align: center;
}

#endScreen.show {
  display: flex;
}

#endScreen .winner {
  font-size: 64px;
  font-weight: 800;
  color: var(--lime);
  letter-spacing: 3px;
  text-shadow: 0 0 26px var(--lime-glow), 0 4px 18px #000;
}

#endScreen .panelTitle {
  margin-top: 24px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 2px;
  opacity: 0.7;
}

#endList {
  margin: 16px 0 28px;
  padding-left: 28px;
  text-align: left;
  font-size: 18px;
  color: var(--gold);
  text-shadow: 0 0 10px var(--gold-glow);
}

#endList li {
  margin: 4px 0;
}

#restartBtn {
  pointer-events: auto;
  background: var(--restart-bg);
  color: var(--lime);
  border: 1px solid var(--success);
  border-radius: 8px;
  padding: 12px 28px;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 0 16px var(--restart-glow);
}

#restartBtn:hover {
  background: var(--restart-hover);
  box-shadow: 0 0 22px var(--restart-hover-glow);
}

/* Join screen */
#joinScreen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 50; }
#joinScreen.hidden { display: none; }
.joinBox { display: flex; flex-direction: column; gap: 10px; min-width: 260px; text-align: center; }
#nickInput { font: inherit; padding: 8px; background: var(--input-bg); color: var(--text);
  border: 1px solid var(--input-border); border-radius: 6px; }
#nickInput:focus { outline: none; border-color: var(--accent); }
#joinBtn { font: inherit; font-weight: 700; padding: 8px; color: var(--bg); background: var(--accent);
  border: 0; border-radius: 6px; cursor: pointer; }
#joinBtn:hover { background: var(--accent-hover); }
#joinState:empty { display: none; }
