/* ============================================================
   NULLSPACE — cabinet shell + screens
   Skin locked to world-spec.md (Elian Voss). Palette lives in
   :root here and in game.js SKIN; the engine reads SKIN.
   ============================================================ */

/* ---- Chakra Petch, self-hosted .ttf (offline-safe, no hotlink) ---- */
@font-face{
  font-family:'Chakra Petch';
  font-style:normal; font-weight:400; font-display:swap;
  src:url('fonts/ChakraPetch-Regular.ttf') format('truetype');
}
@font-face{
  font-family:'Chakra Petch';
  font-style:normal; font-weight:600; font-display:swap;
  src:url('fonts/ChakraPetch-SemiBold.ttf') format('truetype');
}
@font-face{
  font-family:'Chakra Petch';
  font-style:normal; font-weight:700; font-display:swap;
  src:url('fonts/ChakraPetch-Bold.ttf') format('truetype');
}

:root{
  /* ---- NULLSPACE PALETTE (world-spec.md) ---- */
  --ink:        #07090F;   /* ground / void */
  --ink-2:      #0b1220;   /* panel ground */
  --wall:       #12233A;   /* circuit wall core */
  --wall-glow:  #2E6FB0;   /* wall lit glow-trace */
  --cyan:       #00E5FF;   /* player / go / data */
  --magenta:    #FF3B6B;   /* SENTRY red / danger / loss */
  --amber:      #B9F73E;   /* breach / reward (acid-green owns power) */
  --lime:       #B9F73E;   /* points pop / NEW HIGH */
  --cold:       #2B3F63;   /* vulnerable daemon */
  --ghost-txt:  #6C7A94;   /* muted label text */
  --paper:      #EAF2FF;   /* bright UI text */
  --data:       #4FD6C9;   /* data-dot teal */

  /* Chakra Petch display/UI, with the spec's mono fallback tail so a
     clean fallback still reads on-grid. tabular-nums on numbers. */
  --font-display: 'Chakra Petch', 'DIN Alternate', 'Rajdhani', ui-monospace, 'SFMono-Regular', 'Roboto Mono', monospace;
  --font-ui:      'Chakra Petch', 'DIN Alternate', 'Rajdhani', ui-monospace, 'SFMono-Regular', 'Roboto Mono', monospace;
}

*{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
html,body{margin:0; padding:0; height:100%;}
body{
  background:
    radial-gradient(120% 90% at 50% -10%, #0d1526 0%, var(--ink) 60%, #020306 100%);
  color:var(--paper);
  font-family:var(--font-ui);
  overflow:hidden;
  display:flex; align-items:center; justify-content:center;
  min-height:100dvh;
  touch-action:none;
  user-select:none; -webkit-user-select:none;
}

/* ============================================================
   CABINET / BEZEL — spends desktop width like an arcade cabinet
   ============================================================ */
#cabinet{
  width:100%;
  max-width:520px;             /* phone-first column */
  height:100dvh;
  max-height:100dvh;
  padding:env(safe-area-inset-top) 10px env(safe-area-inset-bottom);
  display:flex; flex-direction:column;
}
#bezel{
  flex:1;
  display:flex; flex-direction:column;
  min-height:0;
  background:linear-gradient(180deg, #0a0f1c, #060911);
  border:1px solid #1b2b4d;
  border-radius:18px;
  box-shadow:
    0 0 0 1px rgba(53,240,232,.06),
    0 24px 60px -20px #000,
    inset 0 1px 0 rgba(255,255,255,.04);
  padding:10px 10px 8px;
  position:relative;
  overflow:hidden;
}
#bezel::before{  /* scanline sheen */
  content:""; position:absolute; inset:0; pointer-events:none;
  background:repeating-linear-gradient(0deg, transparent 0 3px, rgba(0,0,0,.10) 3px 4px);
  mix-blend-mode:overlay; opacity:.5; z-index:5;
}

/* ============================================================
   HUD
   ============================================================ */
#hud{
  display:flex; align-items:baseline; justify-content:space-between;
  padding:2px 6px 8px; gap:8px;
  z-index:6;
}
.hud-cell{display:flex; flex-direction:column; gap:1px; min-width:64px;}
.hud-center{align-items:center;}
.hud-right{align-items:flex-end;}
.hud-label{
  font-size:9px; letter-spacing:.22em; color:var(--ghost-txt);
  font-weight:700;
}
.hud-val{
  font-family:var(--font-display);
  font-size:22px; line-height:1; font-weight:700;
  font-variant-numeric:tabular-nums; font-feature-settings:"tnum" 1;
  color:var(--cyan);
  text-shadow:0 0 10px rgba(0,229,255,.55);
}
#lives{display:flex; gap:5px; height:22px; align-items:center;}
.life-pip{
  width:12px; height:12px; flex:0 0 auto;
  background:var(--cyan);
  clip-path:polygon(100% 50%, 30% 100%, 8% 50%, 30% 0%);
  box-shadow:0 0 8px rgba(0,229,255,.7);
}

