:root {
  --tg-runtime-safe-top: 0px;
  --tg-runtime-safe-bottom: 0px;
  --tg-runtime-stable-height: 100dvh;
  --tg-fallback-top: 18px;
}

html.telegram-webapp {
  --tg-fallback-top: 76px;
}

html.telegram-webapp.telegram-fullscreen {
  --tg-fallback-top: 76px;
}

.app-shell {
  padding-top: max(
    18px,
    env(safe-area-inset-top),
    var(--tg-content-safe-area-inset-top, 0px),
    var(--tg-runtime-safe-top, 0px),
    var(--tg-fallback-top, 18px)
  );
  padding-bottom: max(
    18px,
    env(safe-area-inset-bottom),
    var(--tg-content-safe-area-inset-bottom, 0px),
    var(--tg-runtime-safe-bottom, 0px)
  );
}

html.telegram-webapp .app-shell {
  min-height: var(--tg-runtime-stable-height, 100dvh);
}

html.telegram-webapp.telegram-fullscreen .app-shell {
  padding-top: max(
    18px,
    env(safe-area-inset-top),
    var(--tg-content-safe-area-inset-top, 0px),
    var(--tg-runtime-safe-top, 0px),
    var(--tg-fallback-top, 76px)
  );
}

html.browser-webapp .app-shell {
  padding-top: max(10px, env(safe-area-inset-top));
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  gap: 10px;
}

html.browser-webapp .topbar { min-height: 50px; }

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

.sound-toggle {
  width: 38px;
  height: 38px;
  border: 1px solid #2a3039;
  border-radius: 11px;
  display: grid;
  place-items: center;
  padding: 0;
  background: rgba(17, 21, 27, 0.82);
  color: var(--accent);
  font: 900 18px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  box-shadow: inset 0 1px rgba(255,255,255,.035);
  -webkit-tap-highlight-color: transparent;
}
.sound-toggle:active { transform: scale(.95); }
.sound-toggle.muted { color: var(--muted); }

.hold-ring { touch-action: none; -webkit-user-select: none; user-select: none; }

.install-button {
  margin-top: 12px;
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(215,255,63,.24);
  border-radius: 13px;
  background: rgba(215,255,63,.055);
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  -webkit-tap-highlight-color: transparent;
}
.install-button:active { transform: scale(.98); }

.about-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
  text-decoration: none;
  border-bottom: 1px solid rgba(141,151,165,.35);
}

.install-help {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4,6,8,.82);
  backdrop-filter: blur(12px);
}
.install-help.hidden { display: none; }
.install-help-card {
  width: min(420px, 100%);
  border: 1px solid #303742;
  border-radius: 22px;
  padding: 24px;
  background: #10141a;
  box-shadow: 0 30px 100px rgba(0,0,0,.6);
}
.install-help-card h2 { margin: 8px 0 14px; font-size: 28px; line-height: 1.05; }
.install-help-card p { margin: 0 0 20px; color: #a8b1bd; font-size: 14px; line-height: 1.55; }
.install-help-card strong { color: var(--text); }

.noscript-copy { margin: 24px; color: #f4f6f8; font: 16px/1.5 sans-serif; }

@media (max-width: 380px) {
  .app-shell { padding-left: 14px; padding-right: 14px; }
  .brand-wrap { gap: 8px; }
  .brand-mark { width: 38px; height: 38px; }
  .brand { font-size: 12px; }
  .microcopy { max-width: 150px; line-height: 1.35; }
  .sound-toggle { width: 34px; height: 34px; }
  .best-box { min-width: 54px; padding-left: 8px; padding-right: 8px; }
}

@media (max-height: 760px) {
  html.telegram-webapp:not(.telegram-fullscreen) { --tg-fallback-top: 68px; }
  .app-shell { gap: 10px; }
  .overlay-card { padding-top: 22px; padding-bottom: 22px; }
}
