:root {
  --bg: #0b0d12;
  --panel: rgba(18, 20, 28, 0.86);
  --panel-solid: #14161e;
  --line: rgba(255, 255, 255, 0.1);
  --text: #e9ecf3;
  --muted: #8d94a7;
  --accent: #ffd23f;
  --danger: #ff5d5d;
  --ok: #4dff88;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 30px; margin: 0; letter-spacing: 0.01em; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 12px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.warn { color: #ffb86b; }
.center { justify-content: center; }

/* ---------- menu and lobby ---------- */

#screen-menu { padding: 26px 16px 40px; }
.top { max-width: 1100px; margin: 0 auto 18px; }
.top .sub { color: var(--muted); margin: 4px 0 0; }
.menu-grid {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 860px) { .menu-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}

.field { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
.field input { margin-top: 5px; }

input {
  display: block;
  width: 100%;
  background: #0d0f15;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}
input[type=range] { padding: 0; accent-color: var(--accent); }
input:focus { outline: 2px solid rgba(255, 210, 63, 0.5); outline-offset: 0; }
input:disabled { opacity: 0.55; }

.rules {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 8px 0 14px;
}
.rules label { display: block; color: var(--muted); font-size: 12px; }
.rules input { margin-top: 4px; }

button {
  font: inherit;
  background: #222636;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 14px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: rgba(255, 255, 255, 0.3); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: var(--accent); color: #111; border-color: transparent; font-weight: 600; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.lobby-list { display: flex; flex-direction: column; gap: 8px; min-height: 90px; }
.lobby-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #0d0f15;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.lobby-row strong { font-size: 15px; }

.controls {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 7px;
  color: var(--muted);
}
kbd {
  background: #262b3a;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--text);
  font: 12px ui-monospace, Consolas, monospace;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  flex: 0 0 auto;
  vertical-align: middle;
}
.tag {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 6px;
  background: #2a3042;
  color: var(--muted);
  margin-left: 6px;
}
.tag.me { background: var(--accent); color: #111; }

.room-wrap { max-width: 660px; margin: 26px auto; }
.room-title { font-size: 24px; margin: 4px 0 0; }
.room-players { list-style: none; padding: 0; margin: 0; }
.room-players li {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  margin-bottom: 6px;
  background: #0d0f15;
}

/* ---------- game screen ---------- */

#screen-game {
  position: fixed;
  inset: 0;
  background: #000;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}
#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hud-card {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
}
.card-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.stats { left: 14px; top: 14px; min-width: 190px; }
.stats .big { font-size: 36px; font-weight: 700; line-height: 1; }
.stats .big small, .stats .money small {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-left: 8px;
}
.stats .money { font-size: 18px; font-weight: 600; margin-top: 6px; color: var(--accent); }
.stats .money small { color: var(--muted); }

.pips { display: flex; gap: 6px; margin: 8px 0 4px; }
.pip {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--c, #fff);
  background: transparent;
  display: inline-block;
}
.pip.on { background: var(--c, #fff); }

.chip {
  display: inline-block;
  background: rgba(120, 240, 255, 0.18);
  color: #9ff4ff;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 12px;
  margin-top: 4px;
}

.hud-top {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}
.timer {
  display: inline-block;
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 4px 16px;
  border-radius: 10px;
}
.feed { margin-top: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; }
.feed .row { background: rgba(0, 0, 0, 0.55); padding: 2px 10px; border-radius: 8px; white-space: nowrap; }

.board-card { right: 14px; top: 14px; width: 290px; }
#hud-board { display: flex; flex-direction: column; gap: 2px; }
.brow {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 8px;
  font-size: 13px;
}
.brow.me { background: rgba(255, 210, 63, 0.14); }
.brow .dot { margin-right: 2px; }
.brow .bname { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brow .bscore { font-weight: 700; min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.brow .bkills { color: var(--muted); font-size: 12px; min-width: 28px; text-align: right; }
.brow .bstat { min-width: 62px; text-align: right; }
.brow .bstat .pip { width: 8px; height: 8px; border-width: 1.5px; margin-left: 2px; }
.brow .down { color: var(--danger); font-size: 12px; }

.minimap-card { left: 14px; bottom: 14px; }
#minimap {
  display: block;
  width: 220px;
  height: 220px;
  border-radius: 8px;
  image-rendering: pixelated;
}

.hits-card { right: 14px; bottom: 14px; width: 250px; }
.hits-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  font-size: 13px;
}
.hits-row .pts { margin-left: auto; font-weight: 700; color: var(--ok); }
.hits-row .kill { color: var(--danger); font-size: 12px; }

.hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 10px;
  pointer-events: none;
  white-space: nowrap;
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
#hitmarker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  opacity: 0;
  transition: opacity 0.12s;
  pointer-events: none;
}
#hitmarker.on { opacity: 1; }
#hitmarker::before, #hitmarker::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 3px;
  margin: -1.5px 0 0 -13px;
  background: #ff4d4d;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}
#hitmarker::before { transform: rotate(45deg); }
#hitmarker::after { transform: rotate(-45deg); }

#flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(255, 0, 0, 0) 40%, rgba(255, 40, 40, 0.55) 100%);
  transition: opacity 0.3s;
}
#flash.on { opacity: 1; transition: none; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 20;
  cursor: pointer;
  padding: 16px;
}
.overlay.dead {
  background: rgba(60, 0, 0, 0.22);
  cursor: default;
  pointer-events: none;
}
.dialog {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 26px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  cursor: default;
}
.dialog h2 { font-size: 22px; }
.dialog .actions { flex-wrap: wrap; }

.modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  z-index: 30;
  padding: 16px;
}
.modal .panel.wide {
  max-width: 880px;
  width: 100%;
  max-height: 92vh;
  overflow: auto;
}
#endscreen.overlay { cursor: default; }
#endscreen .panel.wide { max-height: 92vh; overflow: auto; }

.buy-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.buy-head h2 { margin: 0; flex: 1; }
.buy-head strong { color: var(--accent); font-size: 18px; }

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.shop-card {
  background: #0d0f15;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.shop-card.owned { border-color: rgba(77, 255, 136, 0.45); }
.shop-card.poor { opacity: 0.6; }
.shop-title { font-weight: 700; font-size: 15px; }
.shop-desc { color: var(--muted); font-size: 13px; flex: 1; }
.shop-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.shop-foot .price { color: var(--accent); font-weight: 600; }
.shop-card.owned .shop-foot .price { color: var(--ok); }

.fullmap-box {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
}
#bigmap { display: block; border-radius: 8px; background: #000; }

.board { width: 100%; border-collapse: collapse; margin-top: 8px; }
.board th, .board td {
  padding: 7px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.board th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.board tr.me td { color: var(--accent); font-weight: 600; }
.board td:nth-child(n+3), .board th:nth-child(n+3) { text-align: right; font-variant-numeric: tabular-nums; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  background: #222636;
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 99;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .board-card { width: 200px; font-size: 12px; }
  .hits-card { display: none; }
  .hint { font-size: 11px; }
  .minimap-card { transform: scale(0.8); transform-origin: left bottom; }
  .stats { min-width: 0; }
}
