/* Мини-приложение «Мир Фантазии». Основные цвета берутся из темы Telegram (--tg-theme-*),
   свои значения - только запасные, если приложение открыто без темы. Сцена боя и поле
   сапёра всегда тёмные: так они выглядят как игра в любой теме. */

:root {
  --fb-bg: #efeff4;
  --fb-card: #ffffff;
  --fb-text: #000000;
  --fb-hint: #8e8e93;
  --fb-accent: #6d4aff;
  --fb-on-accent: #ffffff;
  --fb-danger: #e53935;
  --fb-toast: rgba(28, 28, 30, .94);

  --bg: var(--tg-theme-secondary-bg-color, var(--fb-bg));
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, var(--fb-card)));
  --text: var(--tg-theme-text-color, var(--fb-text));
  --hint: var(--tg-theme-hint-color, var(--fb-hint));
  --accent: var(--tg-theme-button-color, var(--fb-accent));
  --on-accent: var(--tg-theme-button-text-color, var(--fb-on-accent));
  --danger: var(--tg-theme-destructive-text-color, var(--fb-danger));
  --sep: rgba(128, 128, 128, .18);
  --track: rgba(128, 128, 128, .22);
  --soft: rgba(128, 128, 128, .12);

  --hp: #ef4350;
  --mana: #4c8dff;
  --energy: #f4a417;
  --shield: #8fa3c0;
  --xp: #a855f7;
  --good: #22b14c;
  --bad: #e5484d;
  --gold: #e8a90c;

  --stage-1: #1d1736;
  --stage-2: #2e2158;
  --stage-text: #f3f0ff;
  --stage-muted: rgba(243, 240, 255, .62);
  --tile: linear-gradient(160deg, #4a4f7a, #33375a);
  --tile-edge: #23263f;

  --radius: 16px;
  --tabs-h: 60px;
  --safe-bottom: var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --safe-top: var(--tg-content-safe-area-inset-top, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-scheme="light"]) {
    --fb-bg: #0f0f12;
    --fb-card: #1c1c21;
    --fb-text: #ffffff;
    --fb-hint: #8d8d93;
    --fb-accent: #8b6dff;
    --fb-toast: rgba(58, 58, 64, .96);
  }
}

:root[data-scheme="dark"] {
  --fb-bg: #0f0f12;
  --fb-card: #1c1c21;
  --fb-text: #ffffff;
  --fb-hint: #8d8d93;
  --fb-accent: #8b6dff;
  --fb-toast: rgba(58, 58, 64, .96);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
  min-height: 100vh;
}

[hidden] { display: none !important; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

input { font: inherit; }
code { font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

.muted { color: var(--hint); }
.center { text-align: center; justify-content: center; }
.good { color: var(--good); }
.bad { color: var(--bad); }

/* ---------- экраны загрузки и ошибок ---------- */

.screen {
  min-height: 100vh;
  min-height: var(--tg-viewport-stable-height, 100vh);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px 24px;
  text-align: center;
}

.screen-icon { font-size: 56px; line-height: 1; }
.screen h1 { margin: 6px 0 0; font-size: 20px; }
.screen p { margin: 0; max-width: 320px; color: var(--hint); white-space: pre-line; }
.screen .btn { margin-top: 14px; min-width: 200px; padding: 12px 20px; }

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--track);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- каркас ---------- */

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-top)) 12px calc(var(--tabs-h) + var(--safe-bottom) + 20px);
}

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 -12px 4px;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--sep);
}

.avatar {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: linear-gradient(140deg, var(--stage-2), var(--stage-1));
  box-shadow: 0 0 0 2px rgba(168, 85, 247, .35);
}

.who { flex: 1; min-width: 0; }
.who .name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .sub { font-size: 12px; color: var(--hint); }
.xp { height: 3px; margin-top: 4px; border-radius: 3px; background: var(--track); overflow: hidden; max-width: 160px; }
.xp i { display: block; height: 100%; background: var(--xp); border-radius: 3px; transition: width .4s ease; }

