:root {
  font-family: 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  color: #fff;
  background: #8ae1f1;
  touch-action: none;
  --ink: #241750;
  --purple: #5135c5;
  --purple-dark: #27175f;
  --yellow: #ffdd4c;
  --pink: #ff4f92;
  --cyan: #4ce0df;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  /* Настройки управления. Значения здесь — умолчания и адаптивные, их же переопределяют
     медиазапросы ниже. Игрок, тронувший регулятор, переопределяет их инлайновым стилем на body
     (см. Settings.apply): выбор человека сильнее брейкпоинта, а брейкпоинт — сильнее умолчания. */
  --stick-size: 132px;
  --stick-opacity: 1;
  --ui-scale: 1;
  --action-size: 92px;
  --dive-size: 72px;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  background: linear-gradient(180deg, #6bd6ef 0%, #d6f7f4 100%);
  user-select: none;
}
button,
input,
select {
  font: inherit;
}
button {
  touch-action: manipulation;
}
canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  outline: 0;
}
#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 35%, transparent 45%, rgba(48, 29, 110, 0.18));
  z-index: 1;
}
.hidden {
  display: none !important;
}
/* Скрытое платформенным заслоном (client/core/onlinePlayGate.js).
   Отдельный класс, а не `.hidden`: тот меню снимает при переключении режима, а заслон обязан
   держаться весь сеанс. И не один лишь атрибут `hidden`: он проигрывает любому явному `display` в
   наших же правилах — так `.account-section { display: grid }` оставляла на площадке видимым поле
   ввода кода входа, которое там ничего не делает. Атрибут остаётся рядом ради фокуса и дерева
   доступности, а видимость закрывает это правило. */
.online-gated {
  display: none !important;
}
.screen {
  position: fixed;
  z-index: 5;
  inset: 0;
  padding: calc(26px + var(--safe-top)) calc(28px + var(--safe-right)) calc(26px + var(--safe-bottom))
    calc(28px + var(--safe-left));
  pointer-events: none;
}
.screen > * {
  pointer-events: auto;
}
.screen-menu {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 18px;
}
.brand {
  width: min(590px, 48vw);
  filter: drop-shadow(0 10px 22px rgba(37, 20, 92, 0.2));
}
.brand-kicker,
.eyebrow {
  display: block;
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.24em;
  color: #fff;
  text-shadow: 0 2px 8px #37216a;
}
.brand h1 {
  margin: 8px 0 7px;
  font-size: clamp(48px, 7vw, 94px);
  line-height: 0.82;
  letter-spacing: -0.07em;
  color: #fff;
  text-shadow:
    0 7px 0 #38207b,
    0 13px 30px #34206a4d;
  transform: skew(-3deg);
}
.brand h1 em {
  display: block;
  font-style: normal;
  color: var(--yellow);
  margin-left: clamp(38px, 6vw, 85px);
}
.brand p {
  margin: 14px 0 0;
  font-weight: 800;
  color: #3d2878;
  text-shadow: 0 1px #fff8;
}
.glass {
  border: 2px solid rgba(255, 255, 255, 0.74);
  background: linear-gradient(145deg, rgba(62, 39, 151, 0.94), rgba(34, 22, 91, 0.94));
  box-shadow:
    0 20px 55px rgba(43, 25, 103, 0.33),
    inset 0 1px rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(16px);
}
.menu-card {
  width: min(440px, calc(100vw - 56px));
  border-radius: 26px;
  padding: 18px;
  /* Карточка прокручивается сама, когда не влезает. Без этого раскрытая панель аккаунта уводила
     кнопку старта за нижний край экрана — на невысоком окне играть было просто нечем. */
  max-height: calc(100vh - 52px - var(--safe-top) - var(--safe-bottom));
  overflow-y: auto;
}
.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #201354;
  border-radius: 15px;
  padding: 4px;
  margin-bottom: 16px;
}
.mode-tab {
  border: 0;
  border-radius: 11px;
  padding: 12px 8px;
  color: #a99fd3;
  background: transparent;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: 0.2s;
}
.mode-tab.active {
  color: #fff;
  background: linear-gradient(180deg, #7256df, #5b3dc9);
  box-shadow: 0 4px 12px #170b48;
}
.mode-panel {
  display: grid;
  gap: 12px;
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.field {
  display: grid;
  gap: 6px;
  text-align: left;
}
.field span,
.lobby-course small {
  font-size: 9px;
  letter-spacing: 0.13em;
  color: #b8b3df;
  font-weight: 900;
}
.field input,
.field select,
.lobby-course select,
.join-row input {
  width: 100%;
  min-width: 0;
  border: 1px solid #ffffff2c;
  border-radius: 11px;
  background: #ffffff12;
  color: #fff;
  padding: 12px 11px;
  outline: none;
  font-weight: 800;
}
.field select,
.lobby-course select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #fff 50%), linear-gradient(135deg, #fff 50%, transparent 50%);
  background-position:
    calc(100% - 15px) 50%,
    calc(100% - 10px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.field option,
.lobby-course option {
  color: #251852;
}
.field input:focus,
.field select:focus,
.join-row input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px #4ce0df22;
}
.field-full {
  grid-column: 1/-1;
}
.run-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 2px;
  color: #aeb1d9;
  font-size: 10px;
  letter-spacing: 0.06em;
}
.run-summary strong {
  color: #7ce9df;
}
.challenge-rule {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 12px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 217, 75, 0.45);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.76);
  background: rgba(255, 217, 75, 0.09);
  font-size: 0.67rem;
  font-weight: 700;
}
.challenge-rule strong {
  flex: none;
  color: var(--yellow);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}
.challenge-rule.hidden {
  display: none;
}
.profile-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: -4px 0 10px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.56rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.045em;
}
.profile-strip span {
  padding: 5px 3px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
}
.profile-strip b {
  color: var(--cyan);
}
.coop-profile {
  margin: 2px 0 10px;
}
.coop-campaign {
  display: grid;
  gap: 8px;
  margin: 2px 0 4px;
}
.campaign-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}
.campaign-heading span {
  color: var(--yellow);
  font-size: 0.68rem;
  font-weight: 950;
  letter-spacing: 0.09em;
}
.campaign-heading small {
  max-width: 190px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.55rem;
  line-height: 1.25;
  text-align: right;
}
.campaign-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
.campaign-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 8px;
  min-width: 0;
  padding: 9px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 11px;
  color: #fff;
  background:
    radial-gradient(circle at 100% 0, rgba(84, 224, 255, 0.12), transparent 45%), rgba(255, 255, 255, 0.045);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.campaign-card:hover,
