:root {
  color-scheme: dark;
  --cyan: #3df0ff;
  --magenta: #ff3df2;
  --ink: #d7f7ff;
  --dim: #7f9aa6;
  --line: rgba(61, 240, 255, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
}

button, input { font: inherit; color: inherit; }

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

input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 1px solid rgba(61, 240, 255, 0.35);
  padding: 10px 12px;
  outline: none;
}

input:focus { border-color: var(--cyan); }

button {
  background: var(--magenta);
  color: #140210;
  border: 1px solid var(--magenta);
  padding: 10px 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

button.ghost {
  background: transparent;
  color: var(--cyan);
  border-color: var(--line);
}

button:disabled {
  opacity: 0.35;
  cursor: default;
}

#lobby {
  position: fixed;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  color: var(--ink);
  background: radial-gradient(ellipse at 50% 42%, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.42));
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.menu-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0s linear 0.28s;
}

.menu-screen::before,
.menu-screen::after {
  content: "";
  flex: 1 0 0;
  width: 100%;
}

.menu-screen.is-on {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 1;
  transform: translateY(0);
  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0s linear 0s;
}

#lobby .kicker {
  margin: 0;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.42em;
  padding-left: 0.42em;
}

#lobby h1,
#lobby h2,
#lobby h3 {
  font-weight: 650;
  text-wrap: balance;
}

.title-wrap {
  width: min(640px, 100%);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.logo {
  margin: 10px 0 0;
  padding-left: 0.12em;
  font-size: clamp(56px, 18vw, 140px);
  font-weight: 700;
  line-height: 0.86;
  letter-spacing: 0.12em;
  white-space: nowrap;
  color: #f3fdff;
  text-shadow:
    0 0 8px rgba(61, 240, 255, 0.95),
    0 0 28px rgba(61, 240, 255, 0.72),
    0 0 64px rgba(61, 240, 255, 0.38);
}

.logo-sub {
  margin: 12px 0 0;
  padding-left: 0.46em;
  font-size: clamp(14px, 3.4vw, 28px);
  font-weight: 650;
  letter-spacing: 0.46em;
  white-space: nowrap;
  color: var(--magenta);
  text-shadow: 0 0 16px rgba(255, 61, 242, 0.75);
}

.menu-actions {
  width: min(300px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 28px;
  padding: 14px;
  background: rgba(3, 6, 12, 0.74);
  border: 1px solid rgba(61, 240, 255, 0.45);
  box-shadow: 0 0 28px rgba(61, 240, 255, 0.14);
}

.fine {
  margin: 16px 0 0;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.06em;
}

.panel {
  width: min(1120px, 100%);
  flex-shrink: 0;
  margin-block: 8px;
  padding: 22px 20px 18px;
  background: rgba(3, 6, 12, 0.78);
  border: 1px solid rgba(61, 240, 255, 0.42);
  box-shadow:
    0 0 32px rgba(61, 240, 255, 0.12),
    inset 0 0 0 1px rgba(255, 61, 242, 0.08);
  overflow-wrap: break-word;
}

.panel-help { width: min(640px, 100%); }

.panel-head { margin-bottom: 14px; }

#lobby h2 {
  margin: 4px 0 0;
  font-size: clamp(24px, 4vw, 32px);
  letter-spacing: 0.06em;
}

#lobby h2[tabindex="-1"]:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 4px;
}

