:root {
  --bg0: #040818;
  --bg1: #0e1e54;
  --bg2: #0d58a8;
  --bg3: #23c3ff;
  --glass: rgba(10, 28, 78, 0.66);
  --glass-border: rgba(118, 226, 255, 0.32);
  --text: #f0fbff;
  --muted: #b6e8ff;
  --ok: #9bff33;
  --warn: #ffd166;
  --danger: #ff6f96;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  font-family: "Inter", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, rgba(126, 238, 255, 0.35), transparent 22%),
    radial-gradient(circle at 92% 12%, rgba(174, 88, 255, 0.26), transparent 24%),
    radial-gradient(circle at 45% 78%, rgba(86, 223, 255, 0.2), transparent 30%),
    linear-gradient(160deg, var(--bg0), var(--bg1) 40%, var(--bg2) 78%, var(--bg3));
  overscroll-behavior: none;
  overflow-x: hidden;
}

/* Игровой экран на телефоне: без прокрутки всей страницы */
@media (max-width: 900px) {
  html:has(#screen-game.screen-active),
  html:has(#screen-game.screen-active) body,
  body.game-screen-active {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    touch-action: manipulation;
  }
}

.bg-vignette {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at center, transparent 35%, rgba(2, 7, 28, 0.58)),
    repeating-linear-gradient(
      125deg,
      rgba(255, 255, 255, 0.02) 0px,
      rgba(255, 255, 255, 0.02) 2px,
      transparent 2px,
      transparent 8px
    );
  pointer-events: none;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(100vw, 1260px);
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 10px) 10px max(env(safe-area-inset-bottom), 10px);
  position: relative;
  z-index: 1;
  min-height: 100dvh;
}

@media (max-width: 900px) {
  html:has(#screen-game.screen-active) .app-shell,
  body.game-screen-active .app-shell {
    width: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    height: 100dvh;
    padding: max(env(safe-area-inset-top), 6px) max(env(safe-area-inset-right), 8px)
      max(env(safe-area-inset-bottom), 6px) max(env(safe-area-inset-left), 8px);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
  }
}

.screen {
  display: none;
}

.screen-active {
  display: block;
}

@media (max-width: 900px) {
  #screen-game.screen-active {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    gap: 6px;
    overflow: hidden;
  }
}

.card {
  border: 1px solid var(--glass-border);
  background: var(--glass);
  box-shadow: 0 15px 45px rgba(3, 14, 42, 0.35);
  border-radius: 18px;
  backdrop-filter: blur(6px);
  padding: 12px;
}

.loading-card,
.auth-card {
  width: min(100%, 560px);
  margin: 10vh auto 0;
}

.brand {
  margin: 0 0 10px;
  text-align: center;
  line-height: 1;
  font-size: clamp(34px, 6vw, 52px);
  letter-spacing: 1px;
  font-weight: 900;
  text-transform: uppercase;
}

.brand span {
  display: block;
  font-size: clamp(24px, 4vw, 34px);
  color: #89ff36;
  text-shadow: 0 0 22px rgba(155, 255, 51, 0.5);
}

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

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 10px;
}

.tab,
.btn,
.booster-btn,
.nav-btn {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  padding: 10px 12px;
  transition: transform 120ms ease, filter 120ms ease;
}

.tab:hover,
.btn:hover,
.booster-btn:hover,
.nav-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.tab {
  background: rgba(17, 52, 117, 0.78);
  color: #d6eeff;
  font-weight: 700;
}

.tab-active {
  color: #072443;
  background: linear-gradient(90deg, #9eff2f, #35deff);
}

.form {
  display: grid;
  gap: 9px;
}

.form label {
  display: grid;
  gap: 5px;
  font-size: 13px;
}

.form input,
.form textarea {
  border: 1px solid rgba(145, 227, 255, 0.42);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: #112f54;
  padding: 10px;
}

.form input:focus,
.form textarea:focus {
  outline: 2px solid #58eeff;
}

/* Ноутбуки в альбомной: читаемее экран авторизации без смены стиля */
@media (orientation: landscape) and (min-width: 901px) {
  #screen-auth .auth-card {
    width: min(100%, 680px);
    margin-top: 8vh;
    padding: 16px 18px;
  }

  #screen-auth .brand {
    margin-bottom: 12px;
    font-size: clamp(40px, 4.2vw, 58px);
  }

  #screen-auth .brand span {
    font-size: clamp(27px, 2.8vw, 38px);
  }

  #screen-auth .muted {
    font-size: 15px;
  }

  #screen-auth .tab {
    font-size: 15px;
    padding: 12px 14px;
  }

  #screen-auth .form {
    gap: 11px;
  }

  #screen-auth .form label {
    gap: 6px;
    font-size: 15px;
  }

  #screen-auth .form input,
  #screen-auth .form textarea {
    min-height: 44px;
    padding: 11px 12px;
    font-size: 15px;
  }

  #screen-auth .btn {
    min-height: 44px;
    padding: 11px 14px;
    font-size: 15px;
  }
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.row > * {
  flex: 1 1 0;
}

.row.right > * {
  flex: 0 0 auto;
}

.btn {
  font-weight: 800;
}

.btn-primary {
  color: #0a2c54;
  background: linear-gradient(90deg, #96ff34, #31e4ff);
}

.btn-secondary {
  color: #e8f9ff;
  background: rgba(20, 56, 120, 0.82);
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.hud-name {
  font-size: 24px;
  font-weight: 800;
}

.hud-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.hud-metrics.compact .metric {
  min-width: 110px;
}

.hud-metrics.compact {
  justify-content: center;
}

.metric {
  min-width: 102px;
  border: 1px solid rgba(134, 225, 255, 0.3);
  background: rgba(4, 31, 88, 0.82);
  border-radius: 12px;
  padding: 7px 9px;
  display: grid;
  gap: 3px;
}

.metric span,
.metric small {
  font-size: 12px;
  color: var(--muted);
}

.metric .rank-badge {
  display: inline-block;
  min-width: 3.2em;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.metric .rank-badge.rank-tier-none {
  color: #c9e9ff;
  background: rgba(95, 147, 193, 0.32);
}

.metric .rank-badge.rank-tier-top3 {
  color: #ffe9a0;
  background: linear-gradient(90deg, rgba(184, 130, 22, 0.9), rgba(255, 215, 88, 0.95));
  box-shadow: 0 0 12px rgba(255, 214, 84, 0.45);
  transform: scale(1.08);
}

.metric .rank-badge.rank-tier-top5 {
  color: #ffe8b8;
  background: linear-gradient(90deg, rgba(132, 103, 34, 0.86), rgba(208, 174, 98, 0.9));
}

.metric .rank-badge.rank-tier-top10 {
  color: #f7e7c4;
  background: rgba(152, 124, 78, 0.78);
}

.metric .rank-badge.rank-tier-top25 {
  color: #d7f2ff;
  background: rgba(84, 149, 191, 0.72);
}

.metric .rank-badge.rank-tier-top50 {
  color: #d6ecff;
  background: rgba(76, 113, 172, 0.74);
}

.metric .rank-badge.rank-tier-top100 {
  color: #d9ddff;
  background: rgba(87, 89, 164, 0.78);
}

.metric .rank-badge.rank-tier-over100 {
  color: #ffd4de;
  background: rgba(173, 42, 78, 0.82);
}

.metric strong {
  font-size: 21px;
}

#hud-pvp-turn-wrap,
#hud-pvp-match-wrap {
  border-color: rgba(255, 197, 104, 0.6);
  background: rgba(62, 30, 8, 0.86);
}

.metric.metric-summary {
  gap: 2px;
}

.metric.metric-summary .quick-summary-lines {
  display: grid;
  gap: 1px;
}

.metric.metric-summary .quick-summary-lines small {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.2;
}

.metric.metric-summary .quick-summary-lines b {
  color: #e9fbff;
  font-weight: 800;
  font-size: 10px;
}

.game-layout {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(260px, 380px);
  gap: 10px;
}

/* Desktop landscape must stay 2-column regardless width media fallbacks. */
body.layout-landscape #screen-game .game-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(260px, 380px) !important;
}

.side-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

.side-column > .card {
  flex: 0 0 auto;
}

.section-title {
  margin-bottom: 7px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.board-card {
  position: relative;
}

.board-aspect {
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  position: relative;
}

.pvp-prestart-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 16px;
  background: rgba(3, 12, 36, 0.72);
  backdrop-filter: blur(2px);
  z-index: 40;
  pointer-events: none;
}

.pvp-prestart-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.pvp-prestart-count {
  font-size: 54px;
  font-weight: 900;
  line-height: 1;
  color: #8ff7ff;
  text-shadow: 0 0 14px rgba(143, 247, 255, 0.5);
}

.board {
  width: 100%;
  aspect-ratio: 1/1;
  background:
    linear-gradient(150deg, rgba(7, 24, 64, 0.95), rgba(2, 11, 43, 0.95)),
    radial-gradient(circle at 12% 20%, rgba(130, 215, 255, 0.25), transparent 30%);
  border-radius: 16px;
  padding: 10px;
  display: grid;
  gap: 7px;
  position: relative;
  overflow: hidden;
}

.board.move-stage-left {
  animation: board-shift-left 180ms ease-out;
}

.board.move-stage-right {
  animation: board-shift-right 180ms ease-out;
}

.board.move-stage-up {
  animation: board-shift-up 180ms ease-out;
}

.board.move-stage-down {
  animation: board-shift-down 180ms ease-out;
}

.board.board-fx-shake {
  animation: board-fx-shake var(--fx-shake-ms, 820ms) cubic-bezier(0.18, 0.78, 0.2, 1);
}

.board::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, transparent, rgba(0, 0, 0, 0.15));
  pointer-events: none;
  z-index: 1;
}

.board-fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 30;
  will-change: transform, opacity;
  transform: translateZ(0);
}

.board-fx-layer .fx-shard {
  will-change: transform, opacity;
}

