:root {
  --lab-ink: #120f18;
  --lab-white: #fffaf2;
  --lab-muted: #d8d0e8;
  --lab-green: #92ff18;
  --lab-purple: #7e4dff;
  --lab-red: #ff3047;
  --lab-gold: #ffd45c;
  --lab-sand: #f4b95b;
  --lab-blue: #43d8ff;
  --lab-panel: rgba(12, 10, 18, 0.88);
  --lab-line: rgba(255, 255, 255, 0.16);
}

* {
  box-sizing: border-box;
}

body.sphynx-lab-page {
  margin: 0;
  color: var(--lab-white);
  background:
    radial-gradient(circle at 18% 8%, rgba(146, 255, 24, 0.16), transparent 30%),
    radial-gradient(circle at 86% 18%, rgba(126, 77, 255, 0.22), transparent 34%),
    linear-gradient(180deg, #08070b 0%, #12101b 58%, #21170e 100%);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

body.sphynx-lab-page img {
  max-width: 100%;
  height: auto;
}

.lab-site-header,
.lab-site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 16px 0;
}

.lab-brand,
.lab-nav a,
.lab-site-footer a {
  color: var(--lab-white);
  text-decoration: none;
  font-weight: 900;
}

.lab-brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 9px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--lab-line);
}

.lab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lab-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--lab-line);
}

.lab-page-main {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto 42px;
}

.lab-page-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(320px, 1.12fr);
  gap: clamp(16px, 3vw, 32px);
  align-items: center;
  min-height: 270px;
  padding: clamp(18px, 4vw, 40px);
  border: 1px solid var(--lab-line);
  border-radius: 24px;
  background:
    linear-gradient(120deg, rgba(9, 8, 13, 0.96) 0%, rgba(18, 14, 28, 0.82) 48%, rgba(55, 31, 16, 0.58) 100%),
    radial-gradient(circle at 82% 28%, rgba(255, 212, 92, 0.23), transparent 38%);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.42);
  overflow: hidden;
}

.lab-kicker {
  margin: 0 0 8px;
  color: var(--lab-green);
  font-size: 0.76rem;
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lab-page-hero h1 {
  margin: 0;
  max-width: 620px;
  font-size: clamp(2.2rem, 6vw, 4.9rem);
  line-height: 0.93;
  letter-spacing: 0;
  font-weight: 1000;
}

.lab-page-hero h1 span {
  color: var(--lab-green);
}

.lab-page-hero p {
  max-width: 56ch;
  color: var(--lab-muted);
  font-size: clamp(1rem, 2vw, 1.15rem);
  line-height: 1.55;
}

.lab-hero-visual {
  position: relative;
  min-height: 290px;
}

.lab-hero-machine {
  position: absolute;
  inset: auto 0 8px 0;
  height: 74px;
  border-radius: 28px 28px 20px 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 38%),
    linear-gradient(90deg, #232032, #111018 45%, #2f1e12);
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.42);
}

.lab-hero-sphynx,
.lab-hero-hamster {
  position: absolute;
  object-fit: contain;
  filter: drop-shadow(0 24px 24px rgba(0, 0, 0, 0.45));
  pointer-events: none;
}

.lab-hero-sphynx {
  right: 18%;
  bottom: 24px;
  width: min(52vw, 310px);
  transform: rotate(-6deg);
  animation: lab-hero-bob 3.4s ease-in-out infinite;
}

.lab-hero-hamster {
  right: 1%;
  bottom: 58px;
  width: min(34vw, 185px);
  transform: rotate(8deg);
  animation: lab-hero-bob 3s ease-in-out -0.8s infinite;
}

@keyframes lab-hero-bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -10px; }
}

.lab-shell {
  margin-top: 18px;
  border-radius: 24px;
  border: 1px solid var(--lab-line);
  background:
    radial-gradient(circle at 14% 0%, rgba(146, 255, 24, 0.14), transparent 35%),
    radial-gradient(circle at 92% 18%, rgba(255, 48, 71, 0.16), transparent 34%),
    rgba(10, 8, 15, 0.96);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.48);
  overflow: hidden;
}

.lab-game {
  position: relative;
}

.lab-screen {
  display: none;
}

.lab-screen.is-visible {
  display: block;
}

.lab-build-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.78fr) minmax(0, 1.22fr);
  gap: 18px;
  padding: clamp(14px, 3vw, 26px);
}

