:root {
  --truth-font-desktop: 11px;
  --truth-font-mobile: 10px;
  color-scheme: dark;
  --ink: #f2f6f7;
  --muted: #a8b6bc;
  --line: rgba(170, 202, 209, 0.2);
  --panel: rgba(7, 17, 22, 0.82);
  --panel-strong: rgba(6, 15, 19, 0.94);
  --red: #d44a48;
  --amber: #b77b35;
  --cyan: #4fa8b8;
  --green: #69bd91;
  font-family:
    Inter,
    "Segoe UI",
    "PingFang SC",
    "Microsoft YaHei",
    Arial,
    sans-serif;
  background: #071014;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #071014;
  color: var(--ink);
}

button {
  color: inherit;
  font: inherit;
}

#app {
  position: relative;
  display: grid;
  grid-template-columns:
    minmax(260px, 0.72fr) minmax(0, 1.55fr)
    minmax(290px, 0.78fr);
  grid-template-rows: auto 1fr auto;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(
      circle at 49% 38%,
      rgba(48, 99, 112, 0.34),
      transparent 32%
    ),
    radial-gradient(
      circle at 65% 20%,
      rgba(183, 123, 53, 0.09),
      transparent 26%
    ),
    linear-gradient(158deg, #12242b 0%, #081318 58%, #050b0e 100%);
}

canvas#stage {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.floor-grid {
  position: absolute;
  z-index: 2;
  right: 19%;
  bottom: 0;
  left: 18%;
  height: 37%;
  pointer-events: none;
  background:
    linear-gradient(rgba(113, 164, 174, 0.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(113, 164, 174, 0.09) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.74),
    transparent 92%
  );
}

.topbar,
.intro,
.process-panel,
.flow-truth-note,
.qualification,
.corner-actions,
.control-hint {
  position: absolute;
  z-index: 10;
}

.topbar {
  top: 26px;
  right: 34px;
  left: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  background: rgba(7, 17, 21, 0.72);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: block;
  width: 94px;
  height: 43px;
  object-fit: contain;
  background: #fff;
  border-radius: 3px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 19px;
  letter-spacing: 0.04em;
}

.brand small {
  margin-top: 3px;
  color: #81969e;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.demo-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: #8ca0a7;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.16em;
}

.demo-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #68b98c;
  box-shadow: 0 0 12px rgba(104, 185, 140, 0.72);
}

.intro {
  top: 132px;
  left: 46px;
  width: min(340px, 27vw);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 11px;
  color: #77a6b0;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.16em;
}

h1 {
  margin: 0;
  font-size: clamp(31px, 2.8vw, 44px);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.intro-copy {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.72;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 17px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  padding: 5px 8px;
  border: 1px solid rgba(148, 184, 192, 0.14);
  background: rgba(7, 16, 20, 0.54);
  color: #9babb1;
  font-size: 10px;
  font-weight: 750;
}

.legend i {
  display: block;
  width: 17px;
  height: 3px;
}

.legend .process-liquid {
  background: var(--amber);
}

.legend .thermal-medium {
  background: var(--cyan);
}

.legend .condensate {
  background: var(--green);
}

.process-panel {
  top: 118px;
  right: 34px;
  width: min(322px, 24.5vw);
  padding: 17px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(17px);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.panel-head small,
.panel-head strong {
  display: block;
}

.panel-head small {
  margin-bottom: 4px;
  color: #69bac9;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.13em;
}

.panel-head strong {
  font-size: 18px;
}

.panel-head em {
  color: #758990;
  font-size: 10px;
  font-style: normal;
}

#stageDesc {
  min-height: 38px;
  margin: 12px 0 15px;
  color: #9aabb1;
  font-size: 12px;
  line-height: 1.58;
}

.stage-rail {
  display: grid;
  gap: 6px;
}

.stage-button {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  min-height: 42px;
  padding: 7px 10px;
  border: 1px solid rgba(139, 177, 185, 0.12);
  background: rgba(139, 177, 185, 0.04);
  color: #9cabb0;
  cursor: pointer;
  text-align: left;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.stage-button span {
  color: #60757c;
  font-size: 9px;
  font-weight: 850;
}

.stage-button strong {
  font-size: 12px;
}

.stage-button:hover,
.stage-button:focus-visible,
.stage-button[aria-pressed="true"] {
  border-color: rgba(91, 196, 214, 0.48);
  background: rgba(91, 196, 214, 0.1);
  color: #f1f7f8;
  outline: none;
}

.stage-button[aria-pressed="true"] {
  transform: translateX(-3px);
}

.stage-button[aria-pressed="true"] span {
  color: #6cc6d6;
}

.stage-labels {
  position: absolute;
  z-index: 8;
  inset: 0;
  pointer-events: none;
}

.stage-label {
  position: absolute;
  min-width: max-content;
  padding: 6px 9px;
  border: 1px solid rgba(106, 190, 203, 0.34);
  background: rgba(5, 15, 18, 0.82);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
  color: #dce8ea;
  font-size: 10px;
  font-weight: 760;
}

.stage-label::before {
  position: absolute;
  top: 50%;
  right: 100%;
  width: 24px;
  height: 1px;
  background: rgba(106, 190, 203, 0.5);
  content: "";
}

.qualification {
  right: 50%;
  bottom: 28px;
  margin: 0;
  padding: 8px 11px;
  border: 1px solid rgba(148, 184, 192, 0.15);
  background: rgba(5, 14, 18, 0.66);
  color: #87999f;
  font-size: 10px;
  transform: translateX(50%);
  backdrop-filter: blur(12px);
}

.flow-truth-note {
  right: 50%;
  bottom: 61px;
  max-width: 480px;
  margin: 0;
  color: #9aabb1;
  font-size: 9px;
  text-align: center;
  transform: translateX(50%);
}

.corner-actions {
  right: 34px;
  bottom: 28px;
  display: flex;
  gap: 7px;
}

.action-button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(139, 177, 185, 0.2);
  background: rgba(139, 177, 185, 0.07);
  color: #c2ced1;
  cursor: pointer;
  font-size: 11px;
  font-weight: 760;
}

.action-button:hover,
.action-button:focus-visible {
  border-color: rgba(91, 196, 214, 0.5);
  background: rgba(91, 196, 214, 0.12);
  outline: none;
}

.control-hint {
  bottom: 30px;
  left: 44px;
  margin: 0;
  color: #6f8188;
  font-size: 10px;
}

.fallback {
  position: absolute;
  z-index: 50;
  inset: 0;
  display: none;
  place-items: center;
  padding: 32px;
  background: #071014;
  color: #dfe7e9;
  text-align: center;
}

.fallback p {
  margin: 0 0 18px;
}

.fallback-action {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  padding: 0 14px;
  border: 1px solid rgba(104, 185, 140, 0.46);
  color: #b9dfca;
  text-decoration: none;
}

.embed-mode #app {
  min-height: 0;
}

