:root {
  --bg: #0a0a0a;
  --s1: rgba(20, 20, 20, 0.78);
  --s2: #1e1e1e;
  --s3: #2a2a2a;
  --t1: #f4f4f1;
  --t2: #9c9c97;
  --accent: #ffd84d;
  --red: #ff6b5b;
  --font: Lora, Georgia, 'Times New Roman', serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--t1);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#game,
#game canvas {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}

.hidden {
  display: none !important;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.card {
  background: var(--s1);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

/* ---------- Вход ---------- */

#join {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle at 50% 40%, rgba(10, 10, 10, 0.2), rgba(10, 10, 10, 0.65));
  z-index: 20;
}

#join .card {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#join h1 {
  margin: 0;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

#join .sub {
  margin: 0;
  color: var(--t2);
}

#join .place {
  margin: 6px 0 8px;
  color: var(--accent);
  font-weight: 700;
}

#join label {
  font-size: 16px;
  color: var(--t2);
  margin-top: 6px;
}

#join input {
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--s3);
  background: var(--s2);
  color: var(--t1);
  padding: 0 14px;
  font: inherit;
  font-size: 20px;
  outline: none;
  user-select: text;
}

#join input:focus {
  border-color: var(--accent);
}

#join-colors {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#join-colors button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  outline: 2px solid transparent;
}

#join-colors button.sel {
  border-color: var(--bg);
  outline-color: var(--t1);
}

#join-btn {
  margin-top: 14px;
  height: 52px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #211b00;
  font-size: 21px;
  font-weight: 800;
}

#join-btn:disabled {
  opacity: 0.45;
  cursor: wait;
}

.status {
  margin: 4px 0 0;
  min-height: 1.3em;
  font-size: 16px;
  color: var(--t2);
}

.status a {
  color: var(--accent);
}

/* ---------- HUD ---------- */

#hud > * {
  position: fixed;
  z-index: 5;
}

#street {
  top: calc(14px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--s1);
  font-weight: 700;
  font-size: 19px;
  opacity: 0;
  transition:
    opacity 0.3s,
    transform 0.3s;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}

#street.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#players {
  top: calc(12px + var(--safe-t));
  right: calc(12px + var(--safe-r));
  width: 220px;
  max-height: 40vh;
  overflow: auto;
  background: var(--s1);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 16px;
}

#players h3 {
  margin: 0 0 6px;
  font-size: 15px;
  color: var(--t2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#players ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#players li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
}

#players li i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

#players li span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#players li em {
  font-style: normal;
  color: var(--t2);
}

#players li button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 0;
  background: var(--s3);
  color: var(--t1);
}

#players li button:hover {
  background: var(--accent);
  color: #211b00;
}

#ping {
  top: calc(12px + var(--safe-t));
  left: calc(12px + var(--safe-l));
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--s1);
  font-size: 15px;
  color: var(--accent);
}

#ping.bad {
  color: var(--red);
}

#chat {
  left: calc(12px + var(--safe-l));
  bottom: calc(12px + var(--safe-b));
  width: min(420px, calc(100vw - 220px));
}

#chat-log {
  max-height: 180px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 18px;
  pointer-events: none;
}

.chat-row {
  align-self: flex-start;
  background: rgba(10, 10, 10, 0.55);
  padding: 4px 10px;
  border-radius: 10px;
  max-width: 100%;
  word-wrap: break-word;
  animation: chatFade 14s forwards;
}

.chat-row.sys {
  color: var(--t2);
  font-style: italic;
}

@keyframes chatFade {
  0%,
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0.25;
  }
}

#chat-form {
  display: none;
  margin-top: 6px;
}

#chat-form.open {
  display: block;
}

#chat-input {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--accent);
  background: rgba(10, 10, 10, 0.85);
  color: var(--t1);
  padding: 0 12px;
  font: inherit;
  font-size: 20px;
  outline: none;
  user-select: text;
}

#minimap {
  right: calc(12px + var(--safe-r));
  bottom: calc(26px + var(--safe-b));
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 3px solid rgba(10, 10, 10, 0.75);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

#attribution {
  right: calc(12px + var(--safe-r));
  bottom: calc(6px + var(--safe-b));
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 2px #000;
}

#toast {
  top: 22%;
  left: 50%;
  transform: translate(-50%, -10px);
  padding: 10px 20px;
  border-radius: 14px;
  background: var(--s1);
  font-weight: 700;
  opacity: 0;
  transition:
    opacity 0.25s,
    transform 0.25s;
  pointer-events: none;
  text-align: center;
  max-width: calc(100vw - 32px);
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

#emote-bar {
  left: 50%;
  bottom: calc(14px + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 16px;
  background: var(--s1);
}

#emote-bar button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-size: 28px;
}

#emote-bar button:hover {
  background: var(--s3);
}

#flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  background: radial-gradient(circle, transparent 40%, rgba(255, 255, 255, 0.85));
  opacity: 0;
}

#flash.on {
  animation: flash 0.6s ease-out;
}

@keyframes flash {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

#help {
  inset: 0;
  display: none;
  place-items: center;
  padding: 16px;
  z-index: 15 !important;
  background: rgba(0, 0, 0, 0.35);
}

