:root {
  --bg: #0d0b0b;
  --panel: #171313;
  --panel2: #201a1a;
  --line: #3a2d2d;
  --text: #ece4e0;
  --muted: #9a8c87;
  --accent: #c8141f;
  --accent2: #ff4b3e;
  --good: #4fd17a;
  --warn: #f2b84b;
  --bad: #ff4b3e;
  --scale: 1;
  font-size: calc(15px * var(--scale));
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; }
button, input, select {
  font: inherit; color: inherit;
}
button {
  background: var(--accent); border: 0; border-radius: 6px; padding: .55em 1.1em; cursor: pointer;
}
button:hover { background: var(--accent2); }
button.ghost { background: transparent; border: 1px solid var(--line); }
button.icon {
  background: var(--panel2); border: 1px solid var(--line); width: 2.3em; height: 2.3em; padding: 0;
  font-size: 1.05em; line-height: 1;
}
button.icon.small { width: 2em; height: 2em; }
button.icon:hover { border-color: var(--accent); }
input[type=password], input[type=text], select {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: .55em .7em;
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }

.brand { font-weight: 800; letter-spacing: .12em; display: flex; align-items: center; gap: .5em; white-space: nowrap; }
.brand em { color: var(--accent2); font-style: normal; }
.brand.big { font-size: 1.6em; justify-content: center; }
.drop {
  width: .8em; height: 1em; background: var(--accent);
  clip-path: path('M6 0C6 0 0 7.5 0 11a6 6 0 0 0 12 0C12 7.5 6 0 6 0z');
  display: inline-block; transform: scale(1);
}