.board-fx-layer .merge-physics-shard {
  position: absolute;
  pointer-events: none;
  border-radius: 2px;
  border: 1px solid rgba(255, 224, 166, 0.28);
  mix-blend-mode: screen;
  filter: saturate(1.06) brightness(1.02);
  will-change: transform, opacity;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.merge-blast-wrap {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
  transform: translate3d(0, 0, 0) scale(var(--blast-scale, 1));
  transform-origin: center center;
}

.merge-realistic-blast {
  position: absolute;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  margin-top: -7px;
  border-radius: 999px;
  border: 2px solid rgba(255, 216, 132, 0.96);
  box-shadow: 0 0 30px rgba(255, 176, 76, 0.95), 0 0 48px rgba(255, 88, 36, 0.74);
  opacity: 0.08;
  transform: scale(0.25);
}

.merge-realistic-blast.active {
  animation: boundary-blast 760ms cubic-bezier(0.17, 0.78, 0.2, 1);
}

.merge-realistic-core {
  position: absolute;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  margin-top: -9px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.98), rgba(255, 221, 126, 0.92) 34%, rgba(255, 134, 54, 0.68) 64%, rgba(255, 84, 30, 0.26) 100%);
  box-shadow: 0 0 26px rgba(255, 205, 106, 0.92), 0 0 40px rgba(255, 98, 34, 0.75);
  opacity: 0;
  transform: scale(0.24);
}

.merge-realistic-core.active {
  animation: core-flash 520ms cubic-bezier(0.16, 0.78, 0.2, 1);
}

.board-fx-layer .fx-cell-fragment {
  transform-origin: center center;
}

.board-fx-layer .fx-cell-fragment.fx-fragment-edge {
  mix-blend-mode: screen;
}

.board-fx-layer .fx-cell-fragment.fx-fragment-core {
  mix-blend-mode: normal;
  filter: saturate(0.92) brightness(0.93);
}

.cell {
  border-radius: 12px;
  border: 1px solid rgba(151, 229, 255, 0.28);
  background: rgba(183, 224, 255, 0.14);
  display: grid;
  place-items: center;
  user-select: none;
  font-weight: 900;
  font-size: clamp(15px, 3.2vw, 34px);
  transition: transform 140ms ease, box-shadow 180ms ease;
  color: #132d52;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
  position: relative;
  z-index: 2;
  will-change: transform, opacity;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.cell.shockwave-near {
  animation: cell-near-shock var(--near-shock-ms, 320ms) cubic-bezier(0.18, 0.84, 0.24, 1);
}

.cell .frozen {
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  font-size: 15px;
  line-height: 1;
  color: #0c4f8d;
  letter-spacing: 0.04em;
  font-weight: 900;
  white-space: nowrap;
  text-shadow: 0 0 7px rgba(217, 244, 255, 0.95), 0 0 12px rgba(135, 203, 243, 0.75);
}

.cell.value {
  background: var(--tile-bg, rgba(141, 228, 255, 0.82));
  box-shadow: 0 0 18px var(--tile-glow, rgba(123, 221, 255, 0.35));
}

.cell.new {
  animation: tile-pop-wiggle 920ms cubic-bezier(0.2, 0.78, 0.2, 1);
}

.cell.new-build-pending {
  opacity: 0.03;
  transform: scale(0.64);
  filter: brightness(1.5) saturate(1.2);
}

.cell.merge-build-pending {
  opacity: 0;
  transform: scale(0.85);
  filter: brightness(1.24) saturate(1.12);
}

.cell.new-assemble {
  animation: tile-build-reveal 360ms cubic-bezier(0.16, 0.78, 0.2, 1);
}

.cell.merge-impact {
  z-index: 2;
  animation: tile-impact 360ms cubic-bezier(0.2, 0.8, 0.18, 1);
}

.cell.merge {
  animation: tile-burst 760ms ease;
}

.cell.merge-assemble {
  animation: tile-assemble 380ms cubic-bezier(0.2, 0.78, 0.16, 1);
}

.cell.cell-disintegrate {
  opacity: 0.04;
  filter: brightness(1.7) saturate(1.45);
  transform: scale(0.92);
}

body.fx-lite .board-fx-layer .merge-physics-shard {
  mix-blend-mode: normal;
  filter: none;
  box-shadow: none !important;
  border-color: rgba(255, 204, 130, 0.36);
}

body.fx-medium .board-fx-layer .merge-physics-shard {
  box-shadow: none !important;
  filter: none;
}

body.fx-medium .card {
  backdrop-filter: blur(3px);
}

body.fx-medium .board.board-fx-shake {
  animation-duration: 620ms;
}

body.fx-lite .card {
  backdrop-filter: none;
  box-shadow: 0 8px 20px rgba(3, 14, 42, 0.24);
}

body.fx-lite .cell.value {
  box-shadow: 0 0 10px var(--tile-glow, rgba(123, 221, 255, 0.24));
}

body.fx-lite .board.board-fx-shake {
  animation-duration: 480ms;
}

body.fx-lite .cell.new,
body.fx-lite .cell.new-assemble,
body.fx-lite .cell.merge-impact,
body.fx-lite .cell.merge,
body.fx-lite .cell.merge-assemble,
body.fx-lite .merge-boundary-blast.active,
body.fx-lite .merge-core-flash.active,
body.fx-lite .new-tile-core-flash.active {
  animation: none !important;
}

body.fx-lite .merge-boundary-blast,
body.fx-lite .merge-core-flash,
body.fx-lite .merge-smoke,
body.fx-lite .new-tile-core-flash {
  display: none !important;
}

.merge-boundary-blast {
  position: absolute;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  margin-top: -7px;
  border-radius: 999px;
  pointer-events: none;
  border: 2px solid rgba(255, 208, 109, 0.98);
  box-shadow: 0 0 30px rgba(255, 178, 80, 0.98), 0 0 38px rgba(255, 90, 42, 0.86);
  transform: scale(0.2);
  opacity: 0.05;
}

.merge-boundary-blast.active {
  animation: boundary-blast 460ms cubic-bezier(0.16, 0.78, 0.2, 1);
}

.merge-core-flash {
  position: absolute;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  margin-top: -9px;
  border-radius: 999px;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, 1), rgba(255, 222, 126, 0.98) 30%, rgba(255, 145, 56, 0.78) 58%, rgba(255, 70, 31, 0.42) 82%, transparent 100%);
  opacity: 0;
  transform: scale(0.2);
}

.merge-core-flash.active {
  animation: core-flash 420ms cubic-bezier(0.15, 0.78, 0.2, 1);
}

.merge-smoke {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(0, 0, 0) scale(0.6);
  z-index: 35;
  mix-blend-mode: screen;
}

.merge-smoke.active {
  opacity: 0.75;
  transform: translate3d(var(--smoke-dx), var(--smoke-dy), 0) scale(var(--smoke-scale));
  transition: transform 1200ms cubic-bezier(0.16, 0.78, 0.2, 1), opacity 1200ms ease-out;
}

.new-tile-core-flash {
  position: absolute;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  margin-top: -7px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.25);
  background: radial-gradient(circle, rgba(255,255,255,1), rgba(255,223,132,0.98) 38%, rgba(255,136,52,0.56) 72%, transparent 100%);
  box-shadow: 0 0 20px rgba(255,206,96,0.95), 0 0 28px rgba(255,108,48,0.84);
  z-index: 46;
}

.new-tile-core-flash.active {
  animation: new-tile-core-flash 620ms cubic-bezier(0.14, 0.8, 0.2, 1);
}

.cell.frozen-cell {
  border-color: rgba(205, 242, 255, 0.92);
  background:
    linear-gradient(152deg, rgba(245, 253, 255, 0.98), rgba(208, 236, 255, 0.9) 40%, rgba(162, 207, 240, 0.82) 74%, rgba(132, 181, 224, 0.8) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.42),
    inset -10px -12px 18px rgba(89, 156, 206, 0.28),
    inset 8px 10px 16px rgba(255, 255, 255, 0.22),
    0 0 18px rgba(161, 220, 255, 0.52),
    0 4px 14px rgba(78, 132, 175, 0.26);
  color: #0f355e;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.62);
  overflow: hidden;
  /* Faceted silhouette to look like a broken ice chunk. */
  clip-path: polygon(8% 6%, 87% 2%, 98% 20%, 96% 86%, 76% 98%, 12% 96%, 2% 72%, 3% 16%);
  transform: translateZ(0);
}

.cell.frozen-cell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(142deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.08) 40%, transparent 72%),
    repeating-linear-gradient(132deg, rgba(255, 255, 255, 0.34) 0 2px, rgba(255, 255, 255, 0.03) 2px 9px),
    radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.8), transparent 52%),
    radial-gradient(circle at 82% 86%, rgba(169, 221, 255, 0.34), transparent 58%);
  mix-blend-mode: screen;
  opacity: 0.88;
}

.cell.frozen-cell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(42deg, transparent 0 30%, rgba(153, 205, 236, 0.5) 31% 33%, transparent 34% 100%),
    linear-gradient(128deg, transparent 0 44%, rgba(188, 231, 255, 0.42) 45% 47%, transparent 48% 100%),
    linear-gradient(168deg, transparent 0 60%, rgba(157, 215, 247, 0.34) 61% 63%, transparent 64% 100%),
    linear-gradient(95deg, rgba(255, 255, 255, 0.16), transparent 24%);
  opacity: 0.85;
}

.cell.frozen-cell .frozen {
  color: #0c4f8d;
  text-shadow: 0 0 6px rgba(240, 252, 255, 0.98), 0 0 10px rgba(162, 222, 255, 0.88);
  background: linear-gradient(155deg, rgba(244, 252, 255, 0.92), rgba(209, 239, 255, 0.9) 58%, rgba(182, 224, 248, 0.9));
  border: 1px solid rgba(173, 227, 252, 0.88);
  border-radius: 999px;
  padding: 2px 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.58), 0 0 10px rgba(161, 220, 255, 0.62);
}

.cell.booster-primary {
  outline: 3px solid #95ff2e;
}

.cell.booster-secondary {
  outline: 3px solid #ffd166;
}

.booster-hint {
  margin-top: 8px;
  font-size: 13px;
}

.booster-panel-card {
  margin-top: 8px;
  padding: 8px;
  flex: 0 0 auto;
}

.booster-panel-card .section-title {
  margin-bottom: 6px;
}

