:root {
  --bg: #1d2e1f;
  --panel: rgba(17, 24, 21, 0.86);
  --panel-solid: #141b18;
  --line: rgba(255, 255, 255, 0.10);
  --text: #f4f1e6;
  --muted: #a9b3a4;
  --accent: #ffb020;
  --accent-2: #ff6a3d;
  --good: #5fe05a;
  --bad: #ef4b3f;
  --blue: #31b4ff;
  --green: #9bdc2f;
  --red: #ff5a44;
  --radius: 16px;
  --pad: 14px;                                   /* отступ HUD и экранов от края (на маленьком экране меньше) */
  --sal: env(safe-area-inset-left, 0px);         /* вырезы и «челки» телефонов (нужен viewport-fit=cover) */
  --sar: env(safe-area-inset-right, 0px);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sr: 55px;                                    /* радиус стика; input.js подгоняет под размер экрана */
  --mm-w: 220px;                                 /* ширина миникарты */
}
/* Танки открыты во фрейме (внутри bytecoin5): отступы под вырезы и жест «домой» уже сделаны самим приложением, свои были бы вторыми.
   Признак ставит скрипт в <head> страницы. */
html.embedded { --sal: 0px; --sar: 0px; --sat: 0px; --sab: 0px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}

#game { position: fixed; inset: 0; display: block; touch-action: none; }
#hurt {
  position: fixed; inset: 0; pointer-events: none; z-index: 4; opacity: 0; transition: opacity .35s ease-out;
  background: radial-gradient(ellipse at center, rgba(220, 30, 20, 0) 52%, rgba(220, 30, 20, 0.5) 100%);
}
.hidden { display: none !important; }

/* ---------------------------------------------------------------- HUD */

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud.dim { opacity: 0.55; }
/* на большом экране колонки не создают блоков: их дети стоят в углах сами */
#leftcol, #rightcol { display: contents; }

#killfeed {
  position: absolute; left: calc(var(--pad) + var(--sal)); top: calc(var(--pad) + var(--sat)); display: flex; flex-direction: column; gap: 5px; max-width: 46vw;
}
.kf {
  padding: 5px 10px; border-radius: 9px; background: rgba(12, 16, 14, 0.7);
  font-size: 13px; font-weight: 600; line-height: 1.25; animation: kf-in .25s ease-out;
  border-left: 3px solid var(--accent); transition: opacity .5s;
}
.kf.mine { border-left-color: var(--good); background: rgba(24, 56, 28, 0.78); }
.kf.me-dead { border-left-color: var(--bad); background: rgba(70, 22, 18, 0.78); }
.kf.info { border-left-color: #6f7d72; color: var(--muted); font-weight: 500; }
.kf b { color: var(--accent); font-weight: 800; }
.kf i { font-style: normal; color: var(--muted); font-weight: 500; }
@keyframes kf-in { from { transform: translateX(-12px); opacity: 0; } to { transform: none; opacity: 1; } }

#topright {
  position: absolute; right: calc(var(--pad) + var(--sar)); top: calc(var(--pad) + var(--sat)); min-width: 190px; padding: 10px 12px;
  background: rgba(12, 16, 14, 0.66); border-radius: 12px; font-size: 13px;
}
#alive-count { font-weight: 800; color: var(--accent); margin-bottom: 6px; letter-spacing: .02em; }
#leaders { display: flex; flex-direction: column; gap: 3px; }
.ld { display: flex; justify-content: space-between; gap: 12px; }
.ld .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
.ld .k { font-weight: 800; color: #fff; }
.ld.me .n { color: var(--accent); font-weight: 800; }
.ld.dead .n { color: var(--muted); }

#banner {
  position: absolute; left: 50%; top: 74px; transform: translateX(-50%); text-align: center;
  font-size: 20px; font-weight: 800; letter-spacing: .02em;
  padding: 8px 18px; border-radius: 12px; background: rgba(12, 16, 14, 0.72);
  max-width: 90vw; opacity: 0; transition: opacity .25s;
}
#banner.show { opacity: 1; }
#banner small { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 2px; }

