:root {
  --bg: #050505;
  --panel: #0b0b0b;
  --line: #e5e5e5;
  --muted: #b6b6b6;
  --accent: #e4bb3c;
  --accent-dark: #7e6319;
  --font: "Courier New", "Lucida Console", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--line);
  font-family: var(--font);
  overflow: hidden;
}

body {
  min-height: 100vh;
  min-height: 100svh;
}

#app-shell {
  position: relative;
  width: 100%;
  height: 100%;
}

#game-shell {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  opacity: 0;
  transition: opacity 180ms ease;
}

#game-shell.ready {
  opacity: 1;
}

#unity-canvas {
  display: block;
  width: min(100vw, calc(100svh * 0.58));
  height: min(100svh, calc(100vw / 0.58));
  max-width: 100%;
  max-height: 100%;
  background: #000;
  border: 1px solid rgba(229, 229, 229, 0.22);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Landscape browser/device: lock to 16:9 since the button layout is
   designed for that aspect. Portrait falls back to the base rule. */
@media (orientation: landscape) {
  #unity-canvas {
    width: min(100vw, calc(100svh * (16 / 9)));
    height: min(100svh, calc(100vw * (9 / 16)));
  }
}

#loading-shell {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(228, 187, 60, 0.08), transparent 35%),
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)),
    var(--bg);
  z-index: 2;
  transition: opacity 220ms ease, visibility 220ms ease;
}

#loading-shell.loaded {
  opacity: 0;
  visibility: hidden;
}

#loading-card {
  width: min(92vw, 440px);
  border: 1px solid rgba(229, 229, 229, 0.2);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  padding: 28px 24px;
  text-align: center;
}

.loading-kicker {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.22em;
  margin-bottom: 10px;
}

.loading-title {
  font-size: clamp(28px, 5vw, 42px);
  letter-spacing: 0.06em;
  margin-bottom: 22px;
}

.loading-bar {
  width: 100%;
  height: 14px;
  border: 1px solid rgba(229, 229, 229, 0.22);
  background: rgba(255,255,255,0.03);
  overflow: hidden;
}

#loading-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
  transition: width 140ms linear;
}

#loading-text {
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.08em;
}

#diagnostics-icon {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 3;
}

@media (max-width: 900px) and (orientation: portrait) {
  #unity-canvas {
    width: 100%;
    height: 100%;
  }
}