.pvp-score-panel-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.pvp-score-toolbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(120, 200, 255, 0.32);
  border-radius: 12px;
  background: rgba(9, 25, 58, 0.55);
  padding: 6px 8px;
}

.pvp-score-toolbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.pvp-score-chip {
  border: 1px solid rgba(120, 200, 255, 0.4);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(23, 58, 119, 0.5), rgba(10, 28, 66, 0.58));
  padding: 7px 9px;
}

.pvp-score-chip-leader {
  border-color: rgba(88, 255, 158, 0.85);
  box-shadow: 0 0 0 1px rgba(88, 255, 158, 0.35), 0 0 18px rgba(88, 255, 158, 0.22);
  background: linear-gradient(180deg, rgba(27, 90, 83, 0.48), rgba(10, 45, 55, 0.58));
}

.pvp-score-chip-name {
  font-weight: 700;
  margin-bottom: 2px;
  font-size: 13px;
}

.pvp-score-chip-stats {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.2;
}

.quick-rating-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

.quick-rating-heading {
  flex: 0 0 auto;
}

.layout-landscape #screen-game .side-column .quick-rating-card .hud-metrics.compact {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  justify-content: stretch;
  gap: 4px;
  overflow: visible;
}

.layout-landscape #screen-game .side-column .quick-rating-card .metric {
  min-width: 0;
  width: auto;
  padding: 4px 5px;
  gap: 2px;
}

.layout-landscape #screen-game .side-column .quick-rating-card .metric strong {
  font-size: clamp(11px, 1.25vw, 15px);
  line-height: 1.04;
}

.layout-landscape #screen-game .side-column .quick-rating-card .metric span,
.layout-landscape #screen-game .side-column .quick-rating-card .metric small {
  font-size: clamp(7px, 0.75vw, 9px);
  line-height: 1.1;
}

.layout-landscape #screen-game .side-column .quick-rating-card .metric.metric-summary .quick-summary-lines small,
.layout-landscape #screen-game .side-column .quick-rating-card .metric.metric-summary .quick-summary-lines b {
  font-size: clamp(7px, 0.82vw, 10px);
  line-height: 1.16;
}

.layout-landscape #screen-game .side-column .quick-rating-card .metric.metric-summary {
  padding: 5px 6px;
}

.layout-landscape #screen-game .side-column .quick-rating-card .metric.metric-summary > span {
  font-size: clamp(8px, 0.9vw, 11px);
}

.quick-rating-rail {
  flex: 0 0 auto;
  display: none;
  align-items: center;
  justify-content: center;
}

.quick-rating-icon-shell {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(158, 231, 255, 0.45);
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 230, 160, 0.35), transparent 55%),
    linear-gradient(155deg, rgba(12, 48, 118, 0.92), rgba(6, 24, 72, 0.92));
  box-shadow:
    inset 0 1px 0 rgba(255, 248, 220, 0.18),
    0 6px 16px rgba(2, 12, 40, 0.28);
  animation: quick-rating-icon-pulse 2.4s ease-in-out infinite;
}

.quick-rating-icon-svg {
  display: block;
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 0 6px rgba(255, 200, 120, 0.55));
}

@keyframes quick-rating-icon-pulse {
  0%,
  100% {
    transform: translateY(0) scale(1);
    box-shadow:
      inset 0 1px 0 rgba(255, 248, 220, 0.18),
      0 6px 16px rgba(2, 12, 40, 0.28);
  }
  50% {
    transform: translateY(-1px) scale(1.04);
    box-shadow:
      inset 0 1px 0 rgba(255, 248, 220, 0.26),
      0 10px 22px rgba(2, 12, 40, 0.36),
      0 0 18px rgba(255, 186, 86, 0.35);
  }
}

