/* ──────────────────────────────────────────
   Stack Tower — styles
   Layout uses Telegram safe-area insets via
   CSS env() vars + JS-injected --tg-* fallback.
   ────────────────────────────────────────── */

:root {
  --tg-safe-top: 0px;
  --tg-safe-bottom: 0px;
  --tg-safe-left: 0px;
  --tg-safe-right: 0px;
  /* Buffer under the native Telegram header (Back / Close / ⋮ buttons).
     Telegram's safeAreaInset.top covers the OS notch but not the WebView
     chrome — we add this manually so our HUD sits below the chrome. */
  --tg-header-offset: 56px;

  /* ── Bright flat palette (saturated, no semitones) ── */
  --c-pink:    #ff1f8b;
  --c-yellow:  #ffc83d;
  --c-orange:  #f18a39;
  --c-red:     #e94b5c;
  --c-green:   #7bd069;
  --c-cyan:    #3db7e0;
  --c-purple:  #a855f7;
  --c-mint:    #1bd1a5;

  /* Darker companions for the right/bottom face of the cubic 3D buttons. */
  --c-pink-d:   #b3145e;
  --c-yellow-d: #b08412;
  --c-orange-d: #a85d20;
  --c-red-d:    #9a2a37;
  --c-green-d:  #4d8a3f;
  --c-cyan-d:   #1f7ba0;
  --c-purple-d: #6c2dad;
  --c-mint-d:   #0f8c70;
  --c-cube-edge: #1a1a1a;

  /* ── Light theme (default) ── */
  --bg:         #fffbe6;   /* cream */
  --bg-alt:     #ffe98a;
  --ink:        #1a1a1a;   /* near-black */
  --ink-soft:   #5a5a5a;
  --card-bg:    #ffffff;
  --hint-color: #1a1a1a;
  --pill-bg:    #1a1a1a;
  --pill-fg:    #ffffff;
  --accent:     #1bd1a5;
  --pink:       #ff1f8b;
  --border:     #1a1a1a;
  --shadow-c:   #1a1a1a;
  --shadow:     4px 4px 0 0 var(--shadow-c);
  --shadow-sm:  2px 2px 0 0 var(--shadow-c);
  --shadow-lg:  6px 6px 0 0 var(--shadow-c);

  color-scheme: light dark;

  /* Single system monospace for every script — guarantees identical glyph
     metrics across ru/uz (and any other language). No web font, no fallback,
     no x-height mismatch. */
  font-family: ui-monospace, SFMono-Regular, "SF Mono",
               Menlo, Consolas, "Liberation Mono", monospace;
  font-weight: 600;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  font-smooth: never;
  image-rendering: pixelated;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:         #0f0f1a;
    --bg-alt:     #1a1a2e;
    --ink:        #ffffff;
    --ink-soft:   #b8b8c8;
    --card-bg:    #15151f;
    --hint-color: #ffffff;
    --pill-bg:    #15151f;
    --border:     #ffffff;
    --shadow-c:   #ffffff;
    --shadow:     4px 4px 0 0 var(--shadow-c);
    --shadow-sm:  2px 2px 0 0 var(--shadow-c);
    --shadow-lg:  6px 6px 0 0 var(--shadow-c);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

#canvas-root {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#canvas-root canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── HUD ─────────────────────────────────── */

.hud {
  position: fixed;
  top: calc(var(--tg-safe-top) + var(--tg-header-offset));
  left: 0;
  right: 0;
  padding: 0 calc(var(--tg-safe-left) + 14px) 0 calc(var(--tg-safe-right) + 14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 10;
  pointer-events: none;
}
.hud.hidden { display: none; }

.hud > * { pointer-events: auto; }

.round-btn {
  width: 48px;
  height: 48px;
  border-radius: 0;
  background: #ffffff;
  border: 3px solid var(--border);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.06s ease-out, box-shadow 0.06s ease-out;
  flex: 0 0 auto;
  -webkit-tap-highlight-color: transparent;
}
.round-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 0 var(--shadow-c);
}
body.tg-dark .round-btn { background: #ffffff; }

.score-group {
  display: flex;
  gap: 8px;
  flex: 1 1 auto;
  justify-content: center;
  max-width: calc(100% - 120px);
}

.score-pill {
  background: var(--pill-bg);
  color: var(--pill-fg);
  border-radius: 0;
  border: 3px solid var(--border);
  padding: 8px 14px 6px;
  text-align: center;
  min-width: 110px;
  box-shadow: var(--shadow);
  position: relative;
}
body.tg-dark .score-pill { background: var(--pill-bg); border-color: #ffffff; }
.score-pill--solo {
  min-width: 144px;
  padding: 10px 22px 8px;
}
.score-pill--solo .pill-value { font-size: 30px; }

.pill-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  opacity: 0.95;
  text-transform: uppercase;
}

.pill-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  margin-top: 2px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.pill-value--accent { color: var(--c-yellow); }

.crown {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
}

/* ── Hint ────────────────────────────────── */

.hint {
  position: fixed;
  left: 50%;
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  color: var(--ink);
  background: var(--c-yellow);
  border: 3px solid var(--border);
  padding: 10px 16px;
  font-weight: 700;
  letter-spacing: 1px;
  font-size: 16px;
  text-transform: uppercase;
  box-shadow: var(--shadow);
  z-index: 5;
  pointer-events: none;
  /* Hidden by default — the pulse animation only runs when .show is on,
     otherwise its keyframes would override opacity: 0. */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
}
body.tg-dark .hint { background: var(--c-yellow); color: #1a1a1a; }
.hint.show {
  opacity: 1;
  visibility: visible;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1);    opacity: 0.85; }
  50%      { transform: translate(-50%, -50%) scale(1.04); opacity: 1; }
}

/* ── Footer (bottom controls) ────────────── */

.footer {
  position: fixed;
  bottom: calc(var(--tg-safe-bottom) + 18px);
  left: 0;
  right: 0;
  padding: 0 calc(var(--tg-safe-left) + 16px) 0 calc(var(--tg-safe-right) + 16px);
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.play-btn {
  /* Cubic 3D button — defaults to pink CTA. */
  --cube-face-r: var(--c-pink-d);
  --cube-face-b: var(--c-pink-d);
  --cube-fill:   var(--c-pink);
  --cube-fg:     #ffffff;
  --cube-depth:  8px;

  flex: 1 1 auto;
  max-width: 280px;
  height: 54px;
  border-radius: 0;
  background: var(--cube-fill);
  color: var(--cube-fg);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  border: 3px solid var(--c-cube-edge);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.07s ease-out;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 1;
}
.play-btn::after {
  content: "";
  position: absolute;
  top: 4px;
  right: calc(-1 * var(--cube-depth) - 3px);
  width: var(--cube-depth);
  height: 100%;
  background: var(--cube-face-r);
  border: 3px solid var(--c-cube-edge);
  border-left: none;
  z-index: -1;
  pointer-events: none;
}
.play-btn::before {
  content: "";
  position: absolute;
  bottom: calc(-1 * var(--cube-depth) - 3px);
  left: 4px;
  width: 100%;
  height: var(--cube-depth);
  background: var(--cube-face-b);
  border: 3px solid var(--c-cube-edge);
  border-top: none;
  z-index: -1;
  pointer-events: none;
}
.play-btn:active {
  transform: translate(var(--cube-depth), var(--cube-depth));
}
.play-btn:active::before,
.play-btn:active::after { opacity: 0; }

.ghost-btn {
  height: 46px;
  padding: 0 14px;
  border-radius: 0;
  background: var(--card-bg);
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  border: 3px solid var(--border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.06s ease-out, box-shadow 0.06s ease-out;
  -webkit-tap-highlight-color: transparent;
}
.ghost-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 0 var(--shadow-c);
}
body.tg-dark .ghost-btn { background: var(--card-bg); color: #ffffff; }

/* ── Modals ──────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 38, 0.72);
  z-index: 20;
  display: grid;
  place-items: center;
  padding: calc(var(--tg-safe-top) + 16px)
           calc(var(--tg-safe-right) + 18px)
           calc(var(--tg-safe-bottom) + 16px)
           calc(var(--tg-safe-left) + 18px);
  animation: fade 0.18s ease;
}
.modal.hidden { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: 100%;
  max-width: 340px;
  background: var(--card-bg);
  border: 3px solid var(--border);
  border-radius: 0;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  color: var(--ink);
}
.modal-card--wide { max-width: 380px; }

.modal-card h2 {
  margin: 0 0 6px;
  /* Scales down on narrow screens (caps at 24px), so long titles never get
     clipped across devices. */
  font-size: clamp(18px, 5.6vw, 24px);
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
body.tg-dark .modal-card h2 { color: #ffffff; }

/* Buttons inside a modal stretch to the same width regardless of variant. */
.modal-card .play-btn,
.modal-card .ghost-btn {
  width: 100%;
  max-width: none;
  flex: 0 0 auto;
}

/* Game-over button colour variants — cubic 3D tiles. */
.play-btn--menu {
  --cube-face-r: var(--c-yellow-d);
  --cube-face-b: var(--c-yellow-d);
  --cube-fill:   var(--c-yellow);
  --cube-fg:     #1a1a1a;
}
.play-btn--share {
  --cube-face-r: var(--c-cyan-d);
  --cube-face-b: var(--c-cyan-d);
  --cube-fill:   var(--c-cyan);
  --cube-fg:     #ffffff;
}

.modal-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 15px;
  color: var(--ink-soft);
  padding: 8px 4px;
  border-bottom: 2px dashed rgba(26,26,26,0.18);
}
.modal-row:last-of-type { border-bottom: none; }
.modal-row strong {
  font-size: 24px;
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
body.tg-dark .modal-row { color: var(--ink-soft); border-bottom-color: rgba(255,255,255,0.18); }
body.tg-dark .modal-row strong { color: #ffffff; }

/* ── Leaderboard ─────────────────────────── */

.lb-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg);
  border: 3px solid var(--border);
  border-radius: 0;
  padding: 4px;
}
.lb-tab {
  flex: 1;
  border: none;
  background: transparent;
  height: 36px;
  border-radius: 0;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: inherit;
}
.lb-tab.is-active {
  background: var(--c-pink);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.lb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 50vh;
  overflow-y: auto;
}
.lb-list li {
  display: grid;
  grid-template-columns: 32px 36px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 6px;
  border-bottom: 2px dashed rgba(26,26,26,0.15);
  font-size: 14px;
}
.lb-list li.is-me {
  background: var(--c-yellow);
  border: 3px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-bottom: 3px solid var(--border);
  padding: 8px;
  margin: 4px 0;
}
.lb-rank {
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 16px;
}
.lb-avatar {
  width: 32px; height: 32px;
  border-radius: 0;
  border: 2px solid var(--border);
  background: #eef2f5;
  background-size: cover;
  background-position: center;
  image-rendering: pixelated;
}
.lb-name {
  font-weight: 700;
  color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: 0.3px;
}
.lb-score {
  font-weight: 700;
  color: var(--c-pink);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 16px;
}

.lb-me {
  margin-top: 6px;
  padding: 10px;
  background: var(--c-yellow);
  border: 3px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-radius: 0;
  font-size: 14px;
  text-align: center;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.3px;
}
.lb-me.hidden { display: none; }
.lb-empty {
  padding: 18px 8px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ── Telegram theme overrides (pixel-pop day/night) ────────────── */

body.tg-light {
  --bg:         #fffbe6;
  --bg-alt:     #ffe98a;
  --ink:        #1a1a1a;
  --ink-soft:   #5a5a5a;
  --card-bg:    #ffffff;
  --hint-color: #1a1a1a;
  --pill-bg:    #1a1a1a;
  --border:     #1a1a1a;
  --shadow-c:   #1a1a1a;
  --shadow:     4px 4px 0 0 var(--shadow-c);
  --shadow-sm:  2px 2px 0 0 var(--shadow-c);
  --shadow-lg:  6px 6px 0 0 var(--shadow-c);
}

body.tg-dark {
  --bg:         #0f0f1a;
  --bg-alt:     #1a1a2e;
  --ink:        #ffffff;
  --ink-soft:   #b8b8c8;
  --card-bg:    #15151f;
  --hint-color: #ffffff;
  --pill-bg:    #15151f;
  --border:     #ffffff;
  --shadow-c:   #ffffff;
  --shadow:     4px 4px 0 0 var(--shadow-c);
  --shadow-sm:  2px 2px 0 0 var(--shadow-c);
  --shadow-lg:  6px 6px 0 0 var(--shadow-c);
}
body.tg-dark .modal-card { background: var(--card-bg); color: var(--ink); }
body.tg-dark .lb-tabs { background: var(--bg-alt); border-color: var(--border); }
body.tg-dark .lb-tab { color: var(--ink-soft); }
body.tg-dark .lb-tab.is-active { background: var(--c-pink); color: #ffffff; }
body.tg-dark .lb-list li { border-bottom-color: rgba(255,255,255,0.18); }
body.tg-dark .lb-list li.is-me { background: var(--c-purple); color: #ffffff; border-color: var(--border); }
body.tg-dark .lb-rank, body.tg-dark .lb-name { color: #ffffff; }
body.tg-dark .lb-list li.is-me .lb-rank,
body.tg-dark .lb-list li.is-me .lb-name { color: #ffffff; }
body.tg-dark .lb-list li.is-me .lb-score { color: var(--c-yellow); }
body.tg-dark .lb-me { background: var(--c-purple); color: #ffffff; }

/* ──────────────────────────────────────────
   Main menu (screen-menu)
   ────────────────────────────────────────── */

.screen {
  position: fixed;
  inset: 0;
  z-index: 6;
  background: var(--bg);              /* opaque — hides the 3D scene */
  padding:
    calc(var(--tg-safe-top)    + var(--tg-header-offset))
    calc(var(--tg-safe-right)  + 16px)
    calc(var(--tg-safe-bottom) + 16px)
    calc(var(--tg-safe-left)   + 16px);
  overflow-y: auto;
  display: flex;
  align-items: stretch;
  justify-content: center;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.screen-hidden {
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
}

.menu-scroll {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.2dvh, 14px);
}
/* On the menu screen, keep everything inside the viewport — no scroll.
   `dvh` reacts to the dynamic viewport (Telegram WebView resizes when its
   bottom bar collapses), unlike `vh` which is locked at the largest size. */
#screen-menu { overflow: hidden; }
#screen-menu .menu-scroll {
  height: 100%;
  justify-content: flex-start;
}

/* ── Profile card (avatar + name + id).
   On short screens it switches to a horizontal layout via media query below. */
.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(2px, 0.5dvh, 6px);
  background: var(--c-yellow);
  border: 3px solid var(--border);
  box-shadow: var(--shadow);
  padding: clamp(6px, 1.4dvh, 14px) 14px clamp(6px, 1.2dvh, 12px);
  position: relative;
  flex-shrink: 0;
}
body.tg-dark .profile-card { background: var(--c-purple); }

.avatar-frame {
  position: relative;
  width: clamp(44px, 7dvh, 64px);
  height: clamp(44px, 7dvh, 64px);
  border-radius: 0;
  padding: 0;
  background: var(--ink);
  border: 3px solid var(--border);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.avatar-frame--big {
  width: clamp(56px, 9dvh, 84px);
  height: clamp(56px, 9dvh, 84px);
  padding: 0;
}
.avatar-img {
  width: 100%; height: 100%;
  border-radius: 0;
  background: #d8e0e8 center/cover no-repeat;
  display: grid; place-items: center;
  color: #1a1a1a;
  font-weight: 700;
  font-size: clamp(20px, 4dvh, 32px);
  font-family: inherit;
  image-rendering: pixelated;
}
.avatar--initial { color: #fff; }

.profile-name {
  color: var(--ink);
  font-size: clamp(14px, 2.4dvh, 20px);
  font-weight: 700;
  letter-spacing: 0.4px;
  text-align: center;
  text-transform: uppercase;
  line-height: 1.1;
  margin: 0;
}
body.tg-dark .profile-card .profile-name { color: #fff; }
.profile-id {
  color: var(--ink);
  opacity: 0.7;
  font-size: clamp(9px, 1.2dvh, 11px);
  font-weight: 500;
  letter-spacing: 0.5px;
}
body.tg-dark .profile-card .profile-id { color: #fff; opacity: 0.85; }

/* ── Stats card ── */
.stats-card {
  background: var(--card-bg);
  border: 3px solid var(--border);
  border-radius: 0;
  padding: clamp(2px, 0.4dvh, 6px) clamp(8px, 1.5vw, 14px);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
body.tg-dark .stats-card { background: var(--card-bg); }

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(4px, 0.9dvh, 11px) 2px;
  font-size: clamp(14px, 2dvh, 18px);
  color: var(--ink-soft);
  border-bottom: 2px dashed rgba(26,26,26,0.18);
  flex: 1 1 0;
  min-height: 0;
}
.stats-row:last-child { border-bottom: none; }
body.tg-dark .stats-row { color: var(--ink-soft); border-bottom-color: rgba(255,255,255,0.18); }

.stats-label {
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}
.stats-value {
  font-weight: 700;
  font-size: clamp(16px, 2.6dvh, 22px);
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
  padding-left: 8px;
}
body.tg-dark .stats-value { color: #ffffff; }
.rank--gold   { color: var(--c-yellow) !important; }
.rank--silver { color: var(--ink-soft) !important; }

/* ── Menu buttons: cubic 3D tiles with right + bottom faces drawn as
       black-outlined slabs via ::before / ::after.
       Defaults to the pink CTA palette; secondary buttons override the vars. */
.menu-actions {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.6dvh, 18px);
  flex-shrink: 0;
  /* No horizontal padding — buttons + their offset shadow line up exactly
     with the profile-card and stats-card sitting above them. */
}
.menu-btn {
  --cube-face-r: var(--c-pink-d);
  --cube-face-b: var(--c-pink-d);
  --cube-fill:   var(--c-pink);
  --cube-fg:     #ffffff;
  --cube-depth:  clamp(4px, 0.8dvh, 8px);

  height: clamp(36px, 5.5dvh, 52px);
  border-radius: 0;
  border: 3px solid var(--c-cube-edge);
  background: var(--cube-fill);
  color: var(--cube-fg);
  font-family: inherit;
  font-weight: 700;
  font-size: clamp(12px, 1.8dvh, 16px);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.07s ease-out;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 1;     /* establish stacking context for negative-z pseudo faces */
  flex-shrink: 0;
}
/* 3D-cube faces — right + bottom slabs in the darker tone of the button
   colour, with the same black outline. Matches the game-over .play-btn style
   for visual consistency. */
.menu-btn::after {
  content: "";
  position: absolute;
  top: 4px;
  right: calc(-1 * var(--cube-depth) - 3px);
  width: var(--cube-depth);
  height: 100%;
  background: var(--cube-face-r);
  border: 3px solid var(--c-cube-edge);
  border-left: none;
  z-index: -1;
  pointer-events: none;
}
.menu-btn::before {
  content: "";
  position: absolute;
  bottom: calc(-1 * var(--cube-depth) - 3px);
  left: 4px;
  width: 100%;
  height: var(--cube-depth);
  background: var(--cube-face-b);
  border: 3px solid var(--c-cube-edge);
  border-top: none;
  z-index: -1;
  pointer-events: none;
}
.menu-btn:active {
  transform: translate(var(--cube-depth), var(--cube-depth));
}
.menu-btn:active::before,
.menu-btn:active::after { opacity: 0; }
/* "Играть" — slightly taller and bolder than the secondary buttons so it
   reads as the main call to action. Width and font scale stay in sync. */
.menu-btn--primary {
  font-weight: 800;
  letter-spacing: 1.2px;
  height: clamp(44px, 6.5dvh, 60px);
  font-size: clamp(13px, 2dvh, 17px);
}
body.tg-dark .menu-btn { color: var(--cube-fg); }
body.tg-dark .menu-btn--primary { color: #ffffff; }

/* Color-coded secondary buttons via :nth-of-type for visual rhythm. */
.menu-actions .menu-btn:nth-of-type(2) {
  --cube-face-r: var(--c-yellow-d);
  --cube-face-b: var(--c-yellow-d);
  --cube-fill:   var(--c-yellow);
  --cube-fg:     #1a1a1a;
}
.menu-actions .menu-btn:nth-of-type(3) {
  --cube-face-r: var(--c-purple-d);
  --cube-face-b: var(--c-purple-d);
  --cube-fill:   var(--c-purple);
  --cube-fg:     #ffffff;
}
.menu-actions .menu-btn:nth-of-type(4) {
  --cube-face-r: var(--c-green-d);
  --cube-face-b: var(--c-green-d);
  --cube-fill:   var(--c-green);
  --cube-fg:     #1a1a1a;
}
.menu-actions .menu-btn:nth-of-type(5) {
  --cube-face-r: var(--c-cyan-d);
  --cube-face-b: var(--c-cyan-d);
  --cube-fill:   var(--c-cyan);
  --cube-fg:     #ffffff;
}

/* On short screens: collapse profile-card to a horizontal strip (avatar + name
   side-by-side), hide ID. Frees ~60–80 px for the stats card. */
@media (max-height: 720px) {
  .profile-card {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    text-align: left;
  }
  .profile-card .profile-name {
    flex: 1 1 auto;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .profile-id { display: none; }
  .avatar-frame--big {
    width: 48px;
    height: 48px;
  }
  .avatar-img { font-size: 22px; }
}

/* Very short screens (older Androids, landscape): trim more aggressively. */
@media (max-height: 620px) {
  .stats-row {
    padding: 3px 2px;
    font-size: 13px;
  }
  .stats-value { font-size: 15px; }
  .menu-btn { height: 36px; font-size: 12px; }
  .menu-btn--primary { height: 40px; font-size: 14px; }
  .menu-actions { gap: 7px; }
}

/* ──────────────────────────────────────────
   Game over: PB banner + rank delta
   ────────────────────────────────────────── */

.pb-banner {
  text-align: center;
  background: var(--c-yellow);
  color: #1a1a1a;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 10px 12px;
  border: 3px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-radius: 0;
  animation: pop 0.4s cubic-bezier(.34,1.56,.64,1);
}
.pb-banner.hidden { display: none; }
@keyframes pop {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}

.rank-delta {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 6px 0;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.rank-delta.hidden { display: none; }
.rank-delta--up { color: var(--c-mint); }

/* ──────────────────────────────────────────
   Leaderboard additions
   ────────────────────────────────────────── */

.lb-header {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  gap: 8px;
}
.lb-header h2 {
  margin: 0;
  grid-column: 2;
  text-align: center;
  min-width: 0;
  /* Sits between two 32px buttons, so it gets a slightly smaller responsive
     size and is allowed to wrap rather than truncate — the title is never cut
     off on any device (Android/iPhone/large fonts). */
  font-size: clamp(15px, 5vw, 24px);
  letter-spacing: 0.3px;
  line-height: 1.05;
  white-space: normal;
  overflow-wrap: break-word;
}
.lb-refresh {
  grid-column: 3;
  width: 32px; height: 32px;
  border-radius: 0;
  border: 3px solid var(--border);
  background: var(--c-cyan);
  font-size: 16px; font-weight: 700;
  color: #1a1a1a;
  cursor: pointer;
  box-shadow: 2px 2px 0 0 var(--shadow-c);
  font-family: inherit;
  justify-self: end;
  transition: transform 0.06s ease-out, box-shadow 0.06s ease-out;
}
.lb-refresh:active { transform: translate(2px, 2px); box-shadow: 0 0 0 0 var(--shadow-c); }
body.tg-dark .lb-refresh { background: var(--c-cyan); color: #1a1a1a; }

.lb-list li { cursor: pointer; }
.lb-list li.is-me { cursor: default; }

.lb-subtitle {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-top: -4px;
}
body.tg-dark .lb-subtitle { color: var(--ink-soft); }

.lb-skel {
  height: 44px;
  background: linear-gradient(90deg, var(--bg-alt) 0%, var(--card-bg) 50%, var(--bg-alt) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  border: 2px solid var(--border);
  border-radius: 0;
  margin: 4px 0;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
body.tg-dark .lb-skel {
  background: linear-gradient(90deg, var(--bg-alt) 0%, var(--card-bg) 50%, var(--bg-alt) 100%);
  background-size: 200% 100%;
}

/* ──────────────────────────────────────────
   Avatar picker
   ────────────────────────────────────────── */

.ap-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 4px 0;
}
.ap-cell {
  position: relative;
  border: 3px solid var(--border);
  background: var(--card-bg);
  padding: 0;
  cursor: pointer;
  border-radius: 0;
  box-shadow: 2px 2px 0 0 var(--shadow-c);
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out, border-color 0.08s ease-out;
  font-family: inherit;
}
.ap-cell:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 0 var(--shadow-c);
}
.ap-cell.is-selected {
  border-color: var(--c-green);
  box-shadow:
    0 0 0 3px var(--c-green),
    4px 4px 0 0 var(--shadow-c);
  transform: translate(-1px, -1px);
}
/* Big checkmark badge in the corner — unmistakable "selected" signal. */
.ap-cell.is-selected::after {
  content: "✓";
  position: absolute;
  top: -10px;
  right: -10px;
  width: 24px;
  height: 24px;
  background: var(--c-green);
  border: 3px solid var(--c-cube-edge);
  color: #1a1a1a;
  font-weight: 900;
  font-size: 14px;
  line-height: 18px;
  text-align: center;
  z-index: 2;
  box-shadow: 2px 2px 0 0 var(--c-cube-edge);
}
.ap-cell img {
  width: 100%; aspect-ratio: 1; display: block; border-radius: 0;
  image-rendering: pixelated;
}

.ap-or {
  text-align: center;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 12px;
  margin: 6px 0;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.ap-error {
  color: var(--c-red);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  padding: 6px;
  letter-spacing: 0.4px;
}
.ap-error.hidden { display: none; }

/* Crop modal */
.crop-wrap {
  position: relative;
  width: 280px; height: 280px;
  margin: 0 auto;
  border: 3px solid var(--border);
  box-shadow: var(--shadow-sm);
}
#crop-canvas {
  width: 280px; height: 280px;
  background: #000;
  border-radius: 0;
  cursor: grab;
  touch-action: none;
  display: block;
}
.crop-circle {
  position: absolute; inset: 0;
  pointer-events: none;
  border-radius: 0;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.65);
  clip-path: inset(20px 20px 20px 20px);
  background: transparent;
}
.crop-controls { padding: 8px 0; }
.crop-controls input[type=range] {
  width: 100%;
  accent-color: var(--c-pink);
  height: 24px;
}

/* ──────────────────────────────────────────
   Onboarding
   ────────────────────────────────────────── */

#onboarding {
  background: var(--c-purple);
}
.onb-card {
  width: 100%;
  max-width: 360px;
  padding: 24px 20px;
  background: var(--card-bg);
  border: 3px solid var(--border);
  border-radius: 0;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  color: var(--ink);
}
.onb-stage {
  width: 100%;
  position: relative;
  min-height: 180px;
  touch-action: pan-y;
}
.onb-slide {
  text-align: center;
  position: absolute; inset: 0;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.onb-slide.is-active { opacity: 1; transform: none; }
.onb-icon {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 12px;
  display: inline-block;
  background: var(--c-yellow);
  border: 3px solid var(--border);
  padding: 6px 12px;
  box-shadow: var(--shadow-sm);
}
.onb-slide h3 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ink);
}
.onb-slide p  {
  margin: 0;
  opacity: 0.85;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-soft);
}
body.tg-dark .onb-slide h3 { color: #ffffff; }
body.tg-dark .onb-slide p  { color: var(--ink-soft); }

.onb-dots {
  display: flex; gap: 8px;
}
.onb-dots span {
  width: 12px; height: 12px;
  border-radius: 0;
  border: 2px solid var(--border);
  background: var(--bg);
  transition: background 0.2s ease, transform 0.2s ease;
}
.onb-dots span.is-active { background: var(--c-pink); }

.onb-actions { display: flex; gap: 10px; width: 100%; }
.onb-actions .play-btn  { flex: 1; max-width: none; }
.onb-actions .ghost-btn { flex: 0 0 auto; }

/* ──────────────────────────────────────────
   Public user profile
   ────────────────────────────────────────── */
#user-profile .modal-card { align-items: center; }
.up-avatar { margin-bottom: 4px; }

/* ──────────────────────────────────────────
   Toast
   ────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%; bottom: calc(var(--tg-safe-bottom) + 90px);
  transform: translateX(-50%);
  background: var(--ink);
  color: #ffffff;
  padding: 10px 16px;
  border: 3px solid var(--border);
  border-radius: 0;
  box-shadow: var(--shadow-sm);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-size: 13px;
  z-index: 30;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.hidden { opacity: 0; pointer-events: none; transform: translate(-50%, 8px); }
.toast--info { }
.toast--error { background: var(--c-red); color: #ffffff; }
.toast--success { background: var(--c-green); color: #1a1a1a; }
body.tg-dark .toast { background: var(--card-bg); border-color: var(--border); }

/* ──────────────────────────────────────────
   Menu badge (active promocode count)
   ────────────────────────────────────────── */
.menu-btn { position: relative; }
.menu-badge {
  display: inline-block;
  margin-left: 8px;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 0;
  border: 2px solid var(--border);
  background: var(--c-pink);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  line-height: 20px;
  vertical-align: middle;
  box-shadow: 2px 2px 0 0 var(--shadow-c);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.menu-badge.hidden { display: none; }

/* Inline round buttons inside screen headers */
.round-btn--inline { box-shadow: none; background: transparent; }
body.tg-dark .round-btn--inline svg path,
body.tg-dark .round-btn--inline svg polyline { stroke: #ec5e8a; }

/* ──────────────────────────────────────────
   Chest reveal
   ────────────────────────────────────────── */

#chest .chest-stage {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px;
  position: relative;
}

.chest-sparks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}
.spark {
  position: absolute;
  top: 0;
  width: 6px; height: 6px;
  border-radius: 0;
  opacity: 0;
  animation: spark-float 2.4s linear infinite;
  filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.4));
}
@keyframes spark-float {
  0%   { transform: translateY(40%) scale(0.4); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: translateY(180px) scale(1.2); opacity: 0; }
}

.burst {
  position: absolute;
  left: 50%; top: 50%;
  width: 10px; height: 10px;
  border-radius: 0;
  transform: translate(-50%, -50%);
  animation: burst-fly 1s cubic-bezier(.2,.8,.2,1) forwards;
}
@keyframes burst-fly {
  0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1); opacity: 0; }
}

.chest-box {
  width: 220px;
  height: 200px;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 14px 24px rgba(0, 0, 0, 0.45));
}
.chest-svg { width: 100%; height: 100%; display: block; overflow: visible; }
/* Clean "pop the lid" — slides straight up while fading + scaling out.
   No 3D, no rotation, no hinge. The lid just lifts off cleanly. */
.chest-lid {
  transform-origin: 50% 100%;
  transition:
    transform 0.55s cubic-bezier(0.4, 0, 0.2, 1),
    opacity   0.35s ease-out 0.1s;
  will-change: transform, opacity;
}
.chest-box.is-open .chest-lid {
  transform: translateY(-80px) scale(1.05);
  opacity: 0;
}

.chest-svg { shape-rendering: crispEdges; }
.chest-lid-fill, .chest-body-fill { stroke: #1a1a1a; stroke-width: 2; stroke-linejoin: miter; }
.chest-body-band { fill: rgba(0,0,0,0.32); }
.chest-keyhole   { fill: #1a1a1a; }
.chest-lock      { fill: #ffd538; stroke: #1a1a1a; stroke-width: 2; }

/* Tier palettes */
.chest--silver   .chest-lid-fill,
.chest--silver   .chest-body-fill { fill: url(#chest-grad-silver); }
.chest--gold     .chest-lid-fill,
.chest--gold     .chest-body-fill { fill: url(#chest-grad-gold); }
.chest--platinum .chest-lid-fill,
.chest--platinum .chest-body-fill { fill: url(#chest-grad-platinum); }

/* Fallback solid colours for inline SVG (pixel-pop saturated). */
.chest--silver   .chest-lid-fill, .chest--silver   .chest-body-fill { fill: #cfd8dc; }
.chest--gold     .chest-lid-fill, .chest--gold     .chest-body-fill { fill: #ffc83d; }
.chest--platinum .chest-lid-fill, .chest--platinum .chest-body-fill { fill: #3db7e0; }

.chest--gold     { animation: chest-glow-gold     2s ease-in-out infinite; }
.chest--platinum { animation: chest-glow-platinum 1.8s ease-in-out infinite; }

@keyframes chest-glow-gold {
  0%, 100% { filter: drop-shadow(0 14px 24px rgba(0,0,0,0.45)) drop-shadow(0 0 12px rgba(246, 211, 106, 0.6)); }
  50%      { filter: drop-shadow(0 14px 24px rgba(0,0,0,0.45)) drop-shadow(0 0 28px rgba(246, 211, 106, 1.0)); }
}
@keyframes chest-glow-platinum {
  0%, 100% { filter: drop-shadow(0 14px 24px rgba(0,0,0,0.45)) drop-shadow(0 0 18px rgba(155, 232, 255, 0.7)); }
  50%      { filter: drop-shadow(0 14px 24px rgba(0,0,0,0.45)) drop-shadow(0 0 36px rgba(234, 109, 255, 1.0)); }
}

@keyframes chest-drop {
  0%   { transform: translateY(-200px) scale(0.5) rotate(-15deg); opacity: 0; }
  60%  { transform: translateY(20px)   scale(1.05) rotate(2deg);  opacity: 1; }
  100% { transform: translateY(0)      scale(1) rotate(0); }
}
@keyframes chest-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px) rotate(-1.5deg); }
  75% { transform: translateX(6px)  rotate(1.5deg); }
}

/* Tier title above the chest ("Серебряный сундук!" etc.) — hidden by request.
   The chest visual + colour already communicate the tier. */
.chest-title { display: none; }
.chest-open-btn {
  width: 220px !important;
  max-width: 220px !important;
  animation: chest-pulse 1.4s ease-in-out infinite;
}
@keyframes chest-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}

/* ──────────────────────────────────────────
   Discount card
   ────────────────────────────────────────── */

#card-reveal .card-stage {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 16px;
}
.card-back-btn {
  position: absolute;
  top: calc(var(--tg-safe-top) + var(--tg-header-offset));
  left: calc(var(--tg-safe-left) + 14px);
  width: 46px; height: 46px;
  border-radius: 0;
  border: 3px solid #ffffff;
  background: #1a1a1a;
  display: grid; place-items: center;
  cursor: pointer;
  z-index: 5;
  box-shadow: 3px 3px 0 0 #ffffff;
  transition: transform 0.06s ease-out, box-shadow 0.06s ease-out;
}
.card-back-btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 0 #ffffff; }
.card-actions {
  display: flex;
  gap: 10px;
  flex-direction: column;
  width: 100%;
}
/* Match the discount-card's exact width — no more, no less. */
#card-reveal .card-actions .play-btn {
  width: 100%;
  max-width: none;
  flex: 0 0 auto;
}

.discount-card {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  perspective: 1200px;
  cursor: pointer;
  /* Slightly lighter than black (dark slate) so the shadow reads as its own
     layer and separates from the card's black border. */
  filter: drop-shadow(6px 6px 0 #3b3a4a);
}
.discount-card--enter { animation: card-enter 0.5s cubic-bezier(.34,1.56,.64,1); }
@keyframes card-enter {
  0%   { transform: translateY(40px) scale(0.7); opacity: 0; }
  100% { transform: translateY(0)    scale(1);   opacity: 1; }
}

/* Pixel-pop serial number — "#7919" style. Lives in the FRONT face as a real
   DOM element (not a ::after pseudo), because iOS Safari does not propagate
   backface-visibility to absolutely-positioned pseudo-elements inside a 3D
   flip — the badge would bleed through the back face mirrored. A real
   element respects backface-visibility reliably across browsers. */
.dc-serial {
  position: absolute;
  bottom: 12px; right: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #1a1a1a;
  background: rgba(255,255,255,0.85);
  padding: 2px 6px;
  border: 2px solid #1a1a1a;
  z-index: 2;
  pointer-events: none;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translateZ(1px);   /* push slightly forward in 3D space */
  transition: opacity 0.2s ease-out;
}
/* Belt-and-braces: explicitly hide the serial when the card is flipped to
   the back, in case iOS Safari ignores backface-visibility. */
.discount-card.is-flipped .dc-serial {
  opacity: 0;
  visibility: hidden;
}

.dc-flip {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(.5,.15,.2,1);
  transform-style: preserve-3d;
}
.discount-card.is-flipped .dc-flip { transform: rotateY(180deg); }

.dc-face {
  position: absolute; inset: 0;
  border-radius: 0;
  overflow: hidden;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 4px solid #1a1a1a;
}
.dc-face--back { transform: rotateY(180deg); padding: 18px; gap: 10px; align-items: center; justify-content: center; text-align: center; }

/* Tier-coloured halftone frame around the image (CHECKPOINT 2025 vibe).
   We tint .dc-face background with a saturated solid + halftone overlay,
   so the image area sits inside a colored "card" zone. */
.discount-card--silver   .dc-face {
  background:
    radial-gradient(circle, rgba(0,0,0,0.18) 1px, transparent 1.4px) 0 0 / 8px 8px,
    #cfd8dc;
}
.discount-card--gold     .dc-face {
  background:
    radial-gradient(circle, rgba(0,0,0,0.22) 1px, transparent 1.4px) 0 0 / 8px 8px,
    #ffc83d;
}
.discount-card--platinum .dc-face {
  background:
    radial-gradient(circle, rgba(0,0,0,0.20) 1px, transparent 1.4px) 0 0 / 8px 8px,
    #ff1f8b;
}
.discount-card--top10 .dc-face {
  background:
    radial-gradient(circle, rgba(255,255,255,0.22) 1px, transparent 1.4px) 0 0 / 8px 8px,
    linear-gradient(135deg, #ffb347, #ff5e8a);
}

.dc-top {
  flex: 0 0 auto;
  background: #1a1a1a;
  color: #ffffff;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 4px solid #1a1a1a;
}
.dc-top .dc-status-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.95;
}
.dc-timer--big {
  font-family: ui-monospace, "SF Mono", "Menlo", "Roboto Mono", monospace;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  color: #ffffff;
}

.dc-image {
  flex: 1 1 auto;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: transparent;
  margin: 14px;
  image-rendering: pixelated;
}
.dc-meta {
  flex: 0 0 auto;
  padding: 10px 14px 14px;
  background: #ffffff;
  border-top: 4px solid #1a1a1a;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dc-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Decorative pixel "footer icons" mimicking Snail/CHECKPOINT footer row.
   Four small filled squares — pure CSS, no data dependency.
   Hidden in the list previews (.promo-slot) where vertical space is tight;
   visible in the centered modal / reveal view. */
.dc-meta::after {
  content: "";
  display: block;
  height: 12px;
  margin-top: 6px;
  background:
    linear-gradient(#1a1a1a, #1a1a1a) left    center / 12px 12px no-repeat,
    linear-gradient(#1a1a1a, #1a1a1a) 26px    center / 12px 12px no-repeat,
    linear-gradient(#1a1a1a, #1a1a1a) 52px    center / 12px 12px no-repeat,
    linear-gradient(#1a1a1a, #1a1a1a) 78px    center / 12px 12px no-repeat;
  opacity: 0.85;
}
.promo-slot .dc-meta::after { display: none; }
.dc-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  color: #1a1a1a;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.dc-dot {
  width: 10px; height: 10px;
  border-radius: 0;
  border: 1px solid #1a1a1a;
  background: #1bd1a5;
  flex: 0 0 auto;
}
.dc-hint-inline {
  font-size: 11px;
  font-weight: 700;
  color: #5a5a5a;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.dc-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.dc-hint {
  font-size: 11px;
  font-weight: 700;
  color: #5a5a5a;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  text-align: center;
  padding: 6px 0 0;
}

/* Tier badge — pixel-pop pill on the dark top bar. */
.dc-tier {
  background: #ffffff;
  color: #1a1a1a;
  padding: 3px 8px;
  border-radius: 0;
  border: 2px solid #ffffff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
}
.discount-card--silver   .dc-tier { background: #cfd8dc; }
.discount-card--gold     .dc-tier { background: #ffc83d; }
.discount-card--platinum .dc-tier { background: #ff1f8b; color: #ffffff; }
.discount-card--top10    .dc-tier { background: linear-gradient(135deg,#ffb347,#ff5e8a); color: #ffffff; }

.dc-burn-badge {
  position: absolute;
  top: 56px; left: 10px;        /* below the .dc-top header */
  background: #e94b5c;
  color: #ffffff;
  padding: 4px 10px;
  border-radius: 0;
  border: 2px solid #1a1a1a;
  box-shadow: 2px 2px 0 0 #1a1a1a;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  z-index: 2;
  animation: burn-pulse 1s ease-in-out infinite;
}
.dc-burn-badge.hidden { display: none; }
@keyframes burn-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

/* Back face */
.dc-back-inner {
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
  width: 100%;
}
.dc-back-label {
  font-size: 11px; font-weight: 700; color: #5a5a5a;
  letter-spacing: 1px; text-transform: uppercase;
}
.dc-code {
  font-family: ui-monospace, "SF Mono", "Menlo", "Roboto Mono", monospace;
  font-size: 22px;
  font-weight: 700;
  color: #1a1a1a;
  background: #ffc83d;
  padding: 12px 14px;
  border-radius: 0;
  border: 3px solid #1a1a1a;
  box-shadow: 2px 2px 0 0 #1a1a1a;
  width: 100%;
  text-align: center;
  word-break: break-all;
  letter-spacing: 1px;
}
.dc-copy {
  border: 3px solid #1a1a1a;
  background: #1bd1a5;
  color: #06382c;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 10px 16px;
  border-radius: 0;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 2px 2px 0 0 #1a1a1a;
  transition: transform 0.06s ease-out, box-shadow 0.06s ease-out;
}
.dc-copy:active { transform: translate(2px, 2px); box-shadow: 0 0 0 0 #1a1a1a; }
.dc-copy:disabled { opacity: 0.5; cursor: not-allowed; background: #d8e0e8; }

/* Pre-activation: big "Use" button replacing the code on the back face */
.dc-activate {
  border: 3px solid #1a1a1a;
  background: #ff1f8b;
  color: #ffffff;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 14px 16px;
  border-radius: 0;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 4px 4px 0 0 #1a1a1a;
  animation: chest-pulse 1.4s ease-in-out infinite;
}
.dc-activate:disabled { opacity: 0.6; cursor: not-allowed; animation: none; }
.dc-warn {
  font-size: 12px;
  line-height: 1.45;
  color: #1a1a1a;
  font-weight: 600;
  text-align: center;
  padding: 4px 6px;
}
body.tg-dark .dc-warn { color: #1a1a1a; }
.dc-instructions {
  font-size: 12px;
  color: #4a5b6e;
  line-height: 1.4;
  text-align: center;
}
.dc-back-timer { color: #4a5b6e; font-size: 13px; }

/* Delete button hidden — users delete cards from another flow (or never). */
.dc-delete { display: none; }

/* Tier badge hidden everywhere (list previews, modal, reveal) for all tiers —
   silver/gold/platinum/top10. The timer gets the whole header to itself, on
   a saturated red pill so the urgency reads even at a glance. */
.dc-tier { display: none; }
/* "Тапни, чтобы открыть" hint on the front face — redundant with the visual
   affordance of the card and the prominent action button. Hide it. */
.dc-face--front .dc-hint { display: none; }
.dc-top  { justify-content: center; }
.dc-timer--big {
  background: var(--c-red, #e94b5c);
  color: #ffffff;
  padding: 4px 12px;
  border: 2px solid #1a1a1a;
  box-shadow: 2px 2px 0 0 #1a1a1a;
  border-radius: 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

/* Expired state */
.discount-card.is-expired {
  filter: grayscale(1);
  opacity: 0.55;
}
.discount-card.is-expired::after {
  content: 'EXPIRED';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-18deg);
  font-weight: 900;
  font-size: 28px;
  letter-spacing: 4px;
  color: rgba(214, 81, 106, 0.9);
  background: rgba(255, 255, 255, 0.85);
  padding: 4px 14px;
  border: 3px solid rgba(214, 81, 106, 0.9);
  pointer-events: none;
  z-index: 4;
}

/* ──────────────────────────────────────────
   Promocodes screen
   ────────────────────────────────────────── */

.promo-scroll {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.promo-header {
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  align-items: center;
}
/* Hide the refresh button — list reloads when the screen opens. */
#promo-refresh { display: none; }
.promo-header h1 {
  margin: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink);
}
.promo-tabs {
  display: flex;
  gap: 6px;
  background: var(--card-bg);
  border: 3px solid var(--border);
  border-radius: 0;
  padding: 4px;
  box-shadow: var(--shadow-sm);
}
body.tg-dark .promo-tabs { background: var(--card-bg); }
.promo-tab {
  flex: 1;
  border: none;
  background: transparent;
  height: 38px;
  border-radius: 0;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: inherit;
}
body.tg-dark .promo-tab { color: var(--ink-soft); }
.promo-tab.is-active {
  background: var(--c-pink);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}
body.tg-dark .promo-tab.is-active { background: var(--c-pink); color: #ffffff; }

.promo-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding-bottom: 24px;
}
.promo-slot { width: 100%; }

/* Preview tiles in the grid open the card centered on tap. */
.discount-card--preview { cursor: pointer; }
.discount-card--preview:active { transform: scale(0.97); transition: transform .08s ease; }

/* ──────────────────────────────────────────
   Centered promo-card modal
   ────────────────────────────────────────── */
.promo-modal {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.promo-modal.hidden { display: none; }
.promo-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(10, 12, 20, 0.74);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.promo-modal-card {
  position: relative; z-index: 1;
  width: min(80vw, 320px, 56vh);   /* cap by height too so it never overflows */
}
.promo-modal-card .discount-card { width: 100%; }
.promo-modal-close {
  position: absolute; z-index: 2;
  top: calc(var(--tg-safe-top, 0px) + var(--tg-header-offset));
  right: 16px;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid #1a1a1a;
  background: #ffffff; color: #1a1a1a;
  font-size: 18px; font-weight: 800; line-height: 1;
  cursor: pointer;
  box-shadow: 3px 3px 0 #1a1a1a;
}
.promo-modal-close:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #1a1a1a; }
body.promo-modal-open { overflow: hidden; }

.promo-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--hint-color);
  opacity: 0.7;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.6;
}
.promo-empty.hidden { display: none; }

.promo-skel {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: linear-gradient(90deg, var(--bg-alt) 0%, var(--card-bg) 50%, var(--bg-alt) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  border: 3px solid var(--border);
  border-radius: 0;
  box-shadow: var(--shadow-sm);
}
body.tg-dark .promo-skel {
  background: linear-gradient(90deg, var(--bg-alt) 0%, var(--card-bg) 50%, var(--bg-alt) 100%);
  background-size: 200% 100%;
}

/* ──────────────────────────────────────────
   Combo indicator (×2, ×3, …)
   ────────────────────────────────────────── */

.combo {
  position: fixed;
  top: calc(var(--tg-safe-top) + var(--tg-header-offset) + 80px);
  left: 50%;
  transform: translate(-50%, 0);
  font-weight: 700;
  font-size: 44px;
  letter-spacing: 2px;
  z-index: 11;
  pointer-events: none;
  background: var(--c-pink);
  color: #ffffff;
  border: 4px solid var(--border);
  padding: 4px 18px 2px;
  box-shadow: 6px 6px 0 0 var(--shadow-c);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.combo.is-visible {
  opacity: 1;
  visibility: visible;
}
.combo.is-pop {
  animation: combo-pop 0.45s cubic-bezier(.34,1.56,.64,1);
}
@keyframes combo-pop {
  0%   { transform: translate(-50%, 10px) scale(0.55); }
  60%  { transform: translate(-50%, -2px) scale(1.25); }
  100% { transform: translate(-50%, 0)    scale(1); }
}

/* ──────────────────────────────────────────
   Pixel-pop utilities (used by all stages 2–6)
   ────────────────────────────────────────── */

.px-card {
  background: var(--card-bg);
  border: 3px solid var(--border);
  border-radius: 0;
  box-shadow: var(--shadow);
  color: var(--ink);
}

.px-btn {
  appearance: none;
  -webkit-appearance: none;
  border: 3px solid var(--border);
  border-radius: 0;
  background: var(--card-bg);
  color: var(--ink);
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.06s ease-out, box-shadow 0.06s ease-out;
  -webkit-tap-highlight-color: transparent;
}
.px-btn:active {
  transform: translate(3px, 3px);
  box-shadow: var(--shadow-sm);
}

.px-shadow   { box-shadow: var(--shadow); }
.px-shadow-sm{ box-shadow: var(--shadow-sm); }
.px-shadow-lg{ box-shadow: var(--shadow-lg); }

/* .halftone-bg removed — halftone pattern dropped from layout backgrounds. */

/* Pixel-edge corner cut — small triangle "notch" used on cards/buttons. */
.px-notch {
  clip-path: polygon(
    8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px),
    calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px
  );
}

/* Solid-color tile (CTAs, badges) — keeps the same border + offset shadow. */
.px-tile--pink   { background: var(--c-pink);   color: #fff; }
.px-tile--yellow { background: var(--c-yellow); color: #1a1a1a; }
.px-tile--orange { background: var(--c-orange); color: #1a1a1a; }
.px-tile--red    { background: var(--c-red);    color: #fff; }
.px-tile--green  { background: var(--c-green);  color: #1a1a1a; }
.px-tile--cyan   { background: var(--c-cyan);   color: #1a1a1a; }
.px-tile--purple { background: var(--c-purple); color: #fff; }
.px-tile--mint   { background: var(--c-mint);   color: #06382c; }

/* Mono digits for tabular numbers (timers, score, codes) */
.mono {
  font-family: ui-monospace, "SF Mono", Menlo, "Roboto Mono", monospace;
  font-variant-numeric: tabular-nums;
}

/* ─────────── Telegram-only gate ─────────── */
.tg-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: #0f0f1a;
  padding: 24px;
}
.tg-gate.hidden { display: none; }
.tg-gate-card {
  width: 100%;
  max-width: 340px;
  background: var(--card-bg);
  border: 3px solid var(--border);
  padding: 28px 22px;
  box-shadow: var(--shadow-lg);
  color: var(--ink);
  text-align: center;
}
.tg-gate-icon { font-size: 52px; line-height: 1; margin-bottom: 8px; }
.tg-gate-card h2 {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.tg-gate-card p {
  margin: 0;
  font-size: 19px;
  line-height: 1.4;
  color: var(--ink-soft);
}

