:root {
  /* the phone's notch, and in Telegram's full screen its own buttons over the top (the --tg-* are set by Telegram) */
  --safe-t: max(env(safe-area-inset-top, 0px), calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)));
  --safe-b: max(env(safe-area-inset-bottom, 0px), calc(var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px)));
  --safe-l: max(env(safe-area-inset-left, 0px), var(--tg-safe-area-inset-left, 0px));
  --safe-r: max(env(safe-area-inset-right, 0px), var(--tg-safe-area-inset-right, 0px));
  --side: clamp(128px, 17vw, 184px);
  --cmd: 46px;
  /* the strip's buttons: 40 px (fingers) wherever the 17 of them fit — 707 px and wider; on a narrower screen they
     narrow so that all 17 still fit without sliding sideways (640 px: 36 px). --strip-extra — what the strip takes
     besides the buttons: its padding, 17 gaps, the gap after zoom, the least room before the groups */
  --btn-max: 40px;
  --btn-min: 30px;
  --strip-extra: 27px;
  --btn: clamp(var(--btn-min), calc((100vw - var(--safe-l) - var(--safe-r) - var(--strip-extra)) / 17), var(--btn-max));
  --panel: #1d2017;
  --panel2: #2a2e22;
  --edge: #464d38;
  --text: #dfe3d2;
  --dim: #8d927f;
  --accent: #b9e08a;
  /* the battle skin, by the player's side (decision of the user, 30.10; sample: GPT-картинки/20): <body> gets
     skin-nova — dark blue glass with light blue edges (these defaults), or skin-molot — dark steel, rivets, red edges */
  --sk-frame: #2f8cff;
  --sk-glow: rgba(60, 150, 255, 0.45);
  --sk-panel: linear-gradient(180deg, #0d1c3a, #050b19);
  --sk-strip: linear-gradient(180deg, #0e1f42, #050b19);
  --sk-btn: linear-gradient(180deg, rgba(48, 94, 160, 0.95), rgba(13, 30, 64, 0.96) 52%, rgba(6, 15, 34, 0.98));
  --sk-btn-edge: rgba(96, 176, 255, 0.72);
  --sk-btn-shade: inset 0 1px 0 rgba(180, 225, 255, 0.3), inset 0 0 7px rgba(70, 150, 255, 0.22), 0 0 4px rgba(50, 140, 255, 0.28);
  --sk-on: linear-gradient(180deg, #3f93ee, #16449a);
  --sk-on-edge: #a9deff;
  --sk-hi: #9fdcff;
  --sk-icon: #dcebff;
  --sk-r: 6px;
  --sk-rivets: none;
  --sk-sheen: linear-gradient(155deg, rgba(170, 220, 255, 0.2), rgba(170, 220, 255, 0) 42%);
  --sk-well: #02060f;
  --sk-item: radial-gradient(circle at 50% 38%, #24477a, #0a1630 78%);
  --sk-chip: rgba(8, 18, 40, 0.85);
}
body.skin-molot {
  --sk-frame: #d0342a;
  --sk-glow: rgba(255, 60, 40, 0.36);
  --sk-panel: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.022) 0 1px, transparent 1px 4px), linear-gradient(180deg, #2d2e31, #141517);
  --sk-strip: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.022) 0 1px, transparent 1px 4px), linear-gradient(180deg, #303134, #151618);
  --sk-btn: linear-gradient(180deg, #4b4d51, #2b2c2f 50%, #1b1c1e);
  --sk-btn-edge: #ad352c;
  --sk-btn-shade: inset 0 1px 0 rgba(255, 255, 255, 0.17), inset 0 -2px 0 rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.6);
  --sk-on: linear-gradient(180deg, #c63c30, #6b1913);
  --sk-on-edge: #ff8a70;
  --sk-hi: #ff8f72;
  --sk-icon: #f0e7e4;
  --sk-r: 2px;
  /* a rivet in each corner */
  --sk-rivets: radial-gradient(circle at 4px 4px, #b4b4b4 0 0.8px, #4a4a4a 1.4px, transparent 1.9px),
    radial-gradient(circle at calc(100% - 4px) 4px, #b4b4b4 0 0.8px, #4a4a4a 1.4px, transparent 1.9px),
    radial-gradient(circle at 4px calc(100% - 4px), #b4b4b4 0 0.8px, #4a4a4a 1.4px, transparent 1.9px),
    radial-gradient(circle at calc(100% - 4px) calc(100% - 4px), #b4b4b4 0 0.8px, #4a4a4a 1.4px, transparent 1.9px);
  --sk-sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0) 35%);
  --sk-well: #0a0a0b;
  --sk-item: radial-gradient(circle at 50% 38%, #4b4c50, #1c1d1f 78%);
  --sk-chip: rgba(28, 28, 30, 0.88);
}
html,
body {
  margin: 0;
  height: 100%;
  background: #000;
  color: var(--text);
  font: 13px/1.2 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
}
/* the map over the whole screen but the panel on the right; the strip under both, across the whole width */
#app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side);
  grid-template-rows: minmax(0, 1fr) var(--cmd);
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  box-sizing: border-box;
}
#view {
  grid-area: 1 / 1;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
#view canvas {
  display: block;
}

/* ── the command strip at the bottom (like RA2's command bar): icons only, all 17 always in sight ── */
#cmd {
  grid-area: 2 / 1 / 3 / 3;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 0 2px;
  box-sizing: border-box;
  background: var(--sk-strip);
  border-top: 2px solid var(--sk-frame);
  box-shadow: 0 -1px 8px var(--sk-glow);
  overflow: hidden;
}
.cmd {
  position: relative;
  flex: 1 0 var(--btn);
  min-width: var(--btn);
  max-width: 56px;
  height: var(--btn-max);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
  color: var(--sk-icon);
  background-color: transparent;
  background-image: var(--sk-rivets), var(--sk-sheen), var(--sk-btn);
  border: 1px solid var(--sk-btn-edge);
  border-radius: var(--sk-r);
  box-shadow: var(--sk-btn-shade);
}
.cmd .i {
  display: flex;
  line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.8));
}
.cmd svg {
  display: block;
}
.cmd.on {
  color: #fff;
  background-image: var(--sk-rivets), var(--sk-sheen), var(--sk-on);
  border-color: var(--sk-on-edge);
  box-shadow: 0 0 9px var(--sk-glow), var(--sk-btn-shade);
}
.cmd.off {
  opacity: 0.35;
}
.cmd.grp .i {
  font-weight: 800;
  font-size: 17px;
}
/* how many are in the group: a small number in the corner */
.cmd.grp .n {
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: var(--sk-hi);
  text-shadow: 0 0 2px #000, 0 0 2px #000;
}
/* a group that holds someone is lit */
.cmd.grp.set {
  color: var(--sk-hi);
  border-color: var(--sk-on-edge);
}
.cmd.grp.set .i {
  filter: drop-shadow(0 0 4px var(--sk-glow));
}
.cmd:active {
  filter: brightness(1.35);
}
.cmd.sep {
  margin-left: 3px;
}
/* between the commands and the groups: the free room of a wide screen (the groups go to the right end) */
#cmd .strip-gap {
  flex: 1 0 3px;
}

