:root {
  color-scheme: dark;
  --bg: #121712;
  --panel: #1b231a;
  --line: #354031;
  --green: #d5f986;
  --soft: #b1bca5;
  --text: #f1f3e9;
  --sans: system-ui,-apple-system,"Segoe UI",sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 300px;
  background: radial-gradient(ellipse at 40% 0,#20291e 0%,var(--bg) 55%);
  color: var(--text);
  font: 15px var(--sans);
}

button,input {
  font: inherit;
}

[hidden] {
  display: none!important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.shell {
  width: min(1450px,100%);
  margin: 0 auto;
  padding: 22px clamp(14px,3.4vw,48px) 12px;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 19px;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 7px;
}

.sound-toggle {
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: #263021;
  color: #e1ecd6;
  white-space: nowrap;
  font-size: 11px;
  cursor: pointer;
}

.sound-toggle[aria-pressed="false"] {
  color: #a8b2a0;
  background: transparent;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  line-height: 1.02;
  font: 700 21px Georgia,serif;
}

.brand small {
  display: block;
  margin-top: 4px;
  color: #a9b799;
  font: 700 9px var(--sans);
  letter-spacing: .17em;
}

.status,.arena-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .065em;
}

.status {
  color: #c5cdbb;
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 8px 12px;
  white-space: nowrap;
}

.status i,.signal,.eyebrow span {
  height: 7px;
  width: 7px;
  border-radius: 50%;
  background: #ddb46a;
  display: inline-block;
  flex: none;
}

.status.online i,.signal,.eyebrow span {
  background: #c5eb80;
  box-shadow: 0 0 12px #b7e27660;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(218px,265px);
  gap: 16px;
}

.arena {
  height: clamp(515px,calc(100svh - 124px),855px);
  min-width: 0;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid #4a5a3e;
  border-radius: 22px;
  background: #1d281a;
  user-select: none;
}

#field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  -webkit-touch-callout: none;
}

.arena-top {
  position: absolute;
  top: 14px;
  left: 15px;
  z-index: 2;
  padding: 8px 10px;
  background: #182118e8;
  border: 1px solid #4c5b40;
  border-radius: 8px;
  color: #e5ecd8;
  pointer-events: none;
  white-space: nowrap;
}

.arena-right {
  left: auto;
  right: 15px;
  gap: 4px;
  font-weight: 620;
  letter-spacing: 0;
}

.arena-index {
  color: #93a280;
}

.veil {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: safe center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 50px 20px 22px;
  background: radial-gradient(ellipse at 50% 48%,#131d14ee 1%,#141e15d0 30%,#101a1245 78%);
}

.welcome {
  text-align: center;
  width: min(100%,570px);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #b0c890;
  font: 750 10px var(--sans);
  letter-spacing: .19em;
}

.welcome .eyebrow {
  justify-content: center;
}

h1,h2 {
  margin: 0;
  font-family: Georgia,"Times New Roman",serif;
}

h1 {
  font-size: clamp(50px,7.4vw,110px);
  letter-spacing: -.07em;
  line-height: .96;
  margin: 16px 0 14px;
  text-shadow: 0 5px 25px #111810;
  overflow-wrap: normal;
}

.welcome p {
  margin: 0 auto 23px;
  color: #d0dac5;
  max-width: 380px;
  line-height: 1.5;
  font-size: clamp(13px,1.4vw,16px);
}

#join {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 0 auto 10px;
  max-width: 385px;
}

#nickname,#play {
  border-radius: 11px;
  min-height: 48px;
  border: 1px solid #697c50;
}

#nickname {
  width: 0;
  flex: 1;
  min-width: 76px;
  background: #1d281a;
  color: #f0f3e8;
  padding: 0 13px;
  font-size: 16px;
  outline: none;
}

#nickname:focus-visible,button:focus-visible {
  outline: 2px solid #f5ffdc;
  outline-offset: 3px;
}

