@font-face {
  font-family: GameFont;
  src: url("./fonts/mplus-1m-regular.ttf");
}

@font-face {
  font-family: GameFont1;
  src: url("./fonts/FZYS.ttf");
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: #000;
  color: #ecf1ff;
  font-family: GameFont, "Microsoft YaHei", sans-serif;
}

button,
select,
input {
  font: inherit;
}

.app,
.viewer {
  width: 100vw;
  height: 100vh;
}

.viewer {
  display: grid;
  place-items: center;
  background: #000;
}

.canvas-host {
  position: relative;
  width: 1440px;
  height: 900px;
  background: #000;
}

.canvas-host canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 1440px;
  height: 900px;
  outline: none;
}

.black-screen-tip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 28px;
  z-index: 3;
  color: rgba(255, 255, 255, 0.46);
  font-size: 13px;
  line-height: 20px;
  text-align: center;
  opacity: 1;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.canvas-host.scene-rendered .black-screen-tip {
  opacity: 0;
}

.loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.72);
  letter-spacing: 0;
  background: #000;
}

.settings-toggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  color: #fff;
  background: rgba(9, 13, 22, 0.78);
  cursor: pointer;
  padding: 0;          
  display: flex;       
  align-items: center; 
  justify-content: center; 
}

.settings-toggle:hover,
.settings-toggle:focus-visible {
  background: rgba(9, 13, 22, 0.98);
  outline: none;
}

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 15;
  width: min(380px, 100vw);
  height: 100vh;
  padding: 18px;
  overflow-y: auto;
  color: #eaf0ff;
  background: rgba(7, 10, 17, 0.94);
  border-left: 1px solid rgba(255, 255, 255, 0.16);
  transform: translateX(100%);
  transition: transform 180ms ease;
}

.settings-panel.open {
  transform: translateX(0);
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.settings-head h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.settings-head p {
  margin: 3px 0 0;
  color: #aeb8c8;
  font-size: 14px;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.group {
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.group h2 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: #cdd8ee;
}

.control-grid,
.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.control-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 5px;
  color: #aeb8c8;
  font-size: 13px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.check-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.check-row .check {
  margin-top: 0;
  min-height: 28px;
}

.check-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  color: #f3f7ff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
}

select option {
  color: #101622;
  background: #f8fbff;
}

select option:checked {
  color: #fff;
  background: #1f6ed4;
}

select {
  height: 32px;
  padding: 0 8px;
}

input[type="checkbox"] {
  appearance: none;
  flex: 0 0 auto;
  width: 34px;
  height: 18px;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

input[type="checkbox"]::before {
  content: "";
  display: block;
  width: 14px;
  height: 14px;
  margin: 1px;
  border-radius: 50%;
  background: #d5ddeb;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform 140ms ease, background 140ms ease;
}

input[type="checkbox"]:checked {
  border-color: rgba(111, 177, 255, 0.72);
  background: rgba(42, 125, 220, 0.82);
}

input[type="checkbox"]:checked::before {
  transform: translateX(16px);
  background: #fff;
}

input[type="checkbox"]:focus-visible {
  outline: 2px solid rgba(116, 181, 255, 0.72);
  outline-offset: 2px;
}

input[type="range"] {
  appearance: none;
  --range-progress: 0%;
  height: 32px;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(
    90deg,
    rgba(118, 174, 238, 0.58) 0 var(--range-progress),
    rgba(190, 205, 226, 0.28) var(--range-progress) 100%
  );
  border-radius: 999px;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: #dce9ff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.32);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  background: rgba(190, 205, 226, 0.28);
  border-radius: 999px;
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  background: rgba(118, 174, 238, 0.58);
  border-radius: 999px;
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: #dce9ff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.32);
}

input[type="range"]:hover::-webkit-slider-thumb {
  background: #f3f7ff;
}

input[type="range"]:hover::-moz-range-thumb {
  background: #f3f7ff;
}

.wide {
  grid-column: 1 / -1;
}

.range-title {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-height: 20px;
  line-height: 20px;
}

.womb-control output {
  display: inline-flex;
  align-items: center;
  min-width: 34px;
  min-height: 18px;
  padding: 0 5px 2px;
  color: #eaf3ff;
  font-size: 12px;
  line-height: 16px;
  font-variant-numeric: tabular-nums;
}

input[type="range"]:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.72);
  outline-offset: 2px;
}

button {
  min-height: 32px;
  padding: 0 12px;
  color: #f3f7ff;
  background: rgba(56, 103, 164, 0.5);
  border: 1px solid rgba(156, 196, 255, 0.3);
  border-radius: 6px;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  background: rgba(72, 122, 191, 0.7);
  outline: none;
}

output {
  display: inline;
  color: #fff;
  font-size: 13px;
}

@media (max-width: 640px) {
  .settings-toggle {
    right: 12px;
    bottom: 12px;
  }

  .settings-panel {
    width: 100vw;
  }
}
