/* O'yin ekrani: Telegram oynasini to'liq egallaydi, hech qachon aylanmaydi (scroll yo'q).
   Tuzilma: .screen > .topbar · .stats-row · .stage (surish maydoni) · .toolbar, ustida .sheet va .result */

html.game-page, html.game-page body { height: 100%; overflow: hidden; overscroll-behavior: none; }
/* position:fixed stops iOS rubber-band scrolling of the whole page */
html.game-page body { position: fixed; inset: 0; width: 100%; }

.screen {
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-inline: max(12px, env(safe-area-inset-left, 0px));
  padding-top: calc(8px + var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px));
  padding-bottom: calc(10px + var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)) + var(--tg-content-safe-area-inset-bottom, 0px));
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  position: relative;
}
html.in-tg .screen { height: var(--tg-viewport-stable-height, 100dvh); }
.screen button { touch-action: manipulation; }

/* Top bar */
.topbar { flex: none; display: flex; align-items: center; gap: 8px; min-height: 40px; }
.topbar .home {
  flex: none; display: grid; place-items: center; width: 32px; height: 40px;
  color: var(--muted); text-decoration: none; font-size: 20px;
}
.topbar .title {
  flex: 1; min-width: 0; margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--f-display); font-weight: 400; font-size: 1.45rem; line-height: 1.2;
  letter-spacing: .04em; text-transform: uppercase;
}
.icon-btn {
  flex: none; width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; padding: 0;
}
.icon-btn svg, .tool svg { width: 22px; height: 22px; }