.booster-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.booster-btn {
  position: relative;
  overflow: hidden;
  text-align: center;
  display: grid;
  grid-template-rows: auto auto;
  justify-items: center;
  align-content: center;
  gap: 6px;
  min-height: 66px;
  padding: 7px 5px;
  font-size: 11px;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #eefdff;
  border: 1px solid rgba(133, 220, 255, 0.42);
  background:
    radial-gradient(circle at 12% 15%, rgba(159, 243, 255, 0.22), transparent 40%),
    linear-gradient(165deg, rgba(9, 40, 97, 0.96), rgba(5, 24, 71, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(207, 245, 255, 0.24),
    inset 0 -10px 14px rgba(1, 12, 38, 0.26),
    0 7px 16px rgba(1, 14, 43, 0.34);
}

.booster-btn::before {
  content: "";
  position: absolute;
  top: -28%;
  left: -34%;
  width: 80%;
  height: 95%;
  transform: rotate(18deg);
  background: linear-gradient(130deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.booster-btn .booster-label {
  font-size: 11px;
  line-height: 1.05;
  color: #eefdff;
  opacity: 0.95;
}

.booster-btn .booster-count {
  min-width: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 17px;
  line-height: 1;
  font-weight: 900;
  color: #063460;
  background: linear-gradient(180deg, #b8ff59, #7eea2d);
  box-shadow: 0 3px 8px rgba(2, 18, 53, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.booster-btn.active {
  color: #ffffff;
  border-color: rgba(171, 237, 255, 0.95);
  background:
    radial-gradient(circle at 16% 16%, rgba(181, 246, 255, 0.33), transparent 40%),
    linear-gradient(165deg, #1eb9ff, #2f66ff 62%, #3844d9);
  box-shadow:
    inset 0 1px 0 rgba(220, 248, 255, 0.45),
    0 0 0 1px rgba(137, 220, 255, 0.22),
    0 9px 20px rgba(22, 67, 174, 0.5);
}

.booster-btn.active .booster-count {
  color: #053b6a;
  background: linear-gradient(180deg, #f2ffbe, #96ff4b);
}

.bottom-nav {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
}

.nav-btn {
  font-size: 12px;
  font-weight: 800;
  color: #ecf8ff;
  background: rgba(13, 43, 102, 0.84);
}

.nav-btn-active {
  color: #0a2e56;
  background: linear-gradient(90deg, #9eff2f, #45e2ff);
}

.nav-btn-with-dot {
  position: relative;
}

.nav-btn-with-dot .nav-btn-text {
  display: inline-block;
}

.nav-claim-dot {
  position: absolute;
  top: 5px;
  right: 7px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #ffd0d8, #ff3358 55%, #9a061f);
  box-shadow: 0 0 10px rgba(255, 60, 90, 0.9);
  pointer-events: none;
}

.nav-btn.nav-pending {
  animation: nav-claim-wiggle 1.15s ease-in-out infinite;
}

body.ui-idle .quick-rating-icon-shell,
body.ui-idle .nav-btn.nav-pending {
  animation: none !important;
}

@keyframes nav-claim-wiggle {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  20% {
    transform: translate3d(-1.5px, 0, 0) rotate(-0.6deg);
  }
  40% {
    transform: translate3d(1.5px, 0, 0) rotate(0.6deg);
  }
  60% {
    transform: translate3d(-1.2px, 0, 0) rotate(-0.4deg);
  }
  80% {
    transform: translate3d(1.2px, 0, 0) rotate(0.4deg);
  }
}

body.layout-landscape .bottom-nav .nav-btn[data-panel="daily"] {
  display: none !important;
}

.daily-tasks-overlay-wrap .daily-grid {
  max-height: none;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(4, 11, 36, 0.74);
  padding: 12px;
}

body.pwa-standalone {
  background-color: #040818;
}

body.pwa-standalone .overlay {
  padding:
    max(env(safe-area-inset-top), 12px)
    max(env(safe-area-inset-right), 12px)
    max(env(safe-area-inset-bottom), 12px)
    max(env(safe-area-inset-left), 12px);
}

.orientation-lock {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 11, 36, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.orientation-lock.hidden {
  display: none;
}

.orientation-lock-card {
  max-width: min(92vw, 420px);
  text-align: center;
  display: grid;
  gap: 8px;
}

body.orientation-locked #screen-game {
  pointer-events: none;
}

.overlay-card {
  width: min(100%, 980px);
  max-height: calc(100dvh - 24px);
  margin: 0 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.pwa-standalone .overlay-card {
  max-height: calc(
    100dvh
    - max(env(safe-area-inset-top), 12px)
    - max(env(safe-area-inset-bottom), 12px)
    - 24px
  );
}

.overlay-card.narrow {
  width: min(100%, 420px);
  margin-top: 12vh;
}

.overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 3;
  padding-bottom: 8px;
  background: linear-gradient(180deg, rgba(7, 34, 88, 0.96), rgba(7, 34, 88, 0.82) 75%, rgba(7, 34, 88, 0));
}

body.pwa-standalone.layout-portrait .overlay-head {
  top: 0;
  padding-top: max(env(safe-area-inset-top), 2px);
}

.overlay-head h2 {
  margin: 0;
}

.overlay-content {
  margin-top: 10px;
  display: grid;
  gap: 9px;
  overflow-y: auto;
  padding-right: 3px;
  padding-bottom: 4px;
}

.overlay-actions {
  gap: 7px;
}

.overlay-actions .btn {
  min-height: 38px;
  min-width: 118px;
  padding-inline: 12px;
}

/* Реклама: во время просмотра нельзя закрыть оверлей стандартными кнопками */
#overlay.ads-watch-active .overlay-head .overlay-actions #overlay-close,
#overlay.ads-watch-active .overlay-head .overlay-actions #overlay-refresh {
  pointer-events: none;
  opacity: 0.38;
}

/* Окно «Реклама»: карточка оверлея на всю высоту экрана */
#overlay.overlay-ads-panel .overlay-card {
  display: flex;
  flex-direction: column;
  max-height: none;
  height: calc(100dvh - 24px);
  min-height: calc(100dvh - 24px);
}

body.pwa-standalone #overlay.overlay-ads-panel .overlay-card {
  height: calc(
    100dvh
    - max(env(safe-area-inset-top), 12px)
    - max(env(safe-area-inset-bottom), 12px)
    - 24px
  );
  min-height: calc(
    100dvh
    - max(env(safe-area-inset-top), 12px)
    - max(env(safe-area-inset-bottom), 12px)
    - 24px
  );
}

#overlay.overlay-ads-panel .overlay-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 8px;
}

.ads-root {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 10px;
}

.ads-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 10px;
}

.ads-body-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
}

.ads-offer-row .ads-offer-title {
  font-size: 1.05rem;
}

.ads-offer-row .ads-offer-meta {
  margin: 0;
}

.ads-toolbar {
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

.ads-toolbar .btn.ads-toolbar-btn-active {
  border-color: rgba(123, 220, 255, 0.85);
  box-shadow: 0 0 0 1px rgba(123, 220, 255, 0.35);
}

.ads-watch-modal {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: rgba(2, 8, 28, 0.97);
  border-radius: 12px;
  min-height: 100%;
}

.ads-watch-modal-inner {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.ads-telegram-card {
  border-radius: 12px;
  overflow: hidden;
}

.ads-tg-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ads-tg-media-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.ads-tg-media-hit {
  display: flex;
  width: 100%;
  justify-content: center;
  align-items: center;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 12px;
  overflow: hidden;
  cursor: zoom-in;
  /* как в Telegram: полное фото в рамке, без обрезки по crop */
  background: rgba(0, 0, 0, 0.35);
  aspect-ratio: 2 / 1;
}

.ads-tg-img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: none;
  object-fit: cover;
  object-position: center;
  vertical-align: middle;
}

.ads-open-gallery-btn {
  margin-top: 8px;
  width: fit-content;
}

.campaign-images-label input[type="file"] {
  max-width: 100%;
  margin-top: 6px;
}

.campaign-images-hint {
  margin: -4px 0 8px;
  font-size: 0.85rem;
}

.campaign-images-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
  min-height: 0;
}

.campaign-images-thumb img {
  width: 76px;
  height: 76px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(134, 221, 255, 0.35);
  display: block;
}

.advertiser-campaign-item .row {
  flex-wrap: wrap;
}

.campaign-crop-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(6, 14, 34, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.campaign-crop-card {
  width: min(96vw, 720px);
  max-height: min(92dvh, 880px);
  overflow-y: auto;
  border-radius: 14px;
  border: 1px solid rgba(134, 221, 255, 0.28);
  background: rgba(10, 30, 78, 0.94);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.campaign-crop-card h3,
.campaign-crop-card p {
  margin: 0;
}

.campaign-crop-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  border-radius: 10px;
  border: 1px solid rgba(134, 221, 255, 0.35);
  background: #0b1328;
  cursor: grab;
  touch-action: none;
}

.campaign-crop-canvas.is-dragging {
  cursor: grabbing;
}

.ads-tg-title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: #f0f6ff;
  margin: 0 0 8px;
}

.ads-tg-body {
  font-size: 0.95rem;
  line-height: 1.5;
  color: rgba(220, 230, 255, 0.88);
  margin: 0 0 14px;
  white-space: normal;
  word-break: break-word;
}

.ads-tg-timer {
  margin: 0 0 12px;
  font-size: 0.88rem;
}

.ads-tg-empty {
  margin: 0 0 12px;
}

.btn-ads-reward-wait {
  background: rgba(45, 58, 95, 0.55) !important;
  color: rgba(200, 210, 240, 0.42) !important;
  border-color: rgba(100, 130, 180, 0.22) !important;
  box-shadow: none !important;
  cursor: not-allowed !important;
  font-weight: 500;
}

.ads-watch-lightbox {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.92);
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0)
    env(safe-area-inset-left, 0);
}

.ads-watch-lightbox.hidden {
  display: none !important;
}

.ads-lightbox-top {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  padding: 10px 12px 6px;
}

.ads-lightbox-close-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(30, 35, 55, 0.75);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ads-lightbox-track {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.ads-lightbox-cell {
  flex: 0 0 100%;
  width: 100%;
  min-width: 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px 20px;
  box-sizing: border-box;
}

.ads-lightbox-cell img {
  max-width: 100%;
  max-height: calc(100dvh - 120px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

.list-row {
  border-radius: 12px;
  border: 1px solid rgba(134, 221, 255, 0.3);
  background: rgba(7, 34, 90, 0.77);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.list-row h3,
.list-row h4,
.list-row p,
.list-row pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.leaderboard-panel {
  display: grid;
  gap: 10px;
}

.leaderboard-info-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.leaderboard-info-card {
  gap: 6px;
  border-color: rgba(145, 232, 255, 0.48);
  background:
    radial-gradient(circle at 14% 18%, rgba(165, 244, 255, 0.2), transparent 55%),
    linear-gradient(160deg, rgba(8, 38, 101, 0.94), rgba(6, 28, 77, 0.88));
}

.leaderboard-date {
  margin: 0;
  font-weight: 800;
  color: #ecfcff;
}

.leaderboard-reward-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.leaderboard-reward-card {
  gap: 7px;
}

.leaderboard-reward-tier {
  display: grid;
  gap: 2px;
  border-radius: 10px;
  border: 1px solid rgba(146, 231, 255, 0.32);
  background: rgba(5, 28, 78, 0.84);
  padding: 8px 9px;
}

.leaderboard-reward-place {
  font-weight: 800;
}

.leaderboard-reward-value {
  color: #9bff33;
  font-weight: 700;
}

.leaderboard-board-grid {
  align-items: start;
}

.leaderboard-board-card {
  min-height: 0;
}

.leaderboard-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  border-radius: 10px;
  border: 1px solid rgba(148, 230, 255, 0.3);
  background: rgba(5, 30, 84, 0.75);
  padding: 8px 9px;
}

.leaderboard-entry-main {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-entry-score {
  color: #8adff5;
  font-weight: 700;
  white-space: nowrap;
}

.leaderboard-entry-me {
  border-color: rgba(155, 255, 51, 0.56);
  box-shadow: inset 0 0 0 1px rgba(155, 255, 51, 0.24);
}

.shop-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 10px;
}

.shop-section {
  align-content: start;
}

.shop-booster-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.shop-booster-card {
  border-radius: 11px;
  border: 1px solid rgba(146, 232, 255, 0.35);
  background:
    radial-gradient(circle at 16% 18%, rgba(170, 244, 255, 0.18), transparent 50%),
    rgba(5, 28, 78, 0.86);
  padding: 9px;
  display: grid;
  gap: 7px;
}

.shop-booster-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.shop-booster-title {
  font-size: 14px;
}

.shop-booster-stock {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.shop-booster-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shop-price-pill {
  flex: 1 1 auto;
  border-radius: 999px;
  border: 1px solid rgba(154, 232, 255, 0.36);
  background: rgba(6, 37, 97, 0.86);
  color: #ecfbff;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 9px;
  text-align: center;
}

.shop-booster-actions .btn {
  flex: 0 0 auto;
  min-width: 96px;
}

.shop-container-card {
  border-color: rgba(255, 217, 110, 0.48);
  background:
    radial-gradient(circle at 14% 16%, rgba(255, 226, 132, 0.22), transparent 54%),
    rgba(30, 24, 76, 0.9);
}

.shop-container-title-btn {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-align: left;
}

.shop-container-title-btn:hover .shop-booster-title {
  text-decoration: underline;
}

.shop-container-odds-popup {
  margin-top: 6px;
  border-radius: 10px;
  border: 1px solid rgba(170, 232, 255, 0.3);
  background: rgba(4, 24, 66, 0.82);
  padding: 8px;
  display: grid;
  gap: 6px;
}

.shop-odds-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 11px;
}

.shop-odds-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(172, 236, 255, 0.28);
  background: rgba(7, 39, 101, 0.74);
  padding: 2px 7px;
  color: #ecfbff;
}

.shop-odds-modal {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: grid;
  place-items: center;
  padding: 12px;
}

.shop-odds-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(4, 12, 28, 0.68);
  cursor: pointer;
}

.shop-odds-modal-card {
  position: relative;
  width: min(580px, 100%);
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 13px;
  border: 1px solid rgba(170, 232, 255, 0.42);
  background:
    radial-gradient(circle at 14% 12%, rgba(255, 225, 128, 0.14), transparent 46%),
    rgba(4, 25, 69, 0.96);
}

.shop-odds-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* --- Игровой автомат 777 (магазин) --- */
.shop-slot-machine-card {
  border-color: rgba(255, 120, 200, 0.45);
  background:
    radial-gradient(ellipse 120% 80% at 50% 0%, rgba(255, 98, 180, 0.2), transparent 55%),
    linear-gradient(165deg, rgba(30, 12, 55, 0.95), rgba(8, 20, 72, 0.92));
  box-shadow:
    0 0 0 1px rgba(255, 200, 255, 0.12),
    0 12px 40px rgba(0, 0, 0, 0.45);
}

.slot-machine-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 10px;
  pointer-events: auto;
}

.slot-machine-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(2, 6, 20, 0.78);
  cursor: pointer;
  backdrop-filter: blur(3px);
}

.slot-machine-dialog {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  max-height: min(92vh, 640px);
  overflow: auto;
  border-radius: 16px;
  border: 1px solid rgba(255, 196, 120, 0.45);
  background:
    radial-gradient(ellipse 100% 60% at 50% -10%, rgba(255, 214, 120, 0.25), transparent 50%),
    linear-gradient(180deg, #1a0b2e 0%, #0a1538 45%, #04102a 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 20px 50px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 14px 14px 12px;
  display: grid;
  gap: 10px;
}

.slot-win-fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: 16px;
  z-index: 2;
}

.slot-win-fx-layer.slot-win-fx-active {
  animation: slot-win-fx-layer-pulse 420ms ease-out;
}

@keyframes slot-win-fx-layer-pulse {
  0% { opacity: 0; }
  35% { opacity: 1; }
  100% { opacity: 0.2; }
}

.slot-win-fx-particle {
  position: absolute;
  top: 42%;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  background: linear-gradient(145deg, #f3feff 0%, #9fefff 45%, #4fd6ff 100%);
  border: 1px solid rgba(220, 252, 255, 0.75);
  box-shadow:
    0 0 14px rgba(99, 227, 255, 0.9),
    0 0 24px rgba(105, 170, 255, 0.45);
  transform: translateX(-50%);
  animation-name: slot-win-fx-particle-fly;
  animation-timing-function: cubic-bezier(0.12, 0.64, 0.19, 1.02);
  animation-fill-mode: both;
}

.slot-win-badge {
  position: absolute;
  left: 50%;
  top: 28%;
  transform: translate(-50%, -50%);
  z-index: 4;
  display: grid;
  gap: 4px;
  text-align: center;
  pointer-events: none;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 243, 182, 0.78);
  background: linear-gradient(180deg, rgba(45, 19, 78, 0.92), rgba(17, 35, 90, 0.92));
  box-shadow:
    0 0 26px rgba(255, 190, 82, 0.45),
    0 8px 20px rgba(0, 0, 0, 0.45);
  animation: slot-win-badge-pop 760ms cubic-bezier(0.12, 0.9, 0.2, 1);
}

.slot-win-badge strong {
  font-size: 20px;
  line-height: 1;
  letter-spacing: 0.08em;
  color: #fff6c7;
  text-shadow: 0 0 18px rgba(255, 217, 125, 0.95);
}

.slot-win-badge span {
  font-size: 13px;
  font-weight: 800;
  color: #9ff5ff;
  text-shadow: 0 0 10px rgba(95, 214, 255, 0.65);
}

@keyframes slot-win-badge-pop {
  0% { opacity: 0; transform: translate(-50%, -35%) scale(0.62); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes slot-win-fx-particle-fly {
  0% {
    opacity: 0.15;
    transform: translateX(-50%) translateY(0) rotate(0deg) scale(0.65);
  }
  40% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform:
      translateX(calc(-50% + var(--slot-fx-x, 0px)))
      translateY(var(--slot-fx-y, -130px))
      rotate(var(--slot-fx-rot, 120deg))
      scale(1.05);
  }
}

.slot-machine-dialog.slot-win-tier-small {
  animation: slot-win-dialog-pulse-small 460ms ease-out;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 20px 50px rgba(0, 0, 0, 0.55),
    0 0 24px rgba(117, 227, 153, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.slot-machine-dialog.slot-win-tier-medium {
  animation: slot-win-dialog-pulse-medium 560ms ease-out;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 20px 50px rgba(0, 0, 0, 0.55),
    0 0 34px rgba(255, 194, 92, 0.46),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.slot-machine-dialog.slot-win-tier-jackpot {
  box-shadow:
    0 0 0 1px rgba(255, 249, 183, 0.3),
    0 20px 50px rgba(0, 0, 0, 0.55),
    0 0 46px rgba(255, 170, 67, 0.75),
    0 0 82px rgba(255, 103, 183, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  animation:
    slot-jackpot-dialog-glow 560ms ease-in-out 2 alternate,
    slot-jackpot-dialog-shake 420ms ease-in-out 1;
}

@keyframes slot-win-dialog-pulse-small {
  0% { transform: scale(1); }
  45% { transform: scale(1.012); }
  100% { transform: scale(1); }
}

@keyframes slot-win-dialog-pulse-medium {
  0% { transform: scale(1); }
  45% { transform: scale(1.018); }
  100% { transform: scale(1); }
}

@keyframes slot-jackpot-dialog-glow {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-1px) scale(1.01); }
}

@keyframes slot-jackpot-dialog-shake {
  0% { transform: translateX(0); }
  20% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
  100% { transform: translateX(0); }
}

.slot-machine-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.slot-machine-title {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(90deg, #ffe9a8, #ffb347, #ff6ba8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 24px rgba(255, 200, 120, 0.35);
}

.slot-machine-sub {
  margin: 0;
  font-size: 11px;
}

.slot-machine-stage {
  border-radius: 14px;
  padding: 14px 12px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 230, 160, 0.12), transparent 55%),
    linear-gradient(145deg, rgba(0, 0, 0, 0.35), rgba(20, 40, 90, 0.35));
  border: 1px solid rgba(180, 220, 255, 0.2);
}

.slot-machine-reels {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}

.slot-reel {
  flex: 1 1 0;
  min-width: 0;
  max-width: 110px;
}

.slot-reel-window {
  border-radius: 12px;
  border: 2px solid rgba(255, 210, 120, 0.55);
  background:
    linear-gradient(180deg, #0d1024 0%, #151838 40%, #0a0e1c 100%);
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.65),
    0 0 20px rgba(255, 180, 60, 0.15);
  min-height: 88px;
  display: grid;
  place-items: center;
  padding: 6px;
}

.slot-reel-face {
  font-size: clamp(1.35rem, 5vw, 2rem);
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  color: #fff8e8;
  text-shadow:
    0 0 12px rgba(255, 210, 130, 0.85),
    0 2px 0 rgba(0, 0, 0, 0.65);
  word-break: break-word;
}

.slot-reel-face-stop-flash {
  animation: slot-reel-stop-flash 220ms ease-out;
}

@keyframes slot-reel-stop-flash {
  0% {
    transform: scale(1.08);
    filter: brightness(1.4);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

.slot-machine-actions {
  display: flex;
  justify-content: center;
}

.slot-spin-btn {
  min-width: 200px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.slot-machine-details {
  font-size: 11px;
  border-radius: 10px;
  border: 1px solid rgba(140, 200, 255, 0.22);
  background: rgba(4, 14, 40, 0.55);
  padding: 6px 10px;
}

.slot-machine-details summary {
  cursor: pointer;
  font-weight: 700;
  color: #c8e8ff;
}

.slot-machine-meta {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.slot-paytable-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(120, 180, 255, 0.12);
  font-size: 11px;
}

.slot-paytable-line span:first-child {
  color: #e8f4ff;
}

.slot-paytable-line span:last-child {
  color: #a8e8c8;
  font-weight: 700;
  white-space: nowrap;
}

.slot-reel-odds {
  font-size: 10px;
  line-height: 1.35;
}

.shop-exchange-form {
  gap: 10px;
}

.rewards-panel {
  display: grid;
  gap: 10px;
}

.rewards-panel-stack {
  position: relative;
}

.lottery-history-surface {
  position: absolute;
  inset: 0;
  z-index: 8;
  border-radius: 12px;
  background: rgba(3, 10, 26, 0.8);
  padding: 6px;
  display: flex;
  flex-direction: column;
}

/* Портрет: колонка — сундуки → лотерея → еженедельные задачи. Альбом: сетка см. .layout-landscape */
.rewards-columns {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rewards-chests-slot,
.rewards-lottery-slot,
.rewards-milestones-slot {
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
}

.rewards-chest-grid {
  display: grid;
  gap: 8px;
}

.reward-chest-card {
  border-radius: 11px;
  border: 1px solid rgba(148, 232, 255, 0.36);
  background:
    radial-gradient(circle at 16% 18%, rgba(170, 244, 255, 0.16), transparent 52%),
    rgba(7, 32, 88, 0.86);
  padding: 9px;
  display: grid;
  gap: 7px;
}

.reward-chest-head {
  display: grid;
  gap: 2px;
}

.reward-chest-title {
  font-size: 14px;
}

.reward-chest-type {
  color: #a8efff;
  font-size: 12px;
}

.reward-chest-amount {
  margin: 0;
}

.reward-chest-amount b {
  color: #9bff33;
}

.reward-chest-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.rewards-withdraw-form {
  gap: 10px;
}

.reward-history-row {
  gap: 4px;
}

.rewards-withdraw-rules {
  margin: 0;
  border-radius: 10px;
  border: 1px solid rgba(150, 232, 255, 0.33);
  background: rgba(6, 34, 90, 0.78);
  padding: 8px 10px;
}

.rewards-history-list {
  display: grid;
  gap: 7px;
}

.lottery-prizes-card {
  padding: 10px;
}

.lottery-prize-list {
  display: grid;
  gap: 7px;
}


.lottery-prize-more {
  margin-top: 8px;
  border-radius: 10px;
  border: 1px solid rgba(149, 231, 255, 0.28);
  background: rgba(4, 26, 72, 0.62);
  padding: 6px 8px;
}

.lottery-prize-more > summary {
  cursor: pointer;
  user-select: none;
  color: #c3f4ff;
  font-weight: 600;
  font-size: 12px;
  list-style: none;
}

.lottery-prize-more > summary::-webkit-details-marker {
  display: none;
}

.lottery-prize-more > summary::before {
  content: "▸ ";
}

.lottery-prize-more[open] > summary::before {
  content: "▾ ";
}

.lottery-prize-more .lottery-prize-list {
  margin-top: 8px;
}

.lottery-prize-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(152, 233, 255, 0.34);
  border-radius: 10px;
  background: rgba(7, 31, 84, 0.72);
  padding: 7px 9px;
}

.lottery-prize-place {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  border-radius: 999px;
  border: 1px solid rgba(173, 238, 255, 0.45);
  background: rgba(13, 55, 130, 0.75);
  color: #d5f8ff;
  font-weight: 700;
  font-size: 12px;
  padding: 4px 8px;
}

.lottery-prize-value {
  font-weight: 700;
  font-size: 13px;
  text-align: right;
}

.lottery-prize-value-ozon {
  color: #ffd98a;
}

.lottery-prize-value-diamonds {
  color: #8effd3;
}


.lottery-prize-top1 {
  border-color: rgba(255, 217, 122, 0.66);
  background:
    radial-gradient(circle at 8% 14%, rgba(255, 230, 160, 0.24), transparent 55%),
    rgba(62, 44, 10, 0.62);
  box-shadow: inset 0 1px 0 rgba(255, 242, 197, 0.28);
}

.lottery-prize-top1 .lottery-prize-place {
  border-color: rgba(255, 219, 117, 0.8);
  background: rgba(140, 103, 27, 0.82);
  color: #fff3c7;
}

.lottery-prize-top2 {
  border-color: rgba(207, 222, 238, 0.62);
  background:
    radial-gradient(circle at 8% 14%, rgba(219, 233, 247, 0.2), transparent 55%),
    rgba(25, 45, 74, 0.64);
  box-shadow: inset 0 1px 0 rgba(236, 244, 252, 0.2);
}

.lottery-prize-top2 .lottery-prize-place {
  border-color: rgba(212, 227, 245, 0.72);
  background: rgba(73, 97, 126, 0.8);
  color: #eef7ff;
}

.lottery-prize-top3 {
  border-color: rgba(223, 170, 137, 0.62);
  background:
    radial-gradient(circle at 8% 14%, rgba(236, 194, 160, 0.2), transparent 55%),
    rgba(71, 43, 29, 0.64);
  box-shadow: inset 0 1px 0 rgba(245, 217, 196, 0.2);
}

.lottery-prize-top3 .lottery-prize-place {
  border-color: rgba(232, 181, 147, 0.72);
  background: rgba(124, 79, 53, 0.8);
  color: #fff0e6;
}

.rewards-milestone-grid {
  display: grid;
  gap: 7px;
}

.reward-milestone-row {
  border-radius: 10px;
  border: 1px solid rgba(149, 231, 255, 0.34);
  background: rgba(6, 34, 90, 0.78);
  padding: 8px 9px;
  display: grid;
  gap: 2px;
}

.reward-milestone-value {
  color: #9bff33;
  font-weight: 700;
  font-size: 12px;
}

.layout-landscape .rewards-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(0, 1fr);
  grid-template-areas:
    "chests lottery"
    "milestones lottery";
  gap: 10px;
  align-items: start;
}

.layout-landscape .rewards-chests-slot {
  grid-area: chests;
}

.layout-landscape .rewards-lottery-slot {
  grid-area: lottery;
}

.layout-landscape .rewards-milestones-slot {
  grid-area: milestones;
}

.layout-landscape .rewards-withdraw-card {
  border-color: rgba(167, 237, 255, 0.46);
  background:
    radial-gradient(circle at 18% 12%, rgba(182, 246, 255, 0.2), transparent 52%),
    linear-gradient(160deg, rgba(8, 36, 100, 0.95), rgba(5, 23, 76, 0.9));
  box-shadow:
    inset 0 1px 0 rgba(214, 248, 255, 0.18),
    0 10px 24px rgba(2, 10, 35, 0.34);
}

.layout-landscape .rewards-withdraw-card h3 {
  color: #f0fcff;
}

.layout-landscape .rewards-withdraw-card h4 {
  margin: 2px 0 0;
  color: #b9f2ff;
}

.layout-landscape .rewards-withdraw-form {
  border-radius: 10px;
  border: 1px solid rgba(154, 232, 255, 0.34);
  background: rgba(5, 28, 80, 0.68);
  padding: 9px;
}

.layout-landscape .rewards-withdraw-form .btn {
  min-height: 40px;
}

.layout-landscape .rewards-history-list .reward-history-row {
  border-color: rgba(156, 234, 255, 0.3);
  background: rgba(5, 29, 82, 0.72);
}

.layout-landscape .rewards-history-card {
  align-self: start;
  border-color: rgba(154, 232, 255, 0.4);
  background: rgba(6, 31, 87, 0.8);
}

.layout-landscape .rewards-history-card h4 {
  margin: 0;
  color: #b9f2ff;
}

.referral-panel {
  display: grid;
  gap: 10px;
}

.referral-alert-card {
  border-color: rgba(255, 211, 128, 0.52);
  background:
    radial-gradient(circle at 16% 14%, rgba(255, 213, 130, 0.2), transparent 50%),
    linear-gradient(160deg, rgba(75, 45, 12, 0.72), rgba(43, 26, 8, 0.72));
}

.referral-invite-bonus {
  margin: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 227, 143, 0.55);
  background: rgba(99, 63, 20, 0.5);
  color: #fff3c5;
  font-weight: 700;
  padding: 8px 10px;
}

.referral-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.referral-stat-card {
  gap: 4px;
}

.referral-stat-label {
  color: var(--muted);
  font-size: 12px;
}

.referral-stat-value {
  font-size: 18px;
  color: #ecfdff;
}

.referral-link-card {
  gap: 8px;
}

.referral-link-value {
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(152, 232, 255, 0.34);
  background: rgba(6, 33, 88, 0.72);
  color: #dff7ff;
  word-break: break-all;
}

.referral-action-row .btn {
  min-height: 38px;
}

.referral-collect-card .btn {
  min-height: 40px;
}

.daily-grid {
  display: grid;
  gap: 7px;
}

.tasks-card-tabs {
  margin-bottom: 8px;
}

.daily-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.daily-card .section-title {
  flex: 0 0 auto;
}

.daily-card .daily-grid {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-right: 2px;
  user-select: none;
}

.side-column > .daily-card {
  flex: 1 1 auto;
  min-height: 0;
}

.daily-task {
  border: 1px solid rgba(131, 220, 255, 0.3);
  background: rgba(8, 32, 88, 0.7);
  border-radius: 12px;
  padding: 8px;
  display: grid;
  gap: 6px;
}

.daily-task button {
  border: 0;
  border-radius: 9px;
  background: #94ff31;
  color: #0a2d56;
  font-weight: 800;
  padding: 7px;
}

.daily-task button[disabled] {
  background: #8ea8b6;
  color: #2b495f;
  /* Чтобы drag-scroll списка стартовал и с области disabled-кнопок. */
  pointer-events: none;
}

.daily-task.done {
  opacity: 0.67;
}

.progress {
  border-radius: 999px;
  border: 1px solid rgba(141, 224, 255, 0.4);
  height: 12px;
  overflow: hidden;
  background: rgba(8, 24, 61, 0.88);
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #95ff32, #23dfff);
  transition: width 220ms ease;
}

.toast-root {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 10px;
  width: min(95vw, 580px);
  display: grid;
  gap: 6px;
  z-index: 40;
}

.toast {
  border-radius: 11px;
  border: 1px solid rgba(140, 221, 255, 0.42);
  background: rgba(5, 26, 71, 0.92);
  color: #f0fbff;
  padding: 8px 11px;
}

.toast.success {
  border-color: rgba(155, 255, 51, 0.74);
}

.toast.warning {
  border-color: rgba(255, 209, 102, 0.74);
}

.toast.error {
  border-color: rgba(255, 111, 150, 0.72);
}

.lottery-history-panel {
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.lottery-history-head {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 10px 12px 8px;
  border-bottom: 1px solid rgba(141, 221, 255, 0.26);
  background: linear-gradient(180deg, rgba(7, 34, 88, 0.95), rgba(7, 34, 88, 0.72) 75%, rgba(7, 34, 88, 0));
}

.lottery-history-head h3 {
  margin: 0;
}

.lottery-history-body {
  max-height: none;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 10px 10px;
}

/* Нижний клиентский дебаг-логер (телефон / ?debug=1) */
.client-debug {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  /* Поверх любых экранов; iOS/WebKit лучше не ставить pointer-events:none на родителе кнопки */
  z-index: 2147483646;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.35;
  pointer-events: none;
}

.client-debug-fab,
.client-debug-panel {
  pointer-events: auto;
}

.client-debug-fab {
  position: fixed;
  right: max(10px, env(safe-area-inset-right, 0px));
  bottom: max(10px, env(safe-area-inset-bottom, 0px));
  z-index: 2147483647;
  min-width: 56px;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(120, 220, 255, 0.55);
  background: rgba(4, 12, 40, 0.97);
  color: #7ef9ff;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(126, 249, 255, 0.35);
  user-select: none;
}

.client-debug-fab .client-debug-count {
  display: inline-block;
  min-width: 1.4em;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 8px;
  background: rgba(255, 111, 150, 0.35);
  color: #ffd4de;
  font-variant-numeric: tabular-nums;
}

.client-debug-panel {
  display: none;
  flex-direction: column;
  position: fixed;
  left: max(6px, env(safe-area-inset-left, 0px));
  right: max(6px, env(safe-area-inset-right, 0px));
  bottom: max(6px, env(safe-area-inset-bottom, 0px));
  z-index: 2147483647;
  max-height: min(52vh, 420px);
  border-radius: 12px 12px 0 0;
  border: 1px solid rgba(120, 220, 255, 0.45);
  border-bottom: none;
  background: rgba(2, 6, 22, 0.96);
  color: #e8f6ff;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.client-debug.client-debug--open .client-debug-panel {
  display: flex;
}

.client-debug.client-debug--open .client-debug-fab {
  display: none;
}

.client-debug-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(12, 40, 96, 0.95);
  border-bottom: 1px solid rgba(100, 200, 255, 0.25);
}

.client-debug-toolbar strong {
  flex: 1;
  min-width: 120px;
  font-size: 11px;
  color: #9bff33;
}

.client-debug-toolbar button {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(140, 210, 255, 0.4);
  background: rgba(30, 70, 140, 0.9);
  color: #e8f6ff;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.client-debug-toolbar button:active {
  opacity: 0.88;
}

.client-debug-stream {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 8px 10px;
  max-height: min(44vh, 360px);
  -webkit-overflow-scrolling: touch;
  margin: 0;
  font: inherit;
  white-space: pre-wrap;
  word-break: break-word;
  color: #e8f6ff;
  touch-action: manipulation;
}

.client-debug-line {
  margin: 0 0 4px;
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  word-break: break-word;
  white-space: pre-wrap;
}

.client-debug-line .t {
  color: #7a9bb8;
  margin-right: 6px;
}

.client-debug-line.l-warn .lv {
  color: #ffd166;
}

.client-debug-line.l-error .lv {
  color: #ff8ba8;
}

.client-debug-line.l-snap .lv {
  color: #7ef9ff;
}

.hidden {
  display: none !important;
}

@keyframes tile-pop {
  0% {
    transform: scale(0.2);
  }
  70% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes tile-pop-wiggle {
  0% {
    transform: translate3d(0, 0, 0) scale(0.24) rotate(0deg);
  }
  32% {
    transform: translate3d(0, 0, 0) scale(1.1) rotate(0deg);
  }
  46% {
    transform: translate3d(-1px, 0, 0) scale(1.02) rotate(-3.4deg);
  }
  60% {
    transform: translate3d(1px, 0, 0) scale(1.01) rotate(2.9deg);
  }
  74% {
    transform: translate3d(-1px, 0, 0) scale(1) rotate(-1.8deg);
  }
  88% {
    transform: translate3d(1px, 0, 0) scale(1) rotate(1.2deg);
  }
  100% {
    transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
  }
}

@keyframes tile-impact {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  35% {
    transform: scale(0.86);
    filter: brightness(1.7) saturate(1.4);
    box-shadow: 0 0 58px rgba(255, 186, 82, 0.98), 0 0 38px rgba(255, 96, 42, 0.9);
  }
  100% {
    transform: scale(1.14);
    filter: brightness(1.25);
  }
}

@keyframes tile-build-reveal {
  0% {
    opacity: 0.15;
    transform: scale(0.62);
    filter: brightness(1.8) saturate(1.35);
    box-shadow: 0 0 42px rgba(255, 202, 102, 0.96), 0 0 36px rgba(255, 112, 44, 0.82);
  }
  48% {
    opacity: 1;
    transform: scale(1.2);
    filter: brightness(1.45);
  }
  100% {
    opacity: 1;
    transform: scale(1);
    filter: brightness(1);
  }
}

@keyframes tile-burst {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(255, 255, 255, 0.2);
  }
  30% {
    transform: scale(1.22);
    box-shadow: 0 0 26px rgba(255, 255, 255, 0.65);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes tile-assemble {
  0% {
    transform: scale(0.85);
    filter: brightness(1.35) saturate(1.2);
  }
  45% {
    transform: scale(1.24);
    filter: brightness(1.55) saturate(1.35);
    box-shadow: 0 0 44px rgba(255, 186, 88, 0.98), 0 0 32px rgba(255, 92, 36, 0.88);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

@keyframes boundary-blast {
  0% {
    transform: scale(0.15);
    opacity: 0.15;
  }
  45% {
    transform: scale(2.9);
    opacity: 1;
  }
  100% {
    transform: scale(4.8);
    opacity: 0;
  }
}

@keyframes core-flash {
  0% {
    opacity: 0.2;
    transform: scale(0.2);
    filter: blur(0.2px);
  }
  36% {
    opacity: 1;
    transform: scale(2.8);
    filter: blur(0);
  }
  100% {
    opacity: 0;
    transform: scale(5.1);
    filter: blur(1.2px);
  }
}

@keyframes new-tile-core-flash {
  0% {
    opacity: 0.2;
    transform: scale(0.2);
  }
  36% {
    opacity: 1;
    transform: scale(2.6);
  }
  100% {
    opacity: 0;
    transform: scale(4.5);
  }
}

@keyframes board-shift-left {
  0% { transform: translateX(0); }
  35% { transform: translateX(-16px); }
  100% { transform: translateX(0); }
}

@keyframes board-shift-right {
  0% { transform: translateX(0); }
  35% { transform: translateX(16px); }
  100% { transform: translateX(0); }
}

@keyframes board-shift-up {
  0% { transform: translateY(0); }
  35% { transform: translateY(-16px); }
  100% { transform: translateY(0); }
}

@keyframes board-shift-down {
  0% { transform: translateY(0); }
  35% { transform: translateY(16px); }
  100% { transform: translateY(0); }
}

@keyframes board-fx-shake {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  10% { transform: translate3d(calc(-2px * var(--fx-shake-amp, 1)), calc(1px * var(--fx-shake-amp, 1)), 0) scale(calc(1 + 0.004 * var(--fx-shake-amp, 1))); }
  22% { transform: translate3d(calc(2px * var(--fx-shake-amp, 1)), calc(-1px * var(--fx-shake-amp, 1)), 0) scale(calc(1 + 0.008 * var(--fx-shake-amp, 1))); }
  34% { transform: translate3d(calc(-3px * var(--fx-shake-amp, 1)), calc(2px * var(--fx-shake-amp, 1)), 0) scale(calc(1 + 0.01 * var(--fx-shake-amp, 1))); }
  48% { transform: translate3d(calc(2px * var(--fx-shake-amp, 1)), calc(-2px * var(--fx-shake-amp, 1)), 0) scale(calc(1 + 0.006 * var(--fx-shake-amp, 1))); }
  65% { transform: translate3d(calc(-1px * var(--fx-shake-amp, 1)), calc(1px * var(--fx-shake-amp, 1)), 0) scale(calc(1 + 0.003 * var(--fx-shake-amp, 1))); }
  82% { transform: translate3d(calc(1px * var(--fx-shake-amp, 1)), 0, 0) scale(calc(1 + 0.001 * var(--fx-shake-amp, 1))); }
  100% { transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes cell-near-shock {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  20% { transform: translate3d(var(--near-shock-x, 3px), var(--near-shock-y, 2px), 0) scale(var(--near-shock-scale, 1.02)); }
  48% { transform: translate3d(calc(var(--near-shock-x, 3px) * -0.55), calc(var(--near-shock-y, 2px) * -0.55), 0) scale(calc(1 + (var(--near-shock-scale, 1.02) - 1) * 0.6)); }
  74% { transform: translate3d(calc(var(--near-shock-x, 3px) * 0.2), calc(var(--near-shock-y, 2px) * 0.2), 0) scale(1.005); }
  100% { transform: translate3d(0, 0, 0) scale(1); }
}

@media (max-width: 1080px) {
  .bottom-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 920px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
}

/* Desktop landscape: never collapse game into one column. */
@media (max-width: 920px) and (orientation: landscape) {
  body.layout-landscape .game-layout {
    grid-template-columns: minmax(280px, 1fr) minmax(260px, 380px);
  }
}

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

  .booster-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .bottom-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .split {
    grid-template-columns: 1fr;
  }

  .overlay-head {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .overlay-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .leaderboard-info-row,
  .leaderboard-reward-grid {
    grid-template-columns: 1fr;
  }

  .leaderboard-entry {
    grid-template-columns: 1fr;
  }

  .leaderboard-entry-score {
    justify-self: start;
  }

  .shop-panel {
    grid-template-columns: 1fr;
  }

  .shop-booster-grid {
    grid-template-columns: 1fr;
  }

  .shop-booster-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .shop-booster-actions .btn {
    width: 100%;
  }

  .referral-stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Портрет: заголовок оверлея и действия в одну строку */
body.layout-portrait .overlay-head {
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
}

body.layout-portrait .overlay-head h2 {
  font-size: 14px;
  white-space: nowrap;
}

body.layout-portrait .overlay-head .overlay-actions {
  width: auto;
  margin-left: auto;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 4px;
}

body.layout-portrait .overlay-head .overlay-actions .btn {
  min-width: 0;
  min-height: 30px;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1;
}

body.layout-portrait .leaderboard-info-card {
  padding: 8px 9px;
  gap: 4px;
}

body.layout-portrait .leaderboard-info-card h3,
body.layout-portrait .leaderboard-info-card .leaderboard-date {
  font-size: 13px;
  line-height: 1.15;
}

/* Ландшафтный режим (ПК + гаджеты в альбомной): двухколоночный layout */
@media (max-width: 900px) and (orientation: landscape) {
  #screen-game .hud {
    padding: 8px 10px;
    gap: 8px;
  }

  #screen-game .hud-metrics {
    gap: 5px;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  #screen-game .metric {
    min-width: 0;
    padding: 5px 7px;
  }

  #screen-game .metric strong {
    font-size: clamp(13px, 2.4vw, 18px);
  }

  #screen-game .game-layout {
    margin-top: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 34vw);
    gap: 8px;
    min-height: 0;
  }

  #screen-game .board-card {
    min-height: 0;
    padding: 8px;
  }

  #screen-game .side-column {
    max-height: none;
    min-height: 0;
    overflow-y: auto;
    gap: 6px;
    padding-right: 2px;
  }

  #screen-game .board {
    width: min(calc(100dvh - 6.5rem), 62vw, 100%);
    max-height: min(calc(100dvh - 6.5rem), 100%);
    padding: 5px;
    gap: 4px;
  }

  #screen-game .bottom-nav {
    margin-top: 0;
    gap: 4px;
    padding: 6px 8px;
  }

  #screen-game .nav-btn {
    padding: 7px 4px;
    font-size: 9px;
  }

  #screen-game .cell {
    font-size: clamp(11px, 2.2vw, 20px);
  }

  #screen-game .side-column .quick-rating-card .hud-metrics.compact {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: 4px;
    justify-content: stretch;
    overflow: visible;
  }

  #screen-game .side-column .quick-rating-card .metric {
    min-width: 0;
    padding: 4px 5px;
    gap: 2px;
  }

  #screen-game .side-column .quick-rating-card .metric strong {
    font-size: clamp(11px, 2vw, 14px);
    line-height: 1.05;
  }

  #screen-game .side-column .quick-rating-card .metric span,
  #screen-game .side-column .quick-rating-card .metric small {
    font-size: 8px;
    line-height: 1.1;
  }

  #screen-game .side-column .quick-rating-card .metric.metric-summary .quick-summary-lines small,
  #screen-game .side-column .quick-rating-card .metric.metric-summary .quick-summary-lines b {
    font-size: 7px;
    line-height: 1.1;
  }
}