.wallet { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-weight: 650; font-size: 14px; }
.wallet .donut { font-size: 12px; color: var(--hint); font-weight: 600; }

.offline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(229, 72, 77, .12);
  color: var(--danger);
  font-weight: 600;
}

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: var(--card);
  border-top: 1px solid var(--sep);
}

.tabs button {
  flex: 1;
  max-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  border-radius: 12px;
  color: var(--hint);
  font-size: 11px;
  font-weight: 600;
  transition: color .15s, background .15s;
}

.tabs button i { font-style: normal; font-size: 22px; line-height: 1.1; filter: grayscale(.6); transition: filter .15s, transform .15s; }
.tabs button.active { color: var(--accent); background: var(--soft); }
.tabs button.active i { filter: none; transform: translateY(-1px) scale(1.06); }

/* ---------- общие блоки ---------- */

.section { margin: 18px 0 0; }
.section > h2 {
  margin: 0 4px 8px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--tg-theme-section-header-text-color, var(--hint));
}

.card {
  margin: 10px 0 0;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--card);
}

.card-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 2px 0 8px;
  font-weight: 650;
}

.card-title small { color: var(--hint); font-weight: 500; font-size: 12px; }
.card-title + .card-title, .segmented + .card-title { margin-top: 14px; }

.hint { margin: 8px 4px 0; font-size: 12.5px; color: var(--hint); }

.empty { padding: 18px 10px; text-align: center; color: var(--hint); font-size: 14px; }

.list { border-radius: var(--radius); background: var(--card); overflow: hidden; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-top: 1px solid var(--sep);
}

.row:first-child { border-top: 0; }
.row .ico { flex: none; width: 30px; text-align: center; font-size: 20px; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.row .sub { margin-top: 1px; font-size: 12.5px; color: var(--hint); }
.row .side { flex: none; font-weight: 600; font-size: 14px; text-align: right; }
.row.me { background: rgba(109, 74, 255, .1); }
.row .place { width: 26px; text-align: center; font-weight: 700; color: var(--hint); }
.row .place.medal { font-size: 20px; }

.my-place { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--soft);
  color: var(--text);
  white-space: nowrap;
}

