:root {
  color-scheme: dark;
  background: #082d31;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  position: fixed;
  inset: 0;
  background: #082d31;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
#game-root {
  position: fixed;
  inset: env(safe-area-inset-top) env(safe-area-inset-right)
        env(safe-area-inset-bottom) env(safe-area-inset-left);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}
#game-root canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
#portrait-notice { display: none; }
@media (orientation: landscape) and (max-height: 600px) and (any-pointer: coarse) {
  #game-root { visibility: hidden; }
  #portrait-notice {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 24px;
    color: #fff;
    background: #082d31;
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
  }
}
#offline-control {
  position: fixed;
  z-index: 10;
  top: calc(env(safe-area-inset-top) + 8px);
  right: calc(env(safe-area-inset-right) + 8px);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(94vw, 420px);
  padding: 7px 10px;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 10px;
  color: #fff;
  background: rgb(5 20 22 / 88%);
  box-shadow: 0 2px 12px rgb(0 0 0 / 28%);
  font-size: 12px;
  line-height: 1.25;
  pointer-events: none;
}
#offline-retry {
  min-height: 32px;
  padding: 5px 9px;
  border: 0;
  border-radius: 7px;
  color: #092124;
  background: #d1e9df;
  font: inherit;
  font-weight: 700;
  pointer-events: auto;
}
#offline-retry[hidden] { display: none; }
html[data-offline-blocking="true"] #offline-control {
  inset: 0;
  top: 0;
  right: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  justify-items: center;
  gap: 18px;
  max-width: none;
  padding: 24px;
  border: 0;
  border-radius: 0;
  background: radial-gradient(ellipse at center, #164b4d, #082d31 72%);
  text-align: center;
  font-size: 16px;
  pointer-events: auto;
}
html[data-offline-blocking="true"] #offline-status {
  width: min(100%, 24rem);
  min-width: 0;
  font-size: 1.15rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}
html[data-offline-blocking="true"] #loading-tower {
  display: block;
  width: min(68vw, 280px);
  max-height: min(38vh, 280px);
}
html[data-offline-state="ready"] #loading-tower,
html[data-offline-state="ready"] #offline-bytes { display: none; }
#loading-tower { display: none; }
#offline-bytes { color: #c8fff0; font-size: .9rem; font-variant-numeric: tabular-nums; }
.tower-bob { transform-origin: 110px 190px; animation: tower-bob 2.7s ease-in-out infinite; }
.sliding-floor { transform-origin: 110px 130px; animation: floor-slide 2.7s ease-in-out infinite; }
.catch-hands { animation: catch 2.7s ease-in-out infinite; }
#loading-tower circle { transform-box: fill-box; transform-origin: center; animation: blink 4.2s linear infinite; }
@keyframes tower-bob { 0%, 100% { transform: translateY(0) rotate(0); } 45%, 78% { transform: translateY(-3px) rotate(-1deg); } }
@keyframes floor-slide { 0%, 18%, 70%, 100% { transform: translateX(0); } 38%, 52% { transform: translateX(13px); } }
@keyframes catch { 0%, 22%, 72%, 100% { transform: translateY(0); } 40%, 54% { transform: translateY(-8px); } }
@keyframes blink { 0%, 91%, 95%, 100% { transform: scaleY(1); } 93% { transform: scaleY(.12); } }
html[data-page-hidden="true"] #loading-tower *,
html[data-page-hidden="true"] #loading-tower { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  #loading-tower *, #loading-tower { animation: none !important; }
}
#offline-progress { width: min(72vw, 320px); max-width: 100%; height: 12px; accent-color: #62d9bb; }
#offline-progress[hidden] { display: none; }
html[data-offline-blocking="false"][data-offline-state="downloading"] #offline-control {
  flex-wrap: wrap;
}
html[data-offline-blocking="false"][data-offline-state="downloading"] #offline-status {
  flex-basis: 100%;
}
html[data-offline-blocking="false"][data-offline-state="downloading"] #offline-progress {
  flex-basis: 100%;
  width: 100%;
}
html[data-offline-state="ready"] #offline-control {
  padding: 5px 8px;
  opacity: .72;
}
html[data-game-menu="false"][data-offline-blocking="false"] #offline-control { display: none; }
noscript {
  position: fixed;
  inset: 50% 12px auto;
  z-index: 20;
  padding: 1rem;
  color: #fff;
  background: #521c14;
  text-align: center;
}
#install-banner {
  position: fixed;
  z-index: 11;
  top: calc(env(safe-area-inset-top) + 8px);
  left: calc(env(safe-area-inset-left) + 8px);
  right: calc(env(safe-area-inset-right) + 8px);
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(100% - 16px, 360px);
  min-height: 42px;
  margin: 0 auto;
  padding: 4px;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 12px;
  color: #fff;
  background: rgb(5 20 22 / 94%);
  box-shadow: 0 2px 12px rgb(0 0 0 / 30%);
  pointer-events: none;
}
#install-banner[hidden] { display: none; }
#install-now, #install-dismiss {
  min-height: 34px;
  border: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  pointer-events: auto;
}
#install-now {
  flex: 1;
  padding: 6px 9px;
  border-radius: 8px;
  color: #092124;
  background: #d1e9df;
}
#install-now[hidden] { display: none; }
#install-dismiss {
  width: 34px;
  padding: 0;
  border-radius: 8px;
  color: #fff;
  background: transparent;
  font-size: 20px;
}
#install-hint {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 6px 8px;
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
}
#install-hint[hidden] { display: none; }
html[data-install-banner="true"] #offline-control { visibility: hidden; }
#install-guide {
  position: fixed;
  inset: calc(env(safe-area-inset-top) + 60px) 10px auto;
  width: min(94vw, 420px);
  max-height: min(70vh, 560px);
  margin: 0 auto;
  padding: 12px;
  overflow: auto;
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: 14px;
  color: #fff;
  background: #092c30;
  box-shadow: 0 8px 32px rgb(0 0 0 / 42%);
}
#install-guide::backdrop { background: rgb(0 12 14 / 45%); }
.install-guide-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.install-guide-header h2 { margin: 0; font-size: 15px; line-height: 1.25; }
.install-guide-header p { margin: 4px 0 0; color: #bfd0ce; font-size: 11px; }
.telegram-safari-note { margin: 0 0 8px; padding: 8px; border-radius: 8px; background: rgb(98 217 187 / 12%); font-size: 12px; line-height: 1.4; }
#install-guide-close {
  flex: 0 0 34px;
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: rgb(255 255 255 / 10%);
  font: inherit;
  font-size: 20px;
}
.install-guide-steps { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.install-guide-steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 7px 8px;
  border-radius: 10px;
  background: rgb(255 255 255 / 6%);
}
.install-guide-steps svg {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  fill: none;
  stroke: #62d9bb;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.install-guide-steps li:last-child svg rect:last-of-type { fill: #62d9bb; }
.install-guide-steps strong, .install-guide-steps small { display: block; }
.install-guide-steps strong { font-size: 12px; line-height: 1.3; }
.install-guide-steps small { margin-top: 2px; color: #bfd0ce; font-size: 10px; line-height: 1.3; }
