:root {
  --bg: #07050f;
  --ink: #f7ecff;
  --muted: #b9a7c9;
  --hot: #ff5c7a;
  --sun: #ffb347;
  --gold: #ffd166;
  --cool: #6ec6ff;
  --panel: rgba(14, 9, 26, 0.82);
  --outline: rgba(255, 255, 255, 0.14);
  font-family: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: radial-gradient(circle at 50% 0%, #17102b, var(--bg) 70%);
  color: var(--ink);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Размеры интерфейса считаются от ширины stage (cqw), а не от vmin вьюпорта:
   в ландшафте и на десктопе stage уже вьюпорта, иначе меню распирает. */
#stage {
  container-type: inline-size;
  position: relative;
  width: min(100vw, calc(100vh * 0.5625));
  height: min(100vh, calc(100vw * 1.7778));
  width: min(100vw, calc(100dvh * 0.5625));
  height: min(100dvh, calc(100vw * 1.7778));
  overflow: hidden;
  background: #0d0a1c;
  box-shadow: 0 0 80px rgba(255, 92, 122, 0.16);
  touch-action: manipulation;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

/* Горизонтальные safe-area не нужны: в портрете они нулевые,
   в ландшафте stage центрирован и до выреза не дотягивается. */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: max(2.2%, env(safe-area-inset-top, 0px)) 3.4% 2.2%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
  z-index: 5;
}

.hud-score {
  font-family: "Arial Black", "Segoe UI", sans-serif;
  font-size: clamp(24px, 4.6cqw, 46px);
  line-height: 1;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.55);
  font-variant-numeric: tabular-nums;
}

.hud-unit {
  font-size: 0.6em;
  margin-left: 0.18em;
  color: var(--sun);
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 2.4cqw;
  pointer-events: auto;
}

.hud-coins {
  display: flex;
  align-items: center;
  gap: 0.6cqw;
  font-family: "Arial Black", sans-serif;
  font-size: clamp(16px, 2.9cqw, 30px);
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.hud-coins img {
  width: clamp(20px, 3.6cqw, 40px);
  height: clamp(20px, 3.6cqw, 40px);
  object-fit: contain;
}

.icon-button {
  pointer-events: auto;
  width: clamp(44px, 5.6cqw, 54px);
  height: clamp(44px, 5.6cqw, 54px);
  border-radius: 14px;
  border: 2px solid var(--outline);
  background: rgba(20, 12, 36, 0.65);
  color: var(--ink);
  font-size: clamp(14px, 1.8cqw, 17px);
  letter-spacing: 0.1em;
  cursor: pointer;
}

.icon-button:active { transform: scale(0.94); }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  justify-content: safe center;
  gap: 1.6cqw;
  padding: max(6%, env(safe-area-inset-top, 0px)) 7% max(6%, env(safe-area-inset-bottom, 0px));
  text-align: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 92, 122, 0.22), transparent 55%),
    linear-gradient(180deg, rgba(9, 6, 18, 0.62), rgba(9, 6, 18, 0.82));
  backdrop-filter: blur(3px);
  touch-action: pan-y;
}

.loading-screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.6cqw;
  padding: 7%;
  background: radial-gradient(circle at 50% 42%, #1a1230, var(--bg) 72%);
  transition: opacity 0.35s ease;
}

.loading-screen.is-hidden { opacity: 0; pointer-events: none; }

.loading-art {
  width: min(58cqw, 250px);
  height: auto;
  border-radius: 20px;
  box-shadow:
    0 20px 56px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 0 34px rgba(110, 198, 255, 0.18);
}

.loading-text {
  margin: 0;
  color: var(--muted);
  font-size: clamp(13px, 2cqw, 18px);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

#menu {
  justify-content: flex-start;
  padding-top: max(5%, env(safe-area-inset-top, 0px));
}

.screen {
  justify-content: flex-start;
  padding-top: max(5%, env(safe-area-inset-top, 0px));
}

/* На низких экранах (ландшафт телефона) убираем лишние поля, чтобы экраны
   влезали без обрезки; портрет и десктоп не затрагиваются. */
@media (max-height: 520px) {
  .overlay {
    padding-top: max(3%, env(safe-area-inset-top, 0px));
    padding-bottom: max(3%, env(safe-area-inset-bottom, 0px));
  }

  #menu,
  .screen {
    padding-top: max(4%, env(safe-area-inset-top, 0px));
  }
}