/* ── the side panel on the right (like RA2), down to the strip ── */
#side {
  grid-area: 1 / 2;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px 5px 4px;
  box-sizing: border-box;
  min-height: 0;
  background: var(--sk-rivets), var(--sk-panel);
  border-left: 2px solid var(--sk-frame);
  box-shadow: -1px 0 8px var(--sk-glow), inset 1px 0 0 rgba(255, 255, 255, 0.08), inset 0 0 18px rgba(0, 0, 0, 0.45);
}
#res {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#money {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-weight: 800;
  font-size: 16px;
  color: #f4f8ff;
  letter-spacing: 0.5px;
  white-space: nowrap;
  text-shadow: 0 1px 2px #000;
}
#money .gem svg {
  display: block;
  width: 16px;
  height: 16px;
  color: #7fd2ff;
  filter: drop-shadow(0 0 3px rgba(80, 180, 255, 0.7));
}
/* the power bar like RA2's: lit as far as the power made, a white mark at the power used;
   green — to spare, yellow — just enough, red — not enough */
#power-row {
  --pw: #43dc5c;
  --pw2: #1d8a33;
  display: flex;
  align-items: center;
  gap: 3px;
  min-height: 16px;
}
#power-row[data-level='tight'] {
  --pw: #ffd23c;
  --pw2: #b8860e;
}
#power-row[data-level='low'] {
  --pw: #ff4b3b;
  --pw2: #a3170e;
}
#power-row .bolt svg {
  display: block;
  width: 13px;
  height: 13px;
  color: var(--pw);
  filter: drop-shadow(0 0 3px var(--pw));
}
#power {
  position: relative;
  flex: 1;
  height: 9px;
  background: var(--sk-well);
  border: 1px solid var(--sk-btn-edge);
  border-radius: 2px;
}
#power-fill {
  position: absolute;
  top: 1px;
  bottom: 1px;
  left: 1px;
  width: 0;
  background: linear-gradient(180deg, var(--pw), var(--pw2));
  box-shadow: 0 0 5px var(--pw);
  transition: width 0.3s;
}
/* segments */
#power::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 6px, var(--sk-well) 6px 8px);
  pointer-events: none;
}
/* the numbers, small: used / made */
#power-text {
  font-size: 10px;
  line-height: 1;
  color: var(--sk-icon);
  opacity: 0.85;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