/* Stat chips */
.stats-row { flex: none; display: flex; gap: 6px; }
.chip {
  flex: 1 1 0; min-width: 0; display: grid; gap: 1px;
  padding: 6px 10px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--line);
}
.chip .k {
  font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip .v {
  font: 500 1.15rem/1.2 var(--f-mono); font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* The play area: everything inside responds to swipes, so the browser must not pan or zoom it */
.stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
  touch-action: none;
}

/* Bottom toolbar: large thumb-sized targets */
.toolbar { flex: none; display: flex; justify-content: center; gap: 8px; }
.tool {
  flex: 1 1 0; max-width: 130px; min-height: 54px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 600 12px/1.1 var(--f-body); cursor: pointer; padding: 6px 4px;
}
.tool:disabled { opacity: .45; cursor: default; }
.tool[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.tool:active:not(:disabled), .icon-btn:active { transform: scale(.96); }

/* First-run hint over the stage */
.hint-pill {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  pointer-events: none; z-index: 4;
  animation: hint-nudge 1.6s ease-in-out infinite;
}
@keyframes hint-nudge {
  0%, 100% { transform: translateX(-50%); }
  50% { transform: translateX(calc(-50% + 8px)); }
}

/* Result card (win / game over), laid over the stage */
.result {
  position: absolute; inset: 0; z-index: 6;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 16px; text-align: center; overflow: auto;
  background: var(--veil);
  border-radius: 6px;
}
.result .stamp {
  font-family: var(--f-display);
  font-size: clamp(1.6rem, 8vw, 2.3rem);
  line-height: 1.1; letter-spacing: .08em; text-transform: uppercase;
  color: var(--stamp, var(--done));
  border: 3px solid currentColor;
  padding: 2px 14px 0;
  transform: rotate(-5deg);
  animation: stamp .32s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes stamp {
  from { transform: rotate(-5deg) scale(1.7); opacity: 0; }
  to { transform: rotate(-5deg) scale(1); opacity: 1; }
}
.result h2 { margin: 6px 0 0; font-size: 1.1rem; font-weight: 700; }
.result .line { margin: 0; font-family: var(--f-mono); font-size: 14px; font-variant-numeric: tabular-nums; }
.result .note { margin: 0; color: var(--muted); font-size: 14px; max-width: 30ch; }
.result .actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }
.result .btn { min-height: 44px; }

/* Bottom sheet (level list, settings, help) */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0, 0, 0, .45);
  animation: fade .18s ease-out;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 560px; margin: 0 auto; max-height: 78%;
  overflow: auto; overscroll-behavior: contain; touch-action: pan-y;
  background: var(--surface); color: var(--ink);
  border-radius: 16px 16px 0 0;
  padding: 10px 16px calc(18px + var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .25);
  animation: sheet-up .22s cubic-bezier(.2, .8, .3, 1);
}
.sheet::before {
  content: ''; display: block; width: 40px; height: 4px; border-radius: 2px;
  background: var(--line); margin: 0 auto 12px;
}
.sheet h2 { margin: 0 0 12px; font-size: 1rem; font-weight: 700; }
.sheet .sheet-close { width: 100%; margin-top: 14px; min-height: 46px; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Segmented choice (difficulty, mode) */
.seg { display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.seg button {
  flex: 1; min-height: 38px; border: 0; border-radius: 8px; background: transparent; color: var(--muted);
  font: 600 13px var(--f-body); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px var(--shadow); }

/* ---------- Player: wallet pill, energy sheet, rewards, challenge, toast (shared/player.js) ---------- */
.wallet-pill {
  flex: none; display: inline-flex; align-items: center; gap: 10px;
  min-height: 40px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 600 14px/1 var(--f-mono); font-variant-numeric: tabular-nums; cursor: pointer;
  touch-action: manipulation;
}
.wallet-pill svg { width: 18px; height: 18px; flex: none; }
.wallet-pill .wp-e, .wallet-pill .wp-c { display: inline-flex; align-items: center; gap: 4px; }
.wallet-pill .wp-e svg { color: var(--energy); }
.wallet-pill small { font-size: 11px; font-weight: 500; color: var(--muted); }
.wallet-pill small:empty { display: none; }
.wallet-pill.empty .wp-e b { color: var(--danger); }
.wallet-pill.empty { border-color: var(--energy); }

.energy-sheet { text-align: center; }
.eh-hero { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin-top: 4px; }
.eh-hero svg { width: 40px; height: 40px; align-self: center; color: var(--energy); }
.eh-n { font: 600 2.6rem/1 var(--f-mono); }
.eh-max { font: 500 1.1rem var(--f-mono); color: var(--muted); }
.energy-sheet h2 { margin: 6px 0 4px; }
.eh-note { margin: 0 auto 8px; max-width: 34ch; color: var(--muted); font-size: 14px; }
.eh-next { margin: 0 0 14px; font: 500 14px var(--f-mono); }
.energy-sheet .eh-ad { width: 100%; min-height: 50px; font-size: 15px; }
.eh-adleft { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.eh-adleft:empty { display: none; }

/* YouTube Playables package: no energy, coins or Hovli there, and no links out */
.in-yt .wallet-pill, .in-yt .rw-coins, .in-yt .rw-chest, .in-yt .challenge-btn, .in-yt .no-yt,
.in-yt a[href="../../"] { display: none !important; }

/* Davom etish: the energy sheet's layout, with a blue "carry on" mark */
.cont-sheet { text-align: center; }
.cont-sheet h2 { margin: 6px 0 4px; }
.cont-sheet .eh-hero svg { color: var(--worker); }
.cont-sheet .btn:not(.sheet-close) { width: 100%; min-height: 50px; font-size: 15px; }
.cont-sheet .btn:not(.sheet-close) + .btn:not(.sheet-close) { margin-top: 8px; }

.reward { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 4px; }
.rw {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font: 600 13px var(--f-body);
}
.rw svg { width: 16px; height: 16px; }
.rw-energy svg { color: var(--energy); }
.rw-ch.won { border-color: var(--done); color: var(--done); }
.rw-stage { border-color: var(--done); color: var(--done); }
.rw-off { color: var(--muted); }

.challenge-banner {
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%); z-index: 5;
  max-width: calc(100% - 16px); padding: 6px 12px; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}

.p-toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 40; max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 600; text-align: center;
  animation: fade .2s ease-out;
}

.fake-ad {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px;
  background: rgba(0, 0, 0, .82);
}
.fake-ad-card {
  max-width: 320px; padding: 24px; border-radius: 16px; text-align: center;
  background: var(--surface); color: var(--ink); display: grid; gap: 8px;
}
.fake-ad-card p { margin: 0; color: var(--muted); font-size: 14px; }
.fake-ad-n { font: 600 3rem/1 var(--f-mono); }
