/* =========================================================
   NIGHTFALL RUNNER
   Nightfall Automotive — Nord Dark Arcade Theme
   ========================================================= */

/* ---------- Tokens & base ---------- */

:root {
  color-scheme: dark;
  --bg: #242933;
  --bg-deep: #20242d;
  --panel: #2e3440;
  --panel-light: #353d4c;
  --border: #434c5e;
  --text: #eceff4;
  --muted: #aab4c5;
  --dim: #7d899d;
  --cyan: #88c0d0;
  --purple: #b48ead;
  --green: #a3be8c;
  --red: #bf616a;
  --radius: 12px;
  --font: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg-deep);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(136, 192, 208, 0.08), transparent 48%),
    var(--bg-deep);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
}

button,
a {
  font: inherit;
}

a {
  color: var(--cyan);
  text-decoration: none;
}

a:hover {
  color: var(--text);
}

button {
  cursor: pointer;
}

.page {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 18px;
}

/* ---------- Page header ---------- */

.error-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 0 24px;
  margin-bottom: 28px;
  border-bottom: 1px solid rgba(136, 192, 208, 0.16);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  color: var(--cyan);
  font-size: 23px;
  font-weight: 900;
  font-style: italic;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  letter-spacing: 0.15em;
}

.brand-copy strong {
  font-size: 15px;
  font-weight: 900;
}

.brand-copy > span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.3em;
}

.error-code {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.18em;
}

.error-code strong {
  margin-left: 8px;
  color: var(--purple);
  font-size: 20px;
}

/* ---------- Arcade shell ---------- */

.arcade {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.2);
}

.arcade-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  padding: 30px 34px;
  border-bottom: 1px solid var(--border);
}

.eyebrow,
.panel-kicker {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.arcade-header h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(30px, 4vw, 52px);
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.arcade-header h1 span {
  color: var(--purple);
}

.intro {
  max-width: 650px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.live-pill {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border: 1px solid rgba(163, 190, 140, 0.28);
  border-radius: 99px;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px rgba(163, 190, 140, 0.65);
}

.arcade-layout {
  display: grid;
  grid-template-columns: minmax(230px, 0.72fr) minmax(0, 1.8fr);
}

/* ---------- Info panel ---------- */

.info-panel {
  padding: 30px;
  border-right: 1px solid var(--border);
  background: rgba(32, 36, 45, 0.55);
}

.info-panel h2 {
  margin: 0 0 14px;
  font-size: 31px;
  font-weight: 850;
  line-height: 1.12;
  letter-spacing: -0.04em;
}

.info-panel h2 span {
  display: block;
  color: var(--cyan);
}

.info-panel > p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 25px 0;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.stat-card > span,
.stat-card small {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.1em;
}

.stat-card strong {
  color: var(--cyan);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

.controls {
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.control-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 11px;
}

kbd {
  min-width: 30px;
  padding: 3px 7px;
  border: 1px solid #586477;
  border-radius: 4px;
  background: var(--panel-light);
  color: var(--text);
  font-family: var(--font);
  font-size: 10px;
  text-align: center;
}

.touch-hint {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.touch-icon {
  margin-right: 5px;
  color: var(--cyan);
}

.back-link {
  display: inline-block;
  margin-top: 28px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

/* ---------- Game console ---------- */

.console-panel {
  min-width: 0;
  padding: 22px;
}

.console-topline,
.console-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.console-topline {
  margin-bottom: 12px;
}

.console-label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.tiny-led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 9px rgba(136, 192, 208, 0.55);
}

.console-version {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.game-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid #536176;
  border-radius: 8px;
  background: #202833;
  isolation: isolate;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  touch-action: manipulation;
}

#game:focus {
  outline: none;
}

#game:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: -2px;
}

.screen-scanlines {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    rgba(12, 16, 23, 0.12) 4px
  );
}

/* HUD */

.game-hud {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 12px 15px;
  border-bottom: 1px solid rgba(136, 192, 208, 0.15);
  background: rgba(36, 41, 51, 0.78);
  pointer-events: none;
}

.hud-label {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.1em;
}

.hud-label b {
  margin-left: 5px;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

.hud-center {
  color: var(--text);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.hud-center i {
  color: var(--purple);
  font-style: normal;
}

/* Start / game-over overlay */

.game-overlay {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 55px 18px 18px;
  background: rgba(27, 33, 43, 0.72);
  text-align: center;
}

.game-overlay.hidden {
  display: none;
}

.overlay-content {
  max-width: 100%;
}

.overlay-overline {
  color: var(--cyan);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.overlay-content h2 {
  margin: 12px 0;
  color: var(--text);
  font-size: clamp(32px, 5vw, 64px);
  font-weight: 950;
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.overlay-content h2 span {
  color: var(--purple);
}

.overlay-content p {
  margin: 12px 0 20px;
  color: var(--muted);
  font-size: 13px;
}

.start-button {
  padding: 13px 20px;
  border: 1px solid var(--cyan);
  border-radius: 5px;
  background: var(--cyan);
  color: #202833;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.08em;
  transition: background 150ms ease, transform 150ms ease;
}

.start-button:hover {
  transform: translateY(-1px);
  background: #a3d4e1;
}

.start-button span {
  margin-left: 10px;
}

.overlay-content small {
  display: block;
  margin-top: 14px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
}

/* Console footer & decoration */

.console-footer {
  padding: 13px 2px 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
}

.footer-signal {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--green);
}

.footer-right {
  color: var(--text);
}

.footer-slash {
  color: var(--purple);
}

.console-decoration {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-top: 18px;
}

.decor-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #586477;
}

.decor-label {
  margin-left: auto;
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.16em;
}

/* ---------- Page bottom ---------- */

.arcade-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.09em;
}

.arcade-bottom b {
  color: var(--text);
}

.arcade-bottom i {
  color: var(--purple);
  font-style: normal;
}

.page-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 20px 2px 0;
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.12em;
}

/* =========================================================
   RESPONSIVE — standalone page
   ========================================================= */

@media (max-width: 900px) {
  .page {
    width: min(100% - 24px, 700px);
    padding-top: 12px;
  }

  .arcade-header {
    flex-direction: column;
    padding: 24px;
  }

  .arcade-layout {
    grid-template-columns: 1fr;
  }

  .console-panel {
    order: 1;
    padding: 14px;
  }

  .info-panel {
    order: 2;
    padding: 22px;
    border-top: 1px solid var(--border);
    border-right: 0;
  }

  .arcade-bottom {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 520px) {
  .error-header {
    padding-bottom: 15px;
    margin-bottom: 16px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 20px;
  }

  .brand-copy strong {
    font-size: 12px;
  }

  .error-code {
    font-size: 10px;
  }

  .error-code strong {
    font-size: 17px;
  }

  .arcade-header h1 {
    font-size: 34px;
  }

  .info-panel h2 {
    font-size: clamp(28px, 8vw, 36px);
    line-height: 1.18;
    letter-spacing: -0.02em;
  }

  .info-panel h2 span {
    display: block;
    margin-top: 5px;
  }

  .console-panel {
    padding: 8px;
  }

  .console-label {
    font-size: 10px;
  }

  .game-frame {
    aspect-ratio: 4 / 3;
  }

  .game-hud {
    padding: 7px 8px;
  }

  .game-overlay {
    padding: 30px 10px 12px;
  }

  .overlay-content h2 {
    margin: 8px 0 10px;
    font-size: clamp(27px, 8vw, 38px);
    line-height: 0.98;
  }

  .overlay-content p {
    margin: 6px 0 10px;
    font-size: 12px;
  }

  .start-button {
    padding: 10px 12px;
    font-size: 10px;
  }

  .page-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Easy-to-tap return link */
  .back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 11px 13px;
    margin-top: 20px;
    border: 1px solid var(--cyan);
    background: rgba(136, 192, 208, 0.08);
    line-height: 1.4;
  }
}

/* =========================================================
   EMBED MODE — activated with ?embed=1 (html.embed-mode)
   Placed last so these rules win on specificity + order,
   which is why no !important is needed.
   ========================================================= */

html.embed-mode,
html.embed-mode body {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--bg-deep);
}

