:root {
  color-scheme: light;
  --bg: #e0e5ec;
  --ink: #25231f;
  --muted: rgba(37, 35, 31, 0.58);
  --accent: #6f6148;
  font-family:
    MiSans, "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", system-ui,
    sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    linear-gradient(145deg, #f0f5fc, #cacfd6),
    var(--bg);
}

body {
  position: fixed;
  inset: 0;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
}

.controls-toggle {
  position: fixed;
  top: max(22px, env(safe-area-inset-top));
  right: max(22px, env(safe-area-inset-right));
  z-index: 3;
  width: 22px;
  height: 22px;
  border: 1.3px solid rgba(77, 96, 121, 0.62);
  border-radius: 50%;
  background: transparent;
  box-shadow:
    0 2px 6px rgba(39, 55, 73, 0.14),
    0 -1px 2px rgba(255, 255, 255, 0.5),
    inset 0 1px 1px rgba(255, 255, 255, 0.38),
    inset 0 -1px 1px rgba(39, 55, 73, 0.14);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  transform: translateX(0);
  transition:
    transform 520ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 520ms ease;
  animation: control-breathe 3.8s ease-in-out infinite;
}

.controls-toggle::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-bottom-color: rgba(52, 70, 92, 0.18);
}

.controls-open .controls-toggle {
  transform: translateX(calc(-1 * (min(380px, calc(100vw - 56px)) + 14px)));
}

@keyframes control-breathe {
  0%,
  100% {
    border-color: rgba(77, 96, 121, 0.58);
    filter: none;
    box-shadow:
      0 2px 6px rgba(39, 55, 73, 0.12),
      0 -1px 2px rgba(255, 255, 255, 0.48),
      inset 0 1px 1px rgba(255, 255, 255, 0.34),
      inset 0 -1px 1px rgba(39, 55, 73, 0.12);
  }

  50% {
    border-color: rgba(77, 96, 121, 0.82);
    filter: none;
    box-shadow:
      0 3px 8px rgba(39, 55, 73, 0.18),
      0 -1px 3px rgba(255, 255, 255, 0.56),
      inset 0 1px 1px rgba(255, 255, 255, 0.46),
      inset 0 -1px 2px rgba(39, 55, 73, 0.18);
  }
}

.controls {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  z-index: 2;
  width: min(380px, calc(100vw - 56px));
  max-height: calc(100dvh - 36px);
  overflow: auto;
  padding: 16px 18px 18px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(232, 238, 247, 0.08);
  box-shadow:
    14px 18px 34px rgba(117, 133, 155, 0.08),
    -8px -10px 20px rgba(255, 255, 255, 0.14),
    inset 1px 1px 0 rgba(255, 255, 255, 0.22);
  color: rgba(37, 35, 31, 0.72);
  backdrop-filter: blur(5px) saturate(1.03);
  -webkit-backdrop-filter: blur(5px) saturate(1.03);
  pointer-events: auto;
  touch-action: auto;
  transform: translateX(calc(100% + 34px));
  opacity: 0;
  transition:
    transform 520ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 320ms ease;
}

.controls-open .controls {
  transform: translateX(0);
  opacity: 1;
}

.controls__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
}

.controls__head p {
  margin: 0;
  color: rgba(37, 35, 31, 0.72);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.controls__actions {
  display: flex;
  gap: 6px;
}

.controls button {
  appearance: none;
  border: 0;
  border-radius: 6px;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.46);
  box-shadow:
    4px 5px 10px rgba(133, 149, 170, 0.2),
    -3px -3px 8px rgba(255, 255, 255, 0.65);
  color: rgba(37, 35, 31, 0.62);
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
}

.controls label {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.73rem;
  line-height: 1;
}

.controls label span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.controls output {
  min-width: 44px;
  color: rgba(37, 35, 31, 0.5);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.controls input[type="range"] {
  width: 100%;
  accent-color: #78869a;
}

.caption {
  position: fixed;
  left: max(28px, env(safe-area-inset-left));
  bottom: max(26px, env(safe-area-inset-bottom));
  width: min(360px, calc(100vw - 56px));
  pointer-events: none;
}

.label {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.9rem, 5vw, 3.8rem);
  font-weight: 560;
  letter-spacing: 0;
}

.caption .description {
  max-width: 310px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.75;
}

.entry-links {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-top: 24px;
  pointer-events: auto;
}

.entry-links a {
  position: relative;
  color: rgba(37, 35, 31, 0.72);
  font-size: 0.82rem;
  font-weight: 560;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-decoration: none;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.34);
  text-transform: uppercase;
  transition:
    color 220ms ease,
    opacity 220ms ease;
}

.entry-links a:hover,
.entry-links a:focus-visible {
  color: rgba(25, 24, 21, 0.92);
}

.entry-links a:focus-visible {
  border-radius: 1px;
  outline: 1px solid rgba(77, 96, 121, 0.38);
  outline-offset: 8px;
}

@media (max-width: 620px) {
  .controls-toggle {
    top: 16px;
    right: 16px;
  }

  .controls-open .controls-toggle {
    transform: translateX(calc(-1 * (min(280px, calc(100vw - 48px)) + 10px)));
  }

  .controls {
    top: 12px;
    right: 12px;
    width: min(280px, calc(100vw - 48px));
    padding: 12px;
  }

  .controls label {
    margin-top: 8px;
    font-size: 0.68rem;
  }

  .caption {
    left: 20px;
    right: 20px;
    bottom: 22px;
    width: auto;
  }

  .caption .description {
    display: none;
  }

  .entry-links {
    gap: 18px;
    margin-top: 18px;
  }

  .entry-links a {
    font-size: 0.78rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .caption .description::after {
    content: " Motion reduced.";
  }
}