.slots {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.slot {
  --slot: var(--cyan);
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid color-mix(in srgb, var(--slot) 55%, transparent);
  box-shadow:
    inset 0 3px 0 var(--slot),
    0 0 18px color-mix(in srgb, var(--slot) 22%, transparent);
}

.slot.is-empty {
  background: rgba(0, 0, 0, 0.45);
  border-color: rgba(127, 154, 166, 0.28);
  box-shadow: inset 0 3px 0 color-mix(in srgb, var(--slot) 42%, transparent);
}

.slot.is-empty .slot-tag,
.slot.is-empty .empty-note {
  color: var(--dim);
  text-shadow: none;
}

.slot-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.slot-tag {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.16em;
  color: var(--slot);
  text-shadow: 0 0 10px color-mix(in srgb, var(--slot) 70%, transparent);
}

.slot-score {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slot);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.slot-score b {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.seg {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.slot-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.slot-body[hidden] { display: none; }

.name-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#lobby input[type="text"] {
  flex: none;
  width: 100%;
  min-width: 0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(61, 240, 255, 0.35);
  padding: 10px 12px;
  text-transform: none;
  letter-spacing: 0;
}

#lobby input[type="text"]:focus-visible {
  border-color: var(--cyan);
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.keys-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.keys-label {
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.keys {
  color: var(--cyan);
  font-size: clamp(18px, 2.2vw, 28px);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.15;
  text-align: center;
  text-shadow: 0 0 12px rgba(61, 240, 255, 0.55);
  overflow-wrap: anywhere;
}

.bot-name {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 650;
}

.bot-note,
.empty-note {
  margin: 0;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.4;
}

.empty-note {
  padding: 18px 0 8px;
  text-align: center;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.switch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  max-width: 100%;
  min-height: 44px;
  margin-top: 16px;
  cursor: pointer;
}

.switch-hit {
  position: relative;
  width: 44px;
  height: 26px;
  flex: none;
}

#lobby .switch input {
  position: absolute;
  inset: 0;
  width: 44px;
  height: 26px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

#lobby .switch input:focus {
  outline: none;
}

.switch-track {
  display: block;
  width: 44px;
  height: 26px;
  border: 1px solid rgba(61, 240, 255, 0.45);
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.35);
  position: relative;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--dim);
  transition: transform 0.18s ease, background-color 0.18s ease;
}

.switch input:checked + .switch-track {
  border-color: var(--magenta);
  box-shadow: 0 0 12px rgba(255, 61, 242, 0.35);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
  background: var(--magenta);
}

#lobby .switch input:focus-visible + .switch-track {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.switch-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.switch-title {
  color: #ffd0ea;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.switch small {
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: none;
}

.roster-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-top: 16px;
}

.start-wrap {
  flex: 1 1 220px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.hint {
  margin: 0;
  color: #ffd0ea;
  font-size: 13px;
  line-height: 1.35;
}

.help-block { margin-top: 16px; }

#lobby .help-block h3 {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.help-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--dim);
  font-size: 14px;
  line-height: 1.45;
  text-wrap: pretty;
}

.help-list strong,
.help-list b { color: var(--ink); font-weight: 650; }

.panel-help .btn-back { margin-top: 18px; }

#lobby .legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#lobby .legend li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-width: 0;
  color: var(--dim);
  font-size: 14px;
  line-height: 1.4;
}

#lobby .legend b { color: var(--ink); font-weight: 650; }

#lobby .legend i {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  flex: none;
}

#lobby button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  text-transform: none;
  letter-spacing: 0.04em;
  background: transparent;
  color: var(--cyan);
  border: 1px solid rgba(61, 240, 255, 0.4);
  box-shadow: none;
}

#lobby .menu-actions button,
#lobby .btn-start { width: 100%; }

#lobby .btn-play,
#lobby .btn-start {
  background: var(--magenta);
  color: #140210;
  border-color: var(--magenta);
  font-weight: 700;
  box-shadow: 0 0 22px rgba(255, 61, 242, 0.35);
}

#lobby .btn-play {
  min-height: 56px;
  font-size: 18px;
  letter-spacing: 0.12em;
}

#lobby .btn-start {
  min-height: 52px;
  font-size: 18px;
  letter-spacing: 0.18em;
}

#lobby .btn-ghost,
#lobby .btn-back {
  min-height: 48px;
  background: transparent;
  color: var(--cyan);
  border-color: rgba(61, 240, 255, 0.45);
}