.campaign-card:focus-visible {
  border-color: rgba(84, 224, 255, 0.65);
  background-color: rgba(84, 224, 255, 0.09);
}
.campaign-card.selected {
  border-color: var(--cyan);
  box-shadow: inset 0 0 0 1px var(--cyan);
}
.campaign-card.completed {
  background-color: rgba(66, 235, 174, 0.08);
}
.campaign-number {
  color: rgba(255, 255, 255, 0.32);
  font-size: 1.05rem;
  font-weight: 950;
}
.campaign-card.completed .campaign-number {
  color: #42ebae;
}
.campaign-copy {
  display: grid;
  min-width: 0;
}
.campaign-copy b {
  overflow: hidden;
  font-size: 0.63rem;
  letter-spacing: 0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.campaign-copy small {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.48);
  font-size: 0.52rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.campaign-medal {
  grid-column: 1 / -1;
  color: rgba(255, 255, 255, 0.42);
  font-size: 0.53rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}
.campaign-card.completed .campaign-medal {
  color: var(--yellow);
}
.campaign-preview {
  grid-column: 1 / -1;
  display: flex;
  gap: 3px;
  min-height: 15px;
}
.campaign-preview i {
  padding: 3px 5px;
  border-radius: 5px;
  color: #bdf7ff;
  background: rgba(84, 224, 255, 0.11);
  font-size: 0.46rem;
  font-style: normal;
  font-weight: 850;
}
.campaign-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 7px;
}
.campaign-stats small {
  color: rgba(255, 255, 255, 0.38);
  font-size: 0.45rem;
  white-space: nowrap;
}
.campaign-stats b {
  color: rgba(255, 255, 255, 0.83);
}
.campaign-card em {
  position: absolute;
  right: -22px;
  bottom: 7px;
  width: 80px;
  padding: 2px 0;
  transform: rotate(-36deg);
  color: #27194e;
  background: var(--yellow);
  font-size: 0.42rem;
  font-style: normal;
  font-weight: 950;
  text-align: center;
}
.button {
  border: 0;
  border-radius: 13px;
  min-height: 48px;
  padding: 12px 16px;
  font-weight: 950;
  letter-spacing: 0.035em;
  cursor: pointer;
  transition:
    transform 0.12s,
    filter 0.12s,
    box-shadow 0.12s;
}
.button:not(:disabled):active {
  transform: translateY(4px);
}
.button:disabled {
  filter: grayscale(0.7);
  opacity: 0.45;
  cursor: not-allowed;
}
.button-primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #3b2450;
  background: linear-gradient(180deg, #ffe96d, #ffc83d);
  box-shadow:
    0 6px 0 #d98625,
    0 10px 20px #160c3f55;
  font-size: 17px;
}
.button-primary:not(:disabled):active {
  box-shadow: 0 2px 0 #d98625;
}
.button-primary b {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #4a2d96;
  color: #fff;
}
.button-secondary {
  color: #fff;
  background: linear-gradient(#735ae2, #5638bf);
  box-shadow: 0 5px 0 #321e82;
}
.button-start {
  width: 100%;
  color: #103f3d;
  background: linear-gradient(#64f0d1, #27c7b4);
  box-shadow: 0 5px 0 #16877f;
}
.join-row {
  display: grid;
  grid-template-columns: 1fr 105px;
  gap: 9px;
}
.join-row input {
  text-transform: uppercase;
  letter-spacing: 0.25em;
  text-align: center;
}
.status-line {
  min-height: 16px;
  margin: 0;
  color: #b7b3d9;
  font-size: 11px;
  line-height: 1.35;
}
.menu-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #ffffff17;
  padding-top: 12px;
  margin-top: 2px;
}
.menu-footer span {
  font-size: 8px;
  color: #9996c4;
  letter-spacing: 0.08em;
}
.legal-links {
  display: flex;
  justify-content: center;
  margin-top: 9px;
}
.legal-links a {
  padding: 4px 6px;
  border-radius: 7px;
  color: #a9a5cf;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-decoration: none;
}
.legal-links a:hover,
.legal-links a:focus-visible {
  color: #fff;
  background: #ffffff0d;
  outline: 2px solid #4ce0df88;
  outline-offset: 2px;
}
.icon-button,
.copy-button,
.text-button,
.close-button {
  border: 0;
  background: transparent;
  color: #c8c4e7;
  cursor: pointer;
  font-weight: 900;
}
.icon-button {
  font-size: 9px;
  padding: 7px 9px;
  border-radius: 8px;
  background: #ffffff0d;
}
.feature-pills {
  display: flex;
  gap: 8px;
}
.feature-pills span {
  padding: 7px 10px;
  border-radius: 20px;
  background: #ffffff73;
  border: 1px solid #fff9;
  color: #3a2872;
  font-size: 8px;
  font-weight: 950;
  letter-spacing: 0.08em;
  box-shadow: 0 4px 14px #3e287322;
}
.toast {
  position: fixed;
  z-index: 30;
  top: calc(14px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: min(92vw, 520px);
  padding: 12px 18px;
  border-radius: 13px;
  background: #2c206eeb;
  border: 1px solid #ffffff5e;
  box-shadow: 0 10px 32px #20124d55;
  text-align: center;
  font-size: 13px;
}
.toast-error {
  background: #d83e68ee;
}
.center-screen {
  display: grid;
  place-items: center;
}
.lobby-card,
.finish-card {
  position: relative;
  width: min(430px, calc(100vw - 32px));
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px);
  overflow: auto;
  border-radius: 27px;
  padding: 24px;
  text-align: center;
}
.close-button {
  position: absolute;
  right: 12px;
  top: 10px;
  width: 38px;
  height: 38px;
  font-size: 28px;
}
.room-heading {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
}
.room-heading small,
.hud small,
.lobby-course small {
  display: block;
  letter-spacing: 0.18em;
  color: #aea8db;
  font-weight: 900;
}
.room-heading h2 {
  margin: 2px 0 8px;
  color: var(--yellow);
  font-size: 48px;
  letter-spacing: 0.16em;
  line-height: 1;
}
.copy-button {
  font-size: 9px;
  border-radius: 8px;
  background: #ffffff12;
  padding: 8px;
}
.lobby-course {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 14px;
}
.lobby-course > div,
.lobby-course > label {
  display: grid;
  gap: 6px;
  padding: 10px;
  border-radius: 12px;
  background: #ffffff0c;
}
.lobby-course strong {
  font-size: 13px;
  color: #5ce8d0;
}
.lobby-course select {
  padding: 5px;
  text-align: center;
  font-size: 12px;
}
.player-list {
  display: grid;
  gap: 7px;
  margin: 10px 0 15px;
  max-height: 225px;
  overflow: auto;
}
.verified-top {
  margin: 4px 0 10px;
  padding: 7px 10px;
  border-radius: 9px;
  color: rgba(255, 255, 255, 0.58);
  background: rgba(72, 220, 218, 0.08);
  text-align: left;
}
.verified-top-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.verified-top-list {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  /* Десять строк на маленьком экране вытесняли бы кнопку готовности за пределы видимого: список
     прокручивается сам, а лобби остаётся целиком на месте. */
  max-height: 168px;
  overflow-y: auto;
}
.verified-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 3px 4px;
  border-radius: 6px;
  font-size: 0.72rem;
}
.verified-row-self {
  color: #fff;
  background: rgba(72, 220, 218, 0.16);
}
.verified-place {
  color: rgba(255, 255, 255, 0.4);
  text-align: right;
}
.verified-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.verified-time {
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}
.verified-top-standing {
  margin: 6px 0 0;
  color: var(--cyan);
  font-size: 0.68rem;
}
.player-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 11px;
  background: #ffffff0e;
  text-align: left;
}
.player-avatar {
  width: 28px;
  height: 28px;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: inset 0 -6px #0002;
}
.player-row span {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-row b {
  font-size: 9px;
  color: #aaa4ca;
}
.player-row b.ready {
  color: #62eeb9;
}
.lobby-card > .button {
  width: 100%;
  margin-top: 8px;
}
.hud {
  position: fixed;
  z-index: 4;
  top: calc(12px + var(--safe-top));
  left: calc(12px + var(--safe-left));
  right: calc(12px + var(--safe-right));
  display: grid;
  grid-template-columns: auto auto minmax(180px, 460px) auto auto;
  gap: 8px;
  align-items: start;
  justify-content: center;
  pointer-events: none;
}
/* Выход из матча. Намеренно тише остального HUD: он нужен редко, а нажать его случайно на телефоне
   — потерять забег. По той же причине выход подтверждается вторым нажатием, см. main.js. */
.hud-leave {
  pointer-events: auto;
  align-self: stretch;
  padding: 0 12px;
  border: 1px solid #ffffff5c;
  border-radius: 13px;
  background: #2d1c7480;
  color: #ffffffc4;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  backdrop-filter: blur(9px);
  cursor: pointer;
}
.hud-leave.armed {
  border-color: var(--pink);
  background: #6b1f4bcc;
  color: #fff;
}

.hud-card,
.hud-progress {
  border: 1px solid #ffffff9c;
  background: #2d1c74dc;
  box-shadow:
    0 6px 20px #2919634a,
    inset 0 1px #ffffff3b;
  backdrop-filter: blur(9px);
}
.hud-card {
  min-width: 105px;
  padding: 8px 13px;
  border-radius: 13px;
  text-align: center;
}
.hud-card strong {
  display: block;
  color: var(--yellow);
  font-size: 18px;
}
.hud-card.compact {
  min-width: 68px;
}
.hud-progress {
  padding: 8px 12px 10px;
  border-radius: 13px;
}
.hud-progress-label {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: #fff;
  font-size: 10px;
  letter-spacing: 0.06em;
}
.hud-progress-label b {
  color: var(--yellow);
}
.progress-track {
  height: 7px;
  margin-top: 6px;
  border-radius: 10px;
  background: #130d3f;
  overflow: hidden;
}
.progress-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #55e9cf, #ffe456);
  box-shadow: 0 0 10px #5ef0d9;
  transition: width 0.3s;
}
.countdown {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: #2e1d7415;
}
.countdown span {
  font-size: clamp(100px, 24vw, 210px);
  font-weight: 950;
  color: #fff;
  text-shadow:
    0 10px 0 #5c3ec5,
    0 18px 50px #2b1a68;
  animation: count-pop 0.48s ease-out;
}
.checkpoint-banner {
  position: fixed;
  z-index: 12;
  left: 50%;
  top: 24%;
  transform: translate(-50%, -50%);
  display: grid;
  text-align: center;
  padding: 12px 26px;
  border-radius: 16px;
  background: #2b1c71dd;
  border: 2px solid #fff8;
  box-shadow: 0 12px 30px #26165d66;
  animation: banner-pop 0.9s both;
}
.checkpoint-banner small {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: #63eac8;
}
.checkpoint-banner strong {
  font-size: 24px;
  color: var(--yellow);
}
.touch-ui {
  position: fixed;
  z-index: 6;
  inset: 0;
  pointer-events: none;
}
/* Зона плавающего джойстика. Для касаний прозрачна, пока джойстик фиксированный: тогда всё
   работает ровно как раньше, а холст сам решает, что нижняя треть — не обзор. */
