:root {
  --ink: #161616;
  --hud: rgba(255, 255, 255, 0.42);
  --line: #141414;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #67b7ff;
  font-family: Nunito, "Segoe UI", sans-serif;
  color: var(--ink);
  user-select: none;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

button, input, select { font-family: inherit; }

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  min-height: 112px;
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr) 300px;
  gap: 8px;
  align-items: center;
  padding: 8px 10px 10px;
  background: var(--hud);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(1px);
}

#hud[hidden],
#wind[hidden],
#ammo-stats[hidden],
#banner[hidden],
#winner[hidden],
#menu[hidden],
#settings[hidden],
#hint[hidden],
#wep-panel[hidden],
#shell-preview[hidden],
#chat[hidden],
#chat-emojis[hidden],
#chat-badge[hidden] {
  display: none !important;
}

.hud-left { display: flex; flex-direction: column; gap: 6px; }

.turn-line {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #2f5bff;
}

.mini-tank { width: 34px; height: 22px; color: inherit; }

#turn-name {
  font-family: "Lilita One", Nunito, "Segoe UI", sans-serif;
  font-size: 26px;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.move-row, .buy-row, .fire-row, .aim-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.move-row button,
.buy-row button,
#pass,
.inv {
  border: 2px solid var(--line);
  background: #f4f6f8;
  border-radius: 6px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 2px 0 #222;
}

.move-row button { width: 28px; height: 26px; padding: 0; }

#fuel {
  min-width: 36px;
  text-align: center;
  font-weight: 900;
  font-size: 20px;
}

.buy-row button {
  width: 32px;
  height: 26px;
  padding: 0;
  font-size: 14px;
}

.hud-center { display: flex; flex-direction: column; gap: 4px; }

.aim-ico { width: 26px; height: 26px; flex: none; }

.readout {
  width: 62px;
  font-weight: 900;
  font-size: 15px;
  text-align: right;
  flex: none;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 18px;
  flex: 1;
  background: #fff;
  border: 2px solid #111;
  border-radius: 9px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 26px;
  background: #111;
  border-radius: 2px;
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 26px;
  background: #111;
  border: none;
  border-radius: 2px;
  cursor: pointer;
}

input[type="range"].power {
  background: linear-gradient(90deg, #fff36a 0%, #ffb000 42%, #ff4d00 78%, #ff1a00 100%);
}

#wep-name {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1 1 160px;
  max-width: 260px;
  min-width: 0;
  height: 42px;
  padding: 0 22px 0 4px;
  border: 2px solid var(--line);
  background: #f4f6f8;
  border-radius: 6px;
  box-shadow: 0 2px 0 #222;
  font-family: "Lilita One", Nunito, "Segoe UI", sans-serif;
  font-size: 16px;
  letter-spacing: 0.3px;
  cursor: pointer;
}

#wep-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#wep-name::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 50%;
  margin-top: -2px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #161616;
}

#wep-name[aria-expanded="true"] {
  background: #fff;
}

#wep-name[aria-expanded="true"]::after {
  transform: rotate(180deg);
  margin-top: -4px;
}

#wep-name.broke { color: #c01414; }

.shell-ico {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex: none;
  pointer-events: none;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.45));
}

#wep-name .shell-ico {
  width: 34px;
  height: 34px;
}

#wep-panel {
  position: fixed;
  z-index: 7;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid #141414;
  border-radius: 10px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.22);
  overflow: auto;
}

.ammo-head {
  font-family: "Lilita One", Nunito, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0.6px;
  line-height: 1;
  padding: 0 2px;
}

.ammo-tiers { display: flex; flex-direction: column; gap: 4px; }

.ammo-singles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding-top: 6px;
  border-top: 2px solid rgba(0, 0, 0, 0.12);
}

.ammo-row {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(128px, 0.95fr);
  gap: 4px;
  align-items: center;
}

.ammo-row > .ammo-type { grid-column: 1; grid-row: 1; }
.ammo-row > select { grid-column: 2; grid-row: 1; }

.ammo-type {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0 8px 0 2px;
  border: 2px solid #141414;
  border-radius: 6px;
  background: #f4f6f8;
  color: #161616;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 2px 0 #222;
  overflow: hidden;
}

