/* ── Palette ────────────────────────────────────────────────────────────────
   Taken from the game itself so the site and the build cannot drift apart:

     --pink        uifx_panel_text_colour()  rgb(255, 150, 200)  "Tush Status pink"
     --panel       uifx_panel_text_shadow()  rgb(55, 15, 45)     "dark plum"
     --rail        nursery rail body         rgb(250, 218, 221)
     --rail-edge   nursery rail outer edge   rgb(216, 154, 171)
     --rail-shine  nursery rail highlight    rgb(255, 240, 244)
     --orchid      dungeon rail body         rgb(164, 116, 214)

   All six live in scripts/scrUIBarFX/scrUIBarFX.gml. If they change there,
   change them here too.
   ------------------------------------------------------------------------- */

:root {
  color-scheme: dark;
  --page: #1a0611;
  --panel: #370f2d;
  --panel-deep: #2a0a20;
  --ink: #fff0f4;
  --muted: #e0b8cb;
  --pink: #ff96c8;
  --orchid: #a474d6;
  --rail: #fadadd;
  --rail-edge: #d89aab;
  --rail-shine: #fff0f4;
  --gold: #ffe66f;
  --line: rgba(250, 218, 221, 0.22);
  --shadow: rgba(0, 0, 0, 0.72);

  /* The CSS translation of uifx_draw_nursery_rail_rectangle(): a five-pixel
     band reading edge / body / shine / body / edge from the outside in. Each
     later shadow is wider and paints behind the one before it, so the stack
     renders as five one-pixel rings. Drawn inside the element's edges, exactly
     as the GML routine does. */
  --nursery-rail:
    inset 0 0 0 1px var(--rail-edge),
    inset 0 0 0 2px var(--rail),
    inset 0 0 0 3px var(--rail-shine),
    inset 0 0 0 4px var(--rail),
    inset 0 0 0 5px var(--rail-edge);

  /* uifx_draw_nursery_rail_vertical(), for a single right-hand edge. */
  --nursery-rail-right:
    inset -1px 0 0 var(--rail-edge),
    inset -2px 0 0 var(--rail),
    inset -3px 0 0 var(--rail-shine),
    inset -4px 0 0 var(--rail),
    inset -5px 0 0 var(--rail-edge);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--page);
}

body {
  position: relative;
  color: var(--ink);
  font-family: "Segoe UI", Inter, ui-sans-serif, system-ui, sans-serif;
  background-color: #200818;
  animation: signal-pulse 8s ease-in-out infinite;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 999;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(rgba(26, 6, 17, 0) 50%, rgba(0, 0, 0, 0.24) 50%),
    linear-gradient(90deg, rgba(255, 150, 200, 0.045), rgba(250, 218, 221, 0.018), rgba(164, 116, 214, 0.045));
  background-size: 100% 3px, 4px 100%;
}

body::after {
  position: fixed;
  inset: 0;
  z-index: 1000;
  content: "";
  pointer-events: none;
  background: rgba(255, 255, 255, 0.028);
  opacity: 0.02;
  animation: crt-flicker 180ms infinite;
}

html.crt-disabled body {
  background-color: var(--page);
  animation: none;
}

html.crt-disabled body::before,
html.crt-disabled body::after {
  display: none;
}

html.crt-disabled h1 {
  text-shadow: 0 0 15px rgba(255, 150, 200, 0.4);
  animation: none;
}

button,
a {
  font: inherit;
}

a {
  color: var(--rail);
}