.screen-title {
  margin: 0;
  font-family: "Arial Black", "Segoe UI", sans-serif;
  font-size: clamp(22px, 5.4cqw, 54px);
  text-transform: uppercase;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.balance {
  margin: 0 0 1cqw;
  color: var(--gold);
  font-size: clamp(14px, 2.2cqw, 22px);
  letter-spacing: 0.06em;
}

.character-picker {
  display: flex;
  align-items: stretch;
  gap: 1.6cqw;
  width: min(100%, 26em);
  margin-top: 1.4cqw;
}

.hero-nav {
  flex: 0 0 auto;
  width: clamp(44px, 6cqw, 56px);
  min-height: 44px;
  border-radius: 16px;
  border: 2px solid var(--outline);
  background: rgba(20, 12, 36, 0.72);
  color: var(--ink);
  font-size: clamp(22px, 4.4cqw, 40px);
  line-height: 1;
  cursor: pointer;
}

.hero-nav:active { transform: scale(0.94); }

.hero-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6cqw;
  padding: 1.8cqw 2cqw;
  border-radius: 18px;
  border: 2px solid rgba(255, 209, 102, 0.4);
  background: rgba(28, 17, 46, 0.78);
  box-shadow: 0 0 26px rgba(255, 179, 71, 0.16);
}

.hero-thumb {
  height: clamp(48px, 9.5cqw, 92px);
  width: auto;
  margin: -1.4cqw 0 -0.6cqw;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
}

.hero-name {
  margin: 0;
  font-family: "Arial Black", serif;
  font-size: clamp(14px, 2.6cqw, 26px);
  letter-spacing: 0.02em;
}

.hero-perk {
  margin: 0;
  color: var(--muted);
  font-size: clamp(14px, 1.9cqw, 19px);
  line-height: 1.3;
}

.hero-action {
  margin-top: 0.6cqw;
  min-height: 44px;
  padding: 0.9cqw 2.6cqw;
  border-radius: 999px;
  border: 2px solid var(--sun);
  background: rgba(255, 179, 71, 0.16);
  color: var(--sun);
  font-family: "Arial Black", sans-serif;
  font-size: clamp(14px, 1.8cqw, 18px);
  letter-spacing: 0.06em;
  cursor: pointer;
}

.hero-action:disabled { opacity: 0.55; cursor: default; }
.hero-action[data-action="buy"]:not(:disabled) {
  background: linear-gradient(180deg, #ffd166, #ff7a4d);
  color: #2a0f12;
}
.hero-action.is-armed[data-action="buy"] {
  background: rgba(255, 92, 122, 0.2);
  border-color: var(--hot);
  color: var(--hot);
}

.nav-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4cqw;
  width: min(100%, 26em);
  margin-top: 1.2cqw;
}

.nav-button {
  flex: 1 1 70px;
  min-width: 44px;
  min-height: 44px;
  padding: 1.1cqw 1cqw;
  border-radius: 14px;
  border: 2px solid var(--outline);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-size: clamp(14px, 1.8cqw, 18px);
  letter-spacing: 0.04em;
  cursor: pointer;
}

.nav-button:active { transform: scale(0.96); }

.hud-buffs {
  position: absolute;
  left: 3.4%;
  top: 100%;
  margin-top: 1.2cqw;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.7cqw;
}

.buff {
  padding: 0.7cqw 1.6cqw;
  border-radius: 999px;
  border: 2px solid var(--outline);
  font-family: "Arial Black", sans-serif;
  font-size: clamp(14px, 1.6cqw, 17px);
  letter-spacing: 0.08em;
  background: rgba(9, 6, 18, 0.55);
}

.buff-cool { color: var(--cool); border-color: var(--cool); }
.buff-hot { color: var(--hot); border-color: var(--hot); }
.buff-gold { color: var(--gold); border-color: var(--gold); }

.card-list {
  width: min(100%, 28em);
  margin: 0.6cqw 0 1.6cqw;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.1cqw;
}

.card {
  display: flex;
  gap: 1.8cqw;
  padding: 1.6cqw 2cqw;
  border-radius: 16px;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
}

.card-thumb {
  flex: 0 0 auto;
  width: clamp(52px, 11cqw, 104px);
  align-self: center;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45));
}

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5cqw;
  min-width: 0;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.2cqw 1.4cqw;
  align-items: baseline;
}

.card-name {
  font-family: "Arial Black", sans-serif;
  font-size: clamp(14px, 2.2cqw, 22px);
}

.card-price {
  margin-left: auto;
  color: var(--gold);
  font-size: clamp(14px, 1.9cqw, 19px);
  white-space: nowrap;
}

.card-text {
  margin: 0;
  color: var(--muted);
  font-size: clamp(14px, 1.9cqw, 19px);
  line-height: 1.35;
}

.card-button {
  align-self: flex-start;
  min-height: 44px;
  margin-top: 0.4cqw;
  padding: 0.8cqw 2.2cqw;
  border-radius: 999px;
  border: 1px solid var(--sun);
  background: rgba(255, 179, 71, 0.14);
  color: var(--sun);
  font-size: clamp(14px, 1.8cqw, 18px);
  cursor: pointer;
}