#lobby .seg button {
  min-width: 0;
  min-height: 40px;
  padding: 8px 2px;
  font-size: 12px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

#lobby .seg button[aria-pressed="true"] {
  background: var(--slot);
  color: #071018;
  border-color: var(--slot);
  font-weight: 700;
}

#lobby button:hover:not(:disabled) {
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(61, 240, 255, 0.22);
}

#lobby .btn-play:hover:not(:disabled),
#lobby .btn-start:hover:not(:disabled) {
  filter: brightness(1.12);
  border-color: var(--magenta);
  box-shadow: 0 0 28px rgba(255, 61, 242, 0.5);
}

#lobby .seg button:hover:not(:disabled):not([aria-pressed="true"]) {
  border-color: var(--slot);
  color: var(--ink);
  box-shadow: none;
}

#lobby button:active:not(:disabled) { transform: translateY(1px); }

#lobby button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

@media (pointer: coarse) {
  #lobby .seg button { min-height: 44px; }
}

@media (max-width: 980px) {
  .slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .panel { padding: 16px 14px; }
  .slots { grid-template-columns: minmax(0, 1fr); }
  .logo { letter-spacing: 0.08em; }
  .logo-sub { letter-spacing: 0.28em; padding-left: 0.28em; }
}

@media (prefers-reduced-motion: reduce) {
  .menu-screen,
  .menu-screen.is-on,
  .switch-track::after,
  #lobby button {
    transition: none;
    transform: none;
  }

  #lobby button:active:not(:disabled) { transform: none; }

  .switch input:checked + .switch-track::after { transform: translateX(18px); }
}

#hud { position: fixed; inset: 0; z-index: 2; pointer-events: none; }

#boost-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  box-shadow: inset 0 0 140px rgba(61, 240, 255, 0.13);
  transition: opacity 0.18s ease-out;
}

#boost-fx.on { opacity: 1; }

#boost-fx::before,
#boost-fx::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-repeat: no-repeat;
}

#boost-fx::before {
  transform: scale(1.08);
  transition: transform 0.26s ease-out;
  background-image:
    linear-gradient(to right, rgba(61, 240, 255, 0.4), transparent),
    linear-gradient(to right, rgba(255, 255, 255, 0.28), transparent),
    linear-gradient(to right, rgba(61, 240, 255, 0.32), transparent),
    linear-gradient(to right, rgba(255, 255, 255, 0.2), transparent),
    linear-gradient(to left, rgba(61, 240, 255, 0.4), transparent),
    linear-gradient(to left, rgba(255, 255, 255, 0.28), transparent),
    linear-gradient(to left, rgba(61, 240, 255, 0.32), transparent),
    linear-gradient(to left, rgba(255, 255, 255, 0.2), transparent);
  background-size:
    28vw 1px,
    16vw 1px,
    22vw 1px,
    12vw 1px,
    26vw 1px,
    15vw 1px,
    20vw 1px,
    18vw 1px;
  background-position:
    left 0 top 18%,
    left 2% top 34%,
    left 0 top 57%,
    left 4% top 76%,
    right 0 top 22%,
    right 3% top 41%,
    right 0 top 63%,
    right 2% top 81%;
}

#boost-fx.on::before { transform: scale(1); }

#boost-fx::after {
  opacity: 0.8;
  transform: scale(1.14);
  transition: transform 0.18s ease-out;
  background-image:
    linear-gradient(to right, rgba(61, 240, 255, 0.22), transparent),
    linear-gradient(to right, rgba(255, 255, 255, 0.16), transparent),
    linear-gradient(to left, rgba(61, 240, 255, 0.22), transparent),
    linear-gradient(to left, rgba(255, 255, 255, 0.16), transparent);
  background-size:
    34vw 2px,
    20vw 1px,
    32vw 2px,
    18vw 1px;
  background-position:
    left 0 top 26%,
    left 1% top 68%,
    right 0 top 30%,
    right 1% top 72%;
}