.ammo-type span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ammo-type:hover { background: #fff; }

.ammo-row.on .ammo-type,
.ammo-single.on {
  background: #fff6d4;
  box-shadow: inset 4px 0 0 #111, 0 2px 0 #222;
}

.ammo-type.broke,
#wep-panel select.broke,
#wep-panel option.broke { color: #c01414; }

#wep-panel select.ammo-tier {
  grid-column: 2;
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0 4px;
  font-size: 13px;
  cursor: pointer;
}

.ammo-type:focus-visible,
#wep-panel select:focus-visible,
#wep-name:focus-visible {
  outline: 3px solid #16357a;
  outline-offset: 1px;
}

.coins, .income {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 900;
  font-size: 16px;
  flex: none;
}

.coin {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe38a, #f0b429 55%, #c68412);
  border: 2px solid #6a4a10;
  display: inline-block;
}

.coin.small { width: 12px; height: 12px; }

#fire {
  border: 3px solid #3a0a00;
  background: linear-gradient(#ff7a32, #ff2a00);
  color: white;
  font-family: "Lilita One", Nunito, "Segoe UI", sans-serif;
  font-size: 22px;
  letter-spacing: 1px;
  padding: 1px 12px 0;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 3px 0 #6a1400;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  flex: none;
}

#fire:disabled, #pass:disabled, .buy-row button:disabled, .move-row button:disabled, #wep-name:disabled, #range-toggle:disabled {
  filter: grayscale(0.4);
  opacity: 0.55;
  cursor: default;
}

#fire.nope { animation: shake 0.25s linear; }

@keyframes shake {
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

#pass {
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
  letter-spacing: 0.4px;
}

.inv {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 6px;
  background: rgba(255, 255, 255, 0.7);
}

.inv svg { width: 20px; height: 20px; }
.inv b { font-size: 16px; }

#range-toggle.on {
  background: #fff4b0;
}

#range-layer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}

.roster {
  display: grid;
  grid-template-rows: repeat(3, 28px);
  grid-auto-flow: column;
  gap: 4px 12px;
  align-items: center;
}

.slot-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pname {
  font-weight: 900;
  font-size: 15px;
  min-width: 62px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.hpbar {
  position: relative;
  width: 92px;
  height: 20px;
  background: #fff;
  border: 2px solid #111;
  overflow: hidden;
  flex: none;
}

.hpfill {
  position: absolute;
  inset: 0 auto 0 0;
  background: #e10600;
}

.hpbar span {
  position: relative;
  z-index: 1;
  display: block;
  text-align: center;
  font-size: 12px;
  font-weight: 900;
  line-height: 18px;
}

.hpbar.dead span { letter-spacing: 0.3px; }

#shell-preview {
  position: fixed;
  z-index: 4;
  left: 10px;
  top: 116px;
  width: 78px;
  height: 88px;
  pointer-events: none;
}

#shell-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.8)) drop-shadow(0 0 1px rgba(0, 0, 0, 0.55));
}

#ammo-stats {
  position: fixed;
  z-index: 4;
  left: 12px;
  top: 206px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-weight: 900;
  font-size: 18px;
  text-shadow: 0 1px 0 #fff, 1px 0 0 #fff, -1px 0 0 #fff;
  pointer-events: none;
}

#ammo-stats div { display: flex; align-items: center; gap: 8px; }

.burst, .ruler, .weight, .flag {
  width: 18px;
  height: 18px;
  display: inline-block;
}

.burst {
  background: radial-gradient(circle, #ffb000 30%, #ff4d00 70%, transparent 72%);
  border-radius: 50%;
}

.ruler { background: linear-gradient(#222, #222) center/14px 3px no-repeat; }
.weight { background: radial-gradient(circle at 50% 30%, #555 0 35%, transparent 36%), linear-gradient(#555, #555) center 70%/10px 8px no-repeat; }
.flag { background: linear-gradient(#ff2d2d, #ff2d2d) 4px 2px/12px 8px no-repeat, linear-gradient(#222, #222) left/2px 16px no-repeat; }

#wind {
  position: fixed;
  z-index: 4;
  top: 142px;
  right: 8px;
  width: 156px;
  text-align: center;
  pointer-events: none;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.45));
}

#sock {
  display: block;
  width: 156px;
  height: 78px;
}

#wind-speed {
  margin-top: -8px;
  font-family: "Lilita One", Nunito, "Segoe UI", sans-serif;
  font-size: 22px;
  line-height: 1;
  color: #161616;
}

body.night #wind-speed {
  color: #c8ccd4;
}

#banner {
  position: fixed;
  z-index: 6;
  top: 36%;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Lilita One", Nunito, "Segoe UI", sans-serif;
  font-size: 64px;
  color: white;
  -webkit-text-stroke: 7px #111;
  paint-order: stroke fill;
  pointer-events: none;
  letter-spacing: 1px;
}