/* ---- desktop-only cabinet furniture (hidden on phone) ---- */
#marquee{display:none;}
.wing{display:none;}
#playcol{display:flex; flex-direction:column; min-height:0; flex:1;}

/* ============================================================
   STAGE + CANVAS
   ============================================================ */
#stage{
  flex:1; position:relative; min-height:0;
  display:flex; align-items:center; justify-content:center;
}
#game{
  display:block;
  image-rendering:pixelated;
  border-radius:8px;
  box-shadow:0 0 0 1px #12233A, 0 0 40px -6px rgba(46,111,176,.4);
  background:var(--ink);
}

/* ============================================================
   OVERLAY SCREENS
   ============================================================ */
.screen{
  position:absolute; inset:0; z-index:8;
  display:flex; align-items:center; justify-content:center;
  padding:16px;
}
.screen.gone{display:none;}
.panel{
  width:100%; max-width:360px;
  display:flex; flex-direction:column; align-items:center; gap:14px;
  text-align:center;
  background:linear-gradient(180deg, rgba(8,12,22,.86), rgba(4,6,12,.94));
  border:1px solid #1d305a;
  border-radius:14px;
  padding:26px 22px;
  backdrop-filter:blur(3px);
  box-shadow:0 20px 50px -20px #000, inset 0 0 0 1px rgba(53,240,232,.05);
}
.panel.hidden{display:none;}

.logo{display:flex; flex-direction:column; gap:8px; margin-bottom:2px; align-items:center;}
.logo-main{
  font-family:var(--font-display);
  font-size:46px; font-weight:700; letter-spacing:.04em; line-height:.9;
  color:var(--paper);
}
.logo-main .n-null{color:var(--paper);}
.logo-main .n-space{
  color:var(--cyan);
  text-shadow:0 0 16px rgba(0,229,255,.55), 0 0 3px rgba(0,229,255,.9);
}
/* thin cyan underline rule under the wordmark (spec §7) */
.logo-rule{
  width:132px; height:2px; margin:0 auto;
  background:linear-gradient(90deg, transparent, var(--cyan) 20%, var(--cyan) 80%, transparent);
  box-shadow:0 0 10px rgba(0,229,255,.6);
}
.logo-sub{
  font-size:10px; letter-spacing:.26em; color:var(--ghost-txt);
  text-transform:uppercase; font-weight:400;
}
.blurb{
  font-size:12.5px; line-height:1.7; color:var(--ghost-txt);
  letter-spacing:.03em; margin:0;
}
.panel-title{
  font-family:var(--font-display); font-size:30px; font-weight:700;
  letter-spacing:.05em; color:var(--cyan);
  text-shadow:0 0 14px rgba(0,229,255,.5);
}
.panel-title.over{color:var(--magenta); text-shadow:0 0 16px rgba(255,59,107,.55);}

