* { box-sizing: border-box; }

:root {
  --title-scale: 0.82;
  --stage-gap-min: clamp(12px, 2vh, 28px);
  --title-slate: #5e7072;
  --game-blue: #078fc9;
}

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow-x: hidden;
  background: #9be0ff url('Full_Sky_Pano.jpg') center / cover no-repeat;
}

/* A sky panorama surrounds a CSS-sized, permanently 16:9 Unity canvas. */
.game-page {
  display: flex;
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  background: #9be0ff url('Full_Sky_Pano.jpg?v=20260817-sky-pano') center / cover no-repeat;
}

.game-stage {
  display: flex;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  /* Title_9 is 1366 × 179. The cap leaves room for three equal gaps. */
  --content-height: calc(
    100dvh - var(--stage-gap-min) - var(--stage-gap-min) - var(--stage-gap-min)
  );
  --game-width: min(100%, calc(var(--content-height) * 1.44188));
}

.game-title {
  width: calc(var(--game-width) * var(--title-scale));
  aspect-ratio: 1366 / 179;
  flex: 0 0 auto;
  background: url('Title_9.png?v=20260821-title9') center / 100% auto no-repeat;
  image-rendering: pixelated;
}

/* This is the single source of truth for the game aspect ratio. */
#game-frame {
  position: relative;
  width: var(--game-width);
  aspect-ratio: 16 / 9;
  flex: 0 0 auto;
  background: var(--game-blue); /* Game canvas placeholder while Unity starts. */
}

#unity-container {
  position: relative;
  width: 100%;
  height: 100%;
}

#unity-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--game-blue);
}

#game-fullscreen-toggle {
  position: absolute;
  z-index: 2;
  bottom: 12px;
  left: 12px;
  display: grid;
  width: 52px;
  height: 52px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: rgb(0 0 0 / 25%);
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 150ms ease, background-color 150ms ease;
}

#game-fullscreen-toggle img {
  display: block;
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}

#game-fullscreen-toggle:hover,
#game-fullscreen-toggle:focus-visible {
  background: rgb(0 0 0 / 60%);
  opacity: 1;
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* Fullscreen expands only this frame; Unity remains letterboxed at 16:9. */
#game-frame:fullscreen {
  display: flex;
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  align-items: center;
  justify-content: center;
  background: #000000;
}

#game-frame:fullscreen #unity-container {
  width: min(100vw, calc(100vh * 1.7777778));
  height: auto;
  aspect-ratio: 16 / 9;
}

#unity-loading-bar {
  position: absolute;
  top: 50%;
  left: 50%;
  display: none;
  transform: translate(-50%, -50%);
}

#unity-progress-bar-empty {
  width: 141px;
  height: 18px;
  margin-top: 10px;
  margin-left: 6.5px;
  background: url('progress-bar-empty-dark.png') no-repeat center;
}

#unity-progress-bar-full {
  width: 0%;
  height: 18px;
  margin-top: 10px;
  background: url('progress-bar-full-dark.png') no-repeat center;
}

#unity-warning {
  position: absolute;
  top: 5%;
  left: 50%;
  max-width: calc(100% - 24px);
  padding: 10px;
  transform: translateX(-50%);
  background: #ffffff;
  display: none;
}