.site-shell {
  display: grid;
  grid-template-columns: clamp(240px, 19vw, 310px) minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background:
    linear-gradient(rgba(250, 218, 221, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(250, 218, 221, 0.022) 1px, transparent 1px),
    radial-gradient(circle at 0 0, rgba(164, 116, 214, 0.24), transparent 34rem),
    var(--page);
  background-size: 36px 36px, 36px 36px, auto, auto;
}

.about-panel {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: clamp(34px, 5vh, 54px) clamp(18px, 2vw, 30px) 20px;
  overflow-y: auto;
  background:
    linear-gradient(165deg, rgba(255, 150, 200, 0.09), transparent 27%),
    repeating-linear-gradient(135deg, transparent 0 12px, rgba(250, 218, 221, 0.015) 12px 13px),
    var(--panel);
  box-shadow: var(--nursery-rail-right), 9px 0 0 rgba(255, 150, 200, 0.08), 20px 0 48px var(--shadow);
}

.about-panel::before {
  position: absolute;
  top: 13px;
  right: 18px;
  left: 18px;
  height: 10px;
  color: var(--rail);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.55rem;
  line-height: 10px;
  letter-spacing: 0.15em;
  content: "CHRYSALIS // LDQ-01";
  border-top: 1px solid rgba(250, 218, 221, 0.55);
  border-right: 42px solid var(--pink);
  opacity: 0.84;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 17px;
  color: var(--rail);
  font-family: Consolas, "Courier New", monospace;
  font-size: 27px;
  background: linear-gradient(145deg, rgba(255, 150, 200, 0.2), rgba(250, 218, 221, 0.06));
  border: 1px solid var(--rail);
  border-radius: 0;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  box-shadow: inset 0 0 17px rgba(250, 218, 221, 0.14), 5px 5px 0 rgba(255, 150, 200, 0.23);
}

h1 {
  margin: 0;
  font-family: "Arial Black", "Segoe UI Black", Impact, sans-serif;
  font-size: clamp(2rem, 3vw, 2.75rem);
  font-weight: 900;
  font-style: italic;
  line-height: 0.88;
  letter-spacing: -0.075em;
  text-shadow: 2px 0 0 rgba(250, 218, 221, 0.78), -2px 0 0 rgba(255, 150, 200, 0.58), 0 0 16px rgba(255, 150, 200, 0.34);
  animation: chromatic-jitter 4.8s steps(1, end) infinite;
}

.tagline {
  margin: 13px 0 0;
  color: var(--pink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.summary {
  margin: 25px 0 0;
  padding-left: 13px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.65;
  border-left: 2px solid rgba(250, 218, 221, 0.42);
}

.traits {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.traits li {
  padding: 6px 9px;
  color: var(--rail);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  background: rgba(250, 218, 221, 0.045);
  border: 1px solid rgba(250, 218, 221, 0.27);
  border-radius: 0;
  clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px);
}

.notice {
  margin: 23px 0 0;
  padding: 12px 13px;
  color: #e6c3d5;
  font-size: 0.73rem;
  line-height: 1.5;
  background: linear-gradient(90deg, rgba(255, 150, 200, 0.11), rgba(42, 10, 32, 0.32));
  border: 1px solid rgba(255, 150, 200, 0.28);
  border-left: 3px solid var(--pink);
  border-radius: 0;
}

.notice strong {
  color: var(--ink);
}

.panel-actions {
  display: grid;
  gap: 9px;
  margin-top: auto;
  padding-top: 26px;
}

.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 13px;
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
  background: rgba(250, 218, 221, 0.045);
  border: 1px solid rgba(250, 218, 221, 0.48);
  border-radius: 0;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  transition: transform 110ms ease, color 110ms ease, background 110ms ease, box-shadow 110ms ease;
}

.action.primary {
  color: #2b0a1f;
  background: linear-gradient(105deg, var(--pink), #ffc2dd);
  border-color: var(--pink);
  box-shadow: 4px 4px 0 rgba(250, 218, 221, 0.28);
}

/* Gold treatment so the chart reads as content, not another utility control */
.action.chart-link {
  gap: 7px;
  color: var(--gold);
  border-color: rgba(255, 230, 111, 0.62);
  background: rgba(255, 230, 111, 0.08);
  box-shadow: 4px 4px 0 rgba(255, 230, 111, 0.16);
}

.action.chart-link:hover {
  color: #2b0a1f;
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 4px 4px 0 rgba(255, 150, 200, 0.34);
}

.chart-link-star {
  font-size: 0.9rem;
  line-height: 1;
  text-shadow: 0 0 8px rgba(255, 230, 111, 0.8);   /* Makes the star sit forward of the label */
}

.crt-toggle[aria-pressed="true"] {
  color: var(--rail);
  border-color: rgba(250, 218, 221, 0.66);
  box-shadow: inset 3px 0 0 var(--rail);
}

.crt-toggle[aria-pressed="false"] {
  color: var(--muted);
  border-color: rgba(224, 184, 203, 0.28);
  box-shadow: inset 3px 0 0 rgba(224, 184, 203, 0.4);
}

.action:hover {
  color: #1a0611;
  transform: translate(-1px, -1px);
  background: var(--rail);
  border-color: var(--rail);
  box-shadow: 4px 4px 0 rgba(255, 150, 200, 0.34);
}

.action:focus-visible,
.game-frame:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.game-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: clamp(8px, 1vw, 15px);
  background:
    linear-gradient(rgba(250, 218, 221, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(250, 218, 221, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 82% 10%, rgba(255, 150, 200, 0.16), transparent 28rem),
    linear-gradient(145deg, #1a0611, #2a0a20);
  background-size: 38px 38px, 38px 38px, auto, auto;
}

.frame-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #2a0a20;
  border: none;
  border-radius: 0;
  clip-path: polygon(13px 0, 100% 0, 100% calc(100% - 13px), calc(100% - 13px) 100%, 0 100%, 0 13px);
  box-shadow: var(--nursery-rail), 0 0 27px rgba(250, 218, 221, 0.08), 0 20px 55px rgba(0, 0, 0, 0.58);
}

.frame-wrap::before {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 3;
  padding: 5px 12px 6px 18px;
  color: #1a0611;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  content: "SIMULATION FEED // LIVE";
  pointer-events: none;
  background: var(--rail);
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%);
}

.game-frame {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  background: #2a0a20;
  border: 0;
}

.loading-card {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  color: var(--rail);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background:
    radial-gradient(circle, rgba(164, 116, 214, 0.15), transparent 38%),
    #2a0a20;
  transition: opacity 220ms ease, visibility 220ms ease;
}

.loading-card::before {
  position: absolute;
  width: 32px;
  height: 32px;
  margin-top: -58px;
  content: "";
  border: 2px solid rgba(250, 218, 221, 0.16);
  border-top-color: var(--pink);
  border-right-color: var(--rail);
  animation: spin 800ms linear infinite;
}

.frame-wrap.is-loaded .loading-card {
  visibility: hidden;
  opacity: 0;
}

/* In-page debug hotkey modal */

.debug-modal[hidden] {
  display: none;
}

.debug-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2vw, 28px);
  background: rgba(26, 6, 17, 0.84);
  backdrop-filter: blur(8px);
}

.debug-modal-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1120px, 100%);
  max-height: min(900px, 92vh);
  max-height: min(900px, 92dvh);
  overflow: hidden;
  background:
    linear-gradient(115deg, rgba(255, 150, 200, 0.1), transparent 34%),
    repeating-linear-gradient(135deg, transparent 0 15px, rgba(250, 218, 221, 0.015) 15px 16px),
    rgba(42, 10, 32, 0.985);
  border: none;
  clip-path: polygon(16px 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%, 0 16px);
  box-shadow: var(--nursery-rail), 8px 8px 0 rgba(255, 150, 200, 0.16), 0 28px 90px rgba(0, 0, 0, 0.75);
}

