:root {
  color-scheme: dark;
  --bg: #071015;
  --panel: #111925;
  --panel-strong: #172536;
  --ink: #f4fbff;
  --muted: #a7bdc7;
  --line: rgba(195, 227, 234, 0.18);
  --electric: #1faeff;
  --cyan: #42e8d4;
  --lime: #8dff62;
  --sun: #f5c84b;
  --coral: #ff6d65;
  --shadow: rgba(0, 0, 0, 0.46);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(66, 232, 212, 0.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(245, 200, 75, 0.035) 1px, transparent 1px),
    linear-gradient(135deg, rgba(31, 174, 255, 0.16), transparent 42%),
    var(--bg);
  background-size: 48px 48px, 48px 48px, auto, auto;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.relic-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  background: rgba(7, 16, 21, 0.54);
}

.topbar {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(31, 174, 255, 0.14), transparent 42%),
    rgba(7, 16, 21, 0.92);
  backdrop-filter: blur(16px);
}

.brand-stack {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.lab-brand,
.game-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  white-space: nowrap;
}

.lab-brand {
  padding: 0.35rem 0.6rem 0.35rem 0.35rem;
  border: 1px solid rgba(66, 232, 212, 0.22);
  border-radius: 8px;
  background: rgba(17, 25, 37, 0.62);
}

.lab-brand img,
.game-brand img {
  width: 2.7rem;
  height: 2.7rem;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 0 18px rgba(31, 174, 255, 0.36);
}

.game-brand img {
  width: 3.1rem;
  height: 3.1rem;
  border: 1px solid rgba(66, 232, 212, 0.38);
}

.lab-brand span,
.game-brand span {
  display: grid;
  gap: 0.08rem;
}

.lab-brand strong,
.game-brand strong {
  font-size: 1rem;
  line-height: 1;
}

.game-brand strong {
  font-size: 1.18rem;
}

.lab-brand small,
.game-brand small {
  color: var(--electric);
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(31, 174, 255, 0.44);
}

.topnav {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.topnav a {
  min-height: 2.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
}

.topnav a:hover {
  color: var(--ink);
  border-color: rgba(66, 232, 212, 0.28);
  background: rgba(17, 25, 37, 0.72);
}

.game-layout {
  width: min(1640px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 390px);
  gap: 1.25rem;
  padding: clamp(1rem, 3vw, 2rem);
}

.game-stage,
.control-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(31, 174, 255, 0.1), rgba(17, 25, 37, 0.84)),
    rgba(17, 25, 37, 0.84);
  box-shadow: 0 24px 60px var(--shadow);
}

.game-stage {
  min-width: 0;
  padding: clamp(1rem, 3vw, 1.5rem);
}

