/* ============================================================================
   NEON PURGE - DOM overlay styling (ui package, loaded by index.html).

   Self-contained: reads the :root tokens from styles.css, never redefines them,
   and never touches #game, #boot, #fatal or #autotest-report. Only elements
   inside the `.np` root built by src/ui/dom-ui.js are styled.

   POINTER CONTRACT: #ui-root is pointer-events:none. Every panel, scrim and
   decorative layer stays `none` too, so the canvas keeps receiving aim input;
   only .np-btn and .np-card re-enable pointer-events.

   Readable from 900x600 up to 2560x1440.
   ========================================================================= */

.np {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  font-family: var(--font-ui, system-ui, sans-serif);
  color: var(--dim, #7fa8c9);
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------- deco frame ---- */

.np-frame {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease-out;
}

.np-frame::before,
.np-frame::after {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(45, 226, 255, 0.18);
  box-shadow: inset 0 0 90px rgba(45, 226, 255, 0.06);
}

.np-frame::after { inset: 22px; border-color: rgba(157, 123, 255, 0.14); }

.np[data-mode="menu"] .np-frame,
.np[data-mode="paused"] .np-frame,
.np[data-mode="dead"] .np-frame,
.np[data-mode="levelup"] .np-frame { opacity: 1; }

/* -------------------------------------------------------------- scenes ---- */

.np-scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  padding: 3vh 3vw;
  pointer-events: none;
  animation: np-fade 220ms ease-out both;
}

.np-scene[hidden] { display: none; }

.np-scene::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(45, 226, 255, 0.07), transparent 62%),
    radial-gradient(ellipse at 50% 110%, rgba(157, 123, 255, 0.1), transparent 66%),
    rgba(5, 6, 14, 0.72);
}

.np-scene--levelup::before { background: rgba(5, 6, 14, 0.62); }

/* -------------------------------------------------------------- panels ---- */