#bottomleft {
  position: absolute; left: calc(var(--pad) + var(--sal)); bottom: calc(var(--pad) + var(--sab)); width: 270px; padding: 10px 12px 9px;
  background: rgba(12, 16, 14, 0.7); border-radius: 12px;
}
.hud-tank { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; margin-bottom: 5px; }
#hud-tank-name { font-size: 15px; }
#hud-hp-num { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 11px; border-radius: 6px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; border-radius: 6px; background: var(--good); transition: width .08s linear, background .2s; }
.bar.reload { height: 7px; flex: 1; }
.bar.reload i { background: var(--accent); transition: none; }
.bar.reload.ready i { background: #fff3c4; }
.hud-weapon { display: flex; align-items: center; gap: 10px; margin-top: 7px; }
#hud-ammo { font-size: 12px; font-weight: 700; color: var(--muted); min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; }
#hud-stats { margin-top: 6px; font-size: 11px; color: #7f8b7f; font-variant-numeric: tabular-nums; }

#minimap {
  position: absolute; right: calc(var(--pad) + var(--sar)); bottom: calc(var(--pad) + var(--sab)); width: var(--mm-w); height: calc(var(--mm-w) * .75);
  border: 2px solid rgba(255, 255, 255, 0.35); border-radius: 10px; background: #000;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .35);
}

#hint {
  position: absolute; left: 50%; bottom: calc(var(--pad) + var(--sab)); transform: translateX(-50%);
  font-size: 12px; color: var(--muted); background: rgba(12, 16, 14, 0.55); padding: 6px 12px; border-radius: 9px;
  white-space: nowrap; transition: opacity 1s;
}
#hint b { color: #fff; }
#hint.gone { opacity: 0; }

.round {
  pointer-events: auto; position: absolute; right: calc(var(--pad) + var(--sar) + var(--mm-w) + 12px); bottom: calc(var(--pad) + var(--sab));
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(12, 16, 14, 0.7); color: #fff; font-size: 17px; line-height: 1;
}
.round:hover { background: rgba(60, 70, 62, 0.9); }

/* стик: размер задаёт --sr (радиус хода ручки), его выставляет input.js по размеру экрана */
#stick {
  position: fixed; width: calc(var(--sr) * 2 + 10px); height: calc(var(--sr) * 2 + 10px);
  margin: calc(var(--sr) * -1 - 5px) 0 0 calc(var(--sr) * -1 - 5px); border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.08);
}
#stick i {
  position: absolute; left: 50%; top: 50%; width: calc(var(--sr) * .95); height: calc(var(--sr) * .95);
  margin: calc(var(--sr) * -.475) 0 0 calc(var(--sr) * -.475); border-radius: 50%; background: rgba(255, 255, 255, 0.55);
}
#fire-btn {
  position: fixed; right: calc(26px + var(--sar)); bottom: calc(190px + var(--sab)); width: 104px; height: 104px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-weight: 900; letter-spacing: .04em;
  background: rgba(255, 106, 61, 0.55); border: 4px solid rgba(255, 255, 255, 0.5);
}
#fire-btn.on { background: rgba(255, 106, 61, 0.85); border-color: #fff; }

/* ---------------------------------------------------------------- Таблица (Tab) */

