:root {
  color-scheme: dark;
  --bg: #050710;
  --cyan: #5ce1ff;
  --magenta: #ff4fd8;
  --amber: #ffc857;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
  font-family: "Press Start 2P", ui-monospace, monospace;
  touch-action: none;
  overscroll-behavior: none;
}

#shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding:
    max(8px, var(--safe-t))
    max(8px, var(--safe-r))
    max(8px, var(--safe-b))
    max(8px, var(--safe-l));
  background:
    radial-gradient(ellipse at center, #0b1224 0%, #050710 70%),
    #050710;
}

/* Aspect-fit fallback sizing so the canvas is laid out before JS boots.
   Task 2's js/core/viewport.js writes the same width and height inline
   from apply(); keep these min() expressions in lockstep with it. */
#game {
  display: block;
  width: min(100vw - 16px, calc((100vh - 32px) * 960 / 720));
  height: min(100vh - 32px, calc((100vw - 16px) * 720 / 960));
  max-width: 100%;
  max-height: 100%;
  background: #050710;
  border: 1px solid rgba(92, 225, 255, 0.18);
  box-shadow:
    0 0 40px rgba(92, 225, 255, 0.08),
    inset 0 0 80px rgba(0, 0, 0, 0.45);
}

#credit {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(4px, var(--safe-b));
  text-align: center;
  font-size: 8px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.28);
  pointer-events: none;
  padding: 0 12px;
}

/* Touch controls (wired in Task 24) */
#touch-ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

#touch-ui .pad,
#touch-ui .pad-btn {
  pointer-events: auto;
}

#orbit-pad {
  position: absolute;
  left: max(12px, var(--safe-l));
  bottom: max(18px, var(--safe-b));
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 2px solid rgba(92, 225, 255, 0.45);
  background: rgba(8, 16, 32, 0.45);
  backdrop-filter: blur(2px);
}

#orbit-pad .pad-label {
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 8px;
  color: rgba(92, 225, 255, 0.7);
}

#orbit-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #9ef, var(--cyan));
  box-shadow: 0 0 12px rgba(92, 225, 255, 0.6);
  opacity: 0.85;
}

#action-pads {
  position: absolute;
  right: max(12px, var(--safe-r));
  bottom: max(18px, var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pad-btn {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  border: 2px solid rgba(255, 79, 216, 0.55);
  background: rgba(30, 8, 28, 0.55);
  color: #ffc0ef;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.05em;
  box-shadow: 0 0 16px rgba(255, 79, 216, 0.25);
}

.pad-btn.nova {
  width: 72px;
  height: 72px;
  align-self: flex-end;
  border-color: rgba(255, 200, 87, 0.6);
  color: #ffe2a0;
  background: rgba(36, 24, 4, 0.55);
  box-shadow: 0 0 16px rgba(255, 200, 87, 0.2);
  font-size: 10px;
}

.pad-btn:active,
.pad-btn.active {
  transform: scale(0.96);
  background: rgba(255, 79, 216, 0.28);
}

.pad-btn.nova:active,
.pad-btn.nova.active {
  background: rgba(255, 200, 87, 0.28);
}

.hidden {
  display: none !important;
}

#touch-ui.lefty #orbit-pad {
  left: auto;
  right: max(12px, var(--safe-r));
}

#touch-ui.lefty #action-pads {
  right: auto;
  left: max(12px, var(--safe-l));
}

@media (max-width: 700px), (pointer: coarse) {
  #credit {
    font-size: 7px;
    opacity: 0.8;
  }
}