#boost-fx.on::after { transform: scale(1); }

#scoreboard {
  position: absolute;
  top: 16px;
  left: 16px;
  min-width: 280px;
  padding: 10px 12px;
  background: rgba(3, 6, 12, 0.72);
  border: 1px solid var(--line);
}

#scoreboard .round, #scoreboard .out {
  margin: 0 0 6px;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#scoreboard ul { list-style: none; margin: 0; padding: 0; }
#scoreboard li {
  display: grid;
  grid-template-columns: 10px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
  font-size: 14px;
}
#scoreboard li i { width: 10px; height: 10px; background: var(--c); box-shadow: 0 0 8px var(--c); }
#scoreboard .sc { color: var(--cyan); }
#scoreboard .st { color: var(--dim); font-size: 12px; }
#scoreboard .fx { grid-column: 2 / -1; color: #ffe14a; font-size: 12px; }
#scoreboard .fx:empty { display: none; }

.banner {
  position: absolute;
  left: 50%;
  top: 16%;
  transform: translateX(-50%);
  width: min(92vw, 920px);
  text-align: center;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(61, 240, 255, 0.85);
}

#banner-title {
  font-size: clamp(32px, 7vw, 76px);
  letter-spacing: 0.14em;
  line-height: 1;
}

#banner-sub {
  margin-top: 10px;
  font-size: 16px;
  letter-spacing: 0.12em;
  color: #ffd7fb;
}

#stamina {
  position: absolute;
  left: 16px;
  bottom: 88px;
  width: 168px;
  height: 8px;
  border: 1px solid rgba(61, 240, 255, 0.4);
  background: rgba(3, 6, 12, 0.7);
}

#stamina span {
  display: block;
  height: 100%;
  width: 100%;
  background: #3df0ff;
}

#stamina.hot span { background: #ffe14a; }

#stamina em {
  position: absolute;
  left: 176px;
  top: -6px;
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

#help {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 62px;
  margin: 0;
  color: var(--dim);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.dock {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

#toast {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  padding: 10px 14px;
  background: rgba(3, 6, 12, 0.92);
  border: 1px solid var(--magenta);
  color: #ffd7fb;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

/* ---------- онлайн ---------- */
.panel-online { width: min(820px, 100%); }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin-bottom: 14px;
}

.field-caption {
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.online-fine { margin: 8px 0 18px; }

.online-cols {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 18px;
}

.online-cols h3 {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.room-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
}

.room-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(61, 240, 255, 0.22);
  background: rgba(0, 0, 0, 0.3);
}

.room-list li.empty {
  color: var(--dim);
  font-size: 13px;
  justify-content: center;
  border-style: dashed;
}

.room-list .room-code {
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink);
}

.room-list .room-who {
  flex: 1;
  min-width: 0;
  color: var(--dim);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-list .room-count {
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

#lobby .room-list button { padding: 6px 12px; font-size: 12px; }

.online-side { display: flex; flex-direction: column; gap: 12px; }
.online-side .switch { margin: 0; }

.code-form { display: flex; align-items: flex-end; gap: 8px; }
.code-form .field { flex: 1; margin: 0; }
#lobby #room-code { text-transform: uppercase; letter-spacing: 0.2em; }

#online-status:empty { display: none; }

.room-info {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  background: rgba(3, 6, 12, 0.72);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--dim);
  pointer-events: auto;
}

.room-info b { color: var(--ink); letter-spacing: 0.16em; }
.room-info button { padding: 6px 10px; font-size: 11px; }

@media (max-width: 640px) {
  .online-cols { grid-template-columns: 1fr; }
}

/* ---------- настройки ---------- */
.panel-settings { width: min(520px, 100%); }
.panel-settings .btn-back { margin-top: 18px; }

.volume {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 14px;
  margin: 18px 0;
}

.volume label {
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 0.06em;
}

.volume output {
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 13px;
}

#lobby input[type="range"] {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--cyan);
  cursor: pointer;
}

