/* FOUNDERMAN shell styling: HD production canvas plus preserved legacy mode. */

:root {
  --bg: #0a0a12;
  --panel: #14142a;
  --accent: #29adff;
  --ink: #e0e0f0;
}

* { box-sizing: border-box; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background:
    radial-gradient(circle at 50% 0%, #1b1b3a 0%, var(--bg) 60%) fixed;
  color: var(--ink);
  font-family: "Courier New", Courier, monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
}

#game {
  /* Legacy starts at 256x224; production overrides this with a 1280x720 aspect. */
  width: 768px;
  height: 672px;
  max-width: 95vw;
  max-height: 82vh;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  border: 3px solid var(--accent);
  border-radius: 6px;
  box-shadow:
    0 0 0 4px #000,
    0 0 28px rgba(41, 173, 255, 0.45),
    0 12px 40px rgba(0, 0, 0, 0.6);
  outline: none;
}

/* The production slice keeps a true 16:9 CSS box while its backing store tracks
   DPR independently. The class is applied and removed by the HD renderer, so
   the preserved 256x224 legacy route retains its pixel-art presentation. */
#game.founderman-production {
  width: min(1728px, 96vw, calc(90vh * 16 / 9));
  height: auto;
  max-width: none;
  max-height: none;
  aspect-ratio: 16 / 9;
  image-rendering: auto;
  border-color: #d2a348;
  border-radius: 4px;
  box-shadow:
    0 0 0 4px #05080c,
    0 0 34px rgba(20, 207, 244, 0.22),
    0 14px 50px rgba(0, 0, 0, 0.72);
}

#hint {
  font-size: 12px;
  letter-spacing: 0.35px;
  color: #8a8ac0;
  text-align: center;
  max-width: 96vw;
  line-height: 1.25;
  user-select: none;
}

#hint::before {
  content: "▸ ";
  color: var(--accent);
}

/* ------------------------------------------------------------ on-screen controls */
#controls {
  position: fixed;
  inset: 0;
  pointer-events: none; /* only the buttons are interactive */
  z-index: 50;
  font-family: "Courier New", Courier, monospace;
}

#controls .ctl {
  pointer-events: auto;
  position: absolute; /* within .dpad / .actions; the menu button overrides to fixed */
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #eaf2ff;
  background: rgba(20, 26, 54, 0.55);
  border: 2px solid rgba(120, 160, 255, 0.55);
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  backdrop-filter: blur(2px);
}
#controls .ctl.active {
  background: rgba(41, 173, 255, 0.7);
  border-color: #bdf4ff;
  transform: scale(0.94);
}

/* Menu / pause button — visible on every device. */
.ctl-menu {
  display: none !important;
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  width: 52px;
  height: 44px;
  font-size: 16px;
  letter-spacing: 2px;
}

/* The D-pad + action cluster only appear on touch (or when forced). */
.dpad, .actions { display: none; }
body.touch .dpad, body.force-touch .dpad,
body.touch .actions, body.force-touch .actions { display: block; }
body.touch .ctl-menu, body.force-touch .ctl-menu { display: flex !important; }

.dpad { position: fixed; left: max(18px, env(safe-area-inset-left)); bottom: max(22px, env(safe-area-inset-bottom)); width: 168px; height: 168px; pointer-events: none; }
.dpad .ctl { width: 56px; height: 56px; font-size: 20px; }
.dpad .up    { left: 56px; top: 0; }
.dpad .down  { left: 56px; top: 112px; }
.dpad .left  { left: 0;   top: 56px; }
.dpad .right { left: 112px; top: 56px; }

.actions { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); width: 170px; height: 168px; pointer-events: none; }
.actions .ctl { border-radius: 50%; }
.actions .jump  { right: 0;   bottom: 0;   width: 74px; height: 74px; font-size: 26px; border-color: rgba(120,255,170,0.6); }
.actions .shoot { right: 80px; bottom: 18px; width: 66px; height: 66px; font-size: 24px; border-color: rgba(255,210,90,0.6); }
.actions .slide { right: 18px; bottom: 86px; width: 68px; height: 44px; border-radius: 12px; font-size: 16px; letter-spacing: 1px; border-color: rgba(190,160,255,0.6); }

/* On phones, give the canvas more vertical room and float controls over it. */
@media (pointer: coarse) {
  #frame { padding: 6px; gap: 6px; }
  #hint { display: none; }
  #game { max-height: 64vh; max-width: 99vw; }
  #game.founderman-production {
    width: min(99vw, calc(64vh * 16 / 9));
    max-height: none;
    max-width: none;
  }
}