#power-row[data-level='tight'] #power-text,
#power-row[data-level='low'] #power-text {
  color: var(--pw);
  opacity: 1;
}
#power-use {
  position: absolute;
  z-index: 1;
  top: -3px;
  bottom: -3px;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.75);
  transition: left 0.3s;
}
/* the mini-map; dark (no radar or not enough power) — the side's emblem over dead glass */
#mini {
  position: relative;
  flex: none;
  overflow: hidden;
  background: var(--sk-well);
  border: 1px solid var(--sk-btn-edge);
  border-radius: var(--sk-r);
  box-shadow: 0 0 5px var(--sk-glow);
}
#minimap {
  display: block;
  width: 100%;
  background: #000;
  touch-action: none;
}
.mini-dark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 45%, rgba(255, 255, 255, 0.07), transparent 70%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 3px), var(--sk-well);
  animation: mini-dark-in 0.3s ease-out;
}
.mini-dark[hidden] {
  display: none;
}
.mini-dark .emblem {
  height: 84%;
  width: auto;
  filter: drop-shadow(0 0 4px var(--sk-glow)) drop-shadow(0 1px 1px #000);
}
@keyframes mini-dark-in {
  from {
    opacity: 0;
  }
}
/* «⋯»: the shelf with the rarer commands, just above the strip */
#more-pop {
  position: absolute;
  bottom: 4px;
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--sk-strip);
  border: 1px solid var(--sk-frame);
  border-radius: var(--sk-r);
  box-shadow: 0 0 8px var(--sk-glow);
  z-index: 2;
}
#more-pop[hidden] {
  display: none;
}
#more-pop .cmd {
  width: 46px;
  height: 42px;
  flex: none;
  max-width: none;
}
#tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
}
.tab {
  height: 30px;
  padding: 0;
  color: var(--sk-icon);
  background-color: transparent;
  background-image: var(--sk-sheen), var(--sk-btn);
  border: 1px solid var(--sk-btn-edge);
  border-radius: var(--sk-r);
  box-shadow: var(--sk-btn-shade);
  font-size: 15px;
}
.tab.on {
  color: #fff;
  background-image: var(--sk-sheen), var(--sk-on);
  border-color: var(--sk-on-edge);
  box-shadow: 0 0 7px var(--sk-glow), var(--sk-btn-shade);
}
/* the build grid scrolls up and down on its own (a finger, the mouse wheel); never the map behind it */
#grid {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: min-content;
  gap: 3px;
  scrollbar-width: none;
}
#grid::-webkit-scrollbar {
  display: none;
}
.item {
  position: relative;
  height: 48px;
  padding: 0;
  overflow: hidden;
  background: var(--sk-item);
  border: 1px solid var(--sk-btn-edge);
  border-radius: var(--sk-r);
  box-shadow: var(--sk-btn-shade);
}
.item .art {
  position: absolute;
  inset: 2px 2px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.item .art img {
  max-width: 100%;
  max-height: 100%;
}
.item .price {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 700;
  color: #eef5ff;
  background: rgba(0, 0, 0, 0.58);
}
.item .price svg {
  width: 9px;
  height: 9px;
  color: #7fd2ff;
}
.item .clock {
  position: absolute;
  inset: 0;
  background: conic-gradient(transparent var(--p, 0%), rgba(0, 0, 0, 0.62) var(--p, 0%));
}
.item .count {
  position: absolute;
  top: 1px;
  right: 3px;
  font-weight: 700;
  font-size: 12px;
  text-shadow: 0 0 3px #000;
}
.item .ready {
  position: absolute;
  left: 0;
  right: 0;
  top: 15px;
  font-weight: 700;
  font-size: 11px;
  color: var(--sk-hi);
  text-shadow: 0 0 3px #000, 0 0 3px #000;
}
.tab svg {
  display: block;
  margin: auto;
}
/* a button's name: over it on a long press (a PC: the mouse resting on it) */
#tip {
  position: fixed;
  z-index: 20;
  left: 0;
  top: 0;
  max-width: min(60vw, 320px);
  padding: 5px 9px;
  font-size: 12px;
  line-height: 1.25;
  color: #fff;
  background: rgba(6, 10, 20, 0.94);
  border: 1px solid var(--sk-frame);
  border-radius: 6px;
  box-shadow: 0 0 8px var(--sk-glow);
  white-space: pre-line;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}