.np-panel {
  position: relative;
  pointer-events: none;
  width: min(660px, 92vw);
  max-height: 94vh;
  overflow: auto;
  padding: clamp(1.3rem, 2.6vw, 2.4rem);
  border: 1px solid rgba(45, 226, 255, 0.32);
  border-radius: 4px;
  background:
    linear-gradient(180deg, rgba(17, 22, 46, 0.94), rgba(10, 13, 28, 0.96)),
    var(--bg1, #0a0d1c);
  box-shadow:
    0 0 0 1px rgba(5, 6, 14, 0.9),
    0 24px 70px rgba(0, 0, 0, 0.66),
    0 0 60px rgba(45, 226, 255, 0.12);
  backdrop-filter: blur(2px);
  animation: np-rise 260ms cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.np-panel--menu { width: min(760px, 94vw); }
.np-panel--wide { width: min(660px, 94vw); }
.np-panel--tight { width: min(430px, 92vw); text-align: center; }
.np-panel--tight .np-h2 { margin-bottom: 0.9rem; }
.np-panel--tight .np-row { justify-content: center; }

/* ---------------------------------------------------------------- type ---- */

.np-kicker {
  margin: 0 0 0.35rem;
  font-family: var(--font-mono, monospace);
  font-size: clamp(0.6rem, 1vw, 0.72rem);
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--cyan, #2de2ff);
  text-shadow: 0 0 12px rgba(45, 226, 255, 0.5);
}

.np-kicker--dim { color: var(--dim, #7fa8c9); text-shadow: none; letter-spacing: 0.34em; }
.np-kicker--gold { color: var(--gold, #ffe066); text-shadow: 0 0 14px rgba(255, 224, 102, 0.45); }
.np-kicker--red { color: var(--red, #ff2d55); text-shadow: 0 0 14px rgba(255, 45, 85, 0.5); }

.np-title {
  margin: 0;
  font-family: var(--font-mono, monospace);
  font-size: clamp(2.1rem, 7vw, 4.2rem);
  font-weight: 700;
  letter-spacing: 0.2em;
  line-height: 1;
  color: var(--ice, #8ef6ff);
  text-shadow: 0 0 10px rgba(45, 226, 255, 0.7), 0 0 34px rgba(45, 226, 255, 0.35);
}

.np-title__accent {
  color: var(--violet, #9d7bff);
  text-shadow: 0 0 12px rgba(157, 123, 255, 0.7), 0 0 40px rgba(157, 123, 255, 0.4);
}

.np-tag {
  margin: 0.7rem 0 1.5rem;
  font-family: var(--font-mono, monospace);
  font-size: clamp(0.72rem, 1.35vw, 0.88rem);
  letter-spacing: 0.08em;
}

.np-h2 {
  margin: 0 0 1.1rem;
  font-family: var(--font-mono, monospace);
  font-size: clamp(1.25rem, 3.1vw, 2rem);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ice, #8ef6ff);
  text-shadow: 0 0 16px rgba(45, 226, 255, 0.4);
}

.np-h2--gold { color: var(--gold, #ffe066); text-shadow: 0 0 18px rgba(255, 224, 102, 0.5); }
.np-h2--red { color: var(--red, #ff2d55); text-shadow: 0 0 18px rgba(255, 45, 85, 0.55); }
.np-level-no { color: var(--ice, #8ef6ff); font-weight: 700; }

.np-hint {
  margin: 1.1rem 0 0;
  font-family: var(--font-mono, monospace);
  font-size: clamp(0.62rem, 1.1vw, 0.74rem);
  letter-spacing: 0.06em;
  color: rgba(127, 168, 201, 0.85);
}

.np-hint__keys { color: var(--ice, #8ef6ff); }

/* Key chip: shared by the legend, the hints and the action buttons. */
.np-key {
  display: inline-block;
  margin-left: 0.4em;
  padding: 0.1em 0.45em;
  border: 1px solid rgba(45, 226, 255, 0.42);
  border-radius: 3px;
  background: rgba(45, 226, 255, 0.07);
  font-family: var(--font-mono, monospace);
  font-size: 0.82em;
  letter-spacing: 0.1em;
  color: var(--ice, #8ef6ff);
}

/* -------------------------------------------------------------- record ---- */

.np-best-box {
  margin: 0 0 1.5rem;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid rgba(157, 123, 255, 0.28);
  border-radius: 3px;
  background: rgba(157, 123, 255, 0.06);
}

.np-best-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.5rem; }
.np-best-cell { display: flex; flex-direction: column; gap: 0.15rem; }

.np-best-k {
  font-family: var(--font-mono, monospace);
  font-size: 0.6rem;
  letter-spacing: 0.24em;
  color: rgba(127, 168, 201, 0.8);
}

.np-best-v {
  font-family: var(--font-mono, monospace);
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  font-weight: 700;
  color: var(--ice, #8ef6ff);
  text-shadow: 0 0 12px rgba(45, 226, 255, 0.35);
}

/* ------------------------------------------------------------- buttons ---- */

.np-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

.np-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.25rem 0;
  padding: 0.68rem 1.15rem;
  border: 1px solid rgba(45, 226, 255, 0.38);
  border-radius: 3px;
  background: rgba(10, 13, 28, 0.72);
  font-family: var(--font-mono, monospace);
  font-size: clamp(0.7rem, 1.15vw, 0.82rem);
  font-weight: 700;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--ice, #8ef6ff);
  cursor: pointer;
  transition: border-color 140ms ease-out, background 140ms ease-out,
    transform 140ms ease-out, box-shadow 140ms ease-out;
}

.np-btn:hover,
.np-btn:focus-visible {
  border-color: rgba(142, 246, 255, 0.9);
  background: rgba(45, 226, 255, 0.14);
  box-shadow: 0 0 24px rgba(45, 226, 255, 0.28);
  transform: translateY(-1px);
}

.np-btn:active { transform: translateY(1px); }

.np-btn--primary {
  border-color: rgba(182, 255, 59, 0.55);
  background: rgba(182, 255, 59, 0.1);
  color: var(--lime, #b6ff3b);
  box-shadow: 0 0 30px rgba(182, 255, 59, 0.16);
}

.np-btn--primary:hover,
.np-btn--primary:focus-visible {
  border-color: rgba(182, 255, 59, 0.95);
  background: rgba(182, 255, 59, 0.2);
  box-shadow: 0 0 34px rgba(182, 255, 59, 0.32);
}

.np-btn--ghost { border-color: rgba(127, 168, 201, 0.32); background: transparent; color: var(--dim, #7fa8c9); }

.np-btn--ghost:hover,
.np-btn--ghost:focus-visible {
  border-color: rgba(45, 226, 255, 0.6);
  color: var(--ice, #8ef6ff);
  background: rgba(45, 226, 255, 0.08);
}

/* -------------------------------------------------------------- legend ---- */

.np-legend {
  margin-top: 1.6rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(45, 226, 255, 0.16);
}

.np-legend__row {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  align-items: center;
  gap: 0.4rem;
  padding: 0.16rem 0;
  font-family: var(--font-mono, monospace);
  font-size: clamp(0.62rem, 1.1vw, 0.75rem);
}

.np-legend__desc { color: rgba(127, 168, 201, 0.9); letter-spacing: 0.04em; }

/* --------------------------------------------------------------- cards ---- */

.np-level-head { text-align: center; }

.np-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  width: min(1080px, 94vw);
}

.np-card {
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1.05rem 1.1rem 0.9rem;
  border: 1px solid rgba(127, 168, 201, 0.4);
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(17, 22, 46, 0.95), rgba(8, 10, 22, 0.97));
  text-align: left;
  font-family: var(--font-mono, monospace);
  color: var(--dim, #7fa8c9);
  cursor: pointer;
  min-height: clamp(180px, 26vh, 250px);
  transition: transform 150ms ease-out, border-color 150ms ease-out, box-shadow 150ms ease-out;
}

.np-card[hidden] { display: none; }
.np-card--in { animation: np-card-in 340ms cubic-bezier(0.2, 0.8, 0.3, 1) both; }
.np-card__top { display: flex; align-items: center; justify-content: space-between; }

.np-card__glyph {
  font-size: clamp(1.5rem, 3.2vw, 2.1rem);
  line-height: 1;
  color: inherit;
  text-shadow: 0 0 18px currentColor;
}

.np-card__tag { font-size: 0.58rem; letter-spacing: 0.3em; text-transform: uppercase; opacity: 0.85; }

.np-card__name {
  font-size: clamp(0.86rem, 1.5vw, 1.05rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: inherit;
}

.np-card__desc {
  flex: 1;
  font-size: clamp(0.66rem, 1.1vw, 0.78rem);
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: rgba(199, 222, 240, 0.82);
}

.np-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(127, 168, 201, 0.22);
  padding-top: 0.55rem;
}

.np-card__meta { font-size: 0.64rem; letter-spacing: 0.16em; opacity: 0.9; }
.np-card__foot .np-key { margin-left: 0; }

/* Rarity colours: common --dim, rare --cyan, epic --violet. */
.np-card--common { border-color: rgba(127, 168, 201, 0.45); color: var(--dim, #7fa8c9); }
.np-card--rare { border-color: rgba(45, 226, 255, 0.55); color: var(--cyan, #2de2ff); }
.np-card--epic { border-color: rgba(157, 123, 255, 0.6); color: var(--violet, #9d7bff); }

.np-card:hover,
.np-card:focus-visible { transform: translateY(-3px); box-shadow: 0 0 34px rgba(45, 226, 255, 0.24); }

.np-card--common:hover, .np-card--common:focus-visible { box-shadow: 0 0 30px rgba(127, 168, 201, 0.28); }
.np-card--rare:hover, .np-card--rare:focus-visible { box-shadow: 0 0 34px rgba(45, 226, 255, 0.34); }
.np-card--epic:hover, .np-card--epic:focus-visible { box-shadow: 0 0 38px rgba(157, 123, 255, 0.4); }

.np-card--sel {
  transform: translateY(-3px);
  border-color: currentColor;
  box-shadow: 0 0 42px rgba(45, 226, 255, 0.34), inset 0 0 40px rgba(45, 226, 255, 0.08);
}

.np-card--sel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, currentColor 300%);
  opacity: 0.07;
}

.np-card--epic.np-card--sel {
  box-shadow: 0 0 46px rgba(157, 123, 255, 0.42), inset 0 0 44px rgba(157, 123, 255, 0.1);
}

/* ------------------------------------------------------------- summary ---- */

.np-stats { list-style: none; margin: 0.4rem 0 1.3rem; padding: 0; }

.np-stat {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 0.9rem;
  padding: 0.44rem 0;
  border-bottom: 1px solid rgba(45, 226, 255, 0.1);
  font-family: var(--font-mono, monospace);
}

.np-stat__k {
  font-size: clamp(0.6rem, 1.05vw, 0.72rem);
  letter-spacing: 0.26em;
  color: rgba(127, 168, 201, 0.82);
}

.np-stat__v {
  font-size: clamp(1rem, 2.4vw, 1.5rem);
  font-weight: 700;
  color: var(--ice, #8ef6ff);
  font-variant-numeric: tabular-nums;
}

.np-stat__b {
  min-width: 5.5rem;
  text-align: right;
  font-size: clamp(0.58rem, 1vw, 0.7rem);
  letter-spacing: 0.16em;
  color: rgba(127, 168, 201, 0.7);
}

.np-row-beat .np-stat__v { color: var(--gold, #ffe066); text-shadow: 0 0 16px rgba(255, 224, 102, 0.5); }
.np-row-beat .np-stat__b { color: var(--gold, #ffe066); opacity: 0.8; }

.np-best-banner {
  display: inline-block;
  margin: 0 0 1rem;
  padding: 0.35rem 0.9rem;
  border: 1px solid rgba(255, 224, 102, 0.7);
  border-radius: 2px;
  background: rgba(255, 224, 102, 0.08);
  font-family: var(--font-mono, monospace);
  font-size: clamp(0.66rem, 1.2vw, 0.8rem);
  font-weight: 700;
  letter-spacing: 0.34em;
  color: var(--gold, #ffe066);
  text-shadow: 0 0 12px rgba(255, 224, 102, 0.6);
}

.np-best-banner[hidden] { display: none; }
.np-best-banner--on { animation: np-best 1.5s ease-in-out infinite; }

/* --------------------------------------------------------------- toast ---- */

.np-toast {
  position: fixed;
  left: 50%;
  bottom: clamp(3.2rem, 9vh, 5.5rem);
  transform: translateX(-50%);
  padding: 0.4rem 0.95rem;
  border: 1px solid rgba(45, 226, 255, 0.4);
  border-radius: 2px;
  background: rgba(5, 6, 14, 0.82);
  font-family: var(--font-mono, monospace);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  color: var(--ice, #8ef6ff);
  opacity: 0;
  transition: opacity 180ms ease-out;
}

.np-toast[hidden] { display: none; }
.np-toast--on { opacity: 1; }
.np[data-muted="true"] .np-toast { border-color: rgba(255, 45, 85, 0.5); color: var(--red, #ff2d55); }

/* ---------------------------------------------------------- animations ---- */

@keyframes np-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes np-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes np-card-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

@keyframes np-best {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 rgba(255, 224, 102, 0); }
  50% { opacity: 0.75; box-shadow: 0 0 26px rgba(255, 224, 102, 0.35); }
}

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

@media (max-width: 780px) {
  .np-cards { grid-template-columns: minmax(0, 1fr); width: min(460px, 94vw); }
  .np-card { min-height: 0; }
  .np-best-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-height: 640px) {
  .np-stat { padding: 0.28rem 0; }
  .np-card { min-height: 150px; }
  .np-panel { padding: 1.1rem 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .np-scene,
  .np-panel,
  .np-card--in,
  .np-best-banner--on { animation: none !important; }
  .np-btn,
  .np-card,
  .np-frame,
  .np-toast { transition: none !important; }
  .np-btn:hover,
  .np-card:hover,
  .np-card--sel { transform: none; }
}