#help.open {
  display: grid;
}

#help .card {
  width: min(520px, 100%);
}

#help h2 {
  margin: 0 0 10px;
}

.keys {
  margin: 0 0 16px;
  padding-left: 18px;
  line-height: 2;
  color: var(--t2);
}

kbd {
  display: inline-block;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--s3);
  color: var(--t1);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.6;
}

#help-close {
  height: 46px;
  padding: 0 24px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #211b00;
  font-weight: 800;
  font-size: 19px;
}

.touch-only,
#joystick,
#touch-buttons {
  display: none;
}

/* ---------- Сенсорное управление ---------- */

body.touch .touch-only {
  display: list-item;
}

body.touch #joystick {
  display: block;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.25);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

body.touch #joystick.on {
  opacity: 1;
}

#joystick-knob {
  position: absolute;
  left: 45px;
  top: 45px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
}

body.touch #touch-buttons {
  display: grid;
  grid-template-columns: repeat(2, 60px);
  gap: 10px;
  right: calc(14px + var(--safe-r));
  bottom: calc(150px + var(--safe-b));
}

#touch-buttons button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  background: var(--s1);
  color: var(--t1);
  font-size: 30px;
}

#touch-buttons #btn-jump,
#touch-buttons #btn-throw {
  background: rgba(61, 242, 139, 0.85);
  color: #211b00;
}

body.touch #emote-bar {
  display: none;
  bottom: calc(300px + var(--safe-b));
  left: auto;
  right: calc(14px + var(--safe-r));
  transform: none;
  flex-wrap: wrap;
  width: 160px;
}

body.touch #emote-bar.open {
  display: flex;
}

body.touch #minimap {
  width: 120px;
  height: 120px;
  bottom: calc(22px + var(--safe-b));
}

body.touch #players {
  width: 170px;
  max-height: 28vh;
}

body.touch #chat {
  width: calc(100vw - 170px);
  bottom: calc(12px + var(--safe-b));
}

body.touch #chat-log {
  max-height: 110px;
  font-size: 16px;
}

@media (max-width: 600px) {
  #players {
    width: 170px;
  }
  #chat {
    width: calc(100vw - 170px);
  }
  #minimap {
    width: 130px;
    height: 130px;
  }
}

/* ---------- Машина ---------- */

#hint {
  left: 50%;
  bottom: calc(80px + var(--safe-b));
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--s1);
  font-weight: 700;
  font-size: 18px;
  white-space: nowrap;
  pointer-events: none;
  display: none;
}

#hint.show {
  display: block;
}

#speedo {
  right: calc(210px + var(--safe-r));
  bottom: calc(30px + var(--safe-b));
  padding: 8px 14px;
  border-radius: 14px;
  background: var(--s1);
  font-weight: 800;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  display: none;
}

#speedo.show {
  display: block;
}

#btn-car {
  display: none;
}

body.touch #btn-car.show {
  display: block;
  right: calc(14px + var(--safe-r));
  bottom: calc(290px + var(--safe-b));
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  background: rgba(217, 194, 154, 0.92);
  font-size: 32px;
}

body.touch #hint {
  bottom: calc(140px + var(--safe-b));
}

body.touch #speedo {
  right: auto;
  left: 50%;
  transform: translateX(-50%);
  top: calc(56px + var(--safe-t));
  bottom: auto;
}

/* ---------- Ракетный ранец ---------- */

#jet {
  left: 50%;
  top: calc(56px + var(--safe-t));
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--s1);
  font-size: 18px;
  pointer-events: none;
}

#jet.show {
  display: flex;
}

#jet .bar {
  width: 110px;
  height: 8px;
  border-radius: 4px;
  background: var(--s3);
  overflow: hidden;
}

#jet-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.1s linear;
}

#jet-bar.low {
  background: var(--red);
}

#jet-alt {
  min-width: 52px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

body.touch #jet {
  top: calc(96px + var(--safe-t));
}

/* ---------- Меню ---------- */

#menu-btn {
  top: calc(10px + var(--safe-t));
  left: calc(70px + var(--safe-l));
  width: 44px;
  height: 44px;
  margin-top: -8px;
  border: 0;
  border-radius: 12px;
  background: var(--s1);
  color: var(--t1);
  font-size: 25px;
}

#menu {
  inset: 0;
  display: none;
  place-items: center;
  padding: 16px;
  z-index: 16 !important;
  background: rgba(0, 0, 0, 0.4);
}

#menu.open {
  display: grid;
}

#menu .card {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#menu h2 {
  margin: 0 0 4px;
}

#menu button {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--s3);
  color: var(--t1);
  font-size: 19px;
  font-weight: 700;
  text-align: left;
  padding: 0 16px;
}

#menu button:hover {
  background: #353535;
}

#menu button.primary {
  background: var(--accent);
  color: #211b00;
}

#menu .note {
  margin: -4px 0 6px;
  font-size: 15px;
  color: var(--t2);
}

/* ---------- Радио ---------- */