.debug-modal-panel::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 2;
  height: 4px;
  content: "";
  background: linear-gradient(90deg, var(--rail) 0 42%, transparent 42% 45%, var(--pink) 45% 100%);
}

.debug-modal-header {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 22px 26px 18px;
  background: rgba(55, 15, 45, 0.94);
  border-bottom: 1px solid rgba(250, 218, 221, 0.3);
}

.debug-kicker,
.section-code {
  margin: 0;
  color: var(--rail);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.debug-modal-title {
  margin: 7px 0 0;
  color: var(--pink);
  font-family: "Arial Black", "Segoe UI Black", Impact, sans-serif;
  font-size: clamp(1.8rem, 5vw, 3.25rem);
  font-style: italic;
  line-height: 0.9;
  letter-spacing: -0.055em;
  text-shadow: 2px 0 0 rgba(250, 218, 221, 0.7), -2px 0 0 rgba(255, 150, 200, 0.6);
}

.debug-modal-summary {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.debug-modal-close {
  min-width: 150px;
}

.debug-modal-content {
  padding: 0 24px 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--rail) var(--panel-deep);
}

.hotkey-section {
  margin-top: 26px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 10px;
}

.section-heading h2,
.section-heading h3 {
  margin: 5px 0 0;
  font-family: "Arial Black", "Segoe UI Black", Impact, sans-serif;
  font-size: clamp(1.35rem, 3vw, 2rem);
  font-style: italic;
  letter-spacing: -0.035em;
  text-transform: uppercase;
}

.entry-count {
  flex: 0 0 auto;
  color: var(--pink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.66rem;
  letter-spacing: 0.1em;
}

.hotkey-table-wrap {
  overflow-x: auto;
  background: rgba(42, 10, 32, 0.9);
  border: 1px solid rgba(250, 218, 221, 0.28);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

.hotkey-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.hotkey-table th,
.hotkey-table td {
  padding: 13px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(250, 218, 221, 0.12);
}

.hotkey-table tr:last-child td {
  border-bottom: 0;
}

.hotkey-table th {
  color: var(--rail);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: rgba(250, 218, 221, 0.065);
}

.hotkey-table tbody tr {
  transition: background 120ms ease, box-shadow 120ms ease;
}

.hotkey-table tbody tr:hover {
  background: rgba(255, 150, 200, 0.055);
  box-shadow: inset 3px 0 0 var(--pink);
}

.key-cell {
  width: 175px;
  white-space: nowrap;
}

kbd {
  display: inline-block;
  min-width: 38px;
  margin: 0 3px 3px 0;
  padding: 5px 8px;
  color: #2a0a20;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  background: var(--rail);
  border: 1px solid #ffd9e8;
  box-shadow: 3px 3px 0 rgba(255, 150, 200, 0.48);
}

.effect-title {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-weight: 750;
}

.effect-detail,
.condition {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.condition {
  width: 29%;
}

.zone-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.zone-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 13px;
  min-height: 72px;
  padding: 13px;
  background: rgba(42, 10, 32, 0.9);
  border: 1px solid rgba(250, 218, 221, 0.25);
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
}

.zone-card strong {
  display: block;
  color: var(--ink);
  font-size: 0.87rem;
}

.zone-card small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.65rem;
}

.retired-note {
  margin-top: 26px;
  padding: 16px 18px;
  color: #e6c3d5;
  font-size: 0.83rem;
  line-height: 1.6;
  background: linear-gradient(90deg, rgba(255, 150, 200, 0.1), rgba(42, 10, 32, 0.9));
  border: 1px solid rgba(255, 150, 200, 0.3);
  border-left: 4px solid var(--pink);
}

.retired-note strong {
  color: var(--pink);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes signal-pulse {
  0%,
  100% {
    background-color: #200818;
  }
  50% {
    background-color: #200818;
  }
}

@keyframes crt-flicker {
  0%,
  100% {
    opacity: 0.015;
  }
  33% {
    opacity: 0.055;
  }
  71% {
    opacity: 0.025;
  }
}

@keyframes chromatic-jitter {
  0%,
  91%,
  100% {
    text-shadow: 2px 0 0 rgba(250, 218, 221, 0.78), -2px 0 0 rgba(255, 150, 200, 0.58), 0 0 16px rgba(255, 150, 200, 0.34);
  }
  92% {
    text-shadow: 5px 0 0 rgba(250, 218, 221, 0.64), -3px 0 0 rgba(255, 150, 200, 0.7), 0 0 18px rgba(255, 150, 200, 0.42);
  }
  94% {
    text-shadow: 1px 0 0 rgba(250, 218, 221, 0.8), -5px 0 0 rgba(255, 150, 200, 0.55), 0 0 12px rgba(250, 218, 221, 0.3);
  }
}

@media (max-width: 760px) {
  html,
  body {
    overflow: auto;
  }

  .site-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(70vh, 1fr);
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .about-panel {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 15px;
    padding: 27px 16px 14px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid rgba(250, 218, 221, 0.62);
    box-shadow: 0 12px 34px var(--shadow);
  }

  .brand-mark {
    grid-row: 1 / span 2;
    margin: 0;
  }

  h1 {
    font-size: 1.65rem;
    line-height: 1;
  }

  .tagline {
    margin-top: 6px;
    font-size: 0.65rem;
  }

  .summary,
  .traits,
  .notice {
    display: none;
  }

  .panel-actions {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-top: 14px;
  }

  .panel-actions .crt-toggle {
    grid-column: 1 / -1;
  }

  .action {
    min-height: 38px;
    padding: 7px 5px;
    font-size: 0.62rem;
  }

  .game-stage {
    min-height: 70vh;
    min-height: 70dvh;
    padding: 7px;
  }

  .frame-wrap {
    clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  }

  .debug-modal {
    padding: 6px;
  }

  .debug-modal-panel {
    max-height: calc(100dvh - 12px);
    clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  }

  .debug-modal-header {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 20px 14px 14px;
  }

  .debug-modal-title {
    font-size: clamp(1.8rem, 10vw, 2.6rem);
  }

  .debug-modal-close {
    width: 100%;
  }

  .debug-modal-content {
    padding: 0 12px 18px;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
    gap: 5px;
  }

  .zone-grid {
    grid-template-columns: 1fr;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