.stick-zone {
  position: absolute;
  bottom: 0;
  width: 34%;
  height: 62%;
  pointer-events: none;
  touch-action: none;
}
body[data-hand='left'] .stick-zone {
  left: 0;
}
body[data-hand='right'] .stick-zone {
  right: 0;
}
body[data-stick='floating'] .stick-zone {
  pointer-events: auto;
}
.stick {
  position: absolute;
  pointer-events: auto;
  left: calc(18px + var(--safe-left));
  bottom: calc(20px + var(--safe-bottom));
  /* Размером интерфейса джойстик намеренно не масштабируется: у него есть собственный регулятор,
     и два множителя на одно и то же дают 320 пикселей при обоих ползунках вправо — размер, при
     котором джойстик закрывает игру. Кнопки действий масштаб слушают: своей настройки у них нет. */
  width: var(--stick-size);
  height: var(--stick-size);
  opacity: var(--stick-opacity);
  border-radius: 50%;
  background: radial-gradient(circle, #fff1 0 33%, #28196658 35%);
  border: 3px solid #ffffff72;
  box-shadow: inset 0 0 22px #25145f44;
  transition: opacity 0.2s;
  touch-action: none;
}
/* Джойстик справа — для тех, кто держит телефон иначе. Кнопки действий уезжают налево, и вместе
   с ними меняется сторона, которую холст отдаёт под обзор (см. InputManager.inStickZone). */
body[data-hand='right'] .stick {
  left: auto;
  right: calc(18px + var(--safe-right));
}
/* Плавающий джойстик появляется под пальцем: JS ставит left/top в точку касания, здесь остаётся
   сдвинуть его на половину собственного размера, чтобы центр совпал с пальцем. Пока его не
   держат — он невидим, иначе на экране болталось бы кольцо там, где игрок случайно ткнул. */
body[data-stick='floating'] .stick {
  transform: translate(-50%, -50%);
  opacity: 0;
  transition:
    opacity 0.12s,
    transform 0s;
}
body[data-stick='floating'] .stick.active {
  opacity: var(--stick-opacity);
}
body[data-stick='floating'] .stick span {
  display: none;
}
/* Размеры пятака заданы долями, а не пикселями: джойстик теперь меняет размер, и жёсткие 52px
   на маленьком джойстике вылезали бы за его край. */
.stick i {
  position: absolute;
  left: 29%;
  top: 29%;
  width: 39%;
  height: 39%;
  border-radius: 50%;
  background: linear-gradient(#fff, #c9f9ff);
  border: 3px solid #ffffffd9;
  box-shadow: 0 5px 12px #21134d66;
  will-change: transform;
}
.stick span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -18px;
  text-align: center;
  font-size: 8px;
  letter-spacing: 0.16em;
  text-shadow: 0 2px 5px #27165a;
}
.action-button {
  position: absolute;
  pointer-events: auto;
  display: grid;
  place-items: center;
  border: 3px solid #ffffffa0;
  border-radius: 50%;
  color: #fff;
  font-weight: 950;
  box-shadow:
    0 7px 0 #0004,
    0 12px 26px #25165d4d;
  touch-action: none;
}
.action-button i {
  font-style: normal;
  font-size: 24px;
  line-height: 1;
}
.action-button span {
  font-size: 9px;
  letter-spacing: 0.06em;
}
.jump-button {
  right: calc(20px + var(--safe-right));
  bottom: calc(24px + var(--safe-bottom));
  width: calc(var(--action-size) * var(--ui-scale));
  height: calc(var(--action-size) * var(--ui-scale));
  background: linear-gradient(#ff6aa2, #ed347c);
}
.dive-button {
  right: calc(116px + var(--safe-right));
  bottom: calc(29px + var(--safe-bottom));
  width: calc(var(--dive-size) * var(--ui-scale));
  height: calc(var(--dive-size) * var(--ui-scale));
  background: linear-gradient(#765de3, #4f35bf);
}
/* Зеркальная раскладка: всё, что было справа, уезжает налево одним блоком. Отступы берутся от
   своей безопасной зоны — на телефоне с вырезом левый и правый край разные. */
body[data-hand='right'] .jump-button {
  right: auto;
  left: calc(20px + var(--safe-left));
}
body[data-hand='right'] .dive-button {
  right: auto;
  left: calc(116px + var(--safe-left));
}
body[data-hand='right'] .recenter {
  right: auto;
  left: calc(24px + var(--safe-left));
}
.recenter {
  position: absolute;
  pointer-events: auto;
  right: calc(24px + var(--safe-right));
  bottom: calc(128px + var(--safe-bottom));
  width: 42px;
  height: 42px;
  border: 2px solid #ffffff75;
  border-radius: 12px;
  background: #2a1b6c73;
  color: #fff;
  font-size: 23px;
  backdrop-filter: blur(5px);
}
/* Переключатель режима камеры стоит над кнопкой «за спину»: обе про обзор, держим их рядом. */
.camera-mode {
  bottom: calc(178px + var(--safe-bottom));
  font-size: 19px;
}
/* Свободный режим подсвечен — иначе непонятно, в каком ты сейчас, а от этого зависит,
   вернётся камера за спину сама или нет. */
.camera-mode.camera-free {
  border-color: #ffd76a;
  background: #6b4d0f9c;
  color: #ffe6a3;
}
.look-hint {
  position: absolute;
  right: calc(76px + var(--safe-right));
  bottom: calc(139px + var(--safe-bottom));
  font-size: 8px;
  letter-spacing: 0.13em;
  color: #fff9;
  text-shadow: 0 2px 4px #2a175d;
  transition: opacity 0.5s;
}
/* Подсказка про обзор висит над зоной обзора, а та меняет сторону вместе с джойстиком. */
body[data-hand='right'] .look-hint {
  right: auto;
  left: calc(76px + var(--safe-left));
}
/* Плашка «без зачёта» на карточке финиша: заметная, но не празднующая — это не награда. */
.unranked-note {
  margin: 6px auto 2px;
  padding: 7px 13px;
  max-width: 300px;
  border-radius: 10px;
  border: 1px solid #ffd76a80;
  background: #6b4d0f5c;
  color: #ffe6a3;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.45;
}
/* Отсчёт до автоматического возврата в лобби. Приглушённый: это подсказка, а не тревога —
   истечение времени ничего не отнимает, комната просто перестаёт ждать. */
.results-timer {
  margin: 8px auto 0;
  min-height: 13px;
  color: #b9c2e8;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.finish-card .eyebrow {
  margin-top: 2px;
}
.medal {
  width: 78px;
  height: 78px;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 45px;
  color: #4c2e84;
  background: linear-gradient(145deg, #fff48a, #ffbe32);
  border: 5px solid #fff6;
  box-shadow:
    0 7px 0 #c87922,
    0 12px 28px #160d3f55;
  animation: medal-in 0.7s cubic-bezier(0.18, 0.9, 0.3, 1.3);
}
.finish-card h2 {
  margin: 7px 0 0;
  font-size: 36px;
  color: var(--yellow);
  text-shadow: 0 4px #3b2388;
}
.finish-card > p {
  margin: 2px 0 12px;
  font-size: 25px;
  font-weight: 950;
}
.finish-stats {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 10px 0;
}
.finish-stats span {
  padding: 7px 10px;
  border-radius: 9px;
  background: #ffffff10;
  color: #bdb8df;
  font-size: 10px;
}
.finish-highlights {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 10px 0 14px;
}
.finish-highlight {
  padding: 10px;
  border: 1px solid #ffffff20;
  border-radius: 12px;
  background: linear-gradient(145deg, #ffffff12, #ffffff06);
  text-align: left;
}
.finish-highlight strong,
.finish-highlight span {
  display: block;
}
.finish-highlight strong {
  color: var(--yellow);
  font-size: 12px;
}
.finish-highlight span {
  margin-top: 3px;
  color: #c9c5e9;
  font-size: 10px;
  line-height: 1.35;
}
.finish-card > .button {
  width: 100%;
  margin-top: 8px;
}
.leaderboard {
  display: grid;
  gap: 5px;
  margin: 10px 0;
  max-height: 220px;
  overflow: auto;
}
.board-row {
  display: grid;
  grid-template-columns: 30px 30px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 8px 9px;
  border-radius: 10px;
  background: #ffffff0e;
  text-align: left;
  font-size: 12px;
}
.board-row.winner {
  background: linear-gradient(90deg, #ffd94d35, #ffffff0d);
}
.board-row > i {
  width: 23px;
  height: 23px;
  border-radius: 50%;
}
.text-button {
  padding: 11px;
  margin-top: 5px;
}
.loading {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  background: linear-gradient(145deg, #5136c3, #25175f);
  transition: opacity 0.35s;
}
.loading.done {
  opacity: 0;
  pointer-events: none;
}
.loading strong {
  font-size: 13px;
  letter-spacing: 0.12em;
}
.loading span {
  font-size: 10px;
  color: #aba7d1;
}
.loader-orb {
  width: 66px;
  height: 66px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: linear-gradient(145deg, #67eadb, #ffdf50);
  box-shadow:
    inset -12px -12px #7655d3,
    0 10px 25px #160b3e;
  animation: wobble 1.1s infinite alternate ease-in-out;
}
@keyframes wobble {
  to {
    transform: translateY(-12px) rotate(12deg) scaleX(0.92);
  }
}
@keyframes count-pop {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  65% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
@keyframes banner-pop {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }
  25%,
  75% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -70%) scale(0.9);
    opacity: 0;
  }
}
@keyframes medal-in {
  from {
    transform: translateY(-40px) rotate(-25deg) scale(0.3);
    opacity: 0;
  }
}
@media (min-width: 900px) {
  .screen-menu {
    padding-left: max(7vw, calc(28px + var(--safe-left)));
  }
  .menu-card {
    position: absolute;
    right: max(7vw, calc(28px + var(--safe-right)));
    top: 50%;
    transform: translateY(-50%);
  }
}
@media (max-width: 899px) {
  .screen-menu {
    justify-content: flex-start;
    align-items: center;
    overflow: auto;
    padding-top: calc(22px + var(--safe-top));
    gap: 12px;
  }
  .brand {
    width: 100%;
    text-align: center;
  }
  .brand h1 {
    font-size: clamp(45px, 11vw, 74px);
  }
  .brand h1 em {
    display: inline;
    margin-left: 0.12em;
  }
  .brand p {
    font-size: 12px;
  }
  .brand-kicker {
    font-size: 9px;
  }
  .feature-pills {
    justify-content: center;
    flex-wrap: wrap;
  }
  .menu-card {
    margin-top: auto;
    margin-bottom: auto;
  }
  .hud {
    grid-template-columns: auto minmax(140px, 1fr) auto;
  }
  .hud-card {
    min-width: 84px;
    padding: 7px 9px;
  }
  .hud-card strong {
    font-size: 15px;
  }
  #pingBox {
    display: none !important;
  }
}
@media (max-width: 600px) {
  .screen {
    padding-left: calc(12px + var(--safe-left));
    padding-right: calc(12px + var(--safe-right));
  }
  .screen-menu {
    padding-top: calc(14px + var(--safe-top));
    padding-bottom: calc(12px + var(--safe-bottom));
  }
  .brand h1 {
    margin: 5px 0;
  }
  .brand p {
    margin-top: 8px;
  }
  .menu-card {
    width: 100%;
    padding: 14px;
    border-radius: 22px;
  }
  .mode-tabs {
    margin-bottom: 11px;
  }
  .field-grid {
    gap: 7px;
  }
  .field input,
  .field select {
    padding: 10px;
  }
  .button {
    min-height: 44px;
  }
  .feature-pills {
    display: none;
  }
  .menu-footer span {
    display: none;
  }
  .hud {
    top: calc(8px + var(--safe-top));
    left: calc(8px + var(--safe-left));
    right: calc(8px + var(--safe-right));
    grid-template-columns: auto auto 1fr auto;
    gap: 5px;
  }
  .hud-card {
    min-width: 73px;
    padding: 6px 7px;
  }
  .hud-card strong {
    font-size: 13px;
  }
  .hud small {
    font-size: 7px;
  }
  .hud-progress {
    padding: 7px 8px;
  }
  .hud-progress-label {
    font-size: 8px;
  }
  .lobby-card,
  .finish-card {
    padding: 19px;
  }
  /* Размер задаётся переменной, а не width/height: инлайновый выбор игрока обязан её переписать,
     а жёсткое правило отсюда он переписать бы не смог — специфичность у медиазапроса та же. */
  :root {
    --stick-size: 120px;
  }
  :root {
    --action-size: 84px;
    --dive-size: 66px;
  }
  .dive-button {
    right: calc(108px + var(--safe-right));
  }
}
@media (max-height: 590px) and (orientation: landscape) {
  .screen-menu {
    display: grid;
    grid-template-columns: 1fr 380px;
    align-items: center;
    overflow: hidden;
    padding: calc(8px + var(--safe-top)) calc(18px + var(--safe-right)) calc(8px + var(--safe-bottom))
      calc(18px + var(--safe-left));
  }
  .brand {
    width: auto;
    text-align: left;
  }
  .brand h1 {
    font-size: 48px;
  }
  .brand p,
  .brand-kicker,
  .feature-pills {
    display: none;
  }
  .menu-card {
    position: static;
    transform: none;
    width: 380px;
    padding: 12px;
  }
  .mode-tabs {
    margin-bottom: 8px;
  }
  .mode-tab {
    padding: 8px;
  }
  .mode-panel {
    gap: 7px;
  }
  .button {
    min-height: 40px;
  }
  .menu-footer {
    padding-top: 7px;
  }
  .lobby-card,
  .finish-card {
    max-height: calc(100dvh - 12px);
    padding: 13px 20px;
  }
  .room-heading h2 {
    font-size: 38px;
  }
  .player-list {
    max-height: 120px;
  }
  :root {
    --stick-size: 96px;
    --action-size: 72px;
    --dive-size: 58px;
  }
  .stick {
    bottom: calc(10px + var(--safe-bottom));
  }
  .jump-button {
    bottom: calc(12px + var(--safe-bottom));
  }
  .dive-button {
    right: calc(97px + var(--safe-right));
    bottom: calc(15px + var(--safe-bottom));
  }
  .recenter {
    bottom: calc(93px + var(--safe-bottom));
  }
  .camera-mode {
    bottom: calc(139px + var(--safe-bottom));
  }
  .look-hint {
    display: none;
  }
  .hud-progress {
    max-width: 280px;
  }
  .finish-card h2 {
    font-size: 27px;
  }
  .medal {
    width: 58px;
    height: 58px;
    font-size: 32px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/* Регуляторы громкости в меню. Компактный блок, который не спорит с основными кнопками:
   звук настраивают один раз, поэтому он не должен перетягивать внимание с кнопки старта. */
.audio-panel {
  display: grid;
  gap: 6px;
  margin: 10px 0 2px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.audio-row {
  display: grid;
  grid-template-columns: 74px 1fr;
  align-items: center;
  gap: 10px;
}
.audio-row span {
  font-size: 0.62rem;
  letter-spacing: 0.09em;
  opacity: 0.75;
}
.audio-row input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  outline: none;
}
.audio-row input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffd94b;
  border: 2px solid rgba(38, 22, 83, 0.65);
  cursor: pointer;
}
.audio-row input[type='range']::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffd94b;
  border: 2px solid rgba(38, 22, 83, 0.65);
  cursor: pointer;
  border-color: rgba(38, 22, 83, 0.65);
}
/* На коротких экранах блок громкости прячется: там каждый пиксель нужен игровой области. */
@media (max-height: 620px) {
  .audio-panel {
    display: none;
  }
}

/* Кооперативный режим. Вкладка выделена намеренно: это витрина проекта, и она должна
   притягивать взгляд раньше остальных. */
.mode-tab-hero {
  background: linear-gradient(120deg, rgba(255, 79, 145, 0.85), rgba(72, 220, 218, 0.85));
  color: #241056;
}
.coop-lead {
  font-size: 0.76rem;
  line-height: 1.45;
  opacity: 0.85;
  margin: 0 0 10px;
}
.coop-lead b {
  color: #ffd94b;
}
.coop-hint {
  font-size: 0.72rem;
  opacity: 0.7;
  margin: -2px 0 10px;
  min-height: 2.2em;
}

/* Роль в HUD. */

/* Указатель на напарника. Держится у края экрана и всегда смотрит в его сторону. */
.partner-hud {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: grid;
  justify-items: center;
  gap: 4px;
  z-index: 6;
  transition: opacity 0.2s;
}
.partner-arrow {
  width: 0;
  height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-bottom: 18px solid #48dcda;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}
.partner-hud[data-state='down'] .partner-arrow {
  border-bottom-color: #ff4f91;
}
/* «Отошёл» — не тревога, а объяснение: приглушённый цвет, чтобы не путать с зовом о помощи. */
.partner-hud[data-state='away'] .partner-arrow {
  border-bottom-color: #9a8fc4;
}
.partner-hud[data-state='away'] span {
  opacity: 0.8;
}
.partner-hud span {
  font-size: 0.6rem;
  letter-spacing: 0.09em;
  background: rgba(38, 22, 83, 0.72);
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Заставка главы: название и подсказка перед стартом. */
.coop-intro {
  position: fixed;
  left: 50%;
  top: 26%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  z-index: 7;
  animation: coop-intro-in 0.5s ease-out both;
}
.coop-intro h2 {
  margin: 2px 0 6px;
  font-size: clamp(1.6rem, 6vw, 2.6rem);
  letter-spacing: 0.04em;
}
.coop-intro p {
  margin: 0;
  font-size: 0.82rem;
  opacity: 0.88;
  max-width: min(90vw, 460px);
}
@keyframes coop-intro-in {
  from {
    opacity: 0;
    transform: translate(-50%, -12px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .coop-intro {
    animation: none;
  }
}

/* Оверлей соединения. Одно место, где игрок видит состояние сети, вместо всплывающих
   сообщений, которые исчезают раньше, чем их успевают прочитать. */
.link-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(20, 10, 46, 0.72);
  backdrop-filter: blur(6px);
  z-index: 40;
  padding: max(16px, env(safe-area-inset-top)) 16px;
}
.link-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 24px 26px;
  border-radius: 20px;
  text-align: center;
  max-width: min(92vw, 380px);
}
.link-card strong {
  font-size: 1.05rem;
}
.link-card p {
  margin: 0;
  font-size: 0.78rem;
  opacity: 0.82;
}
.link-spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-top-color: #48dcda;
  animation: link-spin 0.9s linear infinite;
}
/* В состоянии отказа кольцо перестаёт быть спиннером: остановленный спиннер читается как
   «всё ещё грузится», а нам нужно сообщить, что попытки закончились. */
.link-overlay[data-state='failed'] .link-spinner {
  border-color: #ff4f91;
  background: rgba(255, 79, 145, 0.16);
  animation: none;
}
@keyframes link-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .link-spinner {
    animation: none;
  }
}

/* Счётчики производительности. Включаются параметром ?perf=1 — это инструмент разработки,
   а не часть интерфейса, поэтому кнопки для него в меню нет. */
.perf-overlay {
  position: fixed;
  left: max(8px, env(safe-area-inset-left));
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 50;
  pointer-events: none;
  white-space: pre;
  font:
    600 11px/1.45 ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  color: #d8ffe8;
  background: rgba(14, 8, 33, 0.72);
  border: 1px solid rgba(120, 255, 190, 0.28);
  border-radius: 8px;
  padding: 6px 9px;
}
.perf-overlay[data-over='1'] {
  color: #ffd8e6;
  border-color: rgba(255, 79, 145, 0.45);
}

/* Обучающая подсказка первой главы. Держится, пока задача не решена, поэтому размещена внизу,
   где не перекрывает ни трассу впереди, ни указатель на напарника. */
.coop-lesson {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(112px + var(--safe-bottom));
  z-index: 7;
  pointer-events: none;
  display: grid;
  justify-items: center;
  gap: 5px;
  max-width: min(88vw, 460px);
  padding: 10px 16px;
  border-radius: 14px;
  text-align: center;
  background: rgba(38, 22, 83, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.32);
  box-shadow: 0 10px 28px rgba(20, 12, 48, 0.4);
  backdrop-filter: blur(8px);
  animation: lesson-in 0.32s ease-out;
}
.coop-lesson p {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.35;
}

/* Баннер досмотра. Живёт внизу — там же, где обучающая подсказка кооператива: центр экрана занят
   трассой, ради которой досмотр и затеян, и перекрывать её нельзя. */
.spectate {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(24px + var(--safe-bottom));
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(92vw, 560px);
  padding: 10px 12px 10px 18px;
  border-radius: 16px;
  background: rgba(38, 22, 83, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.32);
  box-shadow: 0 10px 28px rgba(20, 12, 48, 0.45);
  backdrop-filter: blur(8px);
  animation: lesson-in 0.32s ease-out;
}
.spectate-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.spectate-text .eyebrow {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: #63eac8;
}
.spectate-text strong {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  /* Длинное имя не должно растягивать баннер во всю ширину экрана. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.spectate .button {
  flex: none;
  padding: 10px 16px;
  font-size: 0.72rem;
}
@media (max-width: 520px) {
  .spectate {
    width: min(92vw, 560px);
    justify-content: space-between;
  }
  .spectate-text strong {
    font-size: 0.85rem;
  }
}

.coop-ping-button {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(118px, calc(env(safe-area-inset-bottom) + 92px));
  z-index: 25;
  width: 52px;
  height: 52px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  color: var(--white);
  background: rgba(74, 42, 132, 0.88);
  box-shadow: 0 8px 24px rgba(20, 8, 42, 0.35);
  font-size: 22px;
}

.coop-ping-menu {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(180px, calc(env(safe-area-inset-bottom) + 154px));
  z-index: 26;
  width: 196px;
  height: 196px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(27, 15, 55, 0.92);
  backdrop-filter: blur(12px);
}

.coop-ping-menu button {
  position: absolute;
  width: 76px;
  min-height: 38px;
  border: 0;
  border-radius: 12px;
  color: var(--white);
  background: rgba(143, 92, 255, 0.55);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.coop-ping-menu button:nth-child(1) {
  left: 60px;
  top: 8px;
}
.coop-ping-menu button:nth-child(2) {
  right: 4px;
  top: 47px;
}
.coop-ping-menu button:nth-child(3) {
  right: 4px;
  bottom: 47px;
}
.coop-ping-menu button:nth-child(4) {
  left: 60px;
  bottom: 8px;
}
.coop-ping-menu button:nth-child(5) {
  left: 4px;
  bottom: 47px;
}
.coop-ping-menu button:nth-child(6) {
  left: 4px;
  top: 47px;
}

.coop-ping-bubble {
  position: fixed;
  z-index: 24;
  transform: translate(-50%, -100%);
  padding: 8px 12px;
  border-radius: 14px;
  color: #25123f;
  background: var(--yellow);
  box-shadow: 0 5px 18px rgba(20, 8, 42, 0.35);
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  pointer-events: none;
}
@keyframes lesson-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .coop-lesson {
    animation: none;
  }
}

/* Аккаунт: чип в шапке карточки и панель под ним. */
.account-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 6px;
}
.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: #ffffff14;
  cursor: pointer;
  font: inherit;
  font-size: 0.7rem;
}
.account-chip small {
  color: rgba(255, 255, 255, 0.45);
}
.account-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mint, #58ebb8);
}
/* Сервер не ответил: аккаунт для игры годится, а рекорды никуда не уедут — и это видно. */
.account-chip.offline .account-dot {
  background: var(--orange, #ff914d);
}
.account-card {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(430px, calc(100vw - 32px));
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px);
  overflow: auto;
  border-radius: 27px;
  padding: 24px;
  text-align: left;
}
.account-section {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid #ffffff17;
}
.account-section:first-of-type {
  border-top: 0;
  padding-top: 0;
}
.account-legend {
  font-size: 9px;
  letter-spacing: 0.13em;
  color: #b8b3df;
  font-weight: 900;
}
.account-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.account-row .field {
  flex: 1;
  min-width: 0;
}
.account-row .button {
  flex: 0 0 auto;
  padding: 8px 12px;
  font-size: 0.68rem;
}
.account-list {
  display: grid;
  gap: 4px;
  max-height: 132px;
  overflow-y: auto;
}
.account-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border: 0;
  border-radius: 9px;
  color: #fff;
  background: #ffffff10;
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  text-align: left;
}
.account-item-current {
  background: rgba(72, 220, 218, 0.16);
  cursor: default;
}
.account-item small {
  color: rgba(255, 255, 255, 0.45);
}
.account-code {
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(255, 145, 77, 0.12);
}
.account-code code {
  color: var(--yellow, #ffd94b);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  /* Код переписывают с экрана — он должен переноситься, а не уезжать за край. */
  overflow-wrap: anywhere;
}
.cosmetic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
.cosmetic-card {
  min-height: 68px;
  padding: 9px;
  border: 1px solid #ffffff18;
  border-radius: 11px;
  color: #d9d5f2;
  background: #ffffff08;
  text-align: left;
  cursor: pointer;
}
.cosmetic-card strong,
.cosmetic-card small {
  display: block;
}
.cosmetic-card strong {
  font-size: 10px;
}
.cosmetic-card small {
  margin-top: 4px;
  color: #a9a4cd;
  font-size: 9px;
}
.cosmetic-card-equipped {
  border-color: var(--mint);
  box-shadow: inset 0 0 0 1px #68f4d255;
}
.cosmetic-card-locked {
  opacity: 0.52;
  cursor: default;
}
.cosmetic-goal {
  margin: 9px 0 0;
  color: #bdb8df;
  font-size: 10px;
  line-height: 1.4;
}

/* ==== Доступность: крупный интерфейс и уменьшенная анимация ==== */

/* Крупный интерфейс.
   zoom, а не transform: он увеличивает и область нажатия, а не только картинку — кнопка,
   выглядящая большой, но нажимающаяся по-старому, была бы издевательством именно над тем, кому
   этот режим нужен.
   Масштабируются карточки и блоки, а не их контейнеры: у .screen и .hud задан inset/left+right,
   и zoom растянул бы сам бокс шире экрана вместе с содержимым.
   Экранное управление сюда намеренно не попадает: его геометрию считает JS в пикселях окна, и
   масштабирование контейнера развело бы нарисованный джойстик с тем местом, где его ищет палец.
   Кнопки и джойстик растут через calc(... * var(--ui-scale)) в своих правилах, оставаясь в тех же
   координатах. */
body.large-ui .hud-card,
body.large-ui .hud-progress,
body.large-ui .hud-leave,
body.large-ui .menu-card,
body.large-ui .lobby-card,
body.large-ui .finish-card,
body.large-ui .settings-card,
body.large-ui .countdown,
body.large-ui .checkpoint-banner,
body.large-ui .coop-lesson {
  zoom: var(--ui-scale);
}

/* Уменьшенная анимация по выбору игрока.
   Медиазапросы prefers-reduced-motion выше никуда не деваются — они и есть режим «авто». Этот
   класс добавляет то, чего медиазапрос дать не может: возможность попросить меньше движения
   только в игре, не трогая всю систему, и наоборот — оставить анимацию в игре при включённой
   системной настройке. Тряска камеры гасится отдельно, в Settings.shakeScale: она живёт не в CSS. */
body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* ==== Экран настроек управления ==== */
.settings-card {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px);
  overflow: auto;
  border-radius: 27px;
  padding: 24px;
  text-align: left;
}
.settings-body {
  display: grid;
  gap: 16px;
}
.settings-group {
  display: grid;
  gap: 9px;
  padding-top: 13px;
  border-top: 1px solid #ffffff17;
}
.settings-group:first-child {
  border-top: 0;
  padding-top: 0;
}
.settings-group h3 {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.17em;
  color: var(--yellow);
}
.settings-note {
  margin: -4px 0 2px;
  font-size: 10px;
  line-height: 1.45;
  color: #b0abd8;
}
.settings-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}
/* У ползунка три колонки: подпись, сам ползунок и значение. Значение шириной в фиксированные
   52px, иначе строка дёргается при каждом движении пальца — «5 %» и «100 %» разной ширины. */
.settings-row:has(input[type='range']) {
  grid-template-columns: 1fr minmax(96px, 1.1fr) 52px;
}
.settings-label {
  font-size: 11px;
  font-weight: 800;
  color: #ded9ff;
}
.settings-value {
  font-size: 10px;
  text-align: right;
  color: var(--cyan);
}
.settings-row input[type='range'] {
  width: 100%;
  accent-color: var(--cyan);
}
.settings-choice {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
}
.settings-choice button,
.settings-toggle,
.settings-key {
  border: 1px solid #ffffff2e;
  border-radius: 9px;
  padding: 7px 10px;
  min-height: 32px;
  background: #ffffff10;
  color: #ddd8ff;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: 0.15s;
}
.settings-choice button.active,
.settings-toggle.active {
  color: #241750;
  background: linear-gradient(180deg, #7ceee2, #3fc9d6);
  border-color: transparent;
}
.settings-key {
  min-width: 96px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
/* Ожидание нажатия видно и без чтения подписи внизу: иначе игрок не понимает, что игра ждёт
   именно его, и уходит нажимать что-то ещё. */
.settings-key.awaiting {
  color: #241750;
  background: var(--yellow);
  border-color: transparent;
}
.settings-keys {
  /* Клавиатурный раздел незачем показывать тому, у кого клавиатуры нет. */
  display: grid;
}
body[data-input='touch'] .settings-keys {
  display: none;
}
/* Длинный набор вариантов уезжает под подпись: справа он переносится на вторую строку и тянет
   выравнивание всей строки за собой. */
.settings-row-stack {
  grid-template-columns: 1fr;
  gap: 6px;
}
.settings-row-stack .settings-choice {
  justify-content: flex-start;
}

/* Потолок высоты у масштабированных карточек делится на масштаб.
   zoom увеличивает отрисовку, но 100dvh внутри элемента по-прежнему означает полную высоту экрана
   в неотмасштабированных пикселях — то есть при zoom 1.5 карточка, «влезающая по расчёту», рисуется
   в полтора раза выше экрана, и нижние кнопки уезжают за край. Поймано браузерным тестом: кнопка
   сброса переставала нажиматься ровно при том масштабе, ради которого режим и сделан. */
body.large-ui .settings-card,
body.large-ui .account-card,
body.large-ui .lobby-card,
body.large-ui .finish-card {
  max-height: calc((100dvh - var(--safe-top) - var(--safe-bottom) - 24px) / var(--ui-scale));
}
body.large-ui .menu-card {
  max-height: calc((100vh - 52px - var(--safe-top) - var(--safe-bottom)) / var(--ui-scale));
}

/* Social cosmetics: миниатюра в комнате повторяет canonical body/visor/antenna персонажа. */
.player-avatar {
  position: relative;
  display: block;
  background: var(--body-color, #ff4f91) !important;
}
.player-avatar::before {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  top: 8px;
  height: 7px;
  border: 1px solid #fff9;
  border-radius: 50%;
  background: var(--visor-color, #dffcff);
  box-shadow: 0 1px 3px #24175055;
}
.player-avatar::after {
  content: '';
  position: absolute;
  width: 7px;
  height: 7px;
  left: 50%;
  top: -6px;
  transform: translateX(-50%);
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--antenna-color, #ffde59);
}
.player-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}
.player-copy > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-cosmetics {
  overflow: hidden;
  color: #83eee5;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Profile & Social Loop */
.account-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.profile-chip {
  display: grid;
  align-content: center;
  min-width: 102px;
  border: 1px solid #ffffff26;
  border-radius: 12px;
  padding: 7px 10px;
  color: #fff;
  background: #ffffff0d;
  cursor: pointer;
}
.profile-chip b {
  color: var(--yellow);
  font-size: 10px;
  letter-spacing: 0.08em;
}
.profile-chip small {
  color: #aaa4ca;
  font-size: 7px;
  white-space: nowrap;
}
.profile-card {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 32px - var(--safe-top) - var(--safe-bottom));
  overflow-y: auto;
  border-radius: 26px;
  padding: 22px;
}
.profile-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 16px;
  margin: 14px 0 16px;
}
.profile-badge {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border: 2px solid #ffffff38;
  border-radius: 23px;
  color: #8d82bd;
  background: #ffffff0a;
  font-size: 38px;
  box-shadow: inset 0 -10px #0002;
}
.profile-badge.completed {
  color: var(--yellow);
  border-color: #ffdd4c99;
  text-shadow: 0 0 18px #ffdd4c88;
}
.profile-identity {
  min-width: 0;
}
.profile-identity small {
  color: var(--cyan);
  font-size: 10px;
  font-weight: 950;
  letter-spacing: 0.12em;
}
.profile-identity h2 {
  overflow: hidden;
  margin: 4px 0;
  font-size: clamp(25px, 7vw, 38px);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-identity p {
  margin: 0;
  color: #b9b2dd;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
}
.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}
.profile-stats span {
  display: grid;
  gap: 4px;
  padding: 11px 8px;
  border: 1px solid #ffffff18;
  border-radius: 12px;
  background: #ffffff08;
  text-align: center;
}
.profile-stats small {
  color: #aaa4ca;
  font-size: 7px;
  font-weight: 900;
}
.profile-stats b {
  font-size: 20px;
}
.profile-section {
  margin-top: 15px;
}
.profile-section-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: #aaa4ca;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.1em;
}
.profile-section-head span {
  color: #6fded7;
}
.profile-achievements {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
.profile-achievement {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 9px;
  border: 1px solid #62eeb933;
  border-radius: 11px;
  background: #62eeb90b;
}
.profile-achievement.locked {
  opacity: 0.5;
  border-color: #ffffff16;
  background: #ffffff06;
}
.profile-achievement i {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: var(--yellow);
  background: #ffffff0d;
  font-size: 18px;
  font-style: normal;
}
.profile-achievement span {
  display: grid;
  min-width: 0;
  gap: 3px;
}
.profile-achievement strong {
  font-size: 10px;
}
.profile-achievement small {
  color: #aaa4ca;
  font-size: 8px;
  line-height: 1.25;
}
.recent-partner-empty {
  margin: 0;
  padding: 12px;
  border: 1px dashed #ffffff24;
  border-radius: 11px;
  color: #aaa4ca;
  font-size: 10px;
  line-height: 1.4;
}
.recent-partner-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #4ce0df55;
  border-radius: 13px;
  background: #4ce0df0b;
}
.recent-partner-card > div {
  display: grid;
  min-width: 0;
  gap: 4px;
}
.recent-partner-card strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-partner-card small {
  color: #83eee5;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.05em;
}
.recent-partner-card .button {
  min-height: 42px;
  padding: 9px 12px;
  font-size: 9px;
}
@media (max-width: 560px) {
  .profile-card {
    padding: 18px 14px;
  }
  .profile-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .profile-achievements {
    grid-template-columns: 1fr;
  }
  .recent-partner-card {
    grid-template-columns: 1fr;
  }
  .recent-partner-card .button {
    width: 100%;
  }
}

/* #55 — compact social safety actions inside the existing recent-partner card. */
.recent-partner-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, auto));
  gap: 7px;
}
.social-report-reasons {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.social-report-reasons button {
  min-height: 34px;
  border: 1px solid #ffffff24;
  border-radius: 9px;
  color: #fff;
  background: #ffffff0d;
  font-size: 8px;
  font-weight: 900;
  cursor: pointer;
}
@media (max-width: 760px) {
  .recent-partner-actions {
    grid-template-columns: 1fr;
  }
}

.avoided-players-list {
  display: grid;
  gap: 8px;
}
.avoided-player-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #ffffff1f;
  border-radius: 12px;
  background: #ffffff0a;
}
.avoided-player-row > span {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.avoided-player-row strong,
.avoided-player-row small {
  overflow: hidden;
  text-overflow: ellipsis;
}
.avoided-player-row small,
.avoid-privacy-note {
  color: #ffffff9c;
  font-size: 8px;
  line-height: 1.45;
}
.avoid-privacy-note {
  display: block;
  margin-top: 8px;
}
@media (max-width: 760px) {
  .avoided-player-row {
    grid-template-columns: 1fr;
  }
  .avoided-player-row .button {
    width: 100%;
  }
}

/* Пометка бота рядом с именем. Заметная, но не кричащая: это уточнение, а не предупреждение. */
.bot-badge {
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
  color: #cfc6ef;
  font-size: 0.62em;
  letter-spacing: 0.08em;
  vertical-align: middle;
}

/* ==== Шкаф ==== */

/* Раскладка одна для всех экранов.

   На компьютере — сцена слева и решётка справа; на телефоне те же блоки складываются в колонку,
   вкладки становятся горизонтальной лентой, а панель действий прилипает к нижнему краю. Разметка
   при этом не дублируется: две разметки со временем разъезжаются, и починенное в одной остаётся
   сломанным в другой. */
.wardrobe-screen {
  display: grid;
  place-items: center;
  padding: calc(10px + var(--safe-top)) calc(10px + var(--safe-right)) calc(10px + var(--safe-bottom))
    calc(10px + var(--safe-left));
  background: #1a0f3ccc;
  backdrop-filter: blur(6px);
  z-index: 26;
}
.wardrobe-shell {
  display: flex;
  flex-direction: column;
  width: min(1120px, 100%);
  height: min(760px, 100%);
  padding: 14px;
  border-radius: 20px;
  overflow: hidden;
}
.wardrobe-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}
.wardrobe-head small {
  display: block;
  color: #a9a4cd;
  letter-spacing: 0.16em;
  font-size: 9px;
}
.wardrobe-head h2 {
  margin: 2px 0 0;
  font-size: 22px;
  letter-spacing: 0.04em;
}
.wardrobe-body {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 14px;
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 12px;
}
.wardrobe-stage {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 0;
  overflow-y: auto;
}
.wardrobe-preview {
  /* Обязательный сброс: глобальное правило `canvas` делает любой холст в проекте
     `position: fixed; inset: 0` — оно написано для игровой сцены, которая и должна занимать весь
     экран. Без сброса превью растягивается на всё окно поверх вкладок и перехватывает нажатия,
     причём выглядит это не как ошибка вёрстки, а как «кнопки не работают». */
  position: relative;
  inset: auto;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 320px;
  border: 1px solid #ffffff1a;
  border-radius: 16px;
  background: radial-gradient(circle at 50% 32%, #4b35b7 0%, #1d1145 74%);
  /* Превью вращают пальцем, и браузер не должен перехватывать это как прокрутку страницы. */
  touch-action: none;
  cursor: grab;
}
.wardrobe-stage-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px;
}
.wardrobe-stage-actions .button {
  min-height: 40px;
  padding: 0 12px;
  font-size: 10px;
}
.wardrobe-emotes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}
.wardrobe-emote-slot {
  min-height: 46px;
  border: 1px dashed #ffffff30;
  border-radius: 12px;
  color: #fff;
  background: #ffffff0d;
  font-size: 18px;
  cursor: pointer;
}
.wardrobe-emote-slot.is-empty {
  color: #8f89b8;
  font-size: 11px;
}
.wardrobe-collections {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wardrobe-collection {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 8px;
  padding: 8px 10px;
  border: 1px solid #ffffff14;
  border-left: 3px solid var(--collection-color, #ffffff44);
  border-radius: 10px;
  background: #ffffff08;
  cursor: pointer;
}
.wardrobe-collection b {
  font-size: 10px;
  letter-spacing: 0.06em;
}
.wardrobe-collection span {
  color: #cfcaea;
  font-size: 10px;
}
.wardrobe-collection-bar {
  grid-column: 1 / -1;
  height: 5px;
  border-radius: 3px;
  background: #ffffff1a;
}
.wardrobe-collection-bar::before {
  display: block;
  width: var(--percent, 0%);
  height: 100%;
  border-radius: 3px;
  background: var(--collection-color, #fff);
  content: '';
}
.wardrobe-collection small {
  grid-column: 1 / -1;
  color: #a9a4cd;
  font-size: 9px;
}
.wardrobe-collection.is-complete {
  box-shadow: inset 0 0 0 1px var(--collection-color, #fff);
}
.wardrobe-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.wardrobe-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.wardrobe-tabs::-webkit-scrollbar {
  display: none;
}
.wardrobe-tab {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  /* Пальцу нужна цель, а не пиксель: 44 — минимум, ниже которого промахи становятся правилом. */
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid #ffffff1f;
  border-radius: 999px;
  color: #cfcaea;
  background: #ffffff0a;
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.wardrobe-tab.active {
  border-color: var(--yellow);
  color: var(--ink);
  background: var(--yellow);
}
.wardrobe-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.wardrobe-filters select,
.wardrobe-chip {
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid #ffffff1f;
  border-radius: 10px;
  color: #e6e3f7;
  background: #241750;
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.05em;
  cursor: pointer;
}
.wardrobe-chip.active {
  border-color: var(--yellow);
  color: var(--ink);
  background: var(--yellow);
}
.wardrobe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
  flex: 1 1 auto;
  min-height: 120px;
  overflow-y: auto;
  padding-right: 2px;
}
.wardrobe-card {
  position: relative;
  min-height: 118px;
  padding: 9px;
  border: 1px solid #ffffff1a;
  border-left: 3px solid var(--rarity-color, #ffffff44);
  border-radius: 12px;
  color: #efedfb;
  background: #ffffff0a;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.wardrobe-card-swatch {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  font-size: 17px;
  font-style: normal;
}
.wardrobe-card strong {
  display: block;
  margin-top: 7px;
  font-size: 10px;
  line-height: 1.25;
}
.wardrobe-card-meta {
  display: block;
  margin-top: 3px;
  color: var(--rarity-color, #a9a4cd);
  font-size: 9px;
  letter-spacing: 0.06em;
}
.wardrobe-card-state {
  display: block;
  margin-top: 4px;
  color: #a9a4cd;
  font-size: 9px;
  line-height: 1.3;
}
.wardrobe-card-collection,
.wardrobe-card-favorite,
.wardrobe-card-new {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 9px;
  letter-spacing: 0.08em;
}
.wardrobe-card-collection {
  color: #8f89b8;
}
.wardrobe-card-favorite {
  top: 24px;
  color: var(--yellow);
}
.wardrobe-card-new {
  top: 40px;
  padding: 1px 5px;
  border-radius: 5px;
  color: var(--ink);
  background: var(--mint, #68f4d2);
}
/* Закрытый предмет остаётся видимым и его можно рассмотреть. Отличается он не только
   приглушённостью: у него всегда написано требование, а кнопка «Надеть» выключена. */
.wardrobe-card.is-locked {
  opacity: 0.62;
  border-left-style: dashed;
}
.wardrobe-card.is-equipped {
  box-shadow: inset 0 0 0 1px var(--mint, #68f4d2);
}
.wardrobe-card.is-selected {
  border-color: var(--yellow);
  background: #ffffff18;
}
.wardrobe-empty {
  grid-column: 1 / -1;
  margin: 18px 0;
  color: #a9a4cd;
  text-align: center;
  font-size: 11px;
}
.wardrobe-details {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  flex: 0 0 auto;
  padding: 10px 12px;
  border: 1px solid #ffffff1a;
  border-radius: 14px;
  background: #1d1145cc;
}
.wardrobe-details-copy strong {
  font-size: 13px;
}
.wardrobe-details-meta {
  display: flex;
  gap: 8px;
  margin-top: 3px;
  font-size: 9px;
  letter-spacing: 0.07em;
}
.wardrobe-details-meta b {
  color: var(--rarity-color, #fff);
}
.wardrobe-details-meta i {
  color: #a9a4cd;
  font-style: normal;
}
.wardrobe-details-collection {
  display: block;
  margin-top: 3px;
  color: #8f89b8;
  font-size: 9px;
}
.wardrobe-details-copy p {
  margin: 5px 0 0;
  color: #cfcaea;
  font-size: 10px;
  line-height: 1.4;
}
.wardrobe-details-requirement {
  display: block;
  margin-top: 4px;
  color: var(--mint, #68f4d2);
  font-size: 9px;
}
.wardrobe-details-requirement.locked {
  color: var(--yellow);
}
.wardrobe-details-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}
.wardrobe-details-actions .button {
  min-height: 44px;
  padding: 0 15px;
  font-size: 10px;
}
.wardrobe-details-actions .button:disabled {
  opacity: 0.45;
  cursor: default;
}
.wardrobe-open {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 9px;
}
.wardrobe-open small {
  color: #ffffffcc;
  font-size: 9px;
}

.unlock-toast {
  position: fixed;
  right: calc(12px + var(--safe-right));
  bottom: calc(12px + var(--safe-bottom));
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: min(280px, calc(100vw - 24px));
  padding: 12px 14px;
  border: 1px solid #ffffff22;
  border-left: 4px solid var(--rarity-color, #fff);
  border-radius: 14px;
  background: #1d1145f2;
}
.unlock-toast b {
  color: var(--yellow);
  font-size: 9px;
  letter-spacing: 0.16em;
}
.unlock-toast strong {
  font-size: 14px;
}
.unlock-toast small {
  color: #a9a4cd;
  font-size: 9px;
  letter-spacing: 0.07em;
}
.unlock-toast-actions {
  display: flex;
  gap: 7px;
  margin-top: 7px;
}
.unlock-toast-actions .button {
  flex: 1;
  min-height: 40px;
  font-size: 10px;
}

@media (max-width: 900px) {
  .wardrobe-shell {
    height: 100%;
    padding: 11px;
  }
  .wardrobe-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
  }
  .wardrobe-stage {
    flex: 0 0 auto;
    overflow: visible;
  }
  .wardrobe-preview {
    max-height: 40vh;
  }
  /* На телефоне решётка держит две-три колонки и не растекается за край карточки. */
  .wardrobe-grid {
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
    overflow: visible;
  }
  /* Панель действий липнет к низу: «Надеть» должно быть под пальцем, а не в конце длинной ленты.
     Она внутри шкафа, а не поверх игры, поэтому джойстику и кнопкам прыжка мешать ей нечем —
     во время забега шкаф закрыт. */
  .wardrobe-details {
    position: sticky;
    bottom: 0;
    grid-template-columns: minmax(0, 1fr);
  }
  .wardrobe-details-actions {
    justify-content: stretch;
  }
  .wardrobe-details-actions .button {
    flex: 1;
  }
  .wardrobe-collections {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Уменьшенная анимация: автоповорот превью и появление карточки награды — украшения, и для тех,
   кому движение мешает, они первыми и уходят. Само превью остаётся: его вращают пальцем. */
@media (prefers-reduced-motion: reduce) {
  .wardrobe-card,
  .unlock-toast {
    transition: none;
  }
}

/* Кнопка и колесо эмоций. Правый верхний угол — единственная зона, свободная и от джойстика
   (низ слева), и от прыжка с рывком (низ справа). */
.emote-button {
  top: calc(12px + var(--safe-top));
  right: calc(12px + var(--safe-right) + 58px);
  font-size: 20px;
}
.emote-wheel {
  position: absolute;
  top: calc(66px + var(--safe-top));
  right: calc(12px + var(--safe-right));
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(2, 56px);
  gap: 7px;
  padding: 9px;
  border: 1px solid #ffffff22;
  border-radius: 14px;
  background: #1d1145e8;
}
.emote-wheel-slot {
  min-height: 52px;
  border: 1px solid #ffffff22;
  border-radius: 11px;
  color: #fff;
  background: #ffffff10;
  font-size: 20px;
  cursor: pointer;
}
.emote-wheel-slot:disabled {
  opacity: 0.35;
  cursor: default;
}