.stage-heading {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.eyebrow,
.section-label {
  margin: 0;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.stage-heading h1 {
  margin: 0;
  font-size: clamp(2.6rem, 7vw, 6rem);
  line-height: 0.92;
  text-shadow: 0 0 28px rgba(31, 174, 255, 0.24);
}

.stage-heading p:not(.eyebrow) {
  width: min(680px, 100%);
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.scene-shell {
  overflow: hidden;
  border: 1px solid rgba(66, 232, 212, 0.28);
  border-radius: 8px;
  background: rgba(5, 10, 15, 0.78);
}

.scene-toolbar {
  min-height: 3.25rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  padding: 0.65rem;
  border-bottom: 1px solid rgba(195, 227, 234, 0.16);
}

.scene-toolbar span,
.scene-toolbar button,
.code-row button,
.final-button,
.finish-panel a {
  min-height: 2.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 900;
}

.scene-toolbar span {
  margin-right: auto;
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(66, 232, 212, 0.22);
  color: var(--cyan);
  background: rgba(7, 16, 21, 0.7);
}

.scene-toolbar button,
.code-row button {
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(195, 227, 234, 0.18);
  color: var(--ink);
  cursor: pointer;
  background: rgba(7, 16, 21, 0.78);
}

.scene-toolbar button:hover,
.code-row button:hover {
  border-color: rgba(66, 232, 212, 0.54);
}

.scene-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #071015;
}

.scene-wrap img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.hotspot {
  position: absolute;
  display: block;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  background: transparent;
  transform: translateZ(0);
}

.hotspot::before,
.hotspot::after {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.hotspot::before {
  border: 2px solid rgba(66, 232, 212, 0.86);
  box-shadow: 0 0 18px rgba(66, 232, 212, 0.36);
}

.hotspot::after {
  background: rgba(141, 255, 98, 0.12);
}

.hotspot:hover::before,
.hotspot:focus-visible::before,
.hotspot.is-hinted::before,
.hotspot.is-found::before,
.hotspot:hover::after,
.hotspot:focus-visible::after,
.hotspot.is-hinted::after {
  opacity: 1;
}

.hotspot.is-hinted::before {
  animation: hintPulse 850ms ease-in-out infinite alternate;
}

.hotspot.is-found {
  cursor: default;
}

.hotspot.is-found::before {
  border-color: rgba(141, 255, 98, 0.84);
}

@keyframes hintPulse {
  from {
    transform: scale(0.92);
  }

  to {
    transform: scale(1.12);
  }
}

.control-panel {
  align-self: start;
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.panel-section {
  display: grid;
  gap: 0.75rem;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.inventory-item {
  min-height: 4.2rem;
  display: grid;
  align-content: center;
  gap: 0.18rem;
  padding: 0.65rem;
  border: 1px solid rgba(195, 227, 234, 0.16);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  background: rgba(7, 16, 21, 0.72);
  text-align: left;
}

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

.inventory-item span {
  color: var(--muted);
  font-size: 0.76rem;
}

.inventory-item:disabled {
  cursor: default;
  opacity: 0.42;
}

.inventory-item.is-active {
  color: #071015;
  border-color: transparent;
  background: linear-gradient(135deg, var(--cyan), var(--sun));
}

.inventory-item.is-active strong,
.inventory-item.is-active span {
  color: #071015;
}

.task-list {
  display: grid;
  gap: 0.45rem;
  margin: 0;
  padding-left: 1.25rem;
  color: var(--muted);
}

.task-list li {
  line-height: 1.45;
}

.task-list li.is-done {
  color: var(--lime);
}

.riddle-text,
.log-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
}

.code-row input {
  width: 100%;
  min-height: 2.8rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(195, 227, 234, 0.2);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(7, 16, 21, 0.82);
  outline: none;
}

.code-row input:focus {
  border-color: rgba(66, 232, 212, 0.74);
  box-shadow: 0 0 0 3px rgba(66, 232, 212, 0.12);
}

.code-row input:disabled,
.code-row button:disabled,
.final-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.final-button,
.finish-panel a {
  width: 100%;
  border: 0;
  color: #071015;
  cursor: pointer;
  background: linear-gradient(135deg, var(--lime), var(--cyan));
  box-shadow: 0 0 28px rgba(66, 232, 212, 0.22);
}

.finish-overlay {
  position: fixed;
  z-index: 8;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(2, 6, 10, 0.72);
  backdrop-filter: blur(10px);
}

.finish-overlay[hidden] {
  display: none;
}

.finish-panel {
  width: min(520px, 100%);
  padding: clamp(1.2rem, 4vw, 2rem);
  border: 1px solid rgba(66, 232, 212, 0.42);
  border-radius: 8px;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(31, 174, 255, 0.18), rgba(66, 232, 212, 0.08)),
    rgba(17, 25, 37, 0.92);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.56);
}

.finish-panel h2 {
  margin: 0.25rem 0 0;
  font-size: clamp(2rem, 7vw, 4rem);
  line-height: 0.98;
}

.finish-panel p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.55;
}

.finish-panel a {
  margin-top: 1rem;
}

@media (max-width: 1120px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .control-panel {
    align-self: stretch;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-stack {
    align-items: flex-start;
    flex-direction: column;
  }

  .topnav {
    width: 100%;
  }

  .topnav a {
    flex: 1;
  }

  .game-layout {
    padding: 0.75rem;
  }

  .scene-toolbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .scene-toolbar span {
    width: 100%;
  }

  .scene-toolbar button {
    flex: 1;
  }

  .inventory-grid,
  .code-row {
    grid-template-columns: 1fr;
  }
}