#hint {
  position: fixed;
  z-index: 6;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.45);
  color: white;
  font-weight: 800;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  pointer-events: none;
}

.floater {
  position: fixed;
  z-index: 4;
  font-family: "Lilita One", Nunito, "Segoe UI", sans-serif;
  font-size: 32px;
  color: white;
  -webkit-text-stroke: 5px #111;
  paint-order: stroke fill;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

#winner {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.winner-card { text-align: center; }

.winner-kicker, #winner-name {
  font-family: "Lilita One", Nunito, "Segoe UI", sans-serif;
  line-height: 0.9;
  -webkit-text-stroke: 8px #111;
  paint-order: stroke fill;
}

.winner-kicker {
  font-size: 92px;
  color: #c8ff22;
}

#winner-name {
  font-size: 72px;
  margin-top: 6px;
}

.winner-actions {
  margin-top: 18px;
  display: flex;
  gap: 16px;
  justify-content: center;
  pointer-events: auto;
}

.winner-actions button, #start {
  font-family: "Lilita One", Nunito, "Segoe UI", sans-serif;
  border: 3px solid #111;
  background: #111;
  color: #fff;
  font-size: 22px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 0.5px;
}

#to-lobby { background: transparent; color: #111; -webkit-text-stroke: 0; font-size: 26px; border-color: transparent; text-shadow: 0 2px 0 rgba(255,255,255,0.35); }

#menu {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 5vh;
  pointer-events: none;
}

#menu h1 {
  margin: 0;
  font-family: "Lilita One", Nunito, "Segoe UI", sans-serif;
  font-size: clamp(72px, 12vw, 140px);
  line-height: 0.85;
  color: #ff2a18;
  -webkit-text-stroke: 10px #16357a;
  paint-order: stroke fill;
  text-shadow: 7px 7px 0 #0c1c40;
  transform: rotate(-7deg);
  pointer-events: none;
}

.tag {
  margin: 8px 0 14px;
  font-weight: 900;
  color: #10233f;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 4px 12px;
  pointer-events: none;
}

.panel {
  pointer-events: auto;
  width: min(500px, calc(100% - 28px));
  max-height: min(74vh, 780px);
  overflow-x: hidden;
  overflow-y: auto;
  background: rgba(12, 22, 34, 0.82);
  color: white;
  border: 3px solid #111;
  border-radius: 16px;
  padding: 16px 16px 14px;
  box-shadow: 0 12px 0 rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel[hidden] { display: none !important; }

.field {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 8px;
  align-items: center;
  font-weight: 900;
}

.field input[type="range"] { background: #d7e2ee; }

select {
  grid-column: 2 / -1;
  height: 34px;
  border-radius: 8px;
  border: 2px solid #111;
  font-weight: 800;
  padding: 0 8px;
  background: #fff;
  color: #111;
}

.slot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-weight: 900;
}

.slot select { grid-column: auto; width: 150px; }

#start {
  margin-top: 4px;
  background: linear-gradient(#ff7a32, #ff2a00);
  border-color: #3a0a00;
  font-size: 28px;
  box-shadow: 0 4px 0 #6a1400;
}

.help {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 800;
  color: #d5e4f5;
}

#settings {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 16, 28, 0.55);
  pointer-events: auto;
}

.settings-card {
  width: min(420px, calc(100% - 28px));
  background: #121c2b;
  color: white;
  border: 3px solid #111;
  border-radius: 16px;
  padding: 18px 16px 14px;
  box-shadow: 0 12px 0 rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-card h2 {
  margin: 0;
  text-align: center;
  font-family: "Lilita One", Nunito, "Segoe UI", sans-serif;
  font-size: 36px;
  letter-spacing: 1px;
  color: #ffe14a;
  -webkit-text-stroke: 5px #111;
  paint-order: stroke fill;
}

.vol-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  align-items: center;
  font-weight: 900;
}

