/* ------------------------------------------------------------------
   Kiko the Fox — presentation layer.
   The game itself renders into a 256x240 framebuffer (the NES's real
   resolution). Everything here is about presenting that buffer with
   hard pixel edges and a bit of living-room CRT atmosphere.
   ------------------------------------------------------------------ */

:root{
  --bg:#0d0d10;
  --panel:#17171d;
  --edge:#2c2c36;
  --ink:#c8c8d4;
  --hot:#fca044;
  --scale:3;
}

*{box-sizing:border-box;}

html,body{
  margin:0;
  padding:0;
  height:100%;
  background:var(--bg);
  color:var(--ink);
  font-family:ui-monospace,"SFMono-Regular",Menlo,Consolas,monospace;
  -webkit-font-smoothing:none;
  overscroll-behavior:none;
  touch-action:manipulation;
}

body{
  display:flex;
  align-items:center;
  justify-content:center;
  background:
    radial-gradient(ellipse at 50% 0%, #1b1b24 0%, #0d0d10 62%),
    var(--bg);
}

#cab{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:14px;
  padding:16px;
  max-width:100%;
}

/* ---- the "console" bezel around the picture ---- */
#bezel{
  position:relative;
  padding:10px;
  border-radius:6px;
  background:linear-gradient(#22222b,#14141a);
  border:1px solid var(--edge);
  box-shadow:
    0 0 0 1px #000,
    0 18px 40px -18px #000,
    inset 0 1px 0 #34343f;
  line-height:0;
}

#screen{
  display:block;
  width:calc(256px * var(--scale));
  height:calc(240px * var(--scale));
  background:#000;
  image-rendering:pixelated;
  image-rendering:crisp-edges;
  -ms-interpolation-mode:nearest-neighbor;
  cursor:default;
}

/* ---- optional scanline / aperture-grille overlay ---- */
#scanlines{
  position:absolute;
  inset:10px;
  pointer-events:none;
  opacity:.5;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0,0,0,.30) 0px,
      rgba(0,0,0,.30) 1px,
      rgba(0,0,0,0)   1px,
      rgba(0,0,0,0)   calc(1px * var(--scale))
    );
  mix-blend-mode:multiply;
}
#scanlines.off{display:none;}

/* corner vignette, sold separately */
#bezel::after{
  content:"";
  position:absolute;
  inset:10px;
  pointer-events:none;
  background:radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0) 55%, rgba(0,0,0,.38) 100%);
}

#boot{
  position:absolute;
  inset:10px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#000;
  color:var(--hot);
  font-size:13px;
  letter-spacing:2px;
  line-height:1;
  z-index:3;
  cursor:pointer;
}
#boot.hidden{display:none;}

/* ---- legend ---- */
#legend{
  margin:0;
  font-size:11px;
  line-height:1.9;
  text-align:center;
  color:#7c7c8c;
  max-width:calc(256px * var(--scale));
}
#legend b{color:var(--ink);font-weight:600;}

/* ---- touch pad: hidden on anything with a real keyboard ---- */
#pad{display:none;}

@media (hover:none) and (pointer:coarse){
  #pad{
    display:grid;
    grid-template-columns:1fr 1fr;
    grid-template-areas:"dpad ab" "se se";
    gap:12px;
    width:100%;
    max-width:420px;
    user-select:none;
  }
  #legend{display:none;}
  .dpad{grid-area:dpad;display:flex;gap:8px;}
  .ab{grid-area:ab;display:flex;gap:12px;justify-content:flex-end;align-items:center;}
  .se{grid-area:se;display:flex;gap:12px;justify-content:center;}
  .k{
    flex:1 1 auto;
    min-width:52px;
    height:52px;
    border-radius:8px;
    border:1px solid var(--edge);
    background:linear-gradient(#26262f,#1a1a21);
    color:var(--ink);
    font:600 15px/1 inherit;
    box-shadow:0 3px 0 #0a0a0d;
  }
  .k.round{border-radius:50%;width:62px;height:62px;flex:0 0 auto;
    background:linear-gradient(#8e2a2a,#5e1a1a);color:#fff;border-color:#b04040;}
  .k.wide{height:34px;border-radius:17px;font-size:11px;letter-spacing:1px;}
  .k:active{transform:translateY(3px);box-shadow:none;}
}

@media (max-width:560px){
  #cab{padding:8px;gap:10px;}
  #bezel{padding:6px;}
  #scanlines,#bezel::after{inset:6px;}
  #boot{inset:6px;}
}