#play {
  background: var(--green);
  color: #1b2711;
  font-weight: 800;
  min-width: 140px;
  padding: 0 15px;
  cursor: pointer;
  white-space: nowrap;
}

#play span {
  margin-left: 7px;
}

#play:hover:not(:disabled) {
  background: #e5ffa6;
}

#play:disabled {
  opacity: .58;
  cursor: wait;
}

#hint {
  color: #aebca0;
  font-size: 11px;
  display: block;
  min-height: 1.2em;
}

.lobby-tools,.periods {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 0 8px;
}

.welcome .lobby-controls {
  font-size: 12px;
  margin: 0 auto 6px;
}

#touch-modes {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
}

#touch-modes legend,#touch-modes small {
  color: var(--soft);
  font-size: 12px;
}

#touch-modes label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 5px;
  cursor: pointer;
}

#touch-modes input {
  accent-color: var(--green);
}

#touch-modes small {
  display: block;
}

#mobile-display {
  display: none;
  margin-top: 8px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

#mobile-display summary,#mobile-display label {
  min-height: 44px;
  cursor: pointer;
}

#mobile-display summary {
  padding: 10px 0;
}

#mobile-display label {
  display: flex;
  align-items: center;
  gap: 8px;
}

#mobile-display input {
  accent-color: var(--green);
}

#mobile-display small {
  display: block;
  margin: 0 0 6px;
  color: var(--soft);
}

.lobby-tools button,.periods button,.skin-card,.close-menu {
  min-height: 44px;
  border: 1px solid #57684a;
  border-radius: 10px;
  color: var(--text);
  background: #202d1b;
  cursor: pointer;
  padding: 6px 11px;
}

.lobby-tools button:disabled,.skin-card:disabled {
  opacity: .58;
  cursor: default;
}

#level-label {
  color: var(--green);
}

.menu-dialog {
  width: min(500px, calc(100% - 32px));
  max-height: min(640px, calc(100vh - 28px));
  max-height: min(640px, calc(100dvh - 28px));
  border: 1px solid #63774d;
  border-radius: 17px;
  background: var(--panel);
  color: var(--text);
  padding: 16px;
  overscroll-behavior: contain;
}

.menu-dialog::backdrop {
  background: #0c120cbb;
}

.menu-dialog h2 {
  padding-right: 46px;
}

.menu-dialog p {
  color: var(--soft);
  font-size: 13px;
}

.close-menu {
  position: absolute;
  right: 10px;
  top: 10px;
  min-width: 44px;
  font-size: 22px;
}

.periods {
  justify-content: start;
  flex-wrap: wrap;
}

.periods [aria-pressed="true"],.skin-card[aria-pressed="true"] {
  background: #36472a;
  border-color: var(--green);
}

.records-scroll {
  max-height: 300px;
  overflow: auto;
  overscroll-behavior: contain;
}

.records-scroll table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.records-scroll th,.records-scroll td {
  text-align: left;
  padding: 9px 6px;
  border-bottom: 1px solid var(--line);
}

.records-scroll th {
  position: sticky;
  top: 0;
  background: var(--panel);
}

.records-scroll :is(th,td):last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.records-scroll .self {
  color: var(--green);
}

.skin-list {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 8px;
}

.skin-card {
  display: grid;
  justify-items: center;
  gap: 3px;
}

.skin-card canvas {
  display: block;
  max-width: 100%;
}

.skin-card small {
  color: var(--soft);
}

.results {
  display: flex;
  gap: 13px;
  justify-content: center;
  margin: -7px 0 20px;
}

.results div {
  min-width: 99px;
  padding: 8px 13px;
  border: 1px solid #475637;
  background: #1e281ae0;
  border-radius: 10px;
}

.results b,.results span {
  display: block;
}

.results b {
  color: var(--green);
  font-size: 23px;
}

.results span {
  font-size: 9px;
  letter-spacing: .12em;
  color: #becbb2;
  font-weight: 750;
}

.sidebar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 17px 15px;
  min-width: 0;
}

h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -.035em;
  margin: 6px 0 13px;
}