#radio-btn {
  top: calc(10px + var(--safe-t));
  left: calc(122px + var(--safe-l));
  width: 44px;
  height: 44px;
  margin-top: -8px;
  border: 0;
  border-radius: 12px;
  background: var(--s1);
  color: var(--t1);
  font-size: 25px;
}

#radio-btn.on {
  box-shadow: 0 0 0 2px var(--accent);
}

#radio {
  top: calc(52px + var(--safe-t));
  left: calc(12px + var(--safe-l));
  width: min(300px, calc(100vw - 24px));
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  background: var(--s1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 12 !important;
}

#radio.open {
  display: flex;
}

.radio-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.radio-head button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: var(--s3);
  color: var(--t1);
}

#radio-stations {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 46vh;
  overflow: auto;
}

#radio-stations button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: var(--s2);
  color: var(--t1);
  text-align: left;
}

#radio-stations button small {
  color: var(--t2);
  font-size: 14px;
}

#radio-stations button.sel {
  background: var(--accent);
  color: #211b00;
}

#radio-stations button.sel small {
  color: #3c3000;
}

.radio-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

#radio-play {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #211b00;
  font-size: 22px;
}

#radio-volume {
  flex: 1;
  accent-color: #ffd84d;
  height: 28px;
}

#radio-status {
  margin: 0;
  font-size: 16px;
  color: var(--t1);
  min-height: 1.2em;
}

#radio .note {
  margin: 0;
  font-size: 14px;
  color: var(--t2);
}

#radio-mute { width: 36px; height: 36px; flex-shrink: 0; border: 0; border-radius: 10px; background: var(--s3); color: var(--t1); font-size: 22px; }
#radio-volume { min-width: 45px; width: 100%; }
#radio-volume-value { min-width: 36px; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--t2); }
.join-music { display: flex !important; align-items: center; gap: 8px; font-size: 16px !important; cursor: pointer; }
#join-music { width: 17px; height: 17px; margin: 0; accent-color: #ffd84d; }

#radio { max-height: calc(100dvh - 110px); overflow-y: auto; }
#radio .radio-controls { position: sticky; bottom: 0; background: var(--s2, #20272c); padding: 10px 4px; flex-wrap: wrap; }
#radio .radio-controls label { width: 100%; font-size: 15px; color: var(--t2); }
#radio-volume { flex: 1; height: 26px; accent-color: #ffd84d; cursor: pointer; }