#lobby input[type="range"]:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 4px;
}

.panel-settings .switch { margin-top: 6px; }

/* ---------- настройки в матче ---------- */
.hud-settings {
  position: absolute;
  right: 16px;
  bottom: 64px;
  width: min(360px, calc(100vw - 32px));
  padding: 16px 16px 12px;
  background: rgba(3, 6, 12, 0.88);
  border: 1px solid var(--line);
  box-shadow: 0 0 24px rgba(61, 240, 255, 0.12);
  pointer-events: auto;
}

.hud-settings-title {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hud-settings .volume { margin: 12px 0; grid-template-columns: 72px minmax(0, 1fr) 44px; }

.hud-settings input[type="range"] {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--cyan);
  cursor: pointer;
}

.hud-settings-row { display: flex; gap: 8px; margin-top: 8px; }
.hud-settings-row button { flex: 1; padding: 8px 10px; font-size: 12px; }

.hud-settings-keys {
  margin: 12px 0 0;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.5;
}

#hud-settings-btn[aria-expanded="true"] {
  background: rgba(61, 240, 255, 0.14);
  border-color: var(--cyan);
}

#hud button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

#hud canvas, #c.looking { cursor: grabbing; }
.hud-settings-row button { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* ---------- таблица и итоги ---------- */
#scoreboard { min-width: 300px; }

#scoreboard .clock {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(61, 240, 255, 0.18);
}

#scoreboard .clock b {
  color: var(--ink);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

#scoreboard .clock b.hurry { color: #ff7a4a; text-shadow: 0 0 10px rgba(255, 122, 74, 0.6); }
#scoreboard .clock span { color: var(--dim); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; }

#scoreboard .head,
#scoreboard li {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 38px 38px;
  gap: 8px;
  align-items: center;
}

#scoreboard .head {
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding-bottom: 2px;
}

#scoreboard .head span:nth-child(n + 3),
#scoreboard .k,
#scoreboard .d { text-align: right; font-variant-numeric: tabular-nums; }

#scoreboard .k { color: var(--cyan); font-weight: 600; }
#scoreboard .d { color: var(--dim); }
#scoreboard .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#scoreboard li.me .nm { color: var(--ink); font-weight: 600; }
#scoreboard li.dead .nm { opacity: 0.45; }

.results {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px));
  padding: 24px 24px 20px;
  background: rgba(3, 6, 12, 0.9);
  border: 1px solid var(--line);
  box-shadow: 0 0 40px rgba(61, 240, 255, 0.16);
  text-align: center;
  pointer-events: auto;
}

.results-kicker {
  margin: 0;
  color: var(--cyan);
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

#results-title {
  margin: 8px 0 18px;
  font-size: clamp(22px, 4vw, 32px);
  letter-spacing: 0.06em;
  color: var(--ink);
}