#tip.show {
  opacity: 1;
}

/* ── the ☰ menu: a box in the middle, the battle dimmed behind ── */
#menu {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 10;
}
#menu[hidden],
#menu [hidden] {
  display: none;
}
.m-box {
  min-width: 240px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: linear-gradient(#2a2e22, #1b1d15);
  border: 1px solid var(--edge);
  border-radius: 8px;
}
.m-title {
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}
.m-btn {
  min-height: 42px;
  background: var(--panel2);
  border: 1px solid #5a6248;
  border-radius: 6px;
  font-size: 14px;
}
.m-btn:active {
  filter: brightness(1.4);
}
.m-pair {
  display: flex;
  gap: 8px;
}
.m-pair .m-btn {
  flex: 1;
}
.m-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.m-row select {
  min-height: 34px;
  font: inherit;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid #5a6248;
  border-radius: 4px;
}
.m-row input[type='checkbox'] {
  width: 24px;
  height: 24px;
}
/* in the battle (body.skin-…) the ☰ menu and the end box wear the side's skin */
body[class*='skin-'] #menu .m-box,
body[class*='skin-'] #end .m-box {
  background: var(--sk-rivets), var(--sk-panel);
  border: 2px solid var(--sk-frame);
  border-radius: var(--sk-r);
  box-shadow: 0 0 14px var(--sk-glow);
}
body[class*='skin-'] #menu .m-btn,
body[class*='skin-'] #end .m-btn,
body[class*='skin-'] #menu .m-row select {
  color: var(--sk-icon);
  background-color: transparent;
  background-image: var(--sk-btn);
  border: 1px solid var(--sk-btn-edge);
  border-radius: var(--sk-r);
  box-shadow: var(--sk-btn-shade);
}
body[class*='skin-'] #menu .m-row select option {
  background: #111;
}
#chips {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 4px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  pointer-events: none;
}
.chip {
  pointer-events: auto;
  flex: 0 0 auto;
  height: 40px;
  min-width: 52px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 6px 0 2px;
  background: var(--sk-chip);
  border: 1px solid var(--sk-btn-edge);
  border-radius: var(--sk-r);
  box-shadow: var(--sk-btn-shade);
}
.chip img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}
.chip b {
  font-size: 13px;
}
#toast {
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  max-width: 80%;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.7);
  font-size: 12px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
}
#toast.show {
  opacity: 1;
}

