:root {
  color-scheme: dark;
  --browser-viewport-width: 100vw;
  --browser-viewport-height: 100vh;
  --browser-viewport-center-x: 50vw;
  --browser-viewport-center-y: 50vh;
  --game-viewport-width: 1066px;
  --game-viewport-height: 600px;
  --brand-red: #ed1c24;
  --brand-red-dark: #9f0a13;
  --panel: #0b1f29;
  --panel-edge: rgba(154, 203, 226, 0.25);
  --text: #f7fbfd;
  --muted: #9fb3bd;
}

* {
  box-sizing: border-box;
}

html,
body,
#page-shell {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background:
    radial-gradient(circle at 18% 12%, rgba(83, 142, 170, 0.28), transparent 34%),
    radial-gradient(circle at 78% 88%, rgba(20, 62, 81, 0.4), transparent 40%),
    linear-gradient(145deg, #17333f 0%, #0b202a 48%, #050d12 100%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

body::before {
  position: fixed;
  inset: 0;
  content: "";
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 80%);
}

#brand-corner {
  position: fixed;
  z-index: 4;
  top: max(16px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

#brand-corner img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

#unity-container {
  position: fixed;
  z-index: 2;
  top: var(--browser-viewport-center-y);
  left: var(--browser-viewport-center-x);
  width: var(--game-viewport-width);
  height: var(--game-viewport-height);
  overflow: hidden;
  transform: translate(-50%, -50%);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}

.unity-mobile#unity-container {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

#unity-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #231F20;
  outline: none;
}

#loading-screen,
#load-error {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 7vw, 72px);
  background:
    radial-gradient(circle at 50% 26%, rgba(69, 128, 156, 0.34), transparent 42%),
    linear-gradient(160deg, #16323e 0%, #0b202a 48%, #07151d 100%);
}

#loading-screen[hidden],
#load-error[hidden] {
  display: none;
}

#game-logo {
  width: min(54%, 430px);
  height: auto;
  margin-bottom: clamp(34px, 7vh, 70px);
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.48));
}

#loading-copy {
  display: flex;
  justify-content: space-between;
  width: min(66%, 460px);
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#loading-percent {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

#progress-track {
  width: min(66%, 460px);
  height: 12px;
  overflow: hidden;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.36);
  box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.6);
}

#progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-red-dark), var(--brand-red) 62%, #ff6c59);
  box-shadow: 0 0 16px rgba(237, 28, 36, 0.52);
  transition: width 160ms ease-out;
}

#progress-track[data-starting="true"] #progress-fill {
  width: 30%;
  transition: none;
  animation: starting-progress 1.2s ease-in-out infinite alternate;
}

@keyframes starting-progress {
  from { transform: translateX(0); }
  to { transform: translateX(233%); }
}

@media (prefers-reduced-motion: reduce) {
  #progress-track[data-starting="true"] #progress-fill {
    width: 100%;
    animation: none;
  }
}

#load-error {
  text-align: center;
}

#load-error img {
  width: 72px;
  height: 72px;
  margin-bottom: 18px;
  object-fit: contain;
}

#load-error h1 {
  margin: 0 0 10px;
  font-size: clamp(22px, 4vw, 34px);
}

#load-error p {
  max-width: 520px;
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.5;
}

#retry-button {
  min-width: 150px;
  padding: 12px 22px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 7px;
  background: linear-gradient(#f2353c, #bc1119);
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-transform: uppercase;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

#retry-button:hover,
#retry-button:focus-visible {
  filter: brightness(1.12);
  outline: 2px solid white;
  outline-offset: 3px;
}

#unity-warning {
  position: absolute;
  z-index: 7;
  top: 12px;
  left: 50%;
  width: min(90%, 720px);
  transform: translateX(-50%);
  pointer-events: none;
}

#unity-warning > div {
  margin-bottom: 8px;
  padding: 10px 14px;
  border-radius: 6px;
  background: rgba(17, 26, 31, 0.94);
  color: white;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32);
}

#unity-warning > .warning {
  border: 1px solid #f2bf3e;
}

#fullscreen-button {
  position: absolute;
  z-index: 6;
  right: 14px;
  bottom: 14px;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  background: rgba(4, 12, 17, 0.72);
  cursor: pointer;
  opacity: 0;
  transition: opacity 160ms ease, background 160ms ease;
}

.game-loaded #unity-container:hover #fullscreen-button,
#fullscreen-button:focus-visible {
  opacity: 1;
}

#fullscreen-button:hover,
#fullscreen-button:focus-visible {
  background: rgba(21, 50, 63, 0.94);
  outline: none;
}

#fullscreen-button span,
#fullscreen-button span::before {
  position: absolute;
  inset: 10px;
  content: "";
  border: solid white;
  border-width: 2px 0 0 2px;
}

#fullscreen-button span::before {
  inset: -2px;
  transform: rotate(180deg);
}

#diagnostics-icon {
  position: absolute;
  z-index: 6;
  right: 66px;
  bottom: 14px;
  width: 42px;
  height: 42px;
  cursor: pointer;
}

#unity-container:fullscreen,
#unity-canvas:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  border: 0;
  border-radius: 0;
}

#unity-canvas:fullscreen {
  object-fit: contain;
  background: #000;
}

html:fullscreen #unity-container,
html:-webkit-full-screen #unity-container {
  top: 0;
  left: 0;
  width: 100vw !important;
  height: 100vh !important;
  transform: none;
  border: 0;
  border-radius: 0;
}

html:fullscreen #unity-canvas,
html:-webkit-full-screen #unity-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

@media (max-width: 700px), (max-height: 520px) {
  #brand-corner {
    display: none;
  }

  #game-logo {
    width: min(62%, 360px);
    margin-bottom: clamp(24px, 6vh, 42px);
  }

  #loading-copy,
  #progress-track {
    width: min(76%, 420px);
  }

  #fullscreen-button {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #progress-fill,
  #fullscreen-button {
    transition: none;
  }
}
