:root {
  font-family: "Microsoft YaHei", "PingFang SC", Inter, sans-serif;
  color: #f4f7ff;
  background: #1b1e22;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body,
#app,
#viewport {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #1b1e22;
}

#app {
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(circle at 36% 24%, rgba(146, 153, 160, 0.2), transparent 36%),
    linear-gradient(145deg, #15181b 0%, #303439 56%, #4a4e52 100%);
}

#viewport {
  position: absolute;
  inset: 0;
}

canvas {
  display: block;
  touch-action: none;
}

.world-labels {
  position: absolute !important;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none !important;
}

.tube-plaque {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 82px;
  height: 37px;
  padding: 0 10px 0 14px;
  border: 1px solid rgba(214, 236, 255, 0.3);
  border-radius: 10px;
  background: rgba(3, 9, 16, 0.94);
  color: #f8fbff;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.38);
}

.tube-plaque::before {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 6px;
  width: 3px;
  border-radius: 99px;
  background: var(--gas-accent);
  content: "";
}

.tube-plaque strong {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.tube-plaque span {
  color: rgba(225, 239, 253, 0.9);
  font-size: 16px;
  font-weight: 800;
}

button {
  min-height: 44px;
  padding: 0 17px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: rgba(9, 22, 37, 0.84);
  color: #eef5ff;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

button:hover,
button:focus-visible {
  border-color: rgba(137, 198, 255, 0.58);
  background: rgba(42, 91, 142, 0.6);
  outline: none;
}

button:active {
  transform: translateY(1px);
}

[hidden] {
  display: none !important;
}

#hud {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 1;
  transition: opacity 420ms ease;
}

body.ui-hidden #hud {
  opacity: 0;
}

.title-block {
  position: absolute;
  top: max(24px, env(safe-area-inset-top));
  left: max(28px, env(safe-area-inset-left));
  width: min(520px, calc(100vw - 280px));
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.58);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
  color: #a9d5ff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.eyebrow::before {
  width: 23px;
  height: 1px;
  background: #82bdff;
  content: "";
}

h1 {
  margin: 0;
  font-size: clamp(25px, 2.5vw, 37px);
  line-height: 1.16;
  letter-spacing: -0.035em;
  font-weight: 900;
}

.title-block p {
  margin: 9px 0 0;
  color: rgba(226, 237, 250, 0.72);
  font-size: 15px;
  line-height: 1.5;
}

.progress-card {
  position: absolute;
  top: max(24px, env(safe-area-inset-top));
  right: max(24px, env(safe-area-inset-right));
  min-width: 164px;
  padding: 13px 15px 14px;
  border: 1px solid rgba(161, 205, 255, 0.2);
  border-radius: 18px;
  background: rgba(7, 18, 31, 0.7);
  backdrop-filter: blur(16px);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.2);
}

.progress-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  color: rgba(221, 235, 249, 0.7);
  font-size: 13px;
  font-weight: 700;
}

.progress-label strong {
  color: #fff;
  font-size: 20px;
  line-height: 1;
}

.progress-label i {
  margin-left: 3px;
  color: rgba(226, 237, 250, 0.58);
  font-size: 13px;
  font-style: normal;
  font-weight: 600;
}

.gas-dots {
  display: flex;
  gap: 7px;
  margin-top: 10px;
}

.gas-dot {
  width: 32px;
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
}

.gas-dot::after {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--dot-color);
  box-shadow: 0 0 12px var(--dot-color);
  content: "";
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left;
  transition: opacity 220ms ease, transform 360ms ease;
}

.gas-dot.is-on::after {
  opacity: 1;
  transform: scaleX(1);
}

.guide {
  position: absolute;
  left: 50%;
  bottom: max(78px, calc(env(safe-area-inset-bottom) + 74px));
  display: grid;
  grid-template-columns: 28px auto;
  align-items: center;
  column-gap: 11px;
  min-height: 54px;
  padding: 9px 17px 9px 12px;
  border: 1px solid rgba(158, 205, 255, 0.2);
  border-radius: 17px;
  background: rgba(7, 19, 32, 0.76);
  color: #eaf4ff;
  font-size: 15px;
  font-weight: 800;
  transform: translateX(-50%);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.23);
  transition: opacity 240ms ease, transform 240ms ease;
}

.guide.is-quiet {
  opacity: 0;
  transform: translate(-50%, 8px);
}

.guide small {
  grid-column: 2;
  color: rgba(210, 228, 246, 0.58);
  font-size: 11px;
  font-weight: 600;
}