.ranking {
  --mass-col: 60px;
  --knockouts-col: 42px;
  --ranking-gap: 4px;
}

.table-label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--mass-col) var(--knockouts-col);
  gap: var(--ranking-gap);
  border-top: 1px solid #364330;
  padding: 11px 8px 4px 0;
  color: #a3b195;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .1em;
}

.table-label span:not(:first-child) {
  text-align: right;
}

#leaders {
  margin: 0;
  padding: 0;
  list-style: none;
  min-height: 175px;
  max-height: 175px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  overflow-anchor: none;
  scrollbar-color: #617053 #212a1d;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
}

#leaders:focus-visible {
  outline: 1px solid #b9d690;
  outline-offset: 3px;
}

.ranking-hint {
  margin: 9px 0 0;
  color: #adbca3;
  font-size: 10px;
}

#leaders li {
  display: grid;
  grid-template-columns: 22px 8px minmax(0,1fr) var(--mass-col) var(--knockouts-col);
  align-items: center;
  gap: var(--ranking-gap);
  min-height: 35px;
  border-bottom: 1px solid #303b2e;
  font-size: 12px;
  color: #ecf1e6;
}

#leaders li:last-child {
  border-bottom: 0;
}

#leaders .empty {
  display: flex;
  color: var(--soft);
}