/* ── landscape only: a phone held upright sees «turn the phone» ── */
#rotate {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #111309;
  font-size: 18px;
  text-align: center;
  padding: 24px;
}
#rotate .phone {
  font-size: 64px;
  animation: turn 2s ease-in-out infinite;
}
@keyframes turn {
  0%,
  30% {
    transform: rotate(0deg);
  }
  60%,
  100% {
    transform: rotate(-90deg);
  }
}
@media (orientation: portrait) {
  #app {
    visibility: hidden;
  }
  #rotate {
    display: flex;
  }
}

/* ── the build grid driven by the rules ── */
.item.na {
  opacity: 0.38;
}
/* ready to place, or just out (a unit): the tab and the icon blink, like RA2 */
@keyframes ff-blink {
  0%,
  100% {
    filter: none;
  }
  50% {
    filter: brightness(1.75);
    border-color: var(--sk-hi);
    box-shadow: 0 0 10px var(--sk-glow), inset 0 0 8px var(--sk-glow);
  }
}
.tab.ready,
.tab.done,
.item.ready,
.item.done {
  animation: ff-blink 0.8s ease-in-out infinite;
}
.item.placing {
  border-color: var(--sk-on-edge);
  box-shadow: 0 0 0 2px var(--sk-on-edge) inset, 0 0 8px var(--sk-glow);
}
.item .art img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.grid-empty {
  grid-column: 1 / -1;
  padding: 12px 4px;
  text-align: center;
  color: var(--dim);
  font-size: 12px;
}

/* ── the end of the battle ── */
#end {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  z-index: 11;
}
#end[hidden] {
  display: none;
}
.e-title {
  text-align: center;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #ff7a6a;
}
.e-title.won {
  color: var(--accent);
}
.e-time {
  text-align: center;
  color: var(--dim);
  margin-bottom: 6px;
}