.vol-row b {
  min-width: 48px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.vol-row input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  background: #d7e2ee;
}

#settings-close {
  font-family: "Lilita One", Nunito, "Segoe UI", sans-serif;
  border: 3px solid #3a0a00;
  background: linear-gradient(#ff7a32, #ff2a00);
  color: #fff;
  font-size: 22px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 0 #6a1400;
}

#lang {
  position: fixed;
  z-index: 30;
  right: 14px;
  bottom: 14px;
  display: flex;
  gap: 4px;
  pointer-events: auto;
}

#lang #settings-open {
  min-width: 36px;
  width: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#settings-open svg {
  width: 18px;
  height: 18px;
  display: block;
}

#lang button {
  min-width: 42px;
  height: 32px;
  padding: 0 10px;
  border: 2px solid #111;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: #111;
  font-weight: 900;
  cursor: pointer;
}

#lang button.on {
  background: #16357a;
  color: #fff;
}

html[lang="ru"] #wep-name {
  font-size: 14px;
  letter-spacing: 0;
}

.mode-tabs {
  pointer-events: auto;
  display: flex;
  gap: 8px;
  margin: 0 0 10px;
}

.mode-tabs button {
  font-family: "Lilita One", Nunito, "Segoe UI", sans-serif;
  min-width: 132px;
  height: 40px;
  border: 3px solid #111;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  color: #111;
  font-size: 20px;
  cursor: pointer;
}

.mode-tabs button.on {
  background: #ff5a1f;
  color: #fff;
}

#net-err {
  pointer-events: none;
  margin: 0 0 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #3a0a00;
  color: #fff;
  font-weight: 900;
}

.panel h2 {
  margin: 0;
  font-family: "Lilita One", Nunito, "Segoe UI", sans-serif;
  font-size: 32px;
  letter-spacing: 0.5px;
}

.panel button {
  font-family: "Lilita One", Nunito, "Segoe UI", sans-serif;
  border: 3px solid #111;
  background: #16357a;
  color: #fff;
  font-size: 20px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.panel button.hot {
  background: linear-gradient(#ff7a32, #ff2a00);
  border-color: #3a0a00;
  font-size: 26px;
  box-shadow: 0 4px 0 #6a1400;
}

.panel button.ghost {
  background: transparent;
  color: #fff;
  box-shadow: none;
}

.panel button:disabled { opacity: 0.45; cursor: default; }

.net-actions { display: flex; flex-direction: column; gap: 8px; }

.field input[type="text"] {
  grid-column: 2 / -1;
  height: 34px;
  border-radius: 8px;
  border: 2px solid #111;
  font-weight: 800;
  padding: 0 8px;
  background: #fff;
  color: #111;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  cursor: pointer;
}

.check input { width: 18px; height: 18px; accent-color: #ff5a1f; }

.join-row { display: flex; gap: 8px; }
.join-row input {
  flex: 1;
  height: 40px;
  border-radius: 8px;
  border: 2px solid #111;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0 10px;
}
.join-row button { flex: none; }

#net-link { user-select: text; word-break: break-all; }

#room-list { display: flex; flex-direction: column; gap: 6px; max-height: 180px; overflow-x: hidden; overflow-y: auto; }

.room-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 2px 8px;
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 2px solid #111;
  background: #fff;
  color: #111;
  font-weight: 900;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.room-item span:last-child {
  grid-column: 1 / -1;
  font-size: 12px;
  color: #345;
}

.room-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

#room-code-copy {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

#room-code-copy:hover .room-code,
#room-code-copy:focus-visible .room-code {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.room-code-caption {
  font-family: Nunito, "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.2px;
  color: #d5e4f5;
}

.room-copied {
  font-family: Nunito, "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 900;
  color: #b6ff8a;
}

.room-code { font-family: "Lilita One", Nunito, sans-serif; font-size: 32px; letter-spacing: 2px; line-height: 1; }

#room-players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#room-players li { display: flex; align-items: center; gap: 8px; font-weight: 900; }
#room-players i { width: 12px; height: 12px; border-radius: 3px; border: 2px solid #111; display: block; flex: none; }

#net-chip {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  padding: 4px 12px;
  border: 3px solid #111;
  border-radius: 999px;
  background: rgba(12, 22, 34, 0.88);
  color: #fff;
  font-family: "Lilita One", Nunito, sans-serif;
  letter-spacing: 0.4px;
  pointer-events: none;
}

#net-chip.mine { background: #ff5a1f; }

#net-chip[hidden] { display: none !important; }

#chat {
  position: fixed;
  z-index: 12;
  left: 12px;
  bottom: 12px;
  width: min(280px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  border: 3px solid #111;
  border-radius: 12px;
  background: rgba(12, 22, 34, 0.9);
  color: #fff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

#chat-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 2px 4px 2px 10px;
  cursor: pointer;
  font-family: "Lilita One", Nunito, "Segoe UI", sans-serif;
  letter-spacing: 0.5px;
  font-size: 16px;
}

#chat-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ff5a1f;
  color: #fff;
  font-family: Nunito, "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 900;
  line-height: 18px;
  text-align: center;
}