.card-button:disabled { opacity: 0.5; cursor: default; }
.card-button.is-armed {
  background: rgba(255, 92, 122, 0.2);
  border-color: var(--hot);
  color: var(--hot);
}

.card.is-done { border-color: rgba(120, 255, 190, 0.35); background: rgba(120, 255, 190, 0.07); }
.card.is-done .card-price { color: #78ffbe; }

.ach-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.ach-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffb347, #ffd166);
}

.ach-progress {
  margin: 0;
  color: var(--muted);
  font-size: clamp(14px, 1.7cqw, 17px);
  font-variant-numeric: tabular-nums;
}

.row-button {
  width: min(100%, 28em);
  min-height: 44px;
  padding: 1.6cqw 2cqw;
  border-radius: 14px;
  border: 2px solid var(--outline);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-size: clamp(14px, 2.1cqw, 21px);
  letter-spacing: 0.04em;
  cursor: pointer;
}

.row-button:active { transform: scale(0.98); }
.row-button.danger { border-color: rgba(255, 92, 122, 0.55); color: var(--hot); }
.row-button.danger-armed {
  background: rgba(255, 92, 122, 0.2);
  border-color: var(--hot);
}

.cta.ghost {
  background: transparent;
  border: 2px solid var(--outline);
  color: var(--ink);
  box-shadow: none;
  font-size: clamp(16px, 2.2cqw, 22px);
  padding: 1.4cqw 4cqw;
}

.cta.ghost:active { transform: scale(0.97); box-shadow: none; }

.over-buttons {
  display: flex;
  gap: 1.6cqw;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.final-total {
  color: var(--muted);
}

.toast {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(7% + env(safe-area-inset-bottom, 0px));
  width: fit-content;
  margin: 0 auto;
  z-index: 30;
  max-width: 86%;
  padding: 1.4cqw 2.4cqw;
  border-radius: 14px;
  background: rgba(24, 14, 40, 0.94);
  border: 1px solid rgba(255, 209, 102, 0.5);
  color: var(--ink);
  font-size: clamp(14px, 2cqw, 20px);
  text-align: center;
  pointer-events: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.run-hint {
  position: absolute;
  top: 28%;
  left: 0;
  right: 0;
  z-index: 6;
  width: fit-content;
  max-width: 86%;
  margin: 0 auto;
  padding: 2.2cqw 4cqw;
  border-radius: 999px;
  border: 2px solid var(--sun);
  background: rgba(9, 6, 18, 0.82);
  color: var(--ink);
  font-size: clamp(14px, 2.4cqw, 22px);
  letter-spacing: 0.04em;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.pause-stats {
  margin: 0;
  color: var(--gold);
  font-size: clamp(14px, 2.4cqw, 22px);
  letter-spacing: 0.04em;
}

.overlay-dim { background: rgba(9, 6, 18, 0.55); backdrop-filter: blur(2px); }

.eyebrow {
  margin: 0;
  font-size: clamp(14px, 1.7cqw, 17px);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--sun);
}

.menu-logo {
  width: clamp(84px, 23cqw, 148px);
  height: auto;
  border-radius: 50%;
  filter: drop-shadow(0 6px 20px rgba(255, 92, 122, 0.28));
}

#menu-title {
  margin: 0.4cqw 0 0;
  font-family: "Arial Black", "Segoe UI", sans-serif;
  font-size: clamp(30px, 8.6cqw, 92px);
  line-height: 0.92;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #fff2d6 15%, var(--sun) 55%, #ff6a5e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.45));
}

.subtitle {
  margin: 0;
  font-size: clamp(14px, 2.1cqw, 21px);
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hint {
  margin: 1.2cqw 0 0;
  font-size: clamp(14px, 2cqw, 20px);
  color: var(--muted);
  line-height: 1.45;
  max-width: 30ch;
}

.cta {
  margin-top: 1.6cqw;
  min-height: 48px;
  padding: 1.9cqw 5.4cqw;
  border: none;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffd166, #ff7a4d);
  color: #2a0f12;
  font-family: "Arial Black", "Segoe UI", sans-serif;
  font-size: clamp(16px, 2.7cqw, 28px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 0 #8d2f2a, 0 16px 34px rgba(255, 110, 90, 0.35);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.cta:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 #8d2f2a, 0 8px 18px rgba(255, 110, 90, 0.3);
}

.cta:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: 0 8px 0 #6a2622;
}

.cta:disabled:active {
  transform: none;
}

.board-wrap {
  width: min(100%, 34em);
  margin-top: 2.4cqw;
}

.board-title {
  margin: 0 0 0.9cqw;
  font-size: clamp(14px, 1.8cqw, 18px);
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--muted);
}

.board {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6cqw;
}

.board li {
  display: grid;
  grid-template-columns: 2.4em 1fr auto;
  align-items: baseline;
  gap: 0.8em;
  padding: 1.1cqw 1.6cqw;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: clamp(14px, 2cqw, 21px);
}

.board .rank { color: var(--sun); font-family: "Arial Black", sans-serif; }
.board .nick { color: var(--ink); text-align: left; }
.board .meters { color: var(--gold); font-variant-numeric: tabular-nums; }
.board .empty {
  display: block;
  color: var(--muted);
  text-align: center;
  border-style: dashed;
}

.record-badge {
  margin: 0.4cqw 0 0;
  padding: 0.7cqw 2cqw;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe28a, #ffb347);
  color: #3a1405;
  font-family: "Arial Black", sans-serif;
  font-size: clamp(14px, 1.7cqw, 17px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  box-shadow: 0 0 22px rgba(255, 179, 71, 0.55);
}

.best {
  margin: 1.6cqw 0 0;
  color: var(--muted);
  font-size: clamp(14px, 1.8cqw, 18px);
  letter-spacing: 0.06em;
}

.over-title {
  margin: 0;
  font-family: "Arial Black", sans-serif;
  font-size: clamp(24px, 6.6cqw, 68px);
  line-height: 1;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  color: var(--hot);
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.4));
}