.rank {
  color: #9baa8e;
  font-variant-numeric: tabular-nums;
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.leader-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leader-mass,.leader-knockouts {
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leader-mass {
  font-weight: 750;
}

.leader-knockouts {
  color: #bfcbb5;
}

.self .leader-name,.self .leader-mass,.self .leader-knockouts {
  color: var(--green);
}

.diagram {
  background: #161e15;
  border: 1px solid #374530;
  border-radius: 10px;
}

.diagram svg {
  display: block;
  width: 100%;
  max-height: 66px;
}

.guide p {
  margin: 11px 0 0;
  color: #c3ceb8;
  font-size: 12px;
  line-height: 1.5;
}

.guide strong {
  color: #e2f5bc;
}

.hud {
  position: absolute;
  bottom: 16px;
  left: 15px;
  padding: 10px 12px;
  min-width: 142px;
  z-index: 2;
  background: #182118ed;
  border: 1px solid #4c5b40;
  border-radius: 11px;
  pointer-events: none;
}

.hud-numbers {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.mass,.hud-rank,.hud-knockouts {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: #c5ceb9;
  letter-spacing: .13em;
  font-weight: 750;
  font-size: 9px;
}

.hud-rank,.hud-knockouts {
  border-left: 1px solid #46563c;
  padding-left: 10px;
  gap: 5px;
}

.hud-rank strong,.hud-knockouts strong {
  color: #e3eddb;
  font-size: 16px;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hud-rank strong { color: var(--green); }

.mass strong {
  color: var(--green);
  font-size: 25px;
  letter-spacing: 0;
  line-height: 1;
}

.tunnel-note,.rush-note {
  margin-top: 6px;
  font-size: 10px;
  color: #b0c890;
}

.rush-note {
  color: #ffd068;
}

.bonus-guide {
  list-style: none;
  margin: 13px 0 0;
  padding: 11px 0 0;
  border-top: 1px solid #364330;
  display: grid;
  gap: 8px;
}

.bonus-guide li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
}

.bonus-guide small {
  display: block;
  color: #b6c1ae;
  font-size: 10px;
  margin-top: 1px;
}

.magnet { --effect: #f1a197; }
.sprint { --effect: #f3cf82; }
.double { --effect: #91ddd1; }
.turn { --effect: #cbb8f4; }
.rich-food { --effect: #ffd068; }

.bonus-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 29px;
  flex: 0 0 auto;
  border: 1px solid var(--effect);
  border-radius: 9px;
  color: var(--effect);
  background: #202c23;
  font-weight: 800;
  font-size: 13px;
}

.effects {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.effect {
  color: var(--effect);
  border: 1px solid #4c5b40;
  padding: 3px 6px;
  border-radius: 5px;
  font-size: 10px;
  white-space: nowrap;
}

.effect b {
  margin-left: 3px;
  font-variant-numeric: tabular-nums;
}

.minimap {
  position: absolute;
  bottom: 16px;
  right: 15px;
  width: 136px;
  border: 1px solid #526248;
  border-radius: 12px;
  background: #182118eb;
  pointer-events: none;
}

.minimap canvas {
  display: block;
  width: 100%;
  height: auto;
}

.map-legend {
  display: flex;
  justify-content: space-between;
  gap: 3px;
  padding: 0 7px 6px;
  color: #d0dcc6;
  font-size: 9px;
  white-space: nowrap;
}

.map-player { color: #e8ffae; }
.map-gold { color: #ffd068; }
.map-fall { color: #ff9a8a; }

.boost {
  display: none;
  position: absolute;
  right: 15px;
  bottom: 16px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid #d5f986;
  background: #2c3c22e8;
  color: var(--green);
  font-size: 26px;
  z-index: 3;
  touch-action: none;
}

.boost:active,.boost.active {
  background: var(--green);
  color: #1b2711;
}

.joystick {
  position: absolute;
  left: 16px;
  bottom: 15px;
  width: 78px;
  height: 78px;
  border: 1px solid #d5f98688;
  background: #23341de0;
  border-radius: 50%;
  z-index: 3;
  touch-action: none;
  -webkit-touch-callout: none;
}

.joystick.active {
  border-color: var(--green);
}

.joystick i {
  width: 26px;
  height: 26px;
  background: #c5eb8088;
  border-radius: 50%;
  position: absolute;
  left: 25px;
  top: 25px;
  pointer-events: none;
}

.stick-mode .hud { bottom: 104px; }

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #a0ac97;
  font-size: 11px;
  padding: 12px 2px;
}

footer b {
  margin: 0 3px;
  color: #738767;
}

kbd {
  font: 600 10px var(--sans);
  color: #d4decb;
  border: 1px solid #485543;
  border-radius: 4px;
  padding: 2px 5px;
  margin-right: 2px;
}

.divider {
  display: inline-block;
  width: 1px;
  height: 10px;
  background: #52614b;
  margin: 0 7px;
  vertical-align: middle;
}

.touch-help {
  display: none;
}

@media(max-width:800px) {
  .shell {
    padding-top: 12px;
  }
  .masthead {
    padding-bottom: 12px;
  }
  .layout {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .arena {
    height: clamp(410px,calc(100svh - 92px),760px);
  }
  .sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .panel {
    padding: 13px;
  }
  h2 {
    font-size: 21px;
  }
}

@media(max-width:480px) {
  .arena {
    border-radius: 15px;
  }
  .arena-top {
    left: 8px;
    top: 8px;
  }
  .arena-right {
    left: auto;
    right: 8px;
  }
  .sidebar {
    grid-template-columns: 1fr;
  }
  .hud {
    left: 8px;
    bottom: 8px;
    min-width: 112px;
  }
  .hud-numbers,.mass {
    gap: 6px;
  }
  .hud-rank,.hud-knockouts {
    padding-left: 6px;
  }
  .mass strong {
    font-size: 20px;
  }
  .minimap {
    bottom: 8px;
    right: 8px;
  }
  .brand {
    font-size: 18px;
  }
  .brand img {
    width: 34px;
    height: 34px;
  }
  .status {
    font-size: 9px;
    padding: 6px 8px;
  }
  .sound-label {
    display: none;
  }
  .sound-toggle {
    min-height: 27px;
  }
  footer {
    align-items: flex-start;
    font-size: 10px;
  }
}

@media(any-pointer:coarse) {
  #mobile-display {
    display: block;
  }
  .in-round {
    overflow: hidden;
  }
  .in-round .arena {
    position: fixed;
    inset: env(safe-area-inset-top,0) env(safe-area-inset-right,0)
      env(safe-area-inset-bottom,0) env(safe-area-inset-left,0);
    height: auto;
    min-height: 0;
    border: 0;
    border-radius: 0;
    z-index: 10;
  }
  .in-round .sound-toggle {
    position: fixed;
    top: calc(env(safe-area-inset-top,0px) + 47px);
    left: calc(env(safe-area-inset-left,0px) + 9px);
    z-index: 11;
    min-width: 44px;
    min-height: 44px;
    background: #202c20;
  }
  .in-round .sound-label {
    display: none;
  }
  .boost {
    display: block;
    width: 64px;
    height: 64px;
    -webkit-touch-callout: none;
  }
  .minimap {
    bottom: auto;
    top: 47px;
    width: 94px;
  }
  .hud,.minimap {
    border-color: #83937355;
    background: #121c1270;
    text-shadow: 0 1px 3px #071008;
  }
  .hud {
    padding: 6px 9px;
  }
  .minimap .map-legend {
    display: none;
  }
  .desktop-help {
    display: none;
  }
  .touch-help {
    display: inline;
  }
}

@media(max-height:520px) and (orientation:landscape) {
  .arena {
    height: calc(100svh - 66px);
    min-height: 255px;
  }
  .veil {
    padding: 34px 12px 8px;
  }
  .welcome h1 {
    font-size: 48px;
    margin: 7px 0;
  }
  .welcome p {
    margin-bottom: 9px;
  }
  .welcome .eyebrow {
    display: none;
  }
  .results {
    margin: 0 0 8px;
  }
  .results div {
    padding: 3px 8px;
  }
  .results b {
    font-size: 17px;
  }
  .panel {
    padding: 9px;
  }
  .shell {
    padding-top: 6px;
  }
  .masthead {
    padding-bottom: 5px;
  }
}

#retry-connection {
  margin: 6px 0 0;
}

html.yandex-game,.yandex-game body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

.yandex-game body {
  min-width: 0;
}

.yandex-game .shell {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  padding: 8px 12px 0;
}

.yandex-game .layout {
  min-height: 0;
  grid-template-rows: minmax(0,1fr);
}

.yandex-game .arena {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-width: 200vh;
  max-width: 200dvh;
  max-height: 200vw;
  justify-self: center;
  align-self: center;
}

.yandex-game .sidebar {
  overflow: auto;
  overscroll-behavior: contain;
}

.yandex-game .in-round .shell {
  display: block;
  padding: 0;
}

.yandex-game .in-round .layout {
  height: 100%;
  gap: 0;
}

.yandex-game .in-round .masthead,.yandex-game .in-round .header-tools {
  display: contents;
}

.yandex-game .in-round :is(.brand,.status,footer) {
  display: none;
}

.yandex-game .in-round .arena {
  border-radius: 0;
}

.yandex-game .in-round .sound-toggle {
  position: fixed;
  top: calc(env(safe-area-inset-top,0px) + 47px);
  left: calc(env(safe-area-inset-left,0px) + 10px);
  z-index: 11;
  background: #202c20;
}

@media(max-width:800px) {
  .yandex-game .layout {
    grid-template-rows: auto auto;
    align-content: start;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .yandex-game .arena {
    height: max(310px,calc(100svh - 88px));
  }
  .yandex-game .in-round .layout {
    grid-template-rows: minmax(0,1fr);
    align-content: stretch;
  }
  .yandex-game .in-round .arena {
    height: 100%;
  }
  .yandex-game .in-round .sidebar {
    display: none;
  }
}

@media(any-pointer:coarse) {
  .yandex-game .in-round .arena {
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    place-self: stretch;
  }
}

@media(any-pointer:coarse) and (orientation:landscape) {
  .in-round .hud {
    left: 50%;
    bottom: 15px;
    min-width: 0;
    max-width: calc(100% - 204px);
    width: max-content;
    transform: translateX(-50%);
  }
  .in-round .hud-numbers {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px 8px;
  }
  .in-round .mass {
    gap: 6px;
  }
  .in-round .mass strong {
    font-size: 20px;
    white-space: nowrap;
  }
}