@media (orientation: landscape) and (max-height: 560px) {
  .app-shell {
    width: min(100vw, 1480px);
  }

  .game-layout {
    grid-template-columns: minmax(290px, 1fr) minmax(330px, 430px);
  }

  .board {
    max-height: calc(100vh - 220px);
    max-width: calc(100vh - 220px);
  }
}

/* Strict no-scroll game fit: keep entire game inside viewport. */
html:has(#screen-game.screen-active),
html:has(#screen-game.screen-active) body,
body.game-screen-active {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

body.game-screen-active .app-shell,
html:has(#screen-game.screen-active) .app-shell {
  height: 100dvh;
  min-height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#screen-game.screen-active {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  gap: 6px;
}

#screen-game .game-layout {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

#screen-game .board-card {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#screen-game .side-column {
  min-height: 0;
  overflow: hidden !important;
}

#screen-game .side-column .card {
  min-height: 0;
  overflow: hidden;
}

#screen-game .hud-metrics,
#screen-game .daily-grid {
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

#screen-game .bottom-nav {
  flex: 0 0 auto;
  margin-top: 0;
}

/* Landscape desktop/tablet: keep minimum width for 2-column game layout. */
@media (orientation: landscape) and (min-width: 700px) {
  body.layout-landscape.game-screen-active {
    min-width: 860px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  body.layout-landscape.game-screen-active .app-shell,
  body.layout-landscape #screen-game .game-layout {
    min-width: 840px;
  }
}