.results-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.results-table th {
  padding: 0 8px 8px;
  color: var(--dim);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.results-table td { padding: 9px 8px; border-top: 1px solid rgba(61, 240, 255, 0.12); }
.results-table th:nth-child(2), .results-table td:nth-child(2) { text-align: left; }
.results-table td:nth-child(n + 3) { font-variant-numeric: tabular-nums; }
.results-table td:nth-child(3) { color: var(--cyan); font-weight: 600; }
.results-table td:nth-child(4) { color: var(--dim); }
.results-table .place { color: var(--dim); width: 32px; }
.results-table tr.first td { background: rgba(61, 240, 255, 0.08); }
.results-table tr.first .place { color: #ffe14a; }
.results-table .dot { display: inline-block; width: 10px; height: 10px; margin-right: 10px; background: var(--c); box-shadow: 0 0 8px var(--c); }
.results-table tr.me td:nth-child(2) { font-weight: 600; }

.results-note { margin: 16px 0 0; color: var(--dim); font-size: 13px; }
.results-note:empty { display: none; }
.results-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.results-actions[hidden] { display: none; }

/* ---------- телефон: сенсорное управление и поворот ---------- */
.touch { display: none; }

@media (pointer: coarse) {
  .touch {
    display: block;
    position: absolute;
    inset: 0;
    pointer-events: none;
  }

  .touch-btn {
    position: absolute;
    bottom: max(18px, env(safe-area-inset-bottom));
    width: 84px;
    height: 84px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(61, 240, 255, 0.5);
    background: rgba(3, 10, 18, 0.45);
    color: var(--cyan);
    font-size: 26px;
    letter-spacing: 0;
    text-transform: none;
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .touch-btn.on { background: rgba(61, 240, 255, 0.28); border-color: var(--cyan); }
  .touch-left { left: max(18px, env(safe-area-inset-left)); }
  .touch-right { left: calc(max(18px, env(safe-area-inset-left)) + 100px); }
  .touch-boost {
    right: max(18px, env(safe-area-inset-right));
    width: 96px;
    height: 96px;
    font-size: 13px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #ffe14a;
    border-color: rgba(255, 225, 74, 0.55);
  }
  .touch-boost.on { background: rgba(255, 225, 74, 0.25); }

  /* Кнопки и подсказки уезжают, чтобы не мешать пальцам. */
  #hud .dock { top: max(12px, env(safe-area-inset-top)); bottom: auto; right: max(12px, env(safe-area-inset-right)); }
  #hud .hud-settings { top: 60px; bottom: auto; max-height: calc(100vh - 76px); overflow: auto; }
  #help, .hud-settings-keys { display: none; }
  #stamina { bottom: 120px; }
  #room-info { top: auto; bottom: 120px; right: max(12px, env(safe-area-inset-right)); }
  #scoreboard { min-width: 0; width: 220px; padding: 8px 10px; font-size: 12px; }
  #scoreboard li { font-size: 12px; padding: 2px 0; }
  #scoreboard .clock b { font-size: 18px; }
}

.rotate { display: none; }

@media (pointer: coarse) and (orientation: portrait) {
  body.playing .rotate {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: #02050a;
    color: var(--ink);
    font-size: 16px;
    letter-spacing: 0.06em;
    text-align: center;
    padding: 24px;
  }
}

.rotate-icon {
  width: 46px;
  height: 78px;
  border: 2px solid var(--cyan);
  border-radius: 8px;
  box-shadow: 0 0 16px rgba(61, 240, 255, 0.5);
  animation: rotate-hint 2.2s ease-in-out infinite;
}

@keyframes rotate-hint {
  0%, 25% { transform: rotate(0deg); }
  55%, 100% { transform: rotate(-90deg); }
}

@media (prefers-reduced-motion: reduce) {
  .rotate-icon { animation: none; transform: rotate(-90deg); }
}

#c { touch-action: none; }

/* Невысокий экран (телефон горизонтально): компактный титул, кнопки в две колонки. */
@media (max-height: 520px) {
  .logo { font-size: min(18vw, 19vh); margin-top: 2px; }
  .logo-sub { margin-top: 6px; font-size: min(3.4vw, 5vh); }
  .kicker { margin: 0; }
  .menu-actions {
    width: min(520px, 100%);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
    padding: 10px;
  }
  .menu-actions .btn-play { grid-column: 1 / -1; }
  #lobby .menu-actions button { padding-block: 9px; }
  .fine { margin-top: 8px; }
  .panel { padding: 14px 14px 12px; }
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
}
.setting-row span { color: var(--ink); font-size: 14px; letter-spacing: 0.06em; }
.setting-row button { min-width: 140px; }
.panel-settings .fine { margin-top: 8px; }