.result {
  margin: 1cqw 0 0;
  font-family: "Arial Black", sans-serif;
  font-size: clamp(40px, 12cqw, 120px);
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.result-unit {
  font-size: 0.34em;
  color: var(--sun);
  margin-left: 0.1em;
}

.final-coins {
  margin: 0;
  color: var(--gold);
  font-size: clamp(14px, 2.2cqw, 22px);
  letter-spacing: 0.08em;
}

.punchline {
  margin: 1.6cqw 0 0;
  max-width: 26ch;
  font-size: clamp(14px, 2.2cqw, 23px);
  line-height: 1.4;
  color: var(--ink);
}

.death-cause {
  margin: 0.6cqw 0 0;
  color: var(--muted);
  font-size: clamp(14px, 1.9cqw, 19px);
  letter-spacing: 0.02em;
}

/* «Как играть»: контент скроллится внутри экрана, карточки 2 колонки на широком. */
#guide {
  padding-bottom: max(4%, env(safe-area-inset-bottom, 0px));
}

.guide-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: min(100%, 34em);
  display: flex;
  flex-direction: column;
}

.guide-scroll {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  text-align: left;
  padding-right: 1cqw;
  padding-bottom: 22px;
  -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 22px), transparent);
  mask-image: linear-gradient(180deg, #000 calc(100% - 22px), transparent);
}

/* Подпись у нижней кромки: видна, только пока список можно листать дальше. */
.guide-more {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 1em;
  padding: 0.4cqw 0;
  font-size: clamp(14px, 1.9cqw, 18px);
  letter-spacing: 0.04em;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.guide-more.is-hidden { opacity: 0; }

.guide-more-hint { color: var(--sun); }
.guide-more-count { color: var(--muted); }

.g-block { margin: 0; }

.g-text {
  margin: 0 0 0.8cqw;
  color: var(--muted);
  font-size: clamp(14px, 2cqw, 20px);
  line-height: 1.4;
}

.g-heading {
  margin: 1.6cqw 0 0.8cqw;
  font-family: "Arial Black", sans-serif;
  font-size: clamp(14px, 2.6cqw, 26px);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sun);
}

.g-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.7cqw;
}

.g-list li {
  position: relative;
  padding-left: 1.6em;
  color: var(--muted);
  font-size: clamp(14px, 2cqw, 20px);
  line-height: 1.35;
}

.g-list li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--gold);
}

.g-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 1.1cqw;
}

.g-card {
  display: flex;
  align-items: flex-start;
  gap: 1.2cqw;
  padding: 1.2cqw 1.4cqw;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
}

.g-thumb {
  flex: 0 0 auto;
  width: clamp(64px, 9cqw, 72px);
  height: clamp(64px, 9cqw, 72px);
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45));
}

.g-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4cqw;
}

.g-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.8cqw;
}

.g-name {
  font-family: "Arial Black", sans-serif;
  font-size: clamp(14px, 2.1cqw, 21px);
}

.g-tag {
  padding: 0.1cqw 0.9cqw;
  border-radius: 999px;
  border: 1px solid var(--sun);
  color: var(--sun);
  font-size: clamp(14px, 1.5cqw, 15px);
  letter-spacing: 0.06em;
}

.g-rule {
  margin: 0;
  color: var(--muted);
  font-size: clamp(14px, 1.8cqw, 18px);
  line-height: 1.35;
}