/* CityWalk UI — one palette, one control language. */
:root {
  --bg: #080808;
  --s1: rgba(9, 9, 8, .95);
  --s2: #1c1b17;
  --s3: #2b2921;
  --t1: #fff7d8;
  --t2: #c1bba5;
  --accent: #ffd84d;
  --line: rgba(255, 216, 77, .22);
  --panel-shadow: 0 16px 48px rgba(0, 0, 0, .5), inset 0 1px rgba(255,255,255,.05);
}
button, input { font: inherit; }
button { transition: background .16s, border-color .16s, box-shadow .16s, transform .12s; }
button:active:not(:disabled) { transform: translateY(1px) scale(.97); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
button:disabled { cursor: not-allowed; }
.ui-icon { width: 22px; height: 22px; flex: none; vertical-align: middle; pointer-events: none; }
.card, #players, #radio, #emote-bar, #street, #toast, #hint, #speedo, #jet {
  border: 1px solid var(--line); background: var(--s1); box-shadow: var(--panel-shadow);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.card { border-radius: 24px; padding: 30px; }
.eyebrow { color: var(--accent); letter-spacing: .16em; font-size: 14px; font-weight: 800; }
#join { background: radial-gradient(ellipse at 20% 20%,rgba(255,216,77,.1),transparent 55%), radial-gradient(ellipse at 90% 90%,rgba(150,111,24,.12),transparent 55%),rgba(0,0,0,.78); overflow-y: auto; }
#join .card { width: min(420px,100%); gap: 10px; padding: 34px; }
#join h1 { font-size: 58px; letter-spacing: -.065em; line-height: 1.2; }
#join h1 span { color: var(--accent); }
#join h1 i { font-style: normal; font-size: 38px; color: var(--accent); float: right; }
#join .sub { font-size: 16px; line-height: 1.7; max-width: 280px; }
#join .place { border-block: 1px solid var(--line); padding: 14px 0; font-size: 15px; }
#join input:not([type="checkbox"]), #chat-input { border: 1px solid var(--line); background: #10100e; border-radius: 12px; }
#join input:not([type="checkbox"]):focus { border-color: var(--accent); box-shadow: 0 0 0 3px #ffd84d12; }
#join-colors { gap: 10px; padding: 3px; }
#join-colors button { width: 30px; height: 30px; border-radius: 10px; }
#join-colors button.sel { outline: 2px solid var(--accent); outline-offset: 3px; }
#join .join-music { min-height: 36px; color: var(--t1); }
#join input#join-music { width: 18px; height: 18px; padding: 0; accent-color: var(--accent); flex: none; }
#join-btn, #help-close, #menu button.primary, #menu #menu-close {
  background: var(--accent); color: #201b00; border: 1px solid transparent; border-radius: 12px; font-weight: 800;
}
#join-btn { display: flex; align-items: center; justify-content: space-between; padding: 0 18px; }
#join-btn span { font-size: 31px; }
#join-btn:hover:not(:disabled), #help-close:hover, #menu button.primary:hover, #menu #menu-close:hover { background: #ffe885; box-shadow: 0 0 24px #ffd84d1c; }
#menu-btn, #radio-btn {
  top: calc(16px + var(--safe-t)); margin: 0; height: 46px; width: auto;
  display: flex; align-items: center; gap: 9px; padding: 0 12px;
  background: var(--s1); border: 1px solid var(--line); border-radius: 13px;
  color: var(--t1); font-size: 15px; font-weight: 800; box-shadow: var(--panel-shadow);
}
#menu-btn { left: calc(16px + var(--safe-l)); }
#radio-btn { left: calc(152px + var(--safe-l)); }
#menu-btn:hover, #radio-btn:hover { background: var(--s3); border-color: #ffd84d66; }
#radio-btn.on { color: var(--accent); border-color: #ffd84d70; box-shadow: 0 0 20px #ffd84d12; }
kbd { border: 1px solid var(--line); background: #29271e; border-bottom-width: 3px; border-radius: 5px; color: #f6e8b1; font-size: 14px; padding: 1px 5px; line-height: 1.6; }
#ping { top: calc(72px + var(--safe-t)); left: calc(18px + var(--safe-l)); background: var(--s1); border: 1px solid var(--line); border-radius: 7px; font-size: 14px; padding: 5px 9px; }
#players { top: calc(16px + var(--safe-t)); right: calc(16px + var(--safe-r)); border-radius: 16px; padding: 14px; width: 218px; }
#players h3 { font-size: 14px; letter-spacing: .12em; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
#players li { min-height: 38px; }
#players li button { background: var(--s2); border: 1px solid var(--line); width: 32px; height: 32px; display: grid; place-items: center; }
#players li button .ui-icon { width: 16px; height: 16px; }
#street { top: calc(20px + var(--safe-t)); max-width: calc(100vw - 650px); font-size: 15px; padding: 10px 18px; border-radius: 12px; }
#radio { top: calc(112px + var(--safe-t)); left: calc(16px + var(--safe-l)); width: min(340px,calc(100vw - 32px)); padding: 16px; border-radius: 20px; max-height: calc(100dvh - 140px); gap: 12px; }
.radio-head { padding-bottom: 10px; border-bottom: 1px solid var(--line); font-size: 15px; letter-spacing: .06em; }
.live-tag { color: var(--accent); font-size: 14px; margin-left: 8px; padding: 4px 6px; border: 1px solid #ffd84d40; border-radius: 5px; }
.radio-head button, #radio-mute, #radio-play { border-radius: 10px; display: grid; place-items: center; border: 1px solid var(--line); width: 38px; height: 38px; flex: none; }
.radio-head button:hover, #radio-mute:hover { background: var(--s3); }
#radio-stations { gap: 6px; max-height: 35vh; }
#radio-stations button { min-height: 55px; flex: none; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; padding: 10px 12px; background: #191914; border: 1px solid var(--line); position: relative; }
#radio-stations button b { font-size: 15px; }
#radio-stations button small { font-size: 14px; }
#radio-stations button:hover { border-color: #ffd84d70; background: #2b291c; }
#radio-stations button.sel { background: #ffd84d15; color: var(--accent); border-color: #ffd84d85; padding-right: 35px; }
#radio-stations button.sel small { color: #d3c9a9; }
#radio-stations button.sel::after { content: '●'; position: absolute; right: 13px; top: 18px; color: var(--accent); font-size: 14px; }
#radio .radio-controls { position: static; display: grid; grid-template-columns: 38px 38px minmax(50px,1fr) 38px; gap: 10px; border-top: 1px solid var(--line); padding: 12px 0 0; background: transparent; }
#radio .radio-controls label { grid-row: 1; grid-column: 1 / -1; font-size: 14px; text-transform: uppercase; letter-spacing: .08em; }
#radio-play, #radio-mute, #radio-volume, #radio-volume-value { grid-row: 2; }
#radio-volume { width: 100%; min-width: 0; accent-color: var(--accent); height: 30px; }
#radio-volume-value { color: var(--accent); font-size: 14px; min-width: 0; }
#radio-status { color: var(--accent); font-size: 14px; }
#radio .note { font-size: 14px; line-height: 1.6; }
#menu, #help { background: #030303c9; backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px); overflow-y: auto; }
#menu .card { width: min(420px,100%); gap: 12px; }
#menu h2, #help h2 { font-size: 34px; letter-spacing: -.04em; margin: 4px 0 14px; }
#menu button { background: var(--s2); border: 1px solid var(--line); display: flex; gap: 12px; align-items: center; min-height: 52px; font-size: 16px; }
#menu button:hover { background: var(--s3); border-color: #ffd84d66; }
#menu .note { font-size: 14px; line-height: 1.6; padding-inline: 4px; }
#menu #menu-close { justify-content: center; margin-top: 6px; }
#help .card { max-height: calc(100dvh - 40px); overflow-y: auto; width: min(600px,100%); }
.keys { line-height: 1.8; font-size: 15px; padding-left: 16px; }
.keys li { margin-bottom: 12px; }
#emote-bar { padding: 8px; gap: 5px; border-radius: 18px; bottom: calc(18px + var(--safe-b)); }
#emote-bar button { width: 42px; height: 48px; font-size: 26px; border-radius: 10px; color: var(--t1); position: relative; padding-bottom: 12px; border: 1px solid transparent; }
#emote-bar button::after { content: attr(data-key); position: absolute; bottom: 3px; left: 0; right: 0; font: 14px var(--font); color: var(--t2); }
#emote-bar button:hover { background: var(--s3); border-color: var(--line); }
#minimap { border-radius: 22px; border: 3px solid #51471f; outline: 1px solid #ffd84d66; box-shadow: var(--panel-shadow); right: calc(18px + var(--safe-r)); bottom: calc(28px + var(--safe-b)); }
#chat { left: calc(18px + var(--safe-l)); bottom: calc(20px + var(--safe-b)); width: min(340px,calc(50vw - 170px)); }
.chat-row { background: var(--s1); border: 1px solid var(--line); border-radius: 9px; font-size: 15px; padding: 6px 10px; line-height: 1.5; }
#chat-input { font-size: 16px; }
#hint, #toast { border-radius: 12px; font-size: 15px; }
#speedo { border-radius: 14px; font-size: 31px; color: var(--accent); padding: 12px 18px; }
#jet { border-radius: 12px; font-size: 14px; }
body.touch #touch-buttons button, body.touch #btn-car.show { border: 1px solid #ffd84d50; border-radius: 18px; background: var(--s1); color: var(--t1); box-shadow: var(--panel-shadow); display: grid; place-items: center; }
body.touch #touch-buttons #btn-jump, body.touch #touch-buttons #btn-throw { background: var(--accent); color: #201b00; }
body.touch #joystick { border-color: #ffd84d70; background: #17150d99; }
#joystick-knob { background: #ffd84dbb; box-shadow: 0 0 20px #ffd84d25; }
* { scrollbar-width: thin; scrollbar-color: #72612a transparent; }
@media (max-width: 900px) {
  #street { top: calc(76px + var(--safe-t)); max-width: calc(100vw - 360px); }
  #chat { width: min(300px,calc(100vw - 210px)); bottom: calc(100px + var(--safe-b)); }
}
@media (max-width: 600px) {
  .card, #join .card { padding: 24px; border-radius: 20px; }
  #join h1 { font-size: 50px; }
  #menu-btn, #radio-btn { width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: 12px; }
  #menu-btn .control-label, #radio-btn .control-label, #menu-btn kbd, #radio-btn kbd { display: none; }
  #radio-btn { left: calc(68px + var(--safe-l)); }
  #players, body.touch #players { width: 164px; max-height: 24vh; padding: 10px; font-size: 14px; }
  #street { left: calc(16px + var(--safe-l)); top: calc(111px + var(--safe-t)); transform: none; max-width: calc(100vw - 195px); font-size: 14px; padding: 7px 10px; }
  #street.show { transform: none; }
  #radio { top: calc(150px + var(--safe-t)); max-height: calc(100dvh - 170px); }
  #radio-stations { max-height: 28vh; }
  #emote-bar { bottom: calc(12px + var(--safe-b)); gap: 2px; padding: 5px; }
  #emote-bar button { width: 34px; height: 44px; font-size: 22px; }
  #chat, body.touch #chat { width: calc(100vw - 170px); bottom: calc(100px + var(--safe-b)); left: calc(12px + var(--safe-l)); }
  #minimap, body.touch #minimap { width: 110px; height: 110px; border-radius: 16px; }
  body.touch #touch-buttons { grid-template-columns: repeat(2,54px); gap: 8px; }
  body.touch #touch-buttons button, body.touch #btn-car.show { width: 54px; height: 54px; border-radius: 16px; }
  #help h2 { font-size: 29px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; } }
/* Short title screen, then name and randomized character. */
#splash { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 35%, #302b12, #080808 68%); transition: opacity .3s; pointer-events: auto; }
#splash.leaving { opacity: 0; pointer-events: none; }
.splash-mark { width: 88px; height: 88px; display: grid; place-items: center; position: relative; border: 1px solid #ffd84d55; border-radius: 25px; color: var(--accent); font-size: 41px; font-weight: 800; box-shadow: 0 0 70px #ffd84d12; }
.splash-mark span { position: absolute; right: -7px; top: -9px; font-size: 30px; }
#splash h1 { margin: 22px 0 10px; font-size: clamp(32px,6vw,58px); letter-spacing: -.05em; }
#splash p { color: var(--t2); font-size: 14px; letter-spacing: .22em; }
.splash-track { margin-top: 30px; height: 2px; width: 110px; background: #ffd84d20; overflow: hidden; }
.splash-track i { display: block; width: 100%; height: 100%; background: var(--accent); transform-origin: left; animation: splashIn 1.4s ease-out; }
@keyframes splashIn { from { transform: scaleX(0); } to { transform: scaleX(1); } }
#join h1 { font-size: 42px; letter-spacing: -.05em; }
#join .card { margin: auto; max-height: calc(100dvh - 24px); overflow-y: auto; gap: 7px; padding: 26px; }
#join .place { margin-block: 0; padding-block: 10px; }
.avatar-picker { display: flex; min-height: 168px; border: 1px solid var(--line); border-radius: 16px; background: radial-gradient(ellipse at 27% 55%, #6b561a44, #10100c); align-items: center; overflow: hidden; margin-top: 7px; }
#avatar-preview { width: 145px; height: 168px; flex: none; overflow: hidden; display: flex; align-items: center; justify-content: center; }
#avatar-preview canvas { width: 153px !important; height: 168px !important; }
#avatar-preview svg { width: 126px; height: 155px; }
.avatar-choice { padding: 10px 12px 10px 0; }
.avatar-choice .eyebrow { font-size: 14px; letter-spacing: .08em; }
#avatar-caption { font-size: 14px; color: var(--t2); line-height: 1.5; }
#random-avatar { min-height: 38px; border-radius: 10px; border: 1px solid #ffd84d55; background: #ffd84d10; color: var(--accent); font-size: 14px; padding: 8px 10px; }
#random-avatar:hover { background: #ffd84d25; }
#join-btn { margin-top: 6px; flex: none; }
@media (max-width: 380px) { #join h1 { font-size: 36px; } #avatar-preview { width: 115px; } #join .card { padding: 20px; } }

/* Larger, warm black-and-yellow controls with soft serif lettering. */
body { font-size: 18px; }
button, input { font-family: var(--font); }
.ui-icon { width: 28px; height: 28px; }
.card { border-radius: 24px; }
#join .card { width: min(470px,100%); gap: 10px; padding: 28px; }
#join h1 { font-size: 40px; letter-spacing: -.045em; }
#join .sub { max-width: none; font-size: 17px; line-height: 1.6; }
#join label { font-size: 16px; }
#join input:not([type="checkbox"]) { height: 56px; font-size: 19px; }
#join .place, .status { font-size: 15px; }
#join .join-music { font-size: 16px !important; min-height: 44px; }
#join input#join-music { width: 22px; height: 22px; }
#join-btn { height: 60px; font-size: 20px; }
.avatar-picker { min-height: 180px; }
#avatar-preview { width: 158px; height: 180px; }
#avatar-preview canvas { width: 164px !important; height: 180px !important; }
.avatar-choice .eyebrow { font-size: 13px; letter-spacing: .02em; }
#avatar-caption { font-size: 15px; }
#random-avatar { min-height: 48px; font-size: 15px; }
#menu-btn, #radio-btn { height: 60px; padding: 0 16px; gap: 12px; font-size: 16px; }
#radio-btn { left: calc(202px + var(--safe-l)); }
kbd { font-size: 14px; padding: 2px 6px; }
#ping { top: calc(87px + var(--safe-t)); font-size: 14px; }
#players { width: 270px; font-size: 16px; padding: 16px; }
#players h3 { font-size: 14px; }
#players li { min-height: 48px; }
#players li button { width: 42px; height: 42px; }
#players li button .ui-icon { width: 22px; height: 22px; }
#street { max-width: calc(100vw - 830px); font-size: 17px; padding: 14px 20px; }
#radio { top: calc(132px + var(--safe-t)); width: min(410px,calc(100vw - 32px)); max-height: calc(100dvh - 152px); padding: 20px; }
.radio-head { font-size: 17px; }
.live-tag { font-size: 12px; }
.radio-head button, #radio-play, #radio-mute { width: 48px; height: 48px; }
#radio-stations button { min-height: 72px; padding: 13px 16px; }
#radio-stations button b { font-size: 17px; }
#radio-stations button small { font-size: 14px; }
#radio .radio-controls { grid-template-columns: 48px 48px minmax(50px,1fr) 48px; }
#radio .radio-controls label, #radio-volume-value { font-size: 15px; }
#radio-volume { height: 40px; }
#radio-status { font-size: 15px; }
#radio .note { font-size: 14px; }
#menu .card { width: min(470px,100%); gap: 14px; max-height: calc(100dvh - 32px); overflow-y: auto; }
#menu h2, #help h2 { font-size: 34px; }
#menu button { min-height: 64px; font-size: 18px; }
#menu .note { font-size: 14px; }
#help .card { width: min(690px,100%); }
.keys { font-size: 17px; line-height: 1.85; }
#help-close { min-height: 58px; font-size: 18px; }
#emote-bar { gap: 7px; padding: 9px; }
#emote-bar button { width: 56px; height: 64px; font-size: 28px; padding-bottom: 17px; }
#emote-bar button::after { font-size: 14px; bottom: 4px; }
#chat { width: min(360px,calc(50vw - 210px)); }
.chat-row { font-size: 16px; padding: 8px 12px; }
#chat-input { min-height: 56px; font-size: 18px; }
#minimap { width: 200px; height: 200px; }
#attribution { font-size: 12px; }
#speedo { right: calc(238px + var(--safe-r)); font-size: 32px; }
#hint, #toast { font-size: 17px; padding: 12px 20px; }
#hint { bottom: calc(112px + var(--safe-b)); }
#jet { font-size: 16px; top: calc(90px + var(--safe-t)); padding: 10px 16px; }
#jet .bar { height: 11px; width: 130px; }
#splash p { font-size: 14px; letter-spacing: .12em; }
body.touch #touch-buttons { grid-template-columns: repeat(2,68px); gap: 12px; bottom: calc(180px + var(--safe-b)); }
body.touch #touch-buttons button, body.touch #btn-car.show { width: 68px; height: 68px; border-radius: 20px; }
body.touch #btn-car.show { bottom: calc(350px + var(--safe-b)); }
body.touch #joystick { width: 160px; height: 160px; }
body.touch #joystick-knob { width: 60px; height: 60px; left: 50px; top: 50px; }
body.touch #emote-bar { width: 220px; bottom: calc(435px + var(--safe-b)); }
body.touch #emote-bar button { width: 58px; height: 64px; }
* { scrollbar-color: #75652d transparent; }
@media (max-width: 1100px) {
  #street { top: calc(92px + var(--safe-t)); max-width: calc(100vw - 390px); }
  #chat { width: min(340px,calc(100vw - 240px)); bottom: calc(122px + var(--safe-b)); }
  #jet { top: calc(145px + var(--safe-t)); }
}
@media (max-width: 600px) {
  #join .card { padding: 22px; gap: 9px; }
  #join h1 { font-size: 34px; }
  #join h1 i { font-size: 28px; }
  .eyebrow { font-size: 13px; }
  #menu-btn, #radio-btn { width: 56px; height: 56px; padding: 0; }
  #radio-btn { left: calc(82px + var(--safe-l)); }
  #players, body.touch #players { width: 180px; font-size: 14px; padding: 10px; max-height: 23vh; }
  #players h3 { font-size: 13px; }
  #players li { min-height: 42px; gap: 5px; }
  #players li button { width: 38px; height: 38px; flex: none; }
  #ping { top: calc(82px + var(--safe-t)); }
  #street { left: calc(16px + var(--safe-l)); top: calc(124px + var(--safe-t)); max-width: calc(100vw - 32px); font-size: 15px; padding: 9px 12px; }
  #radio { top: calc(178px + var(--safe-t)); max-height: calc(100dvh - 196px); padding: 16px; }
  #radio-stations { max-height: 28vh; }
  #radio-stations button b { font-size: 16px; }
  #radio-stations button small { font-size: 14px; }
  #radio .radio-controls { grid-template-columns: 48px 48px minmax(35px,1fr) 44px; gap: 8px; }
  #emote-bar { bottom: calc(176px + var(--safe-b)); gap: 3px; padding: 6px; }
  #emote-bar button { width: 44px; height: 58px; font-size: 25px; }
  #chat, body.touch #chat { bottom: calc(32px + var(--safe-b)); width: calc(100vw - 172px); }
  #chat-log { max-height: 128px; }
  .chat-row { font-size: 15px; padding: 7px 9px; }
  #minimap, body.touch #minimap { width: 128px; height: 128px; }
  #hint, body.touch #hint { bottom: calc(340px + var(--safe-b)); font-size: 15px; white-space: normal; text-align: center; width: min(340px,calc(100vw - 32px)); }
  #jet, body.touch #jet { top: calc(174px + var(--safe-t)); font-size: 14px; }
  #menu h2, #help h2 { font-size: 29px; }
  #menu button { font-size: 17px; min-height: 60px; }
  .keys { font-size: 16px; }
  #avatar-preview { width: 130px; }
  .avatar-choice { padding-right: 8px; }
  #random-avatar { font-size: 14px; padding-inline: 8px; }
}
@media (max-width: 359px) {
  #players, body.touch #players { width: 151px; font-size: 13px; }
  #join h1 { font-size: 29px; }
  #avatar-preview { width: 105px; }
  #radio .radio-controls { grid-template-columns: 44px 44px minmax(28px,1fr) 40px; gap: 6px; }
  #radio-play, #radio-mute { width: 44px; height: 48px; }
}
@media (max-width: 600px) {
  #street { max-width: calc(100vw - 218px); }
  #players li button { width: 44px; height: 44px; }
}

/* Spacious character studio, responsive without shrinking controls. */
#join { overflow-y:auto; padding:28px 16px; }
#join .card { width:min(760px,100%); max-width:760px; padding:34px 42px; margin:auto; }
#join h1 { font-size:clamp(38px,5vw,58px); }
#join .sub,#join .place,#join label { font-size:20px; }
#join-name { min-height:60px; font-size:23px; }
.avatar-picker { min-height:340px; gap:20px; padding:12px; }
#avatar-preview { width:300px; height:340px; }
#avatar-preview canvas { width:300px !important; height:340px !important; }
#avatar-preview svg { width:240px; height:300px; }
.avatar-choice { flex:1; min-width:0; padding:14px; }
.avatar-choice .eyebrow { font-size:19px; }
#avatar-caption { font-size:20px; line-height:1.65; }
#random-avatar { min-height:60px; width:100%; font-size:21px; padding:12px 18px; }
#join-btn { min-height:64px; font-size:24px; }
@media(max-width:620px) {
 #join { padding:16px 10px; }
 #join .card { padding:24px 18px; }
 .avatar-picker { flex-direction:column; gap:0; }
 #avatar-preview { width:100%; height:280px; }
 #avatar-preview canvas { width:247px !important; height:280px !important; }
 #avatar-preview svg { height:260px; }
 .avatar-choice { width:100%; padding:10px; text-align:center; }
 #avatar-caption { margin:8px 0 14px; }
}

#rocket-controls { position:fixed;right:22px;bottom:110px;display:grid;grid-template-columns:repeat(2,minmax(120px,1fr));gap:8px;z-index:15; }
#rocket-controls[hidden] { display:none; }
#rocket-controls button { min-height:54px;padding:10px 14px;background:#15140fec;border:1px solid #ffd84d70;border-radius:12px;color:#ffd84d;font:600 17px Lora,Georgia,serif;touch-action:none; }
#rocket-controls button:active { background:#5b4b16; }
#rocket-controls kbd { display:block;font-size:12px;opacity:.7; }
@media(max-width:620px){#rocket-controls{right:10px;bottom:185px;gap:5px;grid-template-columns:repeat(2,100px);}#rocket-controls button{min-height:48px;font-size:14px;padding:6px;}#hint{max-width:calc(100vw - 24px);font-size:15px;bottom:120px;}}

#vitals {position:fixed;left:20px;top:90px;width:210px;display:grid;grid-template-columns:1fr 1fr;gap:9px;padding:16px;background:#11110eed;border:1px solid #ffd84d55;border-radius:15px;font-size:18px;color:#efe8cf;z-index:12;}
#vitals progress {width:100%;height:14px;accent-color:#ffd84d;align-self:center;}
#money-value{font-size:24px;color:#ffd84d;}
#eat-btn,#weapon-select{background:#17160feb;color:#ffd84d;border:1px solid #ffd84d65;border-radius:10px;padding:10px;font:600 16px Lora,Georgia,serif;min-height:44px;}
#weapon-select{position:fixed;left:20px;bottom:32px;z-index:12;}
#crosshair{position:fixed;left:50%;top:50%;transform:translate(-50%,-50%);font:28px sans-serif;color:#fff1ba;text-shadow:0 1px 3px #000;pointer-events:none;z-index:8;}
#crosshair[hidden],#weapon-select[hidden]{display:none;}
@media(max-width:620px){#vitals{left:10px;top:170px;width:175px;padding:10px;gap:6px;font-size:14px;}#money-value{font-size:20px;}#eat-btn{font-size:12px;padding:6px;}#weapon-select{left:10px;bottom:110px;font-size:14px;}}

#voice-panel{position:fixed;left:20px;top:260px;width:230px;background:#11110ef2;border:1px solid #ffd84d66;border-radius:14px;padding:12px;z-index:25;color:#f4e8bf;font-size:16px;}
#voice-panel summary{cursor:pointer;font-weight:700;color:#ffd84d;min-height:26px;}
#voice-panel button{width:100%;padding:10px;margin-top:8px;min-height:44px;background:#2b2615;color:#ffe899;border:1px solid #ffd84d55;border-radius:10px;font:600 15px Lora,Georgia,serif;}
#voice-panel label{display:block;margin-top:10px;}#voice-volume{width:100%;accent-color:#ffd84d;}#voice-status{font-size:13px;line-height:1.5;}#voice-talk{touch-action:none;}#voice-talk.speaking{background:#8c7021;box-shadow:0 0 0 2px #ffd84d;}#voice-talk:disabled{opacity:.5;}
@media(max-width:620px){#voice-panel{top:320px;left:10px;width:175px;padding:10px;font-size:14px;}#voice-panel[open]{top:90px;max-height:calc(100dvh - 220px);overflow:auto;width:230px;}#voice-panel button{font-size:13px;}}

/* ---------- Оборона дома ---------- */

#round-hud {
  top: calc(60px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 20px;
  border-radius: 14px;
  border: 1px solid var(--s3);
  background: var(--s1);
  pointer-events: none;
  text-align: center;
  max-width: calc(100vw - 32px);
}

#round-hud[hidden] {
  display: none;
}

#round-hud b {
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--accent);
}

#round-hud span {
  font-size: 14px;
  color: var(--t2);
}

#round-hud[data-phase='active'] {
  border-color: var(--red);
}

#round-hud[data-phase='active'] b {
  color: var(--red);
}

/* ---------- Гигантский паук ---------- */

#boss-hud {
  top: calc(128px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid #ff3b2a88;
  background: var(--s1);
  pointer-events: none;
}

#boss-hud[hidden] {
  display: none;
}

#boss-hud b {
  font-size: 15px;
  letter-spacing: 0.08em;
  color: var(--red);
}

#boss-hud span {
  font-size: 14px;
  color: var(--t2);
  text-align: right;
}

#boss-hp {
  grid-column: 1 / -1;
  width: 100%;
  height: 10px;
  accent-color: var(--red);
}
