
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  overflow: hidden;
  background: #090817;
  color: white;
  font-family: "Courier New", monospace;
  touch-action: manipulation;
}

.game {
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 10px;
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.hud div {
  background: #17132d;
  border: 2px solid #6a4fc4;
  padding: 10px;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 3px 3px 0 #030208;
}

.scene {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(
    to bottom,
    #100c2d 0%,
    #24205b 52%,
    #54265e 100%
  );
  border: 2px solid #5142a0;
  image-rendering: pixelated;
  isolation: isolate;
}

.moon {
  position: absolute;
  top: 10%;
  right: 15%;
  width: 34px;
  height: 34px;
  background: #f7d8ff;
  box-shadow: 0 0 18px #f7a7ff;
}

.moon::after {
  content: "";
  position: absolute;
  top: -5px;
  left: 9px;
  width: 34px;
  height: 34px;
  background: #171139;
}

.city {
  position: absolute;
  bottom: 22%;
  width: 200%;
  height: 50%;
  background-repeat: repeat-x;
}

.city-back {
  opacity: 0.8;
  background-color: transparent;
  background-image:
    linear-gradient(#201b4a, #201b4a),
    linear-gradient(#31255c, #31255c),
    linear-gradient(#1c1944, #1c1944),
    linear-gradient(#302052, #302052),
    linear-gradient(#201b4a, #201b4a);
  background-size:
    48px 65%,
    58px 90%,
    38px 55%,
    62px 75%,
    45px 100%;
  background-position:
    0 100%,
    48px 100%,
    106px 100%,
    144px 100%,
    206px 100%;
}

.city-front {
  bottom: 22%;
  height: 34%;
  opacity: 0.95;
  background-image:
    linear-gradient(#17132f, #17132f),
    linear-gradient(#21183e, #21183e),
    linear-gradient(#17132f, #17132f),
    linear-gradient(#21183e, #21183e);
  background-size: 70px 70%, 45px 100%, 60px 55%, 54px 80%;
  background-position: 0 100%, 70px 100%, 115px 100%, 175px 100%;
}

.ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22%;
  background: #171326;
  border-top: 4px solid #ff4fd8;
}

.ground::before {
  content: "";
  position: absolute;
  top: 40%;
  left: 0;
  width: 100%;
  height: 4px;
  background: repeating-linear-gradient(
    to right,
    #7560b2 0 28px,
    transparent 28px 58px
  );
}

.player {
  position: absolute;
  z-index: 3;
  left: 18%;
  bottom: 22%;
  width: 36px;
  height: 58px;
}

.hair {
  position: absolute;
  left: 6px;
  top: 0;
  width: 25px;
  height: 12px;
  background: #f4cf4e;
  box-shadow: -4px 8px #f4cf4e, 22px 7px #f4cf4e;
}

.face {
  position: absolute;
  left: 10px;
  top: 9px;
  width: 17px;
  height: 15px;
  background: #efb58c;
  box-shadow: 12px 5px #f4cf4e;
}

.face::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 3px;
  width: 3px;
  height: 3px;
  background: #171326;
}

.body {
  position: absolute;
  top: 24px;
  left: 7px;
  width: 24px;
  height: 22px;
  background: #24203e;
  border-left: 5px solid #ff4fd8;
  border-right: 4px solid #ff4fd8;
}

.leg {
  position: absolute;
  top: 44px;
  width: 9px;
  height: 12px;
  background: #d6cdec;
  border-bottom: 4px solid #ff4fd8;
}

.leg-left {
  left: 7px;
}

.leg-right {
  left: 23px;
}

.obstacle {
  position: absolute;
  z-index: 2;
  right: 12%;
  bottom: 22%;
  width: 36px;
  height: 32px;
  background: #514c70;
  border-top: 6px solid #ff4fd8;
  border-bottom: 5px solid #28223d;
}

/* Обычный кейс с оборудованием */
.obstacle-case {
  width: 42px;
  height: 42px;
  background: #7650a8;
  border: 3px solid #b89bdf;
  box-sizing: border-box;
  border-radius: 3px;
}

/* Большой кейс */
.obstacle-big-case {
  width: 58px;
  height: 58px;
  background: #34364f;
  border: 3px solid #a7a9c7;
  box-sizing: border-box;
  border-radius: 3px;
}

/* Низкое ограждение */
.obstacle-barrier {
  width: 54px;
  height: 25px;
  background: #d84b65;
  border: 3px solid #ffb2bd;
  box-sizing: border-box;
  border-radius: 3px;
}

.coin {
  position: absolute;
  z-index: 2;
  right: 28%;
  bottom: 35%;
  width: 16px;
  height: 16px;
  background: #ffcc35;
  border: 4px solid #fff2a3;
  box-shadow: 0 0 12px #ffcc35;
}

.message {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  background: #090817b8;
}

.message h1 {
  color: #ff64dc;
  font-size: clamp(23px, 7vw, 32px);
  text-shadow: 3px 3px #35205b;
  margin-bottom: 4px;
}

.message p {
  font-size: 14px;
}

button {
  background: #ff4fd8;
  color: #160c22;
  border: 0;
  padding: 14px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
}

footer {
  flex-shrink: 0;
  text-align: center;
  padding: 8px 0;
  font-size: 11px;
  color: #aaa4cb;
}


.pause-button {
  position: relative;
  z-index: 5;
  min-width: 38px;
  min-height: 34px;
  padding: 4px 10px;
  color: white;
  background: #7650a8;
  border: 1px solid #b89bdf;
  border-radius: 6px;
  font-size: 20px;
  cursor: pointer;
}

.pause-menu {
  z-index: 10;
  background: rgba(12, 10, 27, 0.94);
}

.pause-menu button {
  margin-top: 8px;
  width: 80%;
}


/* Главное меню и выбор персонажа */
#mainMenu,
#characterMenu {
  width: 100%;
  box-sizing: border-box;
}

.character-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-height: 42vh;
  overflow-y: auto;
  margin: 14px 0;
}

.character-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 7px 12px;
  color: white;
  background: #17152d;
  border: 2px solid #51416d;
  border-radius: 8px;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
}

.character-card.selected {
  background: #302044;
  border-color: #d6a8ff;
  box-shadow: 0 0 10px rgba(180, 110, 255, 0.3);
}

.character-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 5px;
  font-size: 20px;
  font-weight: bold;
  image-rendering: pixelated;
}

.avatar-0 { background: #7548a8; }
.avatar-1 { background: #287f9c; }
.avatar-2 { background: #b44866; }
.avatar-3 { background: #ad762f; }
.avatar-4 { background: #47784d; }

#characterMenu button {
  margin-top: 5px;
}

#selectedCharacterText {
  font-size: 14px;
}

.player {
  --hero-color: #b58cff;
}

.player .body {
  background-color: var(--hero-color);
}


#resultsMenu {
  width: 100%;
  box-sizing: border-box;
}

#resultsMenu p {
  margin: 10px 0;
}

#resultsMenu button {
  display: block;
  width: 80%;
  margin: 10px auto 0;
}

.results-menu {
  z-index: 10;
  background: rgba(12, 10, 27, 0.94);
}

.results-menu button {
  display: block;
  width: 80%;
  margin: 10px auto 0;
}


/* === МОБИЛЬНАЯ АДАПТАЦИЯ AZARTT RUN === */

/* Не даём странице прокручиваться жестами */
html,
body {
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Стабильная компоновка игры */
.game {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding:
    max(8px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
  gap: 8px;
}

/* HUD не должен сжиматься */
.hud {
  align-items: center;
  flex-shrink: 0;
  min-width: 0;
}

.hud div {
  min-width: 0;
  padding: 8px;
  font-size: clamp(10px, 2.8vw, 12px);
}

/* Игровая сцена занимает оставшееся место */
.scene {
  flex: 1 1 auto;
  min-height: 0;
  touch-action: manipulation;
}

/* Кнопки удобно нажимать пальцем */
button {
  min-height: 44px;
  max-width: 100%;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

/* Меню не выходит за границы игрового поля */
.message {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

/* Список героев можно прокручивать отдельно */
.character-list {
  min-height: 0;
  max-height: 35dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Узкие экраны */
@media (max-width: 360px) {
  .game {
    padding: 6px;
    gap: 6px;
  }

  .hud div {
    padding: 6px;
  }

  .message {
    padding: 12px;
  }

  .character-list {
    max-height: 32dvh;
  }

  .character-card {
    gap: 8px;
    padding: 6px 8px;
    font-size: 12px;
  }
}

/* Низкие экраны */
@media (max-height: 600px) {
  .message {
    justify-content: flex-start;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .message h1 {
    font-size: 22px;
    margin-top: 4px;
  }

  .message p {
    margin: 6px 0;
    font-size: 12px;
  }

  .character-list {
    max-height: 28dvh;
    margin: 6px 0;
    gap: 4px;
  }

  .character-card {
    min-height: 42px;
  }

  .character-avatar {
    width: 30px;
    height: 30px;
  }

  .message button {
    min-height: 38px;
    padding: 8px 12px;
  }
}