/* Portrait layout (mobile): edit ONLY this block — landscape stays in its own media rules above. */
@media (max-width: 900px) {
  body.layout-portrait #screen-game .hud {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    padding: 7px 8px;
    border: 1px solid rgba(158, 233, 255, 0.5);
    background:
      radial-gradient(circle at 16% 14%, rgba(181, 245, 255, 0.22), transparent 42%),
      linear-gradient(155deg, rgba(9, 36, 102, 0.94), rgba(6, 23, 73, 0.94));
    box-shadow:
      inset 0 1px 0 rgba(216, 249, 255, 0.2),
      0 12px 28px rgba(2, 12, 40, 0.34);
  }

  body.layout-portrait #screen-game .hud > div:first-child {
    flex: 0 1 34%;
    min-width: 0;
    padding: 4px 6px;
    border-radius: 10px;
    border: 1px solid rgba(152, 231, 255, 0.34);
    background: rgba(6, 29, 84, 0.66);
    box-shadow: inset 0 1px 0 rgba(219, 249, 255, 0.15);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    overflow: hidden;
  }

  body.layout-portrait #screen-game .hud-metrics {
    flex: 1 1 auto;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    align-items: stretch;
    overflow: hidden !important;
    -webkit-mask-image: none;
    mask-image: none;
  }

  body.layout-portrait #screen-game .hud-name {
    width: 100%;
    font-size: clamp(12px, 3.2vw, 15px);
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 10px rgba(105, 211, 255, 0.24);
  }

  body.layout-portrait #screen-game #connection-status {
    margin-top: 0;
    font-size: 8px;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    white-space: nowrap;
    background: rgba(6, 54, 132, 0.66);
    border: 1px solid rgba(134, 215, 255, 0.36);
    color: #d4f3ff;
  }

  body.layout-portrait #screen-game .metric {
    min-width: 0;
    padding: 4px 4px;
    border-radius: 9px;
    border: 1px solid rgba(154, 231, 255, 0.4);
    background: linear-gradient(160deg, rgba(8, 37, 102, 0.86), rgba(5, 24, 76, 0.86));
    box-shadow: inset 0 1px 0 rgba(209, 248, 255, 0.14);
    gap: 1px;
    text-align: center;
  }

  body.layout-portrait #screen-game .metric strong {
    font-size: clamp(11px, 2.8vw, 13px);
    line-height: 1.05;
  }

  body.layout-portrait #screen-game .metric span,
  body.layout-portrait #screen-game .metric small {
    font-size: 7px;
    letter-spacing: 0.02em;
  }

  body.layout-portrait #screen-game .game-layout {
    flex: 1 1 0;
    min-height: 0;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
  }

  /* Quick rating above the battlefield in portrait */
  body.layout-portrait #screen-game .side-column {
    order: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: none;
    overflow: visible !important;
  }

  body.layout-portrait #screen-game .board-card {
    order: 1;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 8px;
    overflow: hidden;
  }

  body.layout-portrait #screen-game .board-card > .section-title {
    flex: 0 0 auto;
    margin-bottom: 4px;
    font-size: 11px;
  }

  body.layout-portrait #screen-game .board-aspect {
    flex: 1 1 0;
  }

  body.layout-portrait #screen-game .board {
    width: min(100%, calc(100dvh - 11.5rem), 100vw - 24px);
    max-width: 100%;
    max-height: min(calc(100dvh - 11.5rem), 100%);
    height: auto;
    aspect-ratio: 1 / 1;
    padding: 5px;
    gap: 4px;
  }

  body.layout-portrait #screen-game .booster-hint {
    flex: 0 0 auto;
    margin-top: 4px;
    font-size: 11px;
  }

  body.layout-portrait #screen-game .side-column .quick-rating-card {
    order: 0;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    overflow: visible !important;
    border: 1px solid rgba(150, 232, 255, 0.55);
    background:
      radial-gradient(circle at 18% 12%, rgba(170, 244, 255, 0.22), transparent 42%),
      linear-gradient(165deg, rgba(10, 40, 110, 0.92), rgba(6, 22, 72, 0.92));
    box-shadow:
      inset 0 1px 0 rgba(210, 248, 255, 0.22),
      0 8px 18px rgba(2, 12, 40, 0.3);
  }

  body.layout-portrait #screen-game .side-column .quick-rating-heading {
    display: none;
  }

  body.layout-portrait #screen-game .side-column .quick-rating-rail {
    display: flex;
  }

  body.layout-portrait #screen-game .side-column .quick-rating-card .hud-metrics.compact {
    flex: 1 1 auto;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: 5px;
    overflow: visible;
    -webkit-mask-image: none;
    mask-image: none;
  }

  body.layout-portrait #screen-game .side-column .quick-rating-card .metric {
    min-width: 0;
    width: auto;
    padding: 5px 5px;
    gap: 2px;
    border-radius: 10px;
    border-color: rgba(154, 231, 255, 0.4);
    background: linear-gradient(160deg, rgba(8, 37, 102, 0.86), rgba(5, 24, 76, 0.86));
    box-shadow: inset 0 1px 0 rgba(209, 248, 255, 0.14);
    text-align: center;
  }

  body.layout-portrait #screen-game .side-column .quick-rating-card .metric strong {
    font-size: clamp(12px, 3.2vw, 15px);
    line-height: 1.05;
  }

  body.layout-portrait #screen-game .side-column .quick-rating-card .metric span,
  body.layout-portrait #screen-game .side-column .quick-rating-card .metric small {
    font-size: 8px;
    letter-spacing: 0.02em;
  }

  body.layout-portrait #screen-game .side-column .quick-rating-card .metric.metric-summary .quick-summary-lines small,
  body.layout-portrait #screen-game .side-column .quick-rating-card .metric.metric-summary .quick-summary-lines b {
    font-size: 7px;
    line-height: 1.15;
  }

  body.layout-portrait #screen-game .side-column .quick-rating-icon-shell {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  body.layout-portrait #screen-game .side-column .quick-rating-icon-svg {
    width: 22px;
    height: 22px;
  }

  /* Ежедневные задачи в портрете — только через кнопку «Задачи» (оверлей) */
  body.layout-portrait #screen-game .side-column .daily-card {
    display: none !important;
  }

  body.layout-portrait #screen-game .side-column .card:not(.quick-rating-card) {
    padding: 7px 8px;
  }

  body.layout-portrait .shop-booster-card {
    padding: 8px;
    gap: 6px;
  }

  body.layout-portrait .shop-booster-title {
    font-size: 13px;
  }

  body.layout-portrait .reward-chest-card {
    padding: 8px;
    gap: 6px;
  }

  body.layout-portrait .reward-chest-title {
    font-size: 13px;
  }

  body.layout-portrait .reward-chest-type {
    font-size: 11px;
  }

  body.layout-portrait .referral-stat-value {
    font-size: 16px;
  }

  body.layout-portrait .referral-action-row {
    gap: 6px;
  }

  body.layout-portrait .referral-collect-card {
    order: 2;
  }

  body.layout-portrait .referral-link-card {
    order: 3;
  }

  body.layout-portrait #screen-game .side-column .section-title {
    font-size: 10px;
    margin-bottom: 3px;
  }

  body.layout-portrait #screen-game .daily-grid {
    max-height: 120px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  body.layout-portrait #screen-game .booster-btn {
    min-height: 46px;
    min-width: 0;
    padding: 4px 3px;
    font-size: 9px;
  }

  body.layout-portrait #screen-game .booster-panel-card {
    margin-top: 6px;
    padding: 6px 7px;
  }

  body.layout-portrait #screen-game .booster-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  body.layout-portrait #screen-game .booster-panel-card .section-title {
    font-size: 10px;
    margin-bottom: 3px;
  }

  body.layout-portrait #screen-game .booster-btn .booster-label {
    font-size: 8px;
  }

  body.layout-portrait #screen-game .booster-btn .booster-count {
    font-size: 11px;
    min-width: 18px;
    padding: 1px 4px;
  }

  body.layout-portrait #screen-game .bottom-nav {
    flex: 0 0 auto;
    margin-top: 0;
    gap: 4px;
    padding: 6px 8px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  body.layout-portrait #screen-game .nav-btn {
    padding: 7px 3px;
    font-size: 9px;
  }

  body.layout-portrait #screen-game .cell {
    font-size: clamp(11px, 3.8vw, 20px);
  }

  body.layout-portrait #screen-game .cell .frozen {
    font-size: 11px;
  }
}

