:root{
  --bg0:#05060b; --bg1:#0a0c12;
  --hud:#19f9ff; --hudDim:#19f9ff88;
  --warn:#ff486a; --bullet:#f7fca0;
  --panelBorder:#153264;
}

/* ===== Page & centering ===== */
*{ box-sizing:border-box; }
html,body{
  height:100%; margin:0;
  background:
    radial-gradient(1200px 700px at 20% -10%, #0b1130 0%, transparent 60%),
    radial-gradient(1000px 600px at 80% 110%, #0b1a3a 0%, transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  color:#d8f0ff;
  font-family:system-ui, Segoe UI, Roboto, Arial, sans-serif;

  /* center everything */
  display:flex; align-items:center; justify-content:center;
}
main{
  width:100%; height:100%;
  display:flex; align-items:center; justify-content:center;
}

/* ===== Game frame ===== */
.frame{
  position:relative;
  width:min(96vw,1024px);
  aspect-ratio:16/9;
  border:1px solid #0f2244;
  border-radius:12px;
  overflow:hidden;
  box-shadow:0 20px 80px #000 inset, 0 0 30px #05122a;
  background:linear-gradient(180deg,#05080f,#04060a);
}
canvas{
  width:100%; height:100%;
  display:block;
  image-rendering:pixelated;
  cursor:none; /* hide system cursor so crosshair looks clean */
}

/* ===== HUD ===== */
.hud{
  position:absolute; inset:0;
  pointer-events:none;
  display:flex; flex-direction:column;
  justify-content:space-between;
  padding:12px 14px;
}
.topbar{
  display:flex; gap:12px; align-items:center;
  text-shadow:0 0 8px var(--hudDim);
}
.chip{
  border:1px solid #102347;
  background:linear-gradient(180deg,#061226,#071327);
  padding:8px 10px;
  border-radius:8px;
  box-shadow:inset 0 0 10px #06122c, 0 0 14px #03122e66;
  font-family:ui-monospace, Consolas, Menlo, monospace;
}
.healthbar{
  position:relative; width:240px; height:16px;
  background:#081224; border:1px solid #0f2244;
  border-radius:999px; overflow:hidden;
}
.healthbar .fill{
  position:absolute; inset:0 auto 0 0; width:100%;
  background:linear-gradient(90deg,#35ffc0,#19f9ff);
  box-shadow:inset 0 0 12px #19f9ff66;
}
.kbd{
  display:inline-block; padding:2px 6px; border:1px solid #294a9a;
  border-radius:6px; background:#0a1330; font-family:ui-monospace, monospace;
  font-size:.9em; color:#c9e7ff; margin:0 2px;
}

/* ===== Overlays (Menu / Pause / GameOver / Win) ===== */
.menu,.pause,.gameover,.win{
  position:absolute; inset:0;
  display:none; align-items:center; justify-content:center; text-align:center;
  background:linear-gradient(180deg,#05080faa,#02040aaa);
  backdrop-filter:blur(2px);
  z-index:9; pointer-events:auto; /* clickable above canvas */
}
.menu.active,.pause.active,.gameover.active,.win.active{ display:flex; }

.panel{
  width:min(90%,680px);
  border:1px solid var(--panelBorder);
  border-radius:14px;
  padding:22px;
  background:
    radial-gradient(120% 100% at 50% -10%, #0a1a3a, transparent 50%),
    linear-gradient(180deg, #051026, #040914);
  box-shadow:0 8px 40px #000a, inset 0 0 40px #06163a;
}
.panel h2{ margin:0 0 10px 0; }

.btnrow{ display:flex; gap:12px; justify-content:center; flex-wrap:wrap; margin-top:14px; }

button{
  border:1px solid #2550a3;
  background:linear-gradient(180deg,#0b1c44,#0a1734);
  padding:10px 16px; color:#dff7ff;
  border-radius:10px; font-weight:600; letter-spacing:.3px; cursor:pointer;
  box-shadow:0 6px 20px #03142c, inset 0 0 18px #0c2b66aa;
  transition:transform .15s, box-shadow .15s, border-color .15s;
}
button:hover{
  transform:translateY(-1px);
  border-color:#3b84ff;
  box-shadow:0 10px 28px #04183a, inset 0 0 24px #2974f244;
}

/* ===== Footer (optional) ===== */
footer{
  position:absolute; bottom:8px; right:12px;
  opacity:.5; font-size:12px; font-family:ui-monospace, monospace;
}

/* ===== Utility (keep overlays clickable, HUD non-interactive) ===== */
.hud{ pointer-events:none; }
.menu,.pause,.gameover,.win{ pointer-events:auto; }

/* --- Debug dock --- */
#debugDock{
  position: fixed; top: 12px; right: 12px;
  width: 300px; max-height: calc(100vh - 24px); overflow: auto;
  background: rgba(10,16,34,0.92);
  border: 1px solid #1b386e; border-radius: 10px; padding: 10px 10px 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.6), inset 0 0 24px rgba(25,249,255,.08);
  color: #cfe8ff; z-index: 50;
  font: 12px/1.35 ui-monospace, Consolas, monospace;
}
#debugDock header{
  display:flex; justify-content:space-between; align-items:center;
  position: sticky; top: 0; background: rgba(10,16,34,0.95); padding-bottom: 6px; margin-bottom: 6px;
}
#debugDock h4{ margin: 10px 0 6px; color:#9fd0ff; }
#debugDock section{ border-top:1px solid #123; padding-top:6px; }
#debugDock .row{ display:flex; align-items:center; gap:6px; margin:4px 0; }
#debugDock label{ display:flex; justify-content:space-between; align-items:center; gap:8px; margin:4px 0; }
#debugDock input[type="range"]{ width: 150px; }
#debugDock input[type="number"]{ width: 68px; background:#061227; color:#d7f2ff; border:1px solid #1a3d7a; border-radius:6px; padding:2px 6px; }
#debugDock select, #debugDock button{
  background:#0a1634; color:#d7f2ff; border:1px solid #1a3d7a; border-radius:6px; padding:4px 8px;
}
#debugDock button{ cursor:pointer; }
#debugDock input[type="checkbox"]{ transform: translateY(1px); }

/* Editor overlay & panel */
#editorOverlay { pointer-events:none; }
#editorPanel{
  position: fixed; right: 12px; top: 12px; z-index: 50;
  background: rgba(8,12,28,0.92); color:#cfe8ff;
  border:1px solid #1b386e; border-radius:10px; padding:10px;
  font: 12px/1.35 ui-monospace,Consolas,monospace;
  box-shadow: 0 8px 32px rgba(0,0,0,.6), inset 0 0 24px rgba(25,249,255,.08);
  display:none;
}
#editorPanel .row{ display:flex; gap:6px; margin:6px 0; flex-wrap: wrap; }
#editorPanel button{ background:#0a1634; color:#d7f2ff; border:1px solid #1a3d7a; border-radius:6px; padding:4px 8px; cursor:pointer; }
#editorPanel button.active{ background:#1a3f7a; color:#fff; }
#editorPanel label{ display:flex; align-items:center; gap:6px; }

button.editorToggle{
  position: fixed; left: 12px; top: 12px; z-index: 49;
  background:#0a1634; color:#d7f2ff; border:1px solid #1a3d7a; border-radius:8px; padding:6px 10px; cursor:pointer;
}

/* ===== Fullscreen Menu Screen ===== */
.menu-screen {
  position: fixed;
  inset: 0;
  z-index: 999;              /* above everything */
  background: #02040a;       /* fallback behind image */
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

.menu-screen.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.menu-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center,
    rgba(0,0,0,0.1) 0%,
    rgba(0,0,0,0.25) 55%,
    rgba(0,0,0,0.6) 100%);
  pointer-events: none;
}

.menu-center {
  position: relative;
  width: min(100vw, 1100px);
  height: min(100vh, 680px);
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 16px;
  box-shadow: 0 20px 80px rgba(0,0,0,0.7);
}

.menu-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.9) contrast(1.02) brightness(0.9);
  transform: scale(1.02);
}

.menu-panel {
  position: relative;
  z-index: 2;
  width: min(92%, 520px);
  padding: 28px;
  backdrop-filter: blur(6px) saturate(1.1);
  background: linear-gradient(180deg, rgba(6,16,36,0.65), rgba(6,16,36,0.35));
  border: 1px solid rgba(120,200,255,0.18);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

.menu-title {
  margin: 0 0 12px;
  font: 700 36px/1.1 "Orbitron", ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.08em;
  color: #9feaff;
  text-shadow: 0 0 12px rgba(54,200,255,0.35);
  text-align: center;
}

.menu-nav {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.menu-btn {
  padding: 14px 16px;
  font: 600 16px/1 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto;
  border-radius: 10px;
  border: 1px solid rgba(120,200,255,0.2);
  background: rgba(12, 28, 56, 0.55);
  color: #cfeaff;
  letter-spacing: 0.06em;
  text-align: center;
  cursor: pointer;
  transition: transform 80ms ease, background 120ms ease, border-color 120ms ease;
}
.menu-btn:hover { transform: translateY(-1px); border-color: rgba(120,200,255,0.35); background: rgba(14,36,70,0.70); }
.menu-btn:active { transform: translateY(0); }
.menu-btn.primary { background: linear-gradient(180deg, #17d2ff, #1498ff); color: #02101f; border-color: rgba(255,255,255,0.25); }

.menu-subpanel {
  margin-top: 12px;
  padding: 12px;
  background: rgba(6,16,36,0.6);
  border: 1px solid rgba(120,200,255,0.18);
  border-radius: 8px;
  color: #b7dcff;
  font: 14px/1.4 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto;
}

/* ===== Game frame visibility ===== */
.frame.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.frame.is-visible {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 300ms ease;
}
/* ===== MENU TOP-RIGHT LAYOUT (overrides) ===== */

/* The big centering box is no longer centering—just acts as a background holder */
.menu-center {
  width: 100vw;
  height: 100vh;
  display: block;             /* was grid */
  border-radius: 0;
  box-shadow: none;
  position: relative;
}

/* Fullscreen background still shows behind the menu */
.menu-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.9) contrast(1.02) brightness(0.9);
  transform: none;            /* remove subtle scale */
}

/* Kill the glass container look; make menu an invisible holder pinned top-right */
.menu-panel {
  position: absolute;
  top: 24px;
  right: 24px;
  width: auto;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

/* Title + stack of buttons live directly in the corner */
.menu-title {
  margin: 0 0 10px;
  font: 800 28px/1.1 "Orbitron", ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.08em;
  color: #9feaff;
  text-shadow: 0 0 10px rgba(54,200,255,0.35);
  text-align: right;          /* right-align to the corner */
}

/* Vertical button list; right-aligned */
.menu-nav {
  display: grid;
  gap: 8px;
  margin-top: 6px;
  justify-items: end;         /* align buttons to the right edge */
}

/* Buttons keep your original style, but we tighten padding for the corner stack */
.menu-btn {
  padding: 12px 16px;
  min-width: 180px;           /* consistent width for a neat column */
  text-align: center;
}

/* Optional: look a little crisper in the corner */
.menu-btn.primary { filter: drop-shadow(0 4px 12px rgba(0,0,0,0.25)); }

/* Vignette stays, but slightly lighter in the corner */
.menu-vignette {
  background: radial-gradient(ellipse at center,
    rgba(0,0,0,0.08) 0%,
    rgba(0,0,0,0.22) 55%,
    rgba(0,0,0,0.55) 100%);
}

/* Keep the fade behavior as-is */
.menu-screen { transition: opacity 300ms ease; }
.frame.is-visible { transition: opacity 300ms ease; }

/* ---- Mobile: if the screen is narrow, float the stack inward a bit ---- */
@media (max-width: 720px) {
  .menu-panel { top: 16px; right: 16px; }
  .menu-title { font-size: 22px; }
  .menu-btn { min-width: 140px; padding: 10px 14px; }
}

/* ==== Fullscreen game with margin ==== */
:root {
  --frame-pad: 16px; /* tweak this for “slight margin” */
}

html, body {
  height: 100%;
  margin: 0;
}

main { height: 100%; }

/* The game frame fills the window with a small inset margin */
#gameFrame.frame {
  position: fixed;
  inset: var(--frame-pad);
  /* Optional subtle border/glow so the margin feels intentional */
  /* outline: 1px solid rgba(120,200,255,0.18); */
  display: grid;
  place-items: center;
}

/* Make the canvas stretch to the frame’s content box */
#game {
  width: 100%;
  height: 100%;
  display: block;     /* remove inline-gap */
  background: transparent;
}

/* Keep your show/hide transitions */
.frame.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.frame.is-visible {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 300ms ease;
}
:root { --frame-pad: 16px; } /* tweak this to change the margin */

html, body { height: 100%; margin: 0; }

main { height: 100%; }

#gameFrame.frame {
  position: fixed;
  inset: var(--frame-pad);
  display: grid;
  place-items: center;
}

#game {
  width: 100%;
  height: 100%;
  display: block; /* no gaps */
  background: transparent;
}

/* keep your fade classes working */
.frame.is-hidden { opacity: 0; pointer-events: none; }
.frame.is-visible { opacity: 1; pointer-events: auto; transition: opacity 300ms ease; }