#scoreboard {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 8;
  min-width: min(560px, 92vw); max-height: 80vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px;
  backdrop-filter: blur(6px);
}
#scoreboard h3 { margin: 0 0 8px; font-size: 16px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.sb-close { display: none; font-size: 11px; font-weight: 500; color: var(--muted); }
/* название танка под именем игрока: нужен там, где колонку «Танк» убрали ради ширины */
td .sub { display: none; font-size: 11px; font-weight: 500; color: var(--muted); line-height: 1.2; }
td .sub .dot { width: 8px; height: 8px; margin-right: 4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 4px 8px; }
td { padding: 6px 8px; border-top: 1px solid var(--line); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.me td { color: var(--accent); font-weight: 800; }
tr.dead td { color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

/* ---------------------------------------------------------------- Экраны */

.screen {
  position: fixed; inset: 0; z-index: 10; display: flex;
  padding: calc(var(--pad) + var(--sat)) calc(var(--pad) + var(--sar)) calc(var(--pad) + var(--sab)) calc(var(--pad) + var(--sal));
  background: rgba(9, 14, 11, 0.38); backdrop-filter: blur(2.5px);
  -webkit-backdrop-filter: blur(2.5px);
  overflow: auto; touch-action: auto;
}
/* margin:auto вместо align-items:center — панель, выше экрана, не «уезжает» верхом за край, а прокручивается */
.screen > .panel { margin: auto; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: pop .22s ease-out;
}
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

.panel.menu { width: min(1020px, 100%); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.menu header { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 16px 22px 8px; }
.menu h1 { margin: 0; font-size: 28px; letter-spacing: .12em; font-weight: 900; }
.menu h1 span { color: var(--accent); margin-left: .35em; }
#menu-status { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.chip { padding: 5px 11px; border-radius: 99px; background: rgba(255, 255, 255, 0.08); font-weight: 600; }
.chip b { color: var(--accent); font-weight: 800; }
.chip.live { background: rgba(95, 224, 90, 0.16); color: #b6f2b2; }
.chip.wait { background: rgba(255, 176, 32, 0.15); color: #ffd98a; }

#death-banner {
  margin: 4px 22px 0; padding: 10px 16px; border-radius: 12px; font-weight: 700;
  background: linear-gradient(90deg, rgba(239, 75, 63, 0.3), rgba(239, 75, 63, 0.08)); border: 1px solid rgba(239, 75, 63, 0.45);
}
#death-banner b { color: #ffd2cc; }

/* отказ во входе в бой (не хватает байткоинов и т.п.) */
#notice { margin: 8px 22px 0; padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; background: rgba(255, 176, 32, 0.14); border: 1px solid rgba(255, 176, 32, 0.4); }
#notice.error { background: linear-gradient(90deg, rgba(239, 75, 63, 0.3), rgba(239, 75, 63, 0.08)); border-color: rgba(239, 75, 63, 0.45); }
.chip.wallet { background: rgba(95, 224, 90, 0.16); color: #b6f2b2; }
#wallet-hud { margin-bottom: 6px; font-weight: 700; color: #b6f2b2; font-variant-numeric: tabular-nums; }
#wallet-hud b { color: #fff; }

.menu-body { display: flex; gap: 18px; padding: 10px 22px; overflow: auto; flex: 1; min-height: 0; }
#cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; flex: 1.35; align-content: start; }
.card {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px;
  padding: 10px 6px 9px; min-height: 148px; border-radius: 14px; cursor: pointer; font: inherit; color: inherit;
  background: rgba(255, 255, 255, 0.05); border: 2px solid transparent; transition: transform .12s, background .12s, border-color .12s;
}
.card:hover { background: rgba(255, 255, 255, 0.1); transform: translateY(-2px); }
.card.sel { border-color: var(--accent); background: rgba(255, 176, 32, 0.12); }
.card .pic { height: 92px; display: flex; align-items: center; justify-content: center; }
.card .pic img { max-height: 90px; max-width: 86px; transform: rotate(180deg); filter: drop-shadow(0 5px 4px rgba(0, 0, 0, .45)); }
.card .nm { font-weight: 800; font-size: 14px; }
.card .rl { font-size: 11px; color: var(--muted); }
.card .num { position: absolute; left: 8px; top: 6px; font-size: 11px; font-weight: 800; color: var(--muted); }

#side { flex: 1; min-width: 270px; display: flex; flex-direction: column; gap: 8px; }
#detail { display: flex; flex-direction: column; gap: 8px; }
.d-head { display: flex; align-items: center; gap: 14px; }
.d-pic { width: 112px; height: 124px; display: flex; align-items: center; justify-content: center; flex: none; }
.d-pic img { max-width: 104px; max-height: 120px; transform: rotate(180deg); filter: drop-shadow(0 8px 6px rgba(0, 0, 0, .5)); }
.d-name { font-size: 22px; font-weight: 900; }
.d-role { color: var(--accent); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.d-perk { font-size: 13.5px; line-height: 1.4; color: #dfe5d8; background: rgba(255, 176, 32, 0.09); border-left: 3px solid var(--accent); padding: 8px 11px; border-radius: 0 10px 10px 0; }
.stat { display: grid; grid-template-columns: 112px 1fr 78px; align-items: center; gap: 8px; font-size: 12.5px; }
.stat .lb { color: var(--muted); }
.stat .tr { height: 8px; border-radius: 5px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.stat .tr i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.stat .vl { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.d-kill { font-size: 13px; color: var(--muted); }
.d-kill b { color: #fff; }

.menu footer { display: flex; align-items: flex-end; gap: 16px; padding: 12px 22px 18px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.name-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.name-field input {
  width: 210px; padding: 11px 13px; border-radius: 11px; border: 2px solid var(--line); outline: 0;
  background: rgba(0, 0, 0, 0.3); color: #fff; font: 700 15px system-ui; user-select: text; -webkit-user-select: text;
}
.name-field input:focus { border-color: var(--accent); }
/* имя взято из аккаунта bytecoin5 и не правится */
.name-field.locked input { opacity: .75; cursor: not-allowed; border-color: transparent; }
#menu-hint { flex: 1; min-width: 160px; font-size: 13px; color: var(--muted); padding-bottom: 12px; }
#menu-hint-m { display: none; }
#play-cost { display: none; }
button { font-family: inherit; }
button.primary {
  padding: 14px 40px; border-radius: 13px; border: 0; cursor: pointer; font-size: 19px; font-weight: 900; letter-spacing: .08em;
  color: #231a05; background: linear-gradient(180deg, #ffc94a, var(--accent)); box-shadow: 0 6px 0 #b97a0a, 0 12px 24px rgba(0, 0, 0, .35);
  transition: transform .08s, box-shadow .08s;
}
button.primary:hover { filter: brightness(1.06); }
button.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 #b97a0a, 0 6px 14px rgba(0, 0, 0, .35); }
button.primary:disabled { filter: grayscale(.8) brightness(.8); cursor: default; }

.panel.queue { padding: 30px 38px; text-align: center; min-width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.queue h2 { margin: 6px 0 0; font-size: 22px; }
#queue-count { font-size: 56px; font-weight: 900; color: var(--accent); line-height: 1.05; font-variant-numeric: tabular-nums; }
#queue-count.cd { font-size: 92px; }
#queue-sub, #conn-sub { color: var(--muted); font-size: 14px; max-width: 330px; }
#queue-tank { display: flex; align-items: center; gap: 12px; margin: 6px 0; font-weight: 700; }
#queue-tank img { height: 64px; transform: rotate(180deg); filter: drop-shadow(0 5px 4px rgba(0, 0, 0, .45)); }
#btn-cancel {
  margin-top: 6px; padding: 10px 24px; border-radius: 11px; border: 2px solid var(--line); cursor: pointer;
  background: rgba(255, 255, 255, 0.06); color: #fff; font-weight: 700; font-size: 14px;
}
#btn-cancel:hover { background: rgba(255, 255, 255, 0.13); }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 5px solid rgba(255, 255, 255, 0.14); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.panel.end { padding: 26px 32px; min-width: min(560px, 100%); text-align: center; }
.end h2 { margin: 0 0 4px; font-size: 26px; letter-spacing: .06em; }
#end-winner { font-size: 18px; font-weight: 800; color: var(--accent); margin-bottom: 14px; }
#end-sub { margin-top: 12px; color: var(--muted); font-size: 13px; }
.end table { text-align: left; }

/* ---------------------------------------------------------------- адаптив */

/* сенсорный экран: Tab нет, поэтому таблица игроков открывается нажатием на панель лидеров, закрывается нажатием на таблицу */
.touch #topright { pointer-events: auto; cursor: pointer; }
.touch #scoreboard { cursor: pointer; }
.touch .sb-close { display: inline; }
@media (hover: none) { .card:hover { transform: none; } }

/* планшеты и узкие окна */
@media (max-width: 860px) {
  :root { --mm-w: 150px; }
  .menu-body { flex-direction: column; }
  #side { min-width: 0; }
  #cards { grid-template-columns: repeat(3, 1fr); }
  .card { min-height: 118px; padding: 8px 4px; }
  .card .pic { height: 66px; }
  .card .pic img { max-height: 64px; max-width: 62px; }
  .card .nm { font-size: 12px; }
  .menu h1 { font-size: 22px; }
  #bottomleft { width: 210px; }
  #hint { display: none; }
  #topright { min-width: 150px; }
  #killfeed { max-width: 56vw; gap: 3px; }
  .kf { font-size: 11px; padding: 3px 7px; }
  #killfeed .kf:not(:nth-last-child(-n+3)) { display: none; }
}

/* ---------------------------------------------------------------- компактный режим (телефоны, вплоть до 300×500)
   Ширина ≤ 560 (портрет) или высота ≤ 520 (ландшафт). Те же границы продублированы в ui.js (COMPACT_MQ) — менять вместе. */
@media (max-width: 560px), (max-height: 520px) {
  :root { --pad: 8px; --mm-w: 112px; }

  /* HUD: две колонки сверху — низ экрана остаётся свободным для больших пальцев (стик слева, огонь справа) */
  #leftcol, #rightcol { position: absolute; top: calc(var(--pad) + var(--sat)); display: flex; flex-direction: column; gap: 6px; }
  #leftcol { left: calc(var(--pad) + var(--sal)); align-items: flex-start; width: min(152px, 46vw); }
  #rightcol { right: calc(var(--pad) + var(--sar)); align-items: flex-end; max-width: 46vw; }
  #leftcol > *, #rightcol > * { position: static; }

  #bottomleft { width: 100%; padding: 6px 8px 7px; border-radius: 10px; }
  .hud-tank { margin-bottom: 4px; }
  #hud-tank-name { font-size: 13px; }
  #hud-hp-num { font-size: 11px; }
  .bar { height: 9px; }
  .bar.reload { height: 6px; }
  .hud-weapon { margin-top: 5px; gap: 6px; }
  #hud-ammo { font-size: 11px; min-width: 0; }
  #hud-stats { display: none; }

  #killfeed { max-width: 100%; gap: 3px; }
  .kf { font-size: 10.5px; padding: 3px 6px; border-radius: 7px; }
  #killfeed .kf:not(:nth-last-child(-n+2)) { display: none; }

  #topright { min-width: 0; padding: 5px 8px; font-size: 11px; border-radius: 10px; }
  #alive-count { margin-bottom: 3px; }
  #wallet-hud { margin-bottom: 3px; }
  #leaders { gap: 1px; }
  .ld { gap: 8px; }
  .ld .n { max-width: 72px; }
  #minimap { border-width: 1.5px; border-radius: 8px; }
  .round { width: 34px; height: 34px; font-size: 15px; }

  /* сообщения («Защита после появления», «+950 BC…») — над кнопкой огня, а не на месте танка */
  #banner { top: auto; bottom: calc(118px + var(--sab)); font-size: 15px; padding: 6px 12px; max-width: min(88vw, 380px); }
  #banner small { font-size: 11.5px; }

  #fire-btn { right: calc(var(--pad) + var(--sar) + 8px); bottom: calc(var(--pad) + var(--sab) + 18px); width: 84px; height: 84px; font-size: 13px; border-width: 3px; }

  /* на телефонах размытие фона под панелями (канвас под ними живой) слишком дорогое — панели просто плотнее */
  .screen { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(9, 14, 11, 0.5); }
  .panel { border-radius: 14px; backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(17, 24, 21, 0.94); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45); }

  /* меню: во весь экран, шапка и футер компактные, середина листается */
  .panel.menu { width: 100%; height: 100%; }
  .menu header { flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px 12px 4px; }
  .menu h1 { font-size: 18px; letter-spacing: .08em; }
  #menu-status { gap: 4px; font-size: 11px; }
  .chip { padding: 3px 8px; }
  #death-banner { margin: 2px 12px 0; padding: 7px 10px; font-size: 12.5px; }
  #notice { margin: 4px 12px 0; padding: 7px 10px; font-size: 12.5px; }
  .menu-body { gap: 10px; padding: 8px 12px; touch-action: pan-x pan-y; }
  #cards, .card, #side { touch-action: pan-x pan-y; }
  .card { padding: 6px 4px; min-height: auto; } /* не 0: иначе строки сетки (ландшафт) сжимаются меньше содержимого */
  .card .pic { height: 54px; }
  .card .pic img { max-height: 52px; max-width: 54px; }
  .card .nm { font-size: 11.5px; }
  .card .rl { font-size: 10px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .card .num { display: none; }

  #side { min-width: 0; gap: 8px; }
  #detail { gap: 6px; }
  .d-head { gap: 10px; }
  .d-pic { width: 64px; height: 70px; }
  .d-pic img { max-width: 60px; max-height: 68px; }
  .d-name { font-size: 18px; }
  .d-role { font-size: 12px; }
  .d-perk { font-size: 12px; padding: 6px 9px; }
  .stat { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr) minmax(40px, auto); gap: 6px; font-size: 11.5px; line-height: 1.15; }
  .d-kill { font-size: 12px; }
  #menu-hint-m { display: block; font-size: 11.5px; line-height: 1.4; color: var(--muted); }
  #menu-hint-m:empty { display: none; }

  .menu footer { flex-wrap: nowrap; align-items: flex-end; gap: 10px; padding: 8px 12px calc(8px + var(--sab)); }
  .name-field { flex: 1; min-width: 0; font-size: 11px; }
  .name-field > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .name-field input { width: 100%; padding: 9px 10px; border-radius: 10px; font-size: 16px; } /* 16px — чтобы iOS не увеличивал страницу при фокусе */
  #menu-hint { display: none; }
  button.primary { flex: none; padding: 11px 22px; border-radius: 12px; font-size: 17px; letter-spacing: .06em; white-space: nowrap; box-shadow: 0 4px 0 #b97a0a, 0 8px 16px rgba(0, 0, 0, .35); }
  button.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #b97a0a, 0 4px 10px rgba(0, 0, 0, .35); }
  #play-cost:not(:empty) { display: block; margin-top: 1px; font-size: 10.5px; font-weight: 800; letter-spacing: .02em; line-height: 1.1; opacity: .7; }

  /* ожидание, соединение, итоги */
  .panel.queue { padding: 18px 16px; min-width: 0; width: min(100%, 360px); }
  .queue h2 { font-size: 18px; }
  #queue-count { font-size: 44px; }
  #queue-count.cd { font-size: 72px; }
  #queue-sub, #conn-sub { font-size: 12.5px; max-width: 100%; }
  #queue-tank img { height: 52px; }
  .panel.end { padding: 14px 10px; min-width: 0; width: 100%; max-width: 560px; }
  .end h2 { font-size: 20px; }
  #end-winner { font-size: 15px; margin-bottom: 8px; }
  #end-sub { font-size: 12px; }

  /* таблицы: колонку «Танк» убираем — танк пишется под именем игрока */
  table { font-size: 12.5px; }
  th { padding: 3px 5px; font-size: 11px; }
  td { padding: 5px; }
  .end th:nth-child(3), .end td:nth-child(3), #scoreboard th:nth-child(3), #scoreboard td:nth-child(3) { display: none; }
  td .sub { display: block; }
  #scoreboard { min-width: 0; width: calc(100% - 2 * var(--pad) - var(--sal) - var(--sar)); max-width: 560px; max-height: calc(100% - 2 * var(--pad)); padding: 10px 12px; }
  #scoreboard h3 { font-size: 14px; }
}

/* портрет: танки — горизонтальной лентой, под ней описание выбранного */
@media (orientation: portrait) and (max-width: 560px) {
  .menu-body { flex-direction: column; }
  #cards {
    display: flex; flex: none; gap: 6px; overflow-x: auto; margin: 0 -12px; padding: 2px 12px 8px;
    scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
  }
  .card { flex: none; width: 78px; scroll-snap-align: center; }
}

/* ландшафт: слева танки, справа описание; каждая колонка листается сама */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --mm-w: 116px; }
  #fire-btn { bottom: calc(var(--pad) + var(--sab) + 6px); }
  .menu-body { flex-direction: row; gap: 12px; overflow: hidden; }
  #cards { flex: 1.1 1 0; min-width: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; overflow-y: auto; align-content: start; }
  .card { min-width: 0; }
  .card .pic { height: 46px; }
  .card .pic img { max-height: 44px; max-width: 48px; }
  #side { flex: 1 1 0; min-width: 0; overflow-y: auto; }
  /* высоты мало (300–400 px): шапка и футер в одну строку и потеснее, всё освободившееся — списку танков */
  .menu header { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 2px 12px; padding: 6px 12px 2px; }
  .menu h1 { font-size: 16px; }
  #menu-status { font-size: 10.5px; }
  .chip { padding: 2px 7px; }
  .menu-body { padding: 6px 12px; }
  .menu footer { padding: 5px 12px calc(6px + var(--sab)); }
  .name-field input { padding: 6px 10px; }
  button.primary { padding: 8px 22px; }
  #banner { bottom: calc(var(--pad) + var(--sab)); max-width: 46vw; }
}