.guide-hand {
  grid-row: 1 / 3;
  position: relative;
  width: 24px;
  height: 29px;
  border: 1.5px solid #88c5ff;
  border-radius: 9px 9px 11px 11px;
  transform: rotate(-7deg);
  box-shadow: 0 0 14px rgba(83, 168, 255, 0.24);
}

.guide-hand::before,
.guide-hand::after {
  position: absolute;
  width: 4px;
  height: 11px;
  border: 1.5px solid #88c5ff;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  content: "";
}

.guide-hand::before {
  top: -10px;
  left: 4px;
}

.guide-hand::after {
  top: -8px;
  right: 3px;
}

.actions {
  position: absolute;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  gap: 9px;
  pointer-events: auto;
}

.toast {
  position: absolute;
  top: 114px;
  left: 50%;
  min-width: 220px;
  padding: 12px 18px;
  border: 1px solid rgba(158, 217, 255, 0.38);
  border-radius: 14px;
  background: rgba(5, 14, 25, 0.88);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -10px);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.3), 0 0 24px rgba(158, 217, 255, 0.12);
  transition: opacity 200ms ease, transform 240ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 8, 15, 0.6);
  backdrop-filter: blur(12px);
  pointer-events: auto;
}

.modal-card {
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow-y: auto;
  padding: 28px;
  border: 1px solid rgba(160, 207, 255, 0.24);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(20, 41, 64, 0.98), rgba(6, 16, 29, 0.98)),
    #081422;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.52), inset 0 1px rgba(255, 255, 255, 0.08);
}

.modal-kicker {
  color: #8dc7ff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.modal-card h2 {
  margin: 7px 0 18px;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.25;
  letter-spacing: -0.03em;
}

.modal-card > p {
  margin: 0 0 20px;
  color: rgba(226, 239, 252, 0.8);
  font-size: 16px;
  line-height: 1.75;
}

.idea-row {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: start;
  gap: 12px;
  padding: 13px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.idea-row span {
  padding-top: 2px;
  color: #68b6ff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.idea-row p {
  margin: 0;
  color: rgba(232, 242, 252, 0.84);
  font-size: 16px;
  line-height: 1.65;
}

.idea-row b {
  color: #fff;
}

.science-note {
  margin: 17px 0 0 !important;
  padding: 12px 14px;
  border-left: 2px solid rgba(118, 183, 255, 0.62);
  border-radius: 0 10px 10px 0;
  background: rgba(83, 145, 210, 0.1);
  color: rgba(205, 225, 245, 0.7) !important;
  font-size: 13px !important;
  line-height: 1.7 !important;
}

.modal-close,
#restart {
  margin-top: 22px;
}

#restart {
  border-color: rgba(124, 197, 255, 0.38);
  background: rgba(65, 134, 211, 0.25);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.result-list {
  display: grid;
  gap: 7px;
  margin: 4px 0 2px;
}

.result-gas {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.045);
  font-size: 14px;
}

.result-gas strong {
  font-size: 16px;
}

.result-gas i {
  width: 36px;
  height: 5px;
  border-radius: 99px;
  background: var(--gas-color);
  box-shadow: 0 0 13px var(--gas-color);
}

.settings-card {
  width: min(500px, 100%);
}

.settings-card > p {
  margin-bottom: 14px;
}

.setting-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 13px 15px;
  border: 1px solid rgba(161, 205, 255, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
}

.setting-copy {
  display: grid;
  gap: 5px;
}

.setting-copy strong {
  font-size: 17px;
}

.setting-copy span {
  color: rgba(210, 228, 246, 0.66);
  font-size: 13px;
  line-height: 1.45;
}

.setting-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch {
  flex: 0 0 52px;
  position: relative;
  width: 52px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  transition: background 180ms ease, border-color 180ms ease;
}

.switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #d8e0e8;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.36);
  content: "";
  transition: transform 180ms ease, background 180ms ease;
}

.setting-row input:checked + .switch {
  border-color: rgba(125, 190, 255, 0.62);
  background: rgba(62, 136, 213, 0.7);
}

.setting-row input:checked + .switch::after {
  background: #fff;
  transform: translateX(22px);
}

.setting-row input:focus-visible + .switch {
  outline: 2px solid #8ecaff;
  outline-offset: 3px;
}

.setting-state {
  margin: 12px 2px 0 !important;
  color: rgba(191, 220, 249, 0.78) !important;
  font-size: 13px !important;
}