.screen { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-box {
  width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 28px; display: flex; flex-direction: column; gap: .6em;
}
.login-box p { text-align: center; margin: 0 0 .8em; }
.login-box .check { display: flex; gap: .5em; align-items: center; color: var(--muted); }

.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; background: rgba(13, 11, 11, .92); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.tabs { display: flex; gap: 6px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tabs button { background: var(--panel2); border: 1px solid var(--line); white-space: nowrap; padding: .4em .9em; }
.tabs button.active { background: var(--accent); border-color: var(--accent); }
.actions { display: flex; gap: 8px; align-items: center; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); }
.conn.on { background: var(--good); }

.overview { padding: 16px; max-width: 1100px; margin: 0 auto; }
.overview h2 { font-size: 1em; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.lobby-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.lobby {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; text-align: left;
}
.lobby:hover { border-color: var(--accent); background: var(--panel2); }
.lobby .name { font-weight: 700; font-size: 1.1em; }
.badge { display: inline-block; font-size: .75em; padding: .15em .55em; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.badge.playing { color: var(--good); border-color: #2c5a3b; }
.badge.waiting { color: var(--warn); border-color: #5a4a2c; }
.history { display: flex; flex-direction: column; gap: 6px; }
.history .row { display: flex; gap: 12px; flex-wrap: wrap; padding: 8px 12px; background: var(--panel); border-radius: 8px; border: 1px solid var(--line); }

.game { padding: 12px 16px 16px; }
.levelbar {
  display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: baseline; padding: 4px 2px 12px;
}
.levelbar .lvl { font-size: 1.35em; font-weight: 800; }
.levelbar .stat { color: var(--muted); }
.levelbar .stat b { color: var(--text); font-variant-numeric: tabular-nums; }

.game-grid {
  display: grid; gap: 12px;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr);
  grid-template-areas: "map players" "feed players";
  grid-template-rows: minmax(360px, 68vh) auto;
}
.game-grid.no-map { grid-template-columns: 1fr; grid-template-areas: "players" "feed"; grid-template-rows: auto auto; }
.game-grid.no-map .players { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.map-wrap { grid-area: map; position: relative; background: #070606; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.map-wrap canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.map-tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
.map-tools select { padding: .3em .5em; }
.map-empty { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.players { grid-area: players; display: grid; gap: 10px; align-content: start; }
.feed-wrap { grid-area: feed; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.feed-wrap h3 { margin: 0 0 6px; font-size: .85em; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.feed { list-style: none; margin: 0; padding: 0; max-height: 11em; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.feed li { font-size: .95em; }
.feed time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: .6em; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--pc, var(--accent));
  border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 7px;
}
.card.dead { opacity: .55; }
.card .head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card .pname { font-weight: 800; font-size: 1.15em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .frags { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: .7em; background: #2a2020; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--good); transition: width .25s; }
.bar.armor > i { background: #6aa8ff; }
.row2 { display: flex; justify-content: space-between; gap: 8px; font-variant-numeric: tabular-nums; }
.row2 .lbl { color: var(--muted); }
.armor3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: .85em; }
.armor3 span { background: var(--panel2); border-radius: 6px; padding: 2px 6px; text-align: center; font-variant-numeric: tabular-nums; }
.weapon { font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: .78em; padding: .1em .5em; border-radius: 6px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.chip.on { color: var(--text); border-color: #6b4b4b; }
.chip.cur { background: var(--accent); border-color: var(--accent); color: #fff; }
.key { font-size: .78em; padding: .1em .5em; border-radius: 6px; font-weight: 700; color: #111; }

.settings {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 100%); z-index: 10;
  background: var(--panel); border-left: 1px solid var(--line); padding: 16px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px; box-shadow: -10px 0 30px rgba(0,0,0,.5);
}
.settings-head { display: flex; justify-content: space-between; align-items: center; }
.settings h2 { margin: 0; font-size: 1.1em; }
.settings fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 10px; margin: 0; }
.settings legend { color: var(--muted); font-size: .85em; letter-spacing: .08em; text-transform: uppercase; padding: 0 4px; }
.settings label { display: flex; gap: .6em; align-items: center; padding: 4px 0; cursor: pointer; }
.settings select { width: 100%; }

@media (max-width: 820px) {
  .game-grid { grid-template-columns: 1fr; grid-template-areas: "map" "players" "feed"; grid-template-rows: 55vh auto auto; }
  .topbar { flex-wrap: wrap; }
  .tabs { order: 3; flex-basis: 100%; }
}

/* ---- Blood theme (settings > Look) ----------------------------------------------------------
   Fonts: Creepster and Pirata One (SIL Open Font License, see fonts/), served from this server. */
@font-face { font-family: "Creepster"; src: url(fonts/creepster.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Pirata One"; src: url(fonts/pirataone.woff2) format("woff2"); font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "Pirata One"; src: url(fonts/pirataone-ext.woff2) format("woff2"); font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2C60-2C7F, U+A720-A7FF; }

body.theme-blood {
  --bg: #070202;
  --panel: rgba(22, 6, 6, .88);
  --panel2: #2a0909;
  --line: #4d1212;
  --text: #eadfca;
  --muted: #a8907c;
  --accent: #8e0606;
  --accent2: #d4140f;
  --good: #7fbf4d;
  --warn: #e0a030;
  --bad: #ff3326;
  --gothic: "Pirata One", "Times New Roman", serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 55% at 50% -10%, rgba(140, 8, 8, .38), transparent 70%),
    radial-gradient(ellipse 60% 40% at 100% 110%, rgba(90, 0, 0, .3), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .06 0 0 0 0 .04 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-attachment: fixed;
}
.theme-blood .brand { font-family: "Creepster", var(--gothic); font-weight: 400; letter-spacing: .08em; font-size: 1.45em; color: #c40d0d; text-shadow: 0 2px 0 #000, 0 0 14px rgba(200, 0, 0, .45); }
.theme-blood .brand em { color: var(--text); }
.theme-blood .brand.big { font-size: 2.4em; }
.theme-blood .drop { background: #b30b0b; }
.theme-blood .topbar { background: rgba(8, 2, 2, .93); border-bottom: 1px solid #5a0c0c; box-shadow: 0 6px 18px rgba(0, 0, 0, .6); }
/* blood running down from the top bar */
.theme-blood .topbar::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 14px; pointer-events: none;
  background:
    radial-gradient(4px 10px at 7% 0, #7a0505 98%, transparent) no-repeat,
    radial-gradient(3px 6px at 19% 0, #7a0505 98%, transparent) no-repeat,
    radial-gradient(5px 13px at 41% 0, #7a0505 98%, transparent) no-repeat,
    radial-gradient(3px 7px at 63% 0, #7a0505 98%, transparent) no-repeat,
    radial-gradient(4px 11px at 82% 0, #7a0505 98%, transparent) no-repeat,
    radial-gradient(3px 5px at 94% 0, #7a0505 98%, transparent) no-repeat;
}
.theme-blood h2, .theme-blood h3, .theme-blood legend,
.theme-blood .lobby .name, .theme-blood .card .pname, .theme-blood .levelbar .lvl, .theme-blood .weapon {
  font-family: var(--gothic); font-weight: 400; letter-spacing: .04em;
}
.theme-blood .overview h2, .theme-blood .feed-wrap h3 { color: #c9a98a; font-size: 1.35em; text-transform: none; letter-spacing: .06em; }
.theme-blood .levelbar .lvl { font-size: 1.9em; color: #e3d2b3; text-shadow: 0 2px 0 #000; }
.theme-blood .card .pname { font-size: 1.5em; }
.theme-blood .lobby .name { font-size: 1.45em; }
.theme-blood button { background: linear-gradient(#7c0808, #460303); border: 1px solid #9a1a1a; box-shadow: inset 0 1px 0 rgba(255, 120, 120, .2); }
.theme-blood button:hover { background: linear-gradient(#a10c0c, #5c0404); }
.theme-blood button.icon, .theme-blood .tabs button { background: linear-gradient(#2c0b0b, #160505); border-color: #5a1515; }
.theme-blood .tabs button.active { background: linear-gradient(#8e0606, #4a0202); border-color: #c01010; }
.theme-blood .lobby, .theme-blood .card, .theme-blood .feed-wrap, .theme-blood .history .row, .theme-blood .login-box, .theme-blood .settings {
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .6), 0 4px 14px rgba(0, 0, 0, .55);
  background-image: linear-gradient(rgba(255, 255, 255, .02), rgba(0, 0, 0, .25));
}
.theme-blood .settings { background-color: #120404; }
.theme-blood .bar { background: #1d0606; box-shadow: inset 0 1px 2px #000; }
.theme-blood .bar > i { background: linear-gradient(90deg, #6d0303, #d0120c) !important; }
.theme-blood .bar.armor > i { background: linear-gradient(90deg, #3b3b46, #9aa0b3) !important; }
.theme-blood .chip.cur { background: #8e0606; border-color: #c01010; }
.theme-blood .map-wrap { background: #000; border-color: #4d1212; box-shadow: 0 0 0 1px #000, 0 6px 22px rgba(0, 0, 0, .7); }
.theme-blood .badge.playing { color: #e0b35a; border-color: #6a4a1a; }
.muted a, .login-box a { color: var(--accent, #d23c3c); }