/* Hide everything except the console */
html.embed-mode .error-header,
html.embed-mode .arcade-header,
html.embed-mode .info-panel,
html.embed-mode .arcade-bottom,
html.embed-mode .page-footer {
  display: none;
}

html.embed-mode .page,
html.embed-mode main,
html.embed-mode .arcade,
html.embed-mode .arcade-layout {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-width: none;
  margin: 0;
  padding: 0;
}

html.embed-mode .arcade {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

html.embed-mode .arcade-layout {
  display: block;
}

/* Console becomes a column: topline / game / footer / decoration */
html.embed-mode .console-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

html.embed-mode .console-topline {
  flex: 0 0 36px;
  min-height: 36px;
  margin: 0;
  padding: 6px 12px;
  background: var(--bg);
}

html.embed-mode .game-frame {
  flex: 1 1 0;
  width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: auto;
  margin: 0;
  border-right: 0;
  border-left: 0;
  border-radius: 0;
}

html.embed-mode .console-footer {
  flex: 0 0 34px;
  min-height: 34px;
  padding: 10px 12px 0;
}

html.embed-mode .console-decoration {
  flex: 0 0 26px;
  min-height: 26px;
  padding: 8px 12px 6px;
}

html.embed-mode .game-hud {
  padding: 8px 12px;
}

html.embed-mode .game-overlay {
  padding: 42px 12px 12px;
  overflow: hidden;
}

html.embed-mode .overlay-content h2 {
  font-size: clamp(28px, 5vw, 54px);
}

html.embed-mode .overlay-content p {
  margin: 8px 0 14px;
}

html.embed-mode .start-button {
  padding: 10px 16px;
}

@media (max-width: 520px) {
  html.embed-mode .console-topline {
    flex-basis: 30px;
    min-height: 30px;
    padding: 5px 8px;
  }

  html.embed-mode .console-footer {
    flex-basis: 30px;
    min-height: 30px;
  }

  html.embed-mode .console-decoration {
    flex-basis: 22px;
    min-height: 22px;
    padding: 6px 8px 4px;
  }

  html.embed-mode .game-overlay {
    padding: 34px 10px 10px;
  }

  html.embed-mode .overlay-content h2 {
    font-size: clamp(25px, 7vw, 38px);
    line-height: 1.02;
  }

  html.embed-mode .overlay-content p {
    margin: 6px 0 10px;
    font-size: 12px;
  }

  html.embed-mode .start-button {
    padding: 8px 12px;
  }
}