/* buttons */
.btn{
  font-family:var(--font-display);
  font-size:15px; font-weight:700; letter-spacing:.14em;
  padding:13px 22px; width:100%; max-width:260px;
  border-radius:9px; cursor:pointer;
  border:1px solid transparent;
  transition:transform .08s ease, box-shadow .18s ease, background .18s ease;
  touch-action:manipulation;
}
.btn:active{transform:translateY(1px) scale(.99);}
.btn-primary{
  color:var(--ink);
  background:linear-gradient(180deg, var(--cyan), #0392b3);
  box-shadow:0 0 22px -4px rgba(0,229,255,.8), inset 0 1px 0 rgba(255,255,255,.4);
}
.btn-primary:hover{box-shadow:0 0 30px -2px rgba(0,229,255,1);}
/* start CTA breathes gently at ~1Hz so the eye goes there (spec §7) */
#btnStart{animation:ctaGlow 1.05s ease-in-out infinite;}
@keyframes ctaGlow{
  0%,100%{box-shadow:0 0 16px -6px rgba(0,229,255,.7), inset 0 1px 0 rgba(255,255,255,.4);}
  50%{box-shadow:0 0 30px -2px rgba(0,229,255,1), inset 0 1px 0 rgba(255,255,255,.5);}
}
@media (prefers-reduced-motion: reduce){
  #btnStart, .ready-go, .new-hi{animation:none;}
}
.btn-ghost{
  color:var(--ghost-txt);
  background:transparent;
  border:1px solid #26406e;
}
.btn-ghost:hover{color:var(--paper); border-color:var(--cyan);}

.hi{font-size:11px; letter-spacing:.2em; color:var(--ghost-txt);}
.hi b{color:var(--ghost-txt); font-family:var(--font-display); font-size:14px; margin-left:6px; font-variant-numeric:tabular-nums;}

.controls-hint{
  margin-top:4px; font-size:10px; letter-spacing:.14em; color:#4a5b7e;
  line-height:1.6;
}
.controls-hint .k-desk{display:none;}

/* get-ready */
.ready-level{
  font-family:var(--font-display); font-size:16px; letter-spacing:.3em;
  color:var(--ghost-txt); margin-bottom:10px; font-variant-numeric:tabular-nums;
}
.ready-go{
  font-family:var(--font-display); font-size:34px; font-weight:700;
  letter-spacing:.12em; color:var(--cyan);
  text-shadow:0 0 18px rgba(0,229,255,.6);
  animation:pulse 1s ease-in-out infinite;
}
@keyframes pulse{50%{opacity:.45; transform:scale(.96);}}

/* game over final table */
.final{width:100%; max-width:240px; display:flex; flex-direction:column; gap:8px; margin:2px 0;}
.final-row{
  display:flex; justify-content:space-between; align-items:baseline;
  font-size:12px; letter-spacing:.18em; color:var(--ghost-txt);
  border-bottom:1px dashed #1e3059; padding-bottom:6px;
}
.final-row b{font-family:var(--font-display); font-size:18px; color:var(--paper); font-variant-numeric:tabular-nums;}
.final-row.hi-row{color:var(--ghost-txt);}
.final-row.hi-row b{color:var(--ghost-txt);}
.new-hi{
  font-family:var(--font-display); font-size:14px; letter-spacing:.2em;
  color:var(--lime); text-shadow:0 0 12px rgba(185,247,62,.6);
  animation:pulse 1.1s ease-in-out infinite;
}
.new-hi.hidden{display:none;}

/* ============================================================
   TOUCH PAD (phone only)
   ============================================================ */
#pad{
  display:none;                 /* shown on touch/coarse pointers via JS/media */
  padding:6px 0 2px;
  z-index:6;
  justify-content:center;
}
.dpad{
  position:relative;
  width:168px; height:168px;
}
.dbtn{
  position:absolute;
  width:56px; height:56px;
  display:flex; align-items:center; justify-content:center;
  font-size:20px; color:var(--cyan);
  background:linear-gradient(180deg, #12203c, #0a1324);
  border:1px solid #26406e;
  border-radius:12px;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.05);
  touch-action:none;
}
.dbtn:active, .dbtn.on{
  color:var(--ink);
  background:linear-gradient(180deg, var(--cyan), #14b6ae);
  box-shadow:0 0 18px -2px rgba(53,240,232,.9);
}
.dbtn.up{top:0; left:56px;}
.dbtn.down{bottom:0; left:56px;}
.dbtn.left{left:0; top:56px;}
.dbtn.right{right:0; top:56px;}
.dpad-hub{
  position:absolute; left:64px; top:64px; width:40px; height:40px;
  border-radius:50%; border:1px solid #1c2f56;
  background:radial-gradient(circle, #0c1428, #070c17);
}

/* ============================================================
   FOOTER
   ============================================================ */
#barbottom{
  display:flex; justify-content:center; gap:12px;
  padding:6px 0 2px; z-index:6;
}
.chip{
  font-family:var(--font-ui);
  width:44px; height:34px; border-radius:8px;
  background:#0c1526; border:1px solid #223a66; color:var(--ghost-txt);
  cursor:pointer; font-size:14px;
  display:flex; align-items:center; justify-content:center;
  touch-action:manipulation;
}
.chip:active{transform:translateY(1px);}
.chip.muted{color:#3a4a6a; opacity:.7;}

/* ============================================================
   DESKTOP FACE — a real arcade cabinet spending the width.
   Marquee header, playfield centered, two lit side wings.
   ============================================================ */
@media (min-width:900px){
  body{padding:24px;}
  #cabinet{
    max-width:1120px;
    width:100%;
    height:auto; max-height:none;
    border:1px solid #1b2b4d; border-radius:26px;
    background:
      radial-gradient(130% 120% at 50% -10%, #101c38 0%, #070b16 62%, #04060c 100%),
      linear-gradient(180deg,#0b1220,#05080f);
    box-shadow:0 50px 140px -40px #000, 0 0 0 1px rgba(53,240,232,.06);
    padding:0 26px 26px;
  }

  /* marquee header */
  #marquee{
    display:flex; align-items:baseline; justify-content:center; gap:16px;
    padding:20px 0 16px; margin:0 -26px 4px;
    border-bottom:1px solid #14264a;
    background:linear-gradient(180deg, rgba(53,240,232,.05), transparent);
  }
  .mq-name{
    font-family:var(--font-display); font-weight:700; font-size:30px;
    letter-spacing:.22em; color:var(--paper);
  }
  .mq-name .n-space{color:var(--cyan); text-shadow:0 0 16px rgba(0,229,255,.5);}
  .mq-sub{font-size:12px; letter-spacing:.28em; color:var(--ghost-txt); text-transform:uppercase;}

  /* bezel becomes a 3-column cabinet: wing | playfield | wing */
  #bezel{
    display:grid;
    grid-template-columns: 1fr minmax(360px, 520px) 1fr;
    align-items:stretch;
    gap:20px;
    background:transparent; border:none; box-shadow:none;
    border-radius:0; padding:14px 4px 4px;
    overflow:visible;
  }
  #bezel::before{display:none;}

  #playcol{
    background:linear-gradient(180deg,#0a0f1c,#060911);
    border:1px solid #1b2b4d; border-radius:16px;
    padding:14px 16px 12px;
    box-shadow:0 0 40px -10px rgba(47,107,214,.35), inset 0 1px 0 rgba(255,255,255,.04);
    min-height:560px;
  }
  #stage{min-height:480px;}

  .hud-val{font-size:24px;}
  .logo-main{font-size:48px;}
  .logo-sub{font-size:12px;}
  .blurb{font-size:14px;}
  .controls-hint .k-mobile{display:none;}
  .controls-hint .k-desk{display:inline;}
  #barbottom .chip{width:auto; padding:0 14px; height:36px; font-size:11px; letter-spacing:.18em;}

  /* side wings — lit panels that spend the width */
  .wing{
    display:flex; flex-direction:column; justify-content:center; gap:20px;
    padding:8px 6px;
  }
  .wing-l{align-items:flex-end; text-align:right;}
  .wing-r{align-items:flex-start; text-align:left;}
  .wing-block{max-width:230px;}
  .wing-title{
    font-family:var(--font-display); font-size:12px; font-weight:700;
    letter-spacing:.26em; color:var(--cyan);
    text-shadow:0 0 10px rgba(53,240,232,.4);
    margin-bottom:12px;
  }
  .daemon-key, .ctl-key{list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:11px;}
  .daemon-key li{
    display:flex; align-items:center; gap:9px; flex-direction:row-reverse;
    font-family:var(--font-display); font-size:13px; letter-spacing:.1em; color:var(--paper);
  }
  .daemon-key li b{color:var(--ghost-txt); font-weight:400; font-size:11px; letter-spacing:.04em;}
  .daemon-key i{
    width:13px; height:13px; border-radius:4px 4px 3px 3px; flex:0 0 auto;
    background:var(--dc); box-shadow:0 0 10px 0 var(--dc);
  }
  .ctl-key li{font-size:12.5px; letter-spacing:.06em; color:var(--ghost-txt);}
  .ctl-key li b{
    color:var(--cyan); font-family:var(--font-display); font-weight:700;
    margin-right:8px; display:inline-block; min-width:74px;
  }
  .wing-note{font-size:12px; line-height:1.7; color:var(--ghost-txt); margin:0;}
  .wing-note .gold{color:var(--amber);}
}

/* show the d-pad wherever touch is the primary input */
@media (pointer:coarse){
  #pad{display:flex;}
  .controls-hint .k-desk{display:none;}
  .controls-hint .k-mobile{display:inline;}
}

/* very short landscape phones: shrink pad so canvas keeps room */
@media (max-height:520px) and (orientation:landscape){
  .dpad{width:128px; height:128px;}
  .dbtn{width:42px; height:42px;}
  .dbtn.up,.dbtn.down{left:43px;}
  .dbtn.left,.dbtn.right{top:43px;}
  .dpad-hub{left:48px; top:48px; width:32px; height:32px;}
}