.bottom-ui {
  display: contents;
}

@media (max-width: 900px) {
  #app {
    display: block;
    min-height: 0;
  }

  .topbar {
    top: 10px;
    right: 12px;
    left: 12px;
    min-height: 56px;
    padding: 7px 9px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 79px;
    height: 36px;
  }

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

  .brand small,
  .demo-status {
    font-size: 7px;
  }

  .demo-status {
    max-width: 110px;
    text-align: right;
  }

  .intro {
    top: 82px;
    left: 16px;
    width: calc(100% - 32px);
  }

  .eyebrow {
    margin-bottom: 6px;
    font-size: 8px;
  }

  h1 {
    font-size: 28px;
  }

  .intro-copy {
    max-width: 340px;
    margin-top: 7px;
    font-size: 10px;
    line-height: 1.48;
  }

  .legend {
    gap: 5px;
    margin-top: 8px;
  }

  .legend span {
    min-height: 23px;
    padding: 3px 6px;
    font-size: 8px;
  }

  .process-panel {
    top: auto;
    right: 12px;
    bottom: 112px;
    left: 12px;
    width: auto;
    padding: 11px;
  }

  .panel-head strong {
    font-size: 15px;
  }

  .panel-head em {
    display: none;
  }

  #stageDesc {
    min-height: 0;
    margin: 6px 0 9px;
    overflow: hidden;
    font-size: 10px;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .stage-rail {
    display: flex;
    gap: 6px;
    padding-bottom: 3px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }

  .stage-button,
  .action-button {
    min-height: 44px;
  }

  .stage-button {
    flex: 0 0 104px;
    grid-template-columns: 21px 1fr;
    padding: 5px 7px;
  }

  .stage-button[aria-pressed="true"] {
    transform: none;
  }

  .qualification {
    right: 12px;
    bottom: 62px;
    left: 12px;
    width: auto;
    padding: 5px 7px;
    font-size: 8px;
    text-align: center;
    transform: none;
  }

  .flow-truth-note {
    right: 12px;
    bottom: 88px;
    left: 12px;
    width: auto;
    max-width: none;
    font-size: 8px;
    transform: none;
  }

  .corner-actions {
    right: 12px;
    bottom: 10px;
  }

  .action-button {
    padding: 0 11px;
    font-size: 10px;
  }

  .control-hint {
    bottom: 25px;
    left: 14px;
    font-size: 8px;
  }

  .floor-grid {
    right: 4%;
    bottom: 24%;
    left: 4%;
    height: 28%;
  }

  .stage-label {
    padding: 5px 7px;
    font-size: 9px;
  }

  .stage-label::before {
    width: 14px;
  }
}

@media (max-width: 560px) {
  .demo-status {
    display: none;
  }

  .intro-copy {
    max-width: 92%;
  }

  .control-hint {
    display: none;
  }
}

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

.flow-truth-note,
.qualification,
.control-hint {
  font-size: var(--truth-font-desktop);
}

@media (max-width: 900px) {
  .flow-truth-note,
  .qualification,
  .control-hint {
    font-size: var(--truth-font-mobile);
  }

  .flow-truth-note,
  .qualification {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .bottom-ui {
    position: absolute;
    z-index: 10;
    right: 12px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    pointer-events: none;
  }

  .bottom-ui > .process-panel,
  .bottom-ui > .flow-truth-note,
  .bottom-ui > .qualification,
  .bottom-ui > .corner-actions {
    position: static;
    min-width: 0;
    width: auto;
    max-width: none;
    margin: 0;
    transform: none;
  }

  .bottom-ui > .process-panel,
  .bottom-ui button {
    pointer-events: auto;
  }

  .bottom-ui > .flow-truth-note,
  .bottom-ui > .qualification {
    line-height: 1.4;
  }

  .bottom-ui > .corner-actions {
    justify-self: end;
  }
}

@media (max-width: 900px) and (max-height: 500px) {
  .intro-copy,
  .legend,
  .panel-head small,
  #stageDesc {
    display: none;
  }

  .process-panel {
    padding: 8px;
  }

  .stage-rail {
    margin-top: 6px;
  }
}
