:root {
  color-scheme: light;
  background: #d9d6cf;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #d9d6cf;
}

#loading-screen {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  background: #fff;
  color: #263238;
  opacity: 1;
  transition: opacity var(--loading-fade-duration, 400ms) ease;
}

#loading-screen[hidden] {
  display: none;
}

#loading-screen.is-fading {
  opacity: 0;
  pointer-events: none;
}

#loading-screen.is-error {
  color: #9b3b35;
}

.loading-content {
  width: min(320px, calc(var(--loading-layout-width, 100vw) - 48px));
  transform-origin: center;
}

#loading-screen.is-portrait .loading-content {
  transform: rotate(90deg);
}

.loading-brand {
  margin: 0 0 24px;
  color: #869096;
  font: 600 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.28em;
}

.loading-message {
  margin: 0 0 14px;
  font: 400 16px/1.5 "Noto Serif SC", "Songti SC", serif;
}

.loading-progress-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
}

#loading-progress {
  width: 100%;
  height: 2px;
  border: 0;
  border-radius: 0;
  appearance: none;
  background: #e6e9ea;
}

#loading-progress::-webkit-progress-bar {
  background: #e6e9ea;
}

#loading-progress::-webkit-progress-value {
  background: #263238;
  transition: width 180ms ease;
}

#loading-progress::-moz-progress-bar {
  background: #263238;
}

#loading-progress-value {
  min-width: 3.2em;
  color: #6c777c;
  font: 500 12px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: right;
}

@media (prefers-reduced-motion: reduce) {
  #loading-screen,
  #loading-progress::-webkit-progress-value {
    transition-duration: 1ms;
  }
}

/*
 * 固定定位而非参与文档流：脚本按布局视口写入像素宽高，若元素留在流内，
 * 任何一次偏大的取值都会撑宽文档，Android Chrome 随即下调最小页面缩放，
 * 触发“缩放 → resize → 再撑宽”的循环，并让视口外的图块无法栅格化而发黑。
 */
#scene-viewport {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/*
 * 尺寸由脚本按屏幕像素给出（不再是 2560x1440 再缩放）：一个和视口等大的合成层
 * 才能被 Android Chrome 在旋转后完整栅格化，缩放交给 canvas 的 CSS 盒子完成。
 */
#scene {
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #f1eee7;
  transform-origin: top left;
}

#scene-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#teapot-motion-debug {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

#teapot-motion-debug[hidden] {
  display: none;
}

#teapot-debug-arrow path {
  fill: #ffb000;
}

.teapot-debug-trajectory,
.teapot-debug-base-bounds,
.teapot-debug-current-bounds,
.teapot-debug-translation,
.teapot-debug-base-axis,
.teapot-debug-current-axis,
.teapot-debug-rotation-arc,
.teapot-debug-current-pivot path,
.teapot-debug-current-center path {
  fill: none;
  vector-effect: non-scaling-stroke;
}

.teapot-debug-trajectory {
  stroke: #ffb000;
  stroke-width: 3;
  stroke-dasharray: 7 7;
  opacity: 0.9;
}

.teapot-debug-base-bounds {
  stroke: rgb(20 33 43 / 72%);
  stroke-width: 2;
  stroke-dasharray: 10 8;
}

.teapot-debug-current-bounds {
  stroke: #00c8ff;
  stroke-width: 3;
  stroke-dasharray: 14 7;
}

.teapot-debug-translation {
  stroke: #ff4fa3;
  stroke-width: 6;
}

.teapot-debug-base-axis {
  stroke: rgb(20 33 43 / 62%);
  stroke-width: 2;
  stroke-dasharray: 8 6;
}

.teapot-debug-current-axis {
  stroke: #00c8ff;
  stroke-width: 3;
  opacity: 0.9;
}

.teapot-debug-rotation-arc {
  stroke: #ffb000;
  stroke-width: 6;
}

.teapot-debug-base-pivot {
  fill: #14212b;
  stroke: #fff;
  stroke-width: 2;
}

.teapot-debug-current-pivot circle {
  fill: rgb(255 176 0 / 28%);
  stroke: #ffb000;
  stroke-width: 3;
}

.teapot-debug-current-pivot path {
  stroke: #ffb000;
  stroke-width: 3;
}

.teapot-debug-current-center circle {
  fill: rgb(0 200 255 / 30%);
  stroke: #00c8ff;
  stroke-width: 3;
}

.teapot-debug-current-center path {
  stroke: #00c8ff;
  stroke-width: 2;
}

.teapot-debug-label rect {
  fill: rgb(13 20 26 / 88%);
  stroke: rgb(255 255 255 / 32%);
  stroke-width: 1;
}

.teapot-debug-label text {
  fill: #f4f8fa;
  font: 600 14px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.03em;
}

.teapot-debug-label .teapot-debug-label-title {
  fill: #00c8ff;
  font-size: 12px;
  letter-spacing: 0.12em;
}

.teapot-debug-label .teapot-debug-label-guide {
  fill: #ffb000;
  font-size: 10px;
  letter-spacing: 0.04em;
}

#mesh-debug-hud {
  --mesh-debug-base-color: #14212b;
  --mesh-debug-line-color: #00c8ff;
  --mesh-debug-point-color: #ffb000;
  position: absolute;
  top: 20px;
  left: 20px;
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px 16px;
  min-width: 280px;
  padding: 14px 16px;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 12px;
  color: #fff;
  background: rgb(13 20 26 / 82%);
  box-shadow: 0 10px 30px rgb(0 0 0 / 20%);
  font: 600 15px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

#mesh-debug-hud[hidden] {
  display: none;
}

.mesh-debug-title {
  color: #9fb2c2;
  font-size: 12px;
  letter-spacing: 0.16em;
}

#mesh-debug-target {
  justify-self: end;
  color: var(--mesh-debug-line-color);
}

.mesh-debug-legend {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #dce6ec;
  font-size: 13px;
  font-weight: 500;
}

.mesh-debug-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.mesh-debug-legend-item[hidden] {
  display: none;
}

.mesh-debug-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: currentColor;
}

.mesh-debug-base {
  color: var(--mesh-debug-base-color);
  outline: 1px solid rgb(255 255 255 / 45%);
}

.mesh-debug-current {
  color: var(--mesh-debug-line-color);
}

.mesh-debug-point {
  color: var(--mesh-debug-point-color);
}

.mesh-debug-shortcut {
  justify-self: end;
  color: #9fb2c2;
  font-size: 13px;
  font-weight: 500;
}

.mesh-debug-shortcut kbd {
  padding: 1px 6px;
  border: 1px solid rgb(255 255 255 / 32%);
  border-radius: 5px;
  color: #fff;
  background: rgb(255 255 255 / 10%);
  font: inherit;
}

#status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