.tag.soft { color: var(--hint); }
.tag.good { background: rgba(34, 177, 76, .16); color: var(--good); }
.tag.bad { background: rgba(229, 72, 77, .16); color: var(--bad); }
.tag.gold { background: rgba(232, 169, 12, .18); color: var(--gold); }
.tag.diff.easy { color: var(--good); }
.tag.diff.fair { color: #c99a06; }
.tag.diff.hard { color: #ea7a12; }
.tag.diff.deadly { color: var(--bad); }

.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

/* ---------- кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 9px 16px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 650;
  white-space: nowrap;
  transition: transform .08s ease, opacity .15s, filter .15s;
}

.btn:active:not(:disabled) { transform: scale(.97); }
.btn.wide { width: 100%; margin-top: 12px; min-height: 48px; font-size: 16px; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 14px; }
.btn.soft { background: var(--soft); color: var(--accent); }
.btn.danger { background: linear-gradient(135deg, #f0525a, #c62f6b); color: #fff; }
.btn.off, .btn:disabled { background: var(--soft); color: var(--hint); cursor: default; }
.btn.busy { opacity: .6; }
.btn.wait { font-variant-numeric: tabular-nums; }
.btn.chip-btn { min-height: 32px; padding: 5px 10px; font-size: 13px; background: var(--soft); color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.chip {
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--soft);
  font-weight: 600;
  font-size: 14px;
  transition: background .15s, color .15s;
}

.chip.active { background: var(--accent); color: var(--on-accent); }

.segmented {
  display: flex;
  gap: 4px;
  margin: 12px 0 0;
  padding: 4px;
  border-radius: 14px;
  background: var(--card);
}

.card .segmented { background: var(--soft); margin-top: 0; }

.segmented button {
  flex: 1;
  padding: 8px 4px;
  border-radius: 10px;
  font-weight: 650;
  font-size: 14px;
  color: var(--hint);
  transition: background .15s, color .15s;
}

.segmented button.active { background: var(--accent); color: var(--on-accent); box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }

/* ---------- полоски ---------- */

.bar {
  position: relative;
  flex: 1;
  height: 8px;
  border-radius: 8px;
  background: var(--track);
  overflow: hidden;
}

.bar i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 8px;
  transition: width .45s cubic-bezier(.2, .8, .2, 1);
}

.bar.hp i { background: linear-gradient(90deg, #ff6b6b, var(--hp)); }
.bar.mana i { background: linear-gradient(90deg, #6aa8ff, var(--mana)); }
.bar.energy i { background: linear-gradient(90deg, #ffc94a, var(--energy)); }
.bar.shield i { background: linear-gradient(90deg, #b9c6da, var(--shield)); }

.meter { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; }
.meter-icon { width: 20px; text-align: center; }
.meter b { min-width: 76px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- арена: подготовка ---------- */

.hero-card .hero-stats, .rating-stats, .mines-head, .mines-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 6px;
}

.hero-stats div, .rating-stats div, .mstat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 12px;
  background: var(--soft);
  text-align: center;
}

.hero-stats small, .rating-stats small, .mstat small { color: var(--hint); font-size: 11.5px; }
.hero-stats b, .rating-stats b, .mstat b { font-size: 15px; }

.warn-line {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(229, 72, 77, .12);
  color: var(--bad);
  font-size: 13px;
  font-weight: 600;
}

.prep-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* ---------- арена: монстры и соперники ---------- */

.monsters { display: flex; flex-direction: column; gap: 8px; }

.monster { padding: 12px; border-radius: var(--radius); background: var(--card); border-left: 4px solid transparent; }
.monster-body { display: flex; align-items: center; gap: 12px; }
.monster > .tags { margin-top: 8px; }
.monster-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--sep);
}

.rival {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--card);
  border-left: 4px solid transparent;
}

.monster.easy { border-left-color: var(--good); }
.monster.fair { border-left-color: #e3b00d; }
.monster.hard { border-left-color: #ea7a12; }
.monster.deadly { border-left-color: var(--bad); }
.monster.locked { opacity: .55; }
.monster.locked .monster-art { filter: grayscale(1); }
.tower .monster { margin-top: 4px; padding: 10px 0 4px; background: none; border-left: 0; border-top: 1px solid var(--sep); border-radius: 0; }

.monster-art, .rival-art {
  flex: none;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 30px;
  background: linear-gradient(150deg, var(--stage-2), var(--stage-1));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25);
}

.rival-art { border-radius: 50%; }
.monster-main { flex: 1; min-width: 0; }
.monster-title { display: flex; align-items: baseline; gap: 6px; }
.monster-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lvl { flex: none; font-size: 12px; color: var(--hint); font-weight: 600; }
.monster-stats { display: flex; gap: 10px; margin-top: 3px; font-size: 13px; color: var(--hint); font-variant-numeric: tabular-nums; }
.reward { font-size: 13px; font-weight: 600; }

/* ---------- арена: башня ---------- */

.tower-head { display: flex; align-items: center; gap: 12px; }
.tower-icon {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 32px;
  background: linear-gradient(160deg, #4b3a8c, #241a47);
}

.tower-floor { font-size: 22px; font-weight: 750; }

.ladder { display: flex; flex-direction: column; gap: 4px; margin: 14px 0 6px; }

.floor {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--soft);
  font-size: 13px;
  color: var(--hint);
}

.floor span { width: 18px; text-align: center; }
.floor b { flex: 1; font-weight: 600; }
.floor.done { opacity: .6; }
.floor.guard { color: var(--gold); }
.floor.current {
  background: linear-gradient(90deg, rgba(109, 74, 255, .9), rgba(168, 85, 247, .85));
  color: #fff;
  box-shadow: 0 4px 14px rgba(109, 74, 255, .35);
}

.tower-reward { display: flex; justify-content: space-between; gap: 10px; margin-top: 4px; font-size: 13px; }

/* ---------- арена: рейтинг ---------- */

.rating-card .rating-main { display: flex; flex-direction: column; align-items: center; margin-bottom: 12px; }
.rating-card .league { font-weight: 650; }
.rating-card .rating {
  font-size: 40px;
  font-weight: 800;
  line-height: 1.1;
  background: linear-gradient(135deg, #8b6dff, #e84393);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.rating-stats { grid-template-columns: repeat(4, 1fr); margin: 0; }

/* ---------- арена: бой ---------- */

.stage {
  position: relative;
  margin-top: 10px;
  padding: 14px 14px 12px;
  border-radius: 20px;
  background:
    radial-gradient(120% 70% at 50% 18%, rgba(168, 85, 247, .35), transparent 60%),
    linear-gradient(180deg, var(--stage-2), var(--stage-1));
  color: var(--stage-text);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(29, 23, 54, .35);
}

.stage.is-shadow { background: radial-gradient(120% 70% at 50% 18%, rgba(76, 141, 255, .35), transparent 60%), linear-gradient(180deg, #1f2a4f, #121931); }
.stage.guard { box-shadow: 0 0 0 2px rgba(232, 169, 12, .6), 0 10px 30px rgba(29, 23, 54, .35); }
.stage .muted, .stage .lvl { color: var(--stage-muted); }
.stage .tag.soft { color: var(--stage-muted); background: rgba(255, 255, 255, .08); }
.stage .bar { background: rgba(255, 255, 255, .14); }
.stage .meter { color: var(--stage-text); }

.stage-top { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--stage-muted); }

.enemy-art {
  position: relative;
  width: 104px;
  height: 104px;
  margin: 8px auto 4px;
  display: grid;
  place-items: center;
  font-size: 66px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .14), transparent 68%);
  animation: idle 2.6s ease-in-out infinite;
}

.enemy-art.hit { animation: hit .45s ease; }

@keyframes idle { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes hit {
  0% { transform: translateX(0) scale(1); filter: none; }
  20% { transform: translateX(-9px) scale(.96); filter: brightness(1.8) saturate(.4); }
  45% { transform: translateX(8px); }
  70% { transform: translateX(-4px); }
  100% { transform: translateX(0) scale(1); filter: none; }
}

.enemy-name { text-align: center; font-size: 18px; font-weight: 750; }
.enemy-name .lvl { margin-left: 6px; }
.stage .tags { justify-content: center; }

.floater {
  position: absolute;
  top: 6px;
  left: 50%;
  z-index: 2;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 800;
  pointer-events: none;
  white-space: nowrap;
  transform: translateX(-50%);
  animation: float 1.1s ease-out forwards;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .45);
}

.floater.dmg { color: #ff6b6b; }
.floater.shield { color: #c9d4e6; font-size: 15px; top: 34px; }
.floater.heal { color: #4ade80; }

@keyframes float {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(.8); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -34px) scale(1); }
}

.intent {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .09);
  border: 1px solid rgba(255, 255, 255, .12);
}

.intent.heavy, .intent.breath { border-color: rgba(255, 107, 107, .6); background: rgba(255, 107, 107, .14); animation: pulse 1.2s ease-in-out infinite; }
.intent.heal, .intent.drain { border-color: rgba(74, 222, 128, .5); }
.intent-head { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.intent-dmg { margin-left: auto; font-weight: 800; color: #ffb4b4; }
.intent-hint { margin-top: 2px; font-size: 12px; color: var(--stage-muted); }

@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, .0); } 50% { box-shadow: 0 0 0 4px rgba(255, 107, 107, .18); } }

.battle-log {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--card);
  font-size: 13px;
  line-height: 1.45;
  color: var(--hint);
  min-height: 52px;
}

.battle-log .fresh { color: var(--text); font-weight: 600; animation: fresh .35s ease; }
@keyframes fresh { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.hero-panel { position: relative; margin-top: 8px; }
.hero-panel.hurt { animation: hurt .5s ease; }
@keyframes hurt { 0%, 100% { box-shadow: none; } 30% { box-shadow: inset 0 0 0 2px var(--bad), 0 0 18px rgba(229, 72, 77, .35); } }
.hero-title { position: relative; display: flex; align-items: center; gap: 8px; }
.hero-panel .floater { top: -6px; left: auto; right: 10px; transform: none; animation-name: float-side; }
@keyframes float-side {
  0% { opacity: 0; transform: translateY(8px); }
  15% { opacity: 1; transform: translateY(0) scale(1.15); }
  100% { opacity: 0; transform: translateY(-26px); }
}

.moves { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }

.move {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 10px 2px 8px;
  border-radius: 16px;
  background: var(--card);
  box-shadow: inset 0 -3px 0 var(--sep);
  transition: transform .08s ease, background .15s;
}

.move i { font-style: normal; font-size: 24px; line-height: 1.15; }
.move b { font-size: 13px; }
.move small { font-size: 11px; color: var(--hint); }
.move:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.move:disabled { opacity: .45; }
.move.primary { background: linear-gradient(160deg, #f0525a, #b8265f); color: #fff; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25); }
.move.primary small { color: rgba(255, 255, 255, .75); }
.move.open { background: var(--accent); color: var(--on-accent); }
.move.open small { color: inherit; opacity: .8; }

.panel { margin-top: 8px; border-radius: var(--radius); background: var(--card); overflow: hidden; animation: fresh .2s ease; }
.panel-title { padding: 10px 14px 0; font-weight: 650; }

.flee { display: block; margin: 14px auto 0; padding: 8px 14px; color: var(--hint); font-size: 14px; font-weight: 600; }

/* ---------- итог боя ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px 12px calc(12px + var(--safe-bottom));
  background: rgba(8, 6, 20, .55);
  animation: fade .2s ease;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  overflow-y: auto;
  padding: 20px 16px 16px;
  border-radius: 22px;
  background: var(--card);
  animation: rise .28s cubic-bezier(.2, .8, .2, 1);
}

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }

.result-card { text-align: center; }
.result-card h3 { margin: 6px 0 2px; font-size: 24px; }
.result-card > p { margin: 0 0 12px; }
.result-icon { font-size: 60px; line-height: 1; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
.result-card.win h3 { color: var(--good); }
.result-card.loss h3 { color: var(--bad); }

@keyframes pop { from { transform: scale(.3); opacity: 0; } }

.result-lines { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.result-line { display: flex; gap: 10px; padding: 9px 12px; border-radius: 12px; background: var(--soft); font-weight: 600; font-size: 14px; }
.result-line span:first-child { flex: none; width: 22px; text-align: center; }

.result-log { margin-top: 12px; text-align: left; font-size: 13px; color: var(--hint); }
.result-log summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.result-log div { padding: 2px 0; }

/* ---------- сапёр ---------- */

.bet-input {
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--soft);
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  outline: none;
}

.bet-input:focus { box-shadow: 0 0 0 2px var(--accent); }

.steps { display: flex; gap: 6px; margin-top: 12px; overflow-x: auto; padding-bottom: 2px; }
.step { flex: 1; min-width: 52px; display: flex; flex-direction: column; align-items: center; padding: 6px 4px; border-radius: 10px; background: var(--soft); }
.step small { font-size: 11px; color: var(--hint); }
.step b { font-size: 13px; color: var(--good); }

.mines-game, .mines-result {
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(76, 141, 255, .25), transparent 60%),
    linear-gradient(180deg, #232846, #161a30);
  color: var(--stage-text);
}

.mines-game .mstat, .mines-result .mstat { background: rgba(255, 255, 255, .08); }
.mines-game .mstat small { color: var(--stage-muted); }
.mstat.accent b { color: #7dffb0; }
.mstat.good b { color: var(--good); }
.mstat.bad b { color: var(--bad); }
.mines-stats { grid-template-columns: repeat(4, 1fr); margin: 10px 0 0; padding: 10px; border-radius: var(--radius); background: var(--card); }

.board {
  display: grid;
  gap: 8px;
  margin: 12px auto 4px;
  max-width: 380px;
}

.board.s3 { grid-template-columns: repeat(3, 1fr); max-width: 300px; }
.board.s4 { grid-template-columns: repeat(4, 1fr); max-width: 340px; }
.board.s5 { grid-template-columns: repeat(5, 1fr); gap: 7px; }

.cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--tile);
  box-shadow: inset 0 -4px 0 var(--tile-edge), 0 2px 6px rgba(0, 0, 0, .25);
  font-size: 26px;
  transition: transform .08s ease;
}

.board.s5 .cell { font-size: 22px; border-radius: 12px; }
button.cell:active:not(:disabled) { transform: translateY(2px) scale(.97); box-shadow: inset 0 -1px 0 var(--tile-edge); }
.cell.pending { animation: pending .6s ease-in-out infinite alternate; }
@keyframes pending { to { filter: brightness(1.35); transform: scale(.95); } }

.cell.gem {
  background: linear-gradient(160deg, #2bd38f, #129a68);
  box-shadow: inset 0 -4px 0 #0c6b49, 0 0 14px rgba(43, 211, 143, .35);
  animation: reveal .3s cubic-bezier(.2, 1.6, .4, 1);
}

.cell.mine { background: linear-gradient(160deg, #5a2a3a, #3a1824); box-shadow: inset 0 -4px 0 #2a0f19; opacity: .9; }
.cell.boom { background: radial-gradient(circle, #ffb347, #e5484d 60%, #8e1d3a); box-shadow: 0 0 22px rgba(255, 120, 80, .7); animation: boom .55s ease; }
.cell.dim { opacity: .28; filter: grayscale(.5); }
.cell.last { box-shadow: inset 0 -4px 0 #0c6b49, 0 0 0 2px #7dffb0; }

@keyframes reveal { from { transform: scale(.5) rotate(-12deg); } }
@keyframes boom { 0% { transform: scale(.6); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }

.mines-next { margin-top: 8px; text-align: center; font-size: 13px; color: var(--stage-muted); }
.mines-next b { color: #7dffb0; }
.mines-hash { margin-top: 10px; text-align: center; font-size: 11px; color: var(--stage-muted); font-family: ui-monospace, Menlo, monospace; }
.btn.cash { background: linear-gradient(135deg, #2bd38f, #1a9e6c); color: #fff; box-shadow: 0 6px 18px rgba(43, 211, 143, .3); }
.btn.cash:disabled { background: rgba(255, 255, 255, .1); color: var(--stage-muted); box-shadow: none; }

.mines-banner { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; }
.mines-banner b { font-size: 26px; }
.mines-banner span { font-size: 13px; color: var(--stage-muted); }
.mines-result.won .mines-banner b { color: #7dffb0; }
.mines-result.lost .mines-banner b { color: #ff8a8a; }
.mines-result.lost { animation: shake .45s ease; }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

.fair { margin-top: 10px; font-size: 12.5px; }
.fair summary { cursor: pointer; color: var(--stage-muted); font-weight: 600; }
.fair p { margin: 6px 0 0; }
.fair .muted { color: var(--stage-muted); }

/* ---------- всплывающее сообщение ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabs-h) + var(--safe-bottom) + 14px);
  z-index: 40;
  width: max-content;
  max-width: min(92vw, 480px);
  padding: 11px 16px;
  border-radius: 14px;
  background: var(--fb-toast);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  white-space: pre-line;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  transform: translateX(-50%);
  animation: toast .25s cubic-bezier(.2, .8, .2, 1);
}

.toast.good { background: linear-gradient(135deg, #1f9d55, #15803d); }
.toast.bad { background: linear-gradient(135deg, #d93b47, #b4233c); }
.toast.warn { background: linear-gradient(135deg, #d98a06, #b86e00); }

@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