.lab-build-stage,
.lab-builder-panel,
.lab-result-panel,
.lab-book-panel {
  border-radius: 20px;
  border: 1px solid var(--lab-line);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08);
}

.lab-build-stage {
  position: relative;
  min-height: 470px;
  overflow: hidden;
  background:
    radial-gradient(circle at 48% 22%, rgba(67, 216, 255, 0.16), transparent 26%),
    linear-gradient(180deg, rgba(23, 19, 34, 0.88), rgba(10, 9, 14, 0.92));
}

.lab-lab-table {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 42px;
  height: 88px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 46%),
    linear-gradient(90deg, #2b263c, #13111b 55%, #4d3417);
  border: 2px solid rgba(255, 255, 255, 0.14);
}

.lab-machine {
  position: absolute;
  left: 14%;
  bottom: 88px;
  width: 56%;
  min-height: 142px;
}

.lab-machine::before,
.lab-machine::after {
  content: "";
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease;
}

.lab-machine.is-ready::before {
  left: -48px;
  bottom: 46px;
  width: 74px;
  height: 46px;
  border-radius: 50%;
  opacity: 1;
  background: radial-gradient(circle at 78% 50%, rgba(255,255,255,.95), rgba(104,226,255,.52) 40%, transparent 72%);
  filter: blur(1px);
  animation: lab-exhaust 720ms ease-in-out infinite alternate;
}

.lab-machine[data-propulsion="rocket"]::before,
.lab-machine[data-propulsion="turbine"]::before {
  background: linear-gradient(90deg, transparent, #43d8ff 34%, #fff 58%, #ff8f38);
  clip-path: polygon(0 50%, 100% 0, 78% 50%, 100% 100%);
}

.lab-machine[data-propulsion="extinguisher"]::before {
  width: 96px;
  background: radial-gradient(circle at 80% 50%, #fff 0 18%, rgba(206,248,255,.9) 36%, rgba(110,215,255,.18) 68%, transparent 72%);
}

.lab-machine.is-ready::after {
  inset: 8px 0 0 18%;
  border: 2px solid rgba(146,255,24,.38);
  border-radius: 50%;
  opacity: 1;
  animation: lab-scan 1.8s linear infinite;
}

.lab-machine[data-control="lidar"]::after { border-color: rgba(67,216,255,.9); box-shadow: 0 0 22px rgba(67,216,255,.55); }
.lab-machine[data-control="gyro"]::after { border-style: dashed; border-color: rgba(255,212,92,.9); }

@keyframes lab-exhaust { to { transform: translateX(-12px) scale(1.18); opacity: .55; } }
@keyframes lab-scan { to { transform: rotate(360deg); } }

.lab-machine-body,
.lab-machine-wheel,
.lab-machine-slot {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.12);
}

.lab-machine-body {
  left: 18%;
  right: 6%;
  bottom: 20px;
  height: 82px;
  border-radius: 24px 38px 22px 22px;
  background:
    linear-gradient(135deg, rgba(146, 255, 24, 0.2), transparent 38%),
    linear-gradient(180deg, #3a314c, #16131f);
}

.lab-machine-wheel {
  bottom: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle, #302944 0 36%, #0c0a10 38% 100%);
}

.lab-machine-wheel.is-left { left: 28%; }
.lab-machine-wheel.is-right { right: 12%; }

.lab-machine-slot {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 20px;
  color: var(--lab-white);
  font-size: 0.68rem;
  font-weight: 1000;
  text-align: center;
}

.lab-machine-slot[data-slot="propulsion"] {
  left: 0;
  bottom: 50px;
  background: linear-gradient(135deg, rgba(255, 48, 71, 0.45), rgba(255, 212, 92, 0.18));
}

.lab-machine-slot[data-slot="control"] {
  left: 44%;
  bottom: 88px;
  background: linear-gradient(135deg, rgba(67, 216, 255, 0.42), rgba(126, 77, 255, 0.2));
}

.lab-machine-slot[data-slot="protection"] {
  right: 0;
  bottom: 60px;
  background: linear-gradient(135deg, rgba(146, 255, 24, 0.36), rgba(255, 255, 255, 0.16));
}

.lab-build-sphynx,
.lab-build-hamster {
  position: absolute;
  object-fit: contain;
  pointer-events: none;
}

.lab-build-sphynx {
  left: 5%;
  bottom: 118px;
  width: min(38vw, 210px);
  filter: drop-shadow(0 18px 22px rgba(0, 0, 0, 0.48));
}

.lab-build-hamster {
  right: 2%;
  bottom: 120px;
  width: min(24vw, 136px);
  transform: rotate(8deg);
  filter: drop-shadow(0 16px 18px rgba(0, 0, 0, 0.38));
}

.lab-speech {
  position: absolute;
  left: 8%;
  top: 18px;
  max-width: 300px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.93);
  color: var(--lab-ink);
  font-weight: 900;
  line-height: 1.25;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
}

.lab-builder-panel {
  padding: clamp(14px, 2.4vw, 22px);
}

.lab-builder-panel h2,
.lab-result-panel h2,
.lab-book-panel h2 {
  margin: 0 0 8px;
  font-size: clamp(1.45rem, 3vw, 2.25rem);
  line-height: 1;
}

.lab-builder-panel p,
.lab-result-panel p,
.lab-book-panel p {
  color: var(--lab-muted);
  line-height: 1.45;
}

.lab-parts-category {
  margin-top: 14px;
}

.lab-parts-category h3 {
  margin: 0 0 8px;
  color: var(--lab-gold);
  font-size: 0.86rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lab-parts-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(118px, 1fr));
  gap: 8px;
}

