:root {
  color-scheme: dark;
  --bg: #05070c;
  --panel: rgba(5, 7, 12, 0.82);
  --panel-strong: rgba(11, 17, 29, 0.94);
  --text: #f8fafc;
  --muted: #a9b8cc;
  --cyan: #18e7ff;
  --magenta: #ff2bd6;
  --yellow: #f8f04a;
  --orange: #ff8a35;
  --line: rgba(255, 255, 255, 0.18);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button,
a {
  color: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  min-height: 40px;
  padding: 9px 12px;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  border-color: var(--cyan);
  outline: none;
  box-shadow: 0 0 0 2px rgba(24, 231, 255, 0.24);
}

#app-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

.screen-art-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 3;
  background:
    linear-gradient(90deg, rgba(5, 7, 12, 0.24), rgba(5, 7, 12, 0.2) 42%, rgba(5, 7, 12, 0.72)),
    linear-gradient(0deg, rgba(5, 7, 12, 0.78), rgba(5, 7, 12, 0.2) 38%, rgba(5, 7, 12, 0.24)),
    url("../assets/cutscenes/cyberpunk-voxel-sky-start.png") center / cover no-repeat;
}

body[data-screen="intro"] .screen-art-backdrop,
body[data-screen="tutorial"] .screen-art-backdrop,
body[data-screen="settings"] .screen-art-backdrop,
body[data-screen="credits"] .screen-art-backdrop {
  display: block;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(24, 231, 255, 0.1) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 43, 214, 0.08) 1px, transparent 1px),
    rgba(5, 7, 12, 0.96);
  background-size: 42px 42px;
}

.loading-screen[hidden] {
  display: none;
}

.loading-panel {
  width: min(480px, calc(100vw - 36px));
  padding: 20px;
  border: 1px solid rgba(24, 231, 255, 0.55);
  border-radius: 8px;
  background: rgba(5, 7, 12, 0.9);
  box-shadow: 0 0 36px rgba(24, 231, 255, 0.16), 0 0 54px rgba(255, 43, 214, 0.12);
}

.loading-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--yellow);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.loading-panel h1 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 6vw, 3.4rem);
  line-height: 1;
}

.loading-panel p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.4;
}

.loading-meter {
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.loading-meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--magenta), var(--yellow));
  box-shadow: 0 0 18px rgba(24, 231, 255, 0.55);
  transition: width 120ms linear;
}

.loading-panel strong {
  display: block;
  margin-top: 10px;
  color: var(--cyan);
  font-size: 13px;
}

.hud-shell {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.topbar,
.art-card,
.portal-strip,
.diagnostics-line,
.mobile-pad {
  pointer-events: auto;
}

.topbar {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.topbar strong {
  font-size: 15px;
}

.topbar span {
  color: var(--yellow);
  margin-right: auto;
  font-size: 13px;
}

.art-card {
  position: fixed;
  left: 14px;
  bottom: 54px;
  width: min(320px, calc(100vw - 28px));
  max-height: min(54vh, 430px);
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.art-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  margin-bottom: 10px;
}

/* display:block above would otherwise defeat the hidden attribute, leaving a
   broken-image box for records without a downloaded photo. */
.art-card img[hidden] {
  display: none;
}

.art-card h2 {
  margin: 0 0 6px;
  font-size: 17px;
  line-height: 1.16;
}

.art-card p,
.art-card a {
  display: block;
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--muted);
}

.art-card a {
  color: var(--cyan);
  overflow-wrap: anywhere;
}

.portal-strip {
  position: fixed;
  right: 14px;
  top: 82px;
  width: min(250px, calc(100vw - 28px));
  max-height: calc(100vh - 150px);
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

#portal-list {
  display: grid;
  gap: 7px;
}

.portal-button {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  text-align: left;
  font-size: 12px;
}

.diagnostics-line {
  position: fixed;
  left: 14px;
  bottom: 12px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-shadow: 0 2px 8px #000;
}

.screen-panel {
  position: fixed;
  z-index: 5;
  left: 50%;
  top: 50%;
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  transform: translate(-50%, -50%);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.screen-panel[hidden] {
  display: none;
}

.screen-panel h1,
.screen-panel h2 {
  margin: 0 0 10px;
  line-height: 1.05;
}

.screen-panel h1 {
  font-size: clamp(2rem, 7vw, 4.5rem);
}

.screen-panel h2 {
  font-size: 1.6rem;
}

.screen-panel p,
.screen-panel li,
.screen-panel label {
  color: var(--muted);
  line-height: 1.45;
}

.cyber-screen-panel {
  left: auto;
  right: min(7vw, 78px);
  width: min(470px, calc(100vw - 28px));
  border-color: rgba(24, 231, 255, 0.4);
  background: rgba(5, 7, 12, 0.7);
  backdrop-filter: blur(10px);
  box-shadow: 0 0 34px rgba(24, 231, 255, 0.14), 0 18px 54px rgba(0, 0, 0, 0.5);
}

.intro-panel {
  display: block;
}

.tutorial-panel {
  min-height: 250px;
}

.tutorial-panel #tutorial-text {
  min-height: 78px;
  font-size: 1.02rem;
  color: var(--text);
}

.tutorial-panel #tutorial-count {
  display: inline-block;
  color: var(--cyan);
  font-size: 13px;
  font-weight: 700;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.screen-panel label {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 40px;
}

.citations-panel ol {
  display: grid;
  gap: 10px;
  max-height: 52vh;
  overflow: auto;
  padding-left: 22px;
}

.citations-panel a {
  color: var(--cyan);
  font-weight: 700;
}

.citations-panel span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.mobile-pad {
  display: none;
  position: fixed;
  right: 14px;
  bottom: 14px;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(2, 44px);
  gap: 6px;
}

.mobile-pad button {
  min-height: 44px;
  padding: 0;
}

.mobile-pad [data-move="forward"] {
  grid-column: 2;
}

.mobile-pad [data-move="left"] {
  grid-column: 1;
  grid-row: 2;
}

.mobile-pad [data-move="back"] {
  grid-column: 2;
  grid-row: 2;
}

.mobile-pad [data-move="right"] {
  grid-column: 3;
  grid-row: 2;
}

body:not([data-screen="gallery"]) .hud-shell {
  display: none;
}

@media (max-width: 780px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .topbar span {
    width: 100%;
    order: 4;
  }

  .portal-strip {
    display: none;
  }

  .cyber-screen-panel {
    left: 50%;
    right: auto;
    width: min(520px, calc(100vw - 28px));
    transform: translate(-50%, -50%);
  }

  .art-card {
    bottom: 124px;
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 10px;
    max-height: 34vh;
  }

  .art-card img {
    grid-row: 1 / span 4;
    aspect-ratio: 1;
    margin-bottom: 0;
  }

  .art-card h2,
  .art-card p,
  .art-card a {
    margin-bottom: 5px;
  }

  .art-card button {
    grid-column: 2;
    min-height: 36px;
    padding: 7px 9px;
  }

  .mobile-pad {
    display: grid;
  }
}

@media (max-width: 460px) {
  .topbar {
    left: 8px;
    right: 8px;
    top: 8px;
  }

  .art-card {
    left: 8px;
    width: calc(100vw - 16px);
  }

  .screen-panel {
    width: calc(100vw - 16px);
    padding: 14px;
  }

  .screen-panel h1 {
    font-size: 2.15rem;
  }

  .tutorial-panel #tutorial-text {
    min-height: 112px;
  }
}
