/* ==========================================================================
   SPACE INVADERS — presentation layer
   An arcade cabinet sitting in a dark room: bezel, phosphor glow, scanlines.
   ========================================================================== */

:root {
  --px: 3px;                 /* one game pixel, set from JS on resize       */
  --bezel: #16191d;
  --bezel-hi: #2b3138;
  --ink: #cfd8e3;
  --neon: #4dff8f;
  --alert: #ff5f5f;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 10px;
  background:
    radial-gradient(120% 90% at 50% 0%, #101820 0%, #05070a 55%, #000 100%);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body::before {                       /* faint room light behind the cabinet */
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(60% 45% at 50% 42%, rgba(77, 255, 143, .07), transparent 70%);
  pointer-events: none;
}

/* ------------------------------------------------------------- cabinet --- */

.cabinet {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 12px;
  border-radius: 18px;
  border: 1px solid #262c33;
  background: linear-gradient(180deg, #1a1f25 0%, #0e1114 45%, #0a0c0f 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .06),
    inset 0 -2px 0 rgba(0, 0, 0, .6),
    0 30px 70px -20px rgba(0, 0, 0, .95),
    0 0 90px -30px rgba(77, 255, 143, .25);
}

/* ------------------------------------------------------------- marquee --- */

.marquee {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  line-height: 1;
}

.marquee__text {
  font-size: clamp(11px, 2.4vw, 17px);
  font-weight: 700;
  letter-spacing: .46em;
  text-indent: .46em;
  color: #eaf6ff;
  text-shadow:
    0 0 6px rgba(140, 220, 255, .65),
    0 0 18px rgba(77, 255, 143, .45),
    0 0 34px rgba(77, 255, 143, .2);
}

/* -------------------------------------------------------------- screen --- */

.screen {
  position: relative;
  line-height: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
  border: 1px solid #2a3138;
  box-shadow:
    0 0 0 3px #0c0f12,
    0 0 0 4px #242a31,
    inset 0 0 40px rgba(0, 0, 0, .9),
    0 0 26px -6px rgba(77, 255, 143, .35),
    0 0 70px -18px rgba(77, 255, 143, .3);
}

#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  touch-action: none;
}

.scanlines,
.glare,
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, .34) 0,
    rgba(0, 0, 0, .34) calc(var(--px) * .55),
    rgba(255, 255, 255, .015) calc(var(--px) * .55),
    rgba(255, 255, 255, .015) var(--px)
  );
  mix-blend-mode: multiply;
  opacity: .85;
}

.glare {                                  /* soft tube reflection */
  background: linear-gradient(150deg, rgba(255, 255, 255, .055) 0%, transparent 42%, transparent 100%);
}

.vignette {
  background: radial-gradient(120% 100% at 50% 50%, transparent 52%, rgba(0, 0, 0, .55) 100%);
}

/* ------------------------------------------------------------ controls --- */

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.ctl {
  font: inherit;
  font-size: 10px;
  letter-spacing: .12em;
  padding: 5px 10px;
  color: #93a3b3;
  background: linear-gradient(180deg, #1e242b, #14181d);
  border: 1px solid #2c343c;
  border-radius: 5px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}

.ctl:hover { color: var(--neon); border-color: #3c5a47; }
.ctl:active { transform: translateY(1px); }
.ctl:focus-visible { outline: 2px solid var(--neon); outline-offset: 2px; }
.ctl.is-off { color: #5d6a77; }

.hint {
  margin: 0;
  font-size: 10px;
  letter-spacing: .06em;
  color: #6b7a89;
  text-align: center;
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  margin: 0 1px;
  font: inherit;
  font-size: 10px;
  color: #a9b8c6;
  background: #191e24;
  border: 1px solid #2d353d;
  border-bottom-width: 2px;
  border-radius: 4px;
}

/* -------------------------------------------------------- touch pad ------ */

.touch {
  display: none;
  width: 100%;
  gap: 8px;
  margin-top: 2px;
  grid-template-columns: 1fr 1fr 1.4fr;
}

.tbtn {
  font: inherit;
  font-size: 20px;
  font-weight: 700;
  color: #b9f7d1;
  padding: 14px 0;
  background: linear-gradient(180deg, #1b232a, #111519);
  border: 1px solid #2f3a44;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  touch-action: none;
}

.tbtn:active,
.tbtn.is-held {
  color: #04120a;
  background: linear-gradient(180deg, #6dffab, #2fdc7b);
  border-color: #7dffb8;
}

.tbtn--fire { font-size: 14px; letter-spacing: .18em; }

body.is-touch .touch { display: grid; }
body.is-touch .hint { display: none; }

/* -------------------------------------------------------- responsive ----- */

@media (max-height: 560px) {
  .marquee { display: none; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ctl { transition: none; }
}