#loading {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 23px;
  background:
    radial-gradient(circle at 50% 42%, rgba(132, 140, 148, 0.24), transparent 34%),
    linear-gradient(145deg, #171a1d 0%, #2e3237 58%, #474b4f 100%);
  transition: opacity 500ms ease;
}

.loading-orbit {
  position: relative;
  width: 92px;
  height: 92px;
  border: 1px solid rgba(139, 200, 255, 0.22);
  border-radius: 50%;
  box-shadow: inset 0 0 34px rgba(74, 145, 220, 0.18), 0 0 32px rgba(48, 123, 206, 0.12);
  animation: orbit 2.2s linear infinite;
}

.loading-orbit::before,
.loading-orbit::after,
.loading-orbit span {
  position: absolute;
  border-radius: 50%;
  content: "";
}

.loading-orbit::before {
  inset: 20px;
  border: 1px solid rgba(204, 234, 255, 0.34);
}

.loading-orbit::after {
  top: 42%;
  left: 42%;
  width: 16px;
  height: 16px;
  background: #eaf7ff;
  box-shadow: 0 0 24px 9px rgba(255, 70, 168, 0.7);
}

.loading-orbit span {
  top: -3px;
  left: 42px;
  width: 7px;
  height: 7px;
  background: #9ed9ff;
  box-shadow: 0 0 12px #7cc7ff;
}

.loading-copy {
  display: grid;
  gap: 5px;
  text-align: center;
}

.loading-copy strong {
  font-size: 19px;
  letter-spacing: 0.06em;
}

.loading-copy span {
  color: rgba(217, 232, 247, 0.58);
  font-size: 13px;
}

.loading-track {
  width: min(260px, 62vw);
  height: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
}

.loading-track span {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5b8cff, #ff54ae, #8dd8ff);
  transition: width 220ms ease;
}

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

@media (max-width: 720px) {
  .title-block {
    top: max(15px, env(safe-area-inset-top));
    left: 16px;
    width: calc(100vw - 156px);
  }

  .eyebrow {
    margin-bottom: 5px;
    font-size: 10px;
    letter-spacing: 0.1em;
  }

  .eyebrow::before {
    width: 15px;
  }

  h1 {
    font-size: clamp(18px, 5.2vw, 22px);
    letter-spacing: -0.045em;
    white-space: nowrap;
  }

  .title-block p {
    display: none;
  }

  .progress-card {
    top: max(14px, env(safe-area-inset-top));
    right: 13px;
    min-width: 124px;
    padding: 10px 11px 11px;
    border-radius: 15px;
  }

  .progress-label {
    font-size: 11px;
  }

  .progress-label strong {
    font-size: 17px;
  }

  .gas-dots {
    gap: 4px;
    margin-top: 8px;
  }

  .gas-dot {
    width: 18px;
    height: 4px;
  }

  .guide {
    bottom: max(80px, calc(env(safe-area-inset-bottom) + 76px));
    min-height: 48px;
    padding: 8px 13px 8px 10px;
    border-radius: 15px;
    font-size: 13px;
    white-space: nowrap;
  }

  .guide-hand {
    width: 20px;
    height: 24px;
  }

  .guide small {
    font-size: 10px;
  }

  .actions {
    right: 12px;
    bottom: max(15px, env(safe-area-inset-bottom));
    left: 12px;
    justify-content: center;
  }

  .actions button {
    flex: 1;
    min-height: 46px;
    max-width: 150px;
    padding: 0 10px;
    font-size: 13px;
  }

  .tube-plaque {
    min-width: 68px;
    height: 31px;
    gap: 5px;
    padding: 0 7px 0 11px;
    border-radius: 8px;
  }

  .tube-plaque::before {
    top: 5px;
    bottom: 5px;
    left: 5px;
    width: 2px;
  }

  .tube-plaque strong {
    font-size: 16px;
  }

  .tube-plaque span {
    font-size: 13px;
  }

  .toast {
    top: 82px;
    min-width: 190px;
    padding: 10px 14px;
    font-size: 13px;
  }

  .modal-card {
    padding: 22px 19px;
    border-radius: 20px;
  }

  .modal-card h2 {
    margin-bottom: 14px;
    font-size: 23px;
  }

  .idea-row {
    grid-template-columns: 28px 1fr;
    gap: 8px;
    padding: 10px 0;
  }

  .idea-row p,
  .modal-card > p {
    font-size: 14px;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions button {
    width: 100%;
  }
}

@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;
  }
}
