/* Reset and fill the whole window with a dark space background. */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05060c;
  font-family: "Segoe UI", system-ui, sans-serif;

  /* Mobile: no scroll/zoom/long-press behaviors; let the game own all touches. */
  position: fixed;
  inset: 0;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* Center the game area in the window. Use dynamic viewport units (dvh/dvw)
   where supported so the mobile address bar doesn't cause jumps. */
#stage {
  width: 100vw;
  height: 100vh;
  width: 100dvw;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The canvas keeps its 1920x1080 internal resolution (set via width/height
   attributes) but is *displayed* at the largest 16:9 box that fits the window.
   16/9 = 1.7778 -> 177.78vh ; 9/16 = 0.5625 -> 56.25vw. */
#game {
  width: min(100vw, 177.78vh);
  height: min(56.25vw, 100vh);
  width: min(100dvw, 177.78dvh);
  height: min(56.25dvw, 100dvh);
  display: block;
  background: #05060c;
  image-rendering: pixelated; /* crisp pixel-art scaling */
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.8);
  touch-action: none;
}

/* "Rotate your device" overlay — only on touch devices held in portrait. */
#rotate {
  display: none;
}

@media (orientation: portrait) and (pointer: coarse) {
  #stage { display: none; }
  #rotate {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 50;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #9fe9ff;
    background: #05060c;
    padding: 8vw;
    font-size: 6vw;
    line-height: 1.5;
  }
  #rotate .rotate-icon {
    font-size: 18vw;
    margin-bottom: 4vw;
    animation: rotateHint 2s ease-in-out infinite;
  }
}

@keyframes rotateHint {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-90deg); }
}
