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

body {
  color: #f8f0dd;
  font-family: "Noto Serif SC", "Source Han Serif SC", "Microsoft YaHei", SimSun, serif;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background:
    linear-gradient(115deg, rgba(220, 58, 38, 0.08), transparent 28%),
    linear-gradient(245deg, rgba(0, 154, 145, 0.08), transparent 30%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 9px),
    linear-gradient(135deg, var(--bg-color, #0a0907) 0%, color-mix(in srgb, var(--bg-color, #15120f) 76%, #ffffff 8%) 44%, #040403 100%);
}

canvas {
  display: block;
}

#controls {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 5;
  box-sizing: border-box;
  width: min(360px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(250, 244, 224, 0.14);
  border-radius: 8px;
  background: rgba(9, 9, 8, 0.78);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(16px);
  transition: width 180ms ease, padding 180ms ease, max-height 180ms ease;
}

.panel-title,
.button-row,
.color-row {
  display: flex;
  align-items: center;
}

.panel-title {
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-title strong {
  font-size: 20px;
  letter-spacing: 0;
}

.panel-title span {
  color: rgba(248, 240, 221, 0.64);
  font: 12px/1.2 "Microsoft YaHei", sans-serif;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-body {
  display: block;
}

#controls.is-collapsed {
  width: 168px;
  padding: 12px 14px;
}

#controls.is-collapsed .panel-title {
  margin-bottom: 0;
}

#controls.is-collapsed .panel-body {
  display: none;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: rgba(248, 240, 221, 0.74);
  font: 12px/1.2 "Microsoft YaHei", sans-serif;
}

.field span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.field b {
  color: #f8f0dd;
  font-weight: 500;
}

.field-block {
  margin-bottom: 14px;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px 16px;
}

textarea,
input,
button {
  font: inherit;
}

textarea {
  box-sizing: border-box;
  width: 100%;
  resize: vertical;
  min-height: 72px;
  padding: 10px;
  border: 1px solid rgba(248, 240, 221, 0.14);
  border-radius: 6px;
  outline: none;
  color: #f8f0dd;
  background: rgba(255, 255, 255, 0.055);
}

textarea:focus {
  border-color: rgba(238, 196, 82, 0.55);
}

input[type="range"] {
  width: 100%;
  accent-color: #eec452;
}

.color-row {
  justify-content: space-between;
  gap: 10px;
  margin: 16px 0 14px;
}

.background-field {
  margin-bottom: 14px;
}

.color-input {
  width: 46px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(248, 240, 221, 0.18);
  border-radius: 6px;
  background: transparent;
}

#backgroundInput {
  width: 100%;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(248, 240, 221, 0.18);
  border-radius: 6px;
  background: transparent;
}

.button-row {
  gap: 10px;
}

button {
  flex: 1;
  height: 34px;
  border: 1px solid rgba(248, 240, 221, 0.16);
  border-radius: 6px;
  color: #f8f0dd;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
}

.icon-button {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  line-height: 1;
  padding: 0;
  font-size: 18px;
}

button:hover {
  border-color: rgba(238, 196, 82, 0.5);
  background: rgba(238, 196, 82, 0.14);
}

@media (max-width: 680px) {
  #controls {
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    max-height: 48vh;
    padding: 14px;
  }
}