.lab-part-card {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 6px;
  min-height: 154px;
  padding: 10px;
  border: 2px solid rgba(255, 255, 255, 0.13);
  border-radius: 18px;
  color: var(--lab-white);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.lab-part-card:hover,
.lab-part-card.is-selected {
  border-color: var(--lab-green);
  box-shadow: 0 0 0 4px rgba(146, 255, 24, 0.14);
  transform: translateY(-1px);
}

.lab-part-icon {
  position: relative;
  width: 54px;
  height: 44px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.lab-part-icon::before,
.lab-part-icon::after {
  content: "";
  position: absolute;
}

.lab-part-icon.part-rocket::before {
  inset: 9px 12px 9px 18px;
  border-radius: 50% 50% 12px 12px;
  background: var(--lab-red);
  transform: rotate(38deg);
}

.lab-part-icon.part-fan::before {
  width: 34px;
  height: 34px;
  left: 10px;
  top: 5px;
  border-radius: 50%;
  border: 7px solid var(--lab-blue);
}

.lab-part-icon.part-spring::before {
  inset: 10px 8px;
  border-top: 6px solid var(--lab-green);
  border-bottom: 6px solid var(--lab-green);
  transform: skewX(-24deg);
}

.lab-part-icon.part-wheel::before {
  inset: 8px 13px;
  border-radius: 50%;
  border: 8px solid var(--lab-gold);
}

.lab-part-icon.part-compass::before {
  inset: 8px 12px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--lab-blue) 0 18%, transparent 20% 100%);
  border: 3px solid var(--lab-blue);
}

.lab-part-icon.part-magnet::before {
  left: 11px;
  top: 8px;
  width: 30px;
  height: 28px;
  border: 7px solid var(--lab-red);
  border-top: 0;
  border-radius: 0 0 15px 15px;
}

.lab-part-icon.part-helmet::before {
  left: 9px;
  top: 12px;
  width: 36px;
  height: 24px;
  border-radius: 24px 24px 10px 10px;
  background: var(--lab-gold);
}

.lab-part-icon.part-umbrella::before {
  left: 8px;
  top: 10px;
  width: 38px;
  height: 22px;
  border-radius: 38px 38px 4px 4px;
  background: var(--lab-purple);
}

.lab-part-icon.part-cooler::before {
  left: 10px;
  top: 12px;
  width: 34px;
  height: 24px;
  border-radius: 7px;
  background: var(--lab-blue);
}

.lab-part-icon.part-extinguisher::before {
  left: 17px;
  top: 10px;
  width: 20px;
  height: 28px;
  border-radius: 8px 8px 5px 5px;
  background: var(--lab-red);
  box-shadow: 11px -5px 0 -7px var(--lab-white);
}

.lab-part-icon.part-turbine::before {
  inset: 7px 12px;
  border: 6px solid var(--lab-blue);
  border-radius: 50%;
  background: conic-gradient(var(--lab-purple), transparent 18% 32%, var(--lab-purple) 34% 48%, transparent 50% 66%, var(--lab-purple) 68% 82%, transparent 84%);
}

.lab-part-icon.part-gyro::before {
  inset: 7px 9px;
  border: 3px solid var(--lab-gold);
  border-radius: 50%;
  box-shadow: inset 0 0 0 6px transparent, inset 0 0 0 8px var(--lab-blue);
  transform: rotate(-20deg);
}