/* ИИ-чат */
.ai-chat-root {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.ai-chat-status {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
}

.ai-chat-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(42vh, 360px);
  overflow-y: auto;
  padding: 8px;
  border-radius: 12px;
  background: rgba(4, 12, 40, 0.45);
  border: 1px solid rgba(118, 226, 255, 0.18);
}

.ai-chat-empty {
  margin: 0;
}

.ai-chat-msg {
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  max-width: 95%;
}

.ai-chat-msg-user {
  margin-left: auto;
  background: rgba(35, 195, 255, 0.14);
  border: 1px solid rgba(118, 226, 255, 0.28);
}

.ai-chat-msg-assistant {
  margin-right: auto;
  background: rgba(174, 88, 255, 0.12);
  border: 1px solid rgba(174, 88, 255, 0.28);
}

.ai-chat-msg-role {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.75;
}

.ai-chat-msg-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.4;
}

.ai-chat-msg-actions {
  gap: 6px;
  flex-wrap: wrap;
}

.ai-chat-msg-btn {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 11px;
}

.ai-chat-mode-hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
}

.ai-chat-sources {
  margin: 4px 0 0;
  padding-left: 18px;
  font-size: 11px;
  line-height: 1.4;
}

.ai-chat-sources a {
  color: #7ef9ff;
  word-break: break-all;
}

.ai-chat-mode-row {
  flex-wrap: wrap;
  gap: 6px;
}

.ai-chat-mode-row .btn {
  flex: 1 1 auto;
  min-width: 64px;
}

.ai-chat-msg-image {
  display: block;
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  object-fit: contain;
}

.ai-chat-attach-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ai-chat-attach-preview img {
  max-height: 88px;
  border-radius: 8px;
}

.ai-chat-form textarea {
  resize: vertical;
  min-height: 72px;
}

#overlay.overlay-ai-panel .overlay-card {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 24px);
}

#overlay.overlay-ai-panel .overlay-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
