:root {
  --gold: #d8b46a;
  --ink: #f3ead8;
  --panel: rgba(18, 14, 10, 0.86);
  --blood: #8e0f0f;
  --font: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0907; color: var(--ink); font-family: var(--font); }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

#loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #0b0907; font-size: 22px; letter-spacing: 3px; color: var(--gold); z-index: 50; }

/* ---------- menus */
#menu, #pause { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 20;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.25), rgba(0,0,0,0.75)); padding: 16px; overflow-y: auto; }
.panel { background: var(--panel); border: 1px solid rgba(216,180,106,0.45); box-shadow: 0 20px 60px rgba(0,0,0,0.6); padding: 28px 30px; width: min(560px, 100%); border-radius: 4px; }
.panel h1 { margin: 0; font-size: clamp(36px, 8vw, 56px); letter-spacing: 8px; color: var(--gold); text-align: center; text-shadow: 0 2px 0 #3a2a10, 0 0 30px rgba(216,180,106,0.25); }
.panel h2 { margin: 0 0 14px; color: var(--gold); letter-spacing: 4px; }
.tag { text-align: center; margin: 6px 0 22px; opacity: 0.8; font-style: italic; }
.panel label { display: block; margin: 12px 0 6px; font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: #cbbd9f; }
.panel label.check { text-transform: none; letter-spacing: 0; font-size: 15px; }
.panel input[type=text], .panel input:not([type]), .panel select { width: 100%; margin-top: 6px; padding: 10px 12px; background: #1c1712; border: 1px solid #5b4a2c; color: var(--ink); font: 17px var(--font); border-radius: 2px; }
.panel input[type=range] { width: 100%; }
button { cursor: pointer; font: 600 16px var(--font); letter-spacing: 3px; padding: 12px 18px; border: 1px solid var(--gold); background: linear-gradient(#5b1010, #3a0808); color: var(--ink); border-radius: 2px; margin-top: 10px; width: 100%; }
button:hover { background: linear-gradient(#781616, #4a0a0a); }
button.danger { background: #222; border-color: #777; }
.row { display: flex; gap: 10px; }
#playBtn { margin-top: 20px; font-size: 19px; padding: 15px; }
#menuStatus { min-height: 22px; margin-top: 10px; text-align: center; color: #e6a0a0; font-size: 14px; }
#skinPick { display: flex; gap: 8px; flex-wrap: wrap; }
#skinPick .sw { width: 38px; height: 38px; border: 2px solid transparent; border-radius: 2px; cursor: pointer; box-shadow: inset 0 0 0 2px rgba(0,0,0,0.4); }
#skinPick .sw.sel { border-color: var(--gold); transform: scale(1.08); }
details { margin-top: 18px; font-size: 14px; }
summary { cursor: pointer; color: var(--gold); letter-spacing: 2px; }
table.controls { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.controls td { padding: 4px 6px; border-bottom: 1px solid rgba(255,255,255,0.06); vertical-align: top; }
table.controls td:first-child { white-space: nowrap; color: #e7d3a8; width: 40%; }
.tip { opacity: 0.75; font-style: italic; }
#leaderboard { margin-top: 16px; font-size: 14px; }
#leaderboard h3 { margin: 0 0 6px; color: var(--gold); letter-spacing: 2px; font-size: 14px; }
#leaderboard ol { margin: 0; padding-left: 22px; columns: 2; }

/* ---------- HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#vignette { position: absolute; inset: 0; opacity: 0; transition: opacity 0.12s;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 45%, rgba(120,0,0,0.55) 80%, rgba(60,0,0,0.9) 100%); }
#crosshair { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
#crosshair .dot { position: absolute; left: -2px; top: -2px; width: 4px; height: 4px; border-radius: 50%; background: rgba(255,255,255,0.85); box-shadow: 0 0 2px #000; }
#swingDir { position: absolute; left: -50px; top: -50px; width: 100px; height: 100px; fill: rgba(255,240,210,0.75); stroke: rgba(0,0,0,0.6); stroke-width: 1; transition: transform 0.05s linear; }
#hitmarker { position: absolute; left: -12px; top: -12px; width: 24px; height: 24px; opacity: 0; transition: opacity 0.25s;
  background: linear-gradient(45deg, transparent 46%, #fff 46%, #fff 54%, transparent 54%), linear-gradient(-45deg, transparent 46%, #fff 46%, #fff 54%, transparent 54%); }
#hitmarker.kill { background: linear-gradient(45deg, transparent 44%, #e22 44%, #e22 56%, transparent 56%), linear-gradient(-45deg, transparent 44%, #e22 44%, #e22 56%, transparent 56%); }
#bars { position: absolute; left: 22px; bottom: 22px; width: min(300px, 60vw); }
.bar { margin-top: 8px; }
.bar .label { font-size: 11px; letter-spacing: 3px; color: #e9dcc0; text-shadow: 0 1px 2px #000; }
.track { position: relative; height: 12px; background: rgba(0,0,0,0.55); border: 1px solid rgba(216,180,106,0.5); }
.fill { position: absolute; left: 0; top: 0; bottom: 0; transition: width 0.1s; }
.fill.hp { background: linear-gradient(#c42020, #6d0b0b); }
.fill.bleed { background: repeating-linear-gradient(45deg, rgba(255,60,60,0.5) 0 4px, transparent 4px 8px); }
.fill.st { background: linear-gradient(#d9c37a, #8a7330); }
#bodyDoll { margin-top: 8px; font-size: 12px; color: #e6b0a0; min-height: 16px; text-shadow: 0 1px 2px #000; }
#leanMeter { position: absolute; left: 50%; bottom: 26px; width: 180px; margin-left: -90px; height: 8px; background: rgba(0,0,0,0.5); border: 1px solid rgba(216,180,106,0.4); }
#leanMeter .tick { position: absolute; left: 50%; top: -4px; width: 1px; height: 16px; background: rgba(255,255,255,0.5); }
#leanKnob { position: absolute; top: -3px; width: 12px; height: 12px; margin-left: -6px; left: 50%; background: var(--gold); border-radius: 50%; box-shadow: 0 0 6px rgba(0,0,0,0.6); }
#leanMeter span { position: absolute; top: 10px; font-size: 10px; letter-spacing: 2px; opacity: 0.7; }
#leanMeter .l { left: 0; } #leanMeter .r { right: 0; }
#killfeed { position: absolute; right: 18px; top: 16px; text-align: right; font-size: 15px; }
#roster { position: absolute; left: 16px; top: 14px; font-size: 13px; background: rgba(0,0,0,0.42); border-left: 3px solid var(--gold); padding: 5px 9px 6px; min-width: 150px; max-width: min(260px, 45vw); text-shadow: 0 1px 1px #000; }
#roster:empty { display: none; }
#roster .h { display: flex; gap: 10px; font-size: 10px; letter-spacing: 2px; color: var(--gold); opacity: 0.8; margin-bottom: 2px; }
#roster .r { display: flex; gap: 10px; line-height: 1.45; }
#roster .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#roster .k, #roster .d { width: 22px; text-align: right; font-variant-numeric: tabular-nums; }
#roster .me .n { color: #ffe3a3; }
#roster .dead .n { opacity: 0.55; }
#killfeed div { background: rgba(0,0,0,0.5); padding: 4px 10px; margin-bottom: 4px; border-right: 3px solid var(--blood); animation: fadeOut 7s forwards; }
#killfeed b { color: var(--gold); }
#killfeed i { color: #e88; font-style: normal; }
#notices { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); text-align: center; font-size: 18px; text-shadow: 0 2px 4px #000; }
#notices div { animation: fadeOut 3.5s forwards; margin-bottom: 4px; }
#notices .big { font-size: 30px; color: #f2c26b; letter-spacing: 3px; }
@keyframes fadeOut { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }
#chat { position: absolute; left: 22px; bottom: 120px; width: min(420px, 70vw); font-size: 14px; }
#chatLog div { background: rgba(0,0,0,0.4); padding: 2px 8px; margin-top: 2px; text-shadow: 0 1px 1px #000; animation: fadeOut 12s forwards; }
#chatLog b { color: var(--gold); }
#chatInput { display: none; width: 100%; margin-top: 4px; padding: 6px 8px; background: rgba(0,0,0,0.7); border: 1px solid var(--gold); color: var(--ink); font: 14px var(--font); pointer-events: auto; }
#chat.open #chatInput { display: block; }
#chat.open #chatLog div { animation: none; }
#netinfo { position: absolute; right: 12px; bottom: 8px; font: 11px monospace; opacity: 0.6; }
#deathScreen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(ellipse, rgba(40,0,0,0.25), rgba(30,0,0,0.75)); }
#deathScreen .title { font-size: clamp(32px, 7vw, 64px); letter-spacing: 8px; color: #c22; text-shadow: 0 3px 0 #000; }
#deathBy { margin-top: 10px; font-size: 20px; }
#respawnIn { margin-top: 8px; opacity: 0.8; }
#scoreboard { position: absolute; left: 50%; top: 14%; transform: translateX(-50%); background: var(--panel); border: 1px solid rgba(216,180,106,0.4); padding: 14px 18px; min-width: min(560px, 92vw); }
#scoreboard table { width: 100%; border-collapse: collapse; font-size: 15px; }
#scoreboard th { text-align: left; color: var(--gold); font-weight: normal; letter-spacing: 2px; font-size: 12px; padding-bottom: 6px; }
#scoreboard td { padding: 4px 6px; border-top: 1px solid rgba(255,255,255,0.07); }
#scoreboard tr.me td { color: #ffe3a3; }
#clickToPlay { position: absolute; left: 50%; top: 60%; transform: translateX(-50%); font-size: 20px; letter-spacing: 3px; background: rgba(0,0,0,0.5); padding: 10px 20px; border: 1px solid var(--gold); }

@media (max-width: 600px) {
  #bars { left: 16px; bottom: 16px; }
  #chat { left: 16px; }
  .panel { padding: 20px 16px; }
}