.lab-part-icon.part-lidar::before {
  left: 10px;
  top: 17px;
  width: 34px;
  height: 12px;
  border-radius: 50%;
  background: var(--lab-blue);
  box-shadow: 0 -8px 0 -3px var(--lab-purple), 20px 0 16px var(--lab-blue);
}

.lab-part-icon.part-heatshield::before {
  left: 11px;
  top: 7px;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #fff3b0, var(--lab-red));
  clip-path: polygon(50% 0, 93% 18%, 82% 76%, 50% 100%, 18% 76%, 7% 18%);
}

.lab-part-icon.part-parachute::before {
  left: 8px;
  top: 7px;
  width: 38px;
  height: 20px;
  border-radius: 38px 38px 5px 5px;
  background: repeating-linear-gradient(90deg, var(--lab-purple) 0 10px, var(--lab-gold) 10px 20px);
  box-shadow: 0 14px 0 -8px var(--lab-white);
}

.lab-part-card strong {
  font-size: 1rem;
}

.lab-part-card em {
  width: fit-content;
  padding: 3px 7px;
  border-radius: 999px;
  color: #0b1420;
  background: var(--lab-blue);
  font-size: 0.66rem;
  font-style: normal;
  font-weight: 1000;
  line-height: 1.1;
}

.lab-part-card small {
  display: block;
  color: var(--lab-muted);
  line-height: 1.2;
}

.lab-bars {
  display: grid;
  gap: 5px;
  margin-top: 14px;
}

.lab-hypothesis {
  display: grid;
  gap: 5px;
  margin-top: 14px;
  padding: 13px 14px;
  border: 1px solid rgba(67,216,255,.4);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(67,216,255,.12), rgba(126,77,255,.12));
}

.lab-hypothesis[data-tone="hyper"] { border-color: rgba(255,143,56,.7); background: linear-gradient(135deg, rgba(255,48,71,.18), rgba(255,212,92,.12)); }
.lab-hypothesis[data-tone="cryo"] { border-color: rgba(121,235,255,.8); background: linear-gradient(135deg, rgba(164,244,255,.2), rgba(67,216,255,.08)); }
.lab-hypothesis[data-tone="electric"] { border-color: rgba(190,143,255,.8); background: linear-gradient(135deg, rgba(126,77,255,.22), rgba(67,216,255,.08)); }

.lab-hypothesis small {
  color: var(--lab-green);
  font-weight: 1000;
  text-transform: uppercase;
}

.lab-hypothesis strong { font-size: 1.08rem; }
.lab-hypothesis p,
.lab-hypothesis b { margin: 0; color: var(--lab-muted); font-size: .84rem; line-height: 1.35; }
.lab-hypothesis b { color: var(--lab-white); }

.lab-bar {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 900;
}

.lab-bar i {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.lab-bar i::before {
  content: "";
  display: block;
  width: var(--bar, 20%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--lab-green), var(--lab-gold), var(--lab-red));
}

.lab-actions,
.lab-run-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

.lab-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 18px;
  border: 0;
  border-radius: 16px;
  color: #111408;
  background: var(--lab-green);
  font: inherit;
  font-weight: 1000;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(92, 255, 0, 0.2);
}

.lab-button.secondary {
  color: var(--lab-white);
  background: var(--lab-purple);
  box-shadow: 0 12px 24px rgba(126, 77, 255, 0.2);
}

.lab-button.dark {
  color: var(--lab-white);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--lab-line);
  box-shadow: none;
}

.lab-button.danger {
  color: var(--lab-white);
  background: var(--lab-red);
}

.lab-button:disabled,
.lab-button.is-disabled {
  opacity: 0.52;
  cursor: not-allowed;
  pointer-events: none;
}

.lab-button:focus-visible,
.lab-part-card:focus-visible {
  outline: 3px solid var(--lab-gold);
  outline-offset: 3px;
}

.lab-run-screen {
  padding: clamp(10px, 2vw, 18px);
}

.lab-run-frame {
  position: relative;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-radius: 22px;
  background: #120f18;
  touch-action: none;
}

.lab-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #201415;
}