/* ── the start screen «Схватка» ── */
#start {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #2b3324, #0b0d08 75%);
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  overflow-y: auto;
}
#start[hidden] {
  display: none;
}
.s-box {
  width: min(560px, 94vw);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0;
}
.s-logo {
  text-align: center;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 6px;
  color: #e7ecd8;
  text-shadow: 0 2px 0 #000, 0 0 16px rgba(120, 190, 215, 0.45);
}
.s-sub {
  text-align: center;
  color: var(--dim);
  font-size: 12px;
  margin-top: -6px;
}
.s-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.s-row > span {
  flex: 0 0 96px;
  font-size: 12px;
  color: var(--dim);
}
.s-opts {
  flex: 1;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.s-opt {
  flex: 1 1 0;
  min-width: 64px;
  min-height: 40px;
  padding: 2px 6px;
  background: var(--panel2);
  border: 1px solid #4a523c;
  border-radius: 6px;
  font-size: 13px;
}
.s-opt.on {
  background: #4d5a2e;
  border-color: var(--accent);
  color: #fff;
}
.s-opt.off {
  opacity: 0.4;
}
.s-opt.nova.on {
  background: #23476e;
  border-color: #6fa8ff;
}
.s-opt.molot.on {
  background: #6a2420;
  border-color: #ff5a4a;
}
/* «Found a bug?» under «To battle» (the beta) */
.s-bug {
  align-self: center;
  padding: 4px 10px;
  background: none;
  border: none;
  color: var(--text);
  opacity: 0.7;
  font-size: 13px;
  text-decoration: underline;
}
#e-story {
  margin-top: 8px;
  width: 100%;
}
.s-go {
  min-height: 48px;
  margin-top: 4px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(#6a7d3a, #4d5a2e);
  border: 1px solid var(--accent);
  border-radius: 8px;
}

/* a phone on its side: five rows of choices and «В бой» still fit without scrolling */
@media (max-height: 420px) {
  .s-box:not(.room) {
    gap: 6px;
  }
  .s-box:not(.room) .s-opt {
    min-height: 36px;
  }
}

/* ── «Схватка» with a friend: the room (on the start screen) ── */
.s-box {
  margin: auto; /* centred, yet scrolls from the top when taller than the screen */
}
.s-box.room {
  width: min(860px, 96vw);
  gap: 6px;
}
.s-box.room .s-logo {
  font-size: 20px;
  letter-spacing: 4px;
}
.s-box.room .s-sub {
  margin-top: -4px;
}
.s-box.room .s-opt {
  min-height: 34px;
  min-width: 52px;
}
.r-seats {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 6px;
  align-items: stretch;
}
.r-vs {
  align-self: center;
  font-weight: 900;
  color: var(--dim);
  letter-spacing: 1px;
}
.r-seat {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 7px;
  background: linear-gradient(#262a1f, #1a1c14);
  border: 1px solid #3c4232;
  border-radius: 8px;
}
.r-seat.me {
  border-color: var(--accent);
}
.r-seat.open {
  border-style: dashed;
}
.r-seat .s-row {
  gap: 0;
}
.r-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  flex-wrap: wrap;
}
.r-name b {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}
.r-name small {
  color: var(--dim);
  font-size: 11px;
}
.r-name small.ok {
  color: var(--accent);
}
.r-sw {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.5);
}
.r-colors {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.r-color {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.5);
}
.r-color.on {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent);
}
.r-color.off {
  opacity: 0.25;
}
.r-hint {
  color: var(--dim);
  font-size: 12px;
}
.r-inv {
  flex: 0 0 auto;
  min-height: 36px;
}
.r-status {
  min-height: 16px;
  text-align: center;
  color: var(--dim);
  font-size: 12px;
}
.r-status.lost {
  color: #ff8a6a;
}
.r-status.sel {
  user-select: text;
  -webkit-user-select: text;
  color: var(--text);
  word-break: break-all;
}
.r-foot {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.r-foot .m-btn {
  flex: 0 1 auto;
  padding: 0 10px;
}
.r-foot .r-ready {
  flex: 1;
  margin-top: 0;
}
.r-foot .r-ready.on {
  background: linear-gradient(#3a4030, #2a2e22);
  border-color: #5a6248;
}
.r-ask {
  position: fixed;
  inset: 0;
  z-index: 13;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}
.r-msg {
  margin: 8px 0;
  font-size: 14px;
  color: var(--text);
}
.r-back {
  font-size: 14px;
  font-weight: 600;
}
@media (max-width: 700px) {
  .s-box.room .s-opt {
    min-width: 0;
    padding: 2px 4px;
    font-size: 12px;
  }
  .r-seat {
    padding: 5px;
  }
}

/* ── a battle through the server: the connection in the corner, the pause over the battle ── */
#net-state {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 7px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 11px;
  color: #8fdc7a;
  pointer-events: none;
}
#net-state.bad,
#net-state.sync {
  color: #f2c94c;
}
#net-state.lost {
  color: #ff6a5a;
}
#net-state[hidden],
#net-pause[hidden],
.e-why[hidden] {
  display: none;
}
#net-pause {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  max-width: 80%;
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.78);
  border: 1px solid #f2c94c;
  color: #f7e3a0;
  font-size: 15px;
  text-align: center;
  pointer-events: none;
}
.e-why {
  text-align: center;
  color: var(--text);
  margin: -2px 0 6px;
}

/* the battle's pictures are loading: a turning ring in the middle of the map */
.ff-loading {
  position: absolute;
  left: 50%;
  top: 45%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.15);
  border-top-color: rgba(140, 210, 255, 0.95);
  animation: ff-spin 0.9s linear infinite;
  z-index: 5;
  pointer-events: none;
}
@keyframes ff-spin {
  to {
    transform: rotate(360deg);
  }
}

/* the beta mark by the logo (01.11): a small amber tag, raised like an exponent */
.s-beta {
  display: inline-block;
  margin-left: 0.45em;
  padding: 0.15em 0.45em;
  border-radius: 4px;
  background: #e8a317;
  color: #1a1408;
  font-size: 0.38em;
  letter-spacing: 0.08em;
  vertical-align: super;
}
