html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  /* Touch screens: no zoom, scroll, rubber-banding, text selection or
     long-press menus. The game handles every touch itself. */
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

html.touch, html.touch body {
  /* Keep the page pinned in place on iPad Safari. */
  position: fixed;
  inset: 0;
}

#game {
  display: block;
  background: #000;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
}

/* The on-screen touch controls, drawn over the whole window. Touches are
   handled on the window, so this layer never catches them itself. */
#touch {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
}

/* Never shown: main.js reads its padding to learn the safe-area insets. */
#safe-area {
  position: fixed;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  visibility: hidden;
  pointer-events: none;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
           env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

/* "Turn your iPad sideways", only on touch screens held upright. */
#rotate {
  display: none;
}

@media (orientation: portrait) {
  html.touch #rotate {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 10;
    align-items: center;
    justify-content: center;
    background: #2c2340;
    color: #fff4a6;
    font: bold 28px -apple-system, "Helvetica Neue", Arial, sans-serif;
    text-align: center;
    padding: 24px;
  }
  html.touch #touch {
    visibility: hidden;
  }
}

.rotate-box p {
  margin: 28px 0 0;
  line-height: 1.3;
}

/* A little tablet that tips over onto its side, again and again. */
.rotate-icon {
  width: 90px;
  height: 130px;
  margin: 0 auto;
  border: 6px solid #fff4a6;
  border-radius: 14px;
  box-sizing: border-box;
  animation: tip 2.4s ease-in-out infinite;
}

@keyframes tip {
  0%, 25% { transform: rotate(0deg); }
  55%, 85% { transform: rotate(-90deg); }
  100% { transform: rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
  .rotate-icon { animation: none; transform: rotate(-90deg); }
}

/* ---- "Add to Home Screen" offer (title screen, touch devices) ---- */

[hidden] {
  display: none !important;
}

#home-screen {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  font: 600 18px -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: #fff4a6;
}

#home-screen .hs-x {
  color: #ffffff;
}

#home-screen button,
#home-screen-help button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.hs-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px 8px 8px;
  border: 2px solid #ffd84a;
  border-radius: 999px;
  background: rgba(27, 20, 36, 0.88);
  color: #fff4a6;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}

.hs-pill img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: block;
}

.hs-x {
  width: 40px;
  height: 40px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  background: rgba(27, 20, 36, 0.8);
  color: #ffffff;
  font-size: 24px !important;
  line-height: 1;
  padding: 0;
}

#home-screen-help {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.6);
  font: 18px/1.4 -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: #ffffff;
}

.hs-card {
  width: 100%;
  max-width: 460px;
  max-height: 100%;
  overflow: auto;
  box-sizing: border-box;
  padding: 24px 26px 22px;
  border: 3px solid #ffd84a;
  border-radius: 18px;
  background: #2c2340;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  text-align: center;
}

.hs-icon {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  display: block;
  margin: 0 auto 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.hs-card h2 {
  margin: 0 0 14px;
  font-size: 22px;
  color: #ffd84a;
}

.hs-steps {
  margin: 0 0 12px;
  padding-left: 1.4em;
  text-align: left;
}

.hs-steps li {
  margin: 6px 0;
}

.hs-share {
  width: 1.2em;
  height: 1.2em;
  vertical-align: -0.2em;
  color: #79b0ff;
}

.hs-note {
  margin: 0 0 16px;
  font-size: 15px;
  color: #c9c3d8;
}

.hs-ok {
  min-width: 140px;
  padding: 10px 24px;
  border: 0;
  border-radius: 999px;
  background: #ffd84a;
  color: #1b1424 !important;
  font-weight: 700 !important;
}

@media (orientation: portrait) {
  html.touch #home-screen,
  html.touch #home-screen-help {
    display: none !important;
  }
}

.noscript {
  color: #fff;
  font: 18px sans-serif;
  text-align: center;
}