#chat-fold,
#chat-emoji,
#chat-send {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid #111;
  border-radius: 6px;
  background: #f4f6f8;
  color: #111;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 2px 0 #222;
}

#chat-fold { margin-left: auto; font-size: 18px; line-height: 1; }
#chat-badge:not([hidden]) + #chat-fold { margin-left: 0; }

#chat.collapsed { width: auto; }
#chat.collapsed #chat-body { display: none; }

#chat-log {
  height: 128px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 4px 4px 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
  user-select: text;
}

#chat-log,
.panel,
#room-list {
  scrollbar-width: thin;
  scrollbar-color: #ffb000 rgba(255, 255, 255, 0.08);
}

#chat-log::-webkit-scrollbar,
.panel::-webkit-scrollbar,
#room-list::-webkit-scrollbar {
  width: 12px;
}

#chat-log::-webkit-scrollbar-track,
.panel::-webkit-scrollbar-track,
#room-list::-webkit-scrollbar-track {
  margin: 4px 2px;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 999px;
}

#chat-log::-webkit-scrollbar-thumb,
.panel::-webkit-scrollbar-thumb,
#room-list::-webkit-scrollbar-thumb {
  min-height: 28px;
  border: 3px solid transparent;
  border-radius: 999px;
  background:
    linear-gradient(180deg, #fff36a 0%, #ffb000 48%, #ff5a1f 100%) padding-box;
  box-shadow: inset 0 0 0 2px #161616;
}

#chat-log::-webkit-scrollbar-thumb:hover,
.panel::-webkit-scrollbar-thumb:hover,
#room-list::-webkit-scrollbar-thumb:hover {
  background:
    linear-gradient(180deg, #fff8b0 0%, #ffc42e 46%, #ff3b12 100%) padding-box;
}

#chat-log::-webkit-scrollbar-thumb:active,
.panel::-webkit-scrollbar-thumb:active,
#room-list::-webkit-scrollbar-thumb:active {
  background:
    linear-gradient(180deg, #ffe14a 0%, #ff7a1a 100%) padding-box;
}

#chat-log::-webkit-scrollbar-corner,
.panel::-webkit-scrollbar-corner,
#room-list::-webkit-scrollbar-corner {
  background: transparent;
}

.chat-line { word-break: break-word; }
.chat-line b { margin-right: 5px; }
.chat-line.mine span { color: #ffe7bf; }

#chat-emojis {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 4px 6px 2px;
  border-top: 2px solid rgba(255, 255, 255, 0.12);
}

#chat-emojis button {
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

#chat-emojis button:hover,
#chat-emojis button:focus-visible { background: rgba(255, 255, 255, 0.14); }

#chat-form {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-top: 2px solid rgba(255, 255, 255, 0.12);
}

#chat-input {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 2px solid #111;
  border-radius: 6px;
  background: #fff;
  color: #161616;
  font-weight: 800;
  font-size: 14px;
  user-select: text;
}

@media (max-width: 720px) {
  #hud {
    grid-template-columns: 1fr;
    min-height: 0;
    max-height: 46vh;
    overflow: auto;
  }
  .roster { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
  #chat-log { height: 96px; }
  #banner { font-size: 36px; }
  .winner-kicker { font-size: 56px; }
  #winner-name { font-size: 42px; }
}