.lab-hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.lab-stat {
  display: grid;
  gap: 5px;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid var(--lab-line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
}

.lab-stat span {
  color: var(--lab-muted);
  font-size: 0.72rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.lab-stat strong {
  font-size: 1.15rem;
}

.lab-meter {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

.lab-meter i {
  display: block;
  width: var(--value, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--lab-green);
  transition: width 120ms linear;
}

.lab-meter.heat i {
  background: linear-gradient(90deg, var(--lab-green), var(--lab-gold), var(--lab-red));
}

.lab-repair-stack {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 14px;
  z-index: 15;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.lab-repair {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 8px 10px 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 16px;
  background: rgba(15, 12, 20, 0.88);
  color: var(--lab-white);
  pointer-events: auto;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
}

.lab-repair.is-visible {
  display: flex;
}

.lab-repair button {
  min-height: 38px;
  border: 0;
  border-radius: 12px;
  padding: 8px 12px;
  background: var(--lab-green);
  color: #111408;
  font: inherit;
  font-weight: 1000;
  cursor: pointer;
}

.lab-touch-controls {
  display: grid;
  grid-template-columns: 1fr 0.48fr;
  gap: 10px;
  margin-top: 10px;
}

.lab-touch-controls .lab-button {
  min-height: 62px;
  width: 100%;
}

.lab-run-note {
  margin: 8px 0 0;
  color: var(--lab-muted);
  font-size: 0.88rem;
  text-align: center;
}

.lab-result-screen,
.lab-book-screen {
  padding: clamp(14px, 3vw, 26px);
}

.lab-result-panel,
.lab-book-panel {
  padding: clamp(16px, 3vw, 28px);
}

.lab-result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.lab-result-card {
  min-height: 84px;
  padding: 12px;
  border: 1px solid var(--lab-line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
}

.lab-result-card span {
  display: block;
  color: var(--lab-muted);
  font-size: 0.72rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.lab-result-card strong {
  display: block;
  margin-top: 5px;
  font-size: clamp(1.2rem, 3vw, 1.9rem);
  line-height: 1;
}

.lab-gag-stage {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 130px;
  padding: 12px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 18% 24%, rgba(255, 212, 92, 0.2), transparent 35%),
    rgba(255, 255, 255, 0.07);
}

.lab-gag-stage img {
  width: 92px;
  height: 92px;
  object-fit: contain;
  filter: drop-shadow(0 12px 16px rgba(0, 0, 0, 0.38));
}

.lab-reward {
  display: none;
  grid-template-columns: 104px 1fr;
  gap: 14px;
  align-items: center;
  margin: 16px 0;
  padding: 12px;
  border-radius: 20px;
  border: 2px solid rgba(146, 255, 24, 0.55);
  background: linear-gradient(135deg, rgba(146, 255, 24, 0.16), rgba(126, 77, 255, 0.16));
}

.lab-reward.is-visible {
  display: grid;
}

.lab-reward img {
  width: 104px;
  height: 104px;
  object-fit: contain;
}

.lab-book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.lab-book-progress {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  align-items: center;
  margin-top: 14px;
  padding: 13px;
  border-radius: 16px;
  background: rgba(146,255,24,.1);
  border: 1px solid rgba(146,255,24,.28);
}

.lab-book-progress span { color: var(--lab-muted); font-size: .82rem; }
.lab-book-progress i { grid-column: 1 / -1; height: 10px; border-radius: 999px; background: rgba(255,255,255,.12); overflow: hidden; }
.lab-book-progress i::before { content: ""; display: block; width: var(--book,0%); height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--lab-green),var(--lab-blue)); }

.lab-book-item {
  min-height: 112px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--lab-line);
  background: rgba(255, 255, 255, 0.08);
}

.lab-book-item.is-locked {
  opacity: 0.55;
  background: rgba(255, 255, 255, 0.04);
}

.lab-book-item strong {
  display: block;
}

.lab-book-item small {
  display: block;
  margin-top: 5px;
  color: var(--lab-muted);
}

.lab-related {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.lab-related a {
  min-height: 92px;
  padding: 14px;
  border-radius: 18px;
  color: var(--lab-white);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--lab-line);
}

.lab-related strong,
.lab-related span {
  display: block;
}

.lab-related span {
  margin-top: 6px;
  color: var(--lab-muted);
  font-size: 0.9rem;
}

.lab-site-footer {
  color: var(--lab-muted);
  border-top: 1px solid var(--lab-line);
}

.lab-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 900px) {
  .lab-page-hero,
  .lab-build-layout {
    grid-template-columns: 1fr;
  }

  .lab-build-stage {
    min-height: 360px;
  }

  .lab-build-sphynx {
    width: 170px;
  }

  .lab-build-hamster {
    width: 116px;
  }

  .lab-result-grid,
  .lab-related {
    grid-template-columns: 1fr;
  }

  .lab-parts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  body.sphynx-lab-page {
    padding-bottom: 280px;
  }

  .lab-page-main,
  .lab-site-header,
  .lab-site-footer {
    width: min(100% - 16px, 1180px);
  }

  .lab-page-hero {
    padding: 18px 14px;
    border-radius: 18px;
  }

  .lab-page-hero h1 {
    font-size: clamp(2rem, 12vw, 3rem);
  }

  .lab-hero-visual {
    min-height: 220px;
  }

  .lab-hero-sphynx {
    right: 18%;
    width: 210px;
  }

  .lab-hero-hamster {
    width: 120px;
  }

  .lab-build-layout,
  .lab-run-screen,
  .lab-result-screen,
  .lab-book-screen {
    padding: 6px;
  }

  .lab-shell {
    margin-top: 8px;
    border-radius: 16px;
  }

  .lab-screen.is-visible {
    height: calc(100dvh - 8px);
    min-height: 620px;
  }

  .lab-game {
    height: auto;
    min-height: 0;
  }

  .lab-build-layout {
    grid-template-rows: 190px minmax(0, 1fr);
    gap: 6px;
    height: 100%;
    overflow: hidden;
  }

  .lab-build-stage {
    height: auto;
    min-height: 0;
    border-radius: 14px;
  }

  .lab-speech {
    z-index: 4;
    top: 7px;
    left: 8px;
    right: 8px;
    max-width: none;
    padding: 7px 9px;
    border-radius: 12px;
    font-size: 0.72rem;
    line-height: 1.15;
  }

  .lab-build-sphynx {
    left: 2%;
    bottom: 18px;
    width: 160px;
  }

  .lab-build-hamster {
    right: 1%;
    bottom: 24px;
    width: 100px;
  }

  .lab-lab-table {
    bottom: 7px;
    height: 42px;
  }

  .lab-machine {
    left: 11%;
    bottom: 28px;
    width: 78%;
    min-height: 112px;
    transform: scale(0.66);
    transform-origin: 50% 100%;
  }

  .lab-builder-panel {
    min-height: 0;
    padding: 10px 9px 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  .lab-builder-panel h2 {
    margin-bottom: 5px;
    font-size: 1.28rem;
  }

  .lab-builder-panel > p:not(.lab-kicker) {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.3;
  }

  .lab-builder-panel > .lab-actions {
    position: sticky;
    z-index: 8;
    bottom: 0;
    margin: 10px -9px 0;
    padding: 9px;
    background: linear-gradient(180deg, rgba(13, 10, 19, 0), rgba(13, 10, 19, 0.98) 26%);
  }

  .lab-builder-panel > .lab-actions .lab-button {
    flex: 1 1 138px;
    min-height: 46px;
    padding-inline: 10px;
  }

  .lab-hud {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    margin: 0;
  }

  .lab-stat {
    min-height: 47px;
    gap: 2px;
    padding: 5px 6px;
    border-radius: 10px;
  }

  .lab-stat span {
    font-size: 0.56rem;
  }

  .lab-stat strong {
    font-size: 0.82rem;
  }

  .lab-meter {
    height: 6px;
  }

  .lab-run-screen.is-visible {
    display: grid;
    grid-template-rows: auto auto auto auto;
    align-content: start;
    gap: 6px;
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  .lab-run-frame {
    width: 100%;
    min-height: 0;
    aspect-ratio: 16 / 9;
    border-width: 2px;
    border-radius: 14px;
  }

  .lab-canvas {
    width: 100%;
    height: auto;
  }

  .lab-touch-controls {
    grid-template-columns: 1.25fr 0.75fr;
    gap: 6px;
    margin: 0;
  }

  .lab-touch-controls .lab-button {
    min-height: 54px;
    padding-inline: 8px;
    font-size: 0.82rem;
  }

  .lab-run-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    margin: 0;
  }

  .lab-run-actions .lab-button {
    min-height: 42px;
    padding: 7px 5px;
    font-size: 0.72rem;
  }

  .lab-run-note {
    display: none;
  }

  .lab-parts-grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(156px, 72vw);
    overflow-x: auto;
    padding: 3px 3px 10px;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
  }

  .lab-part-card {
    min-height: 168px;
    scroll-snap-align: start;
  }

  .lab-result-screen.is-visible,
  .lab-book-screen.is-visible {
    display: block;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .lab-result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .lab-hero-sphynx,
  .lab-hero-hamster {
    animation: none;
  }
}
