:root {
  color-scheme: dark;
  --panel-bg: rgba(7, 11, 18, 0.56);
  --panel-border: rgba(255, 255, 255, 0.1);
  --panel-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --text-main: rgba(243, 247, 255, 0.96);
  --text-soft: rgba(214, 223, 242, 0.72);
  --chip-off: rgba(255, 255, 255, 0.09);
  --overlay-grid-color: rgba(255, 255, 255, 0);
  --overlay-dot-color: rgba(255, 255, 255, 0.03);
  --overlay-scan-color: rgba(255, 255, 255, 0.015);
  --overlay-grid-size: 124px;
  --overlay-dot-size: 164px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Aptos", "Segoe UI Variable", "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--text-main);
}

button,
select {
  font: inherit;
}

button {
  border: 0;
  padding: 0;
  background: none;
  color: inherit;
}

select {
  width: 100%;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 0.8rem 0.95rem;
  color: var(--text-main);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    rgba(7, 11, 18, 0.58);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  outline: none;
  transition:
    border-color 180ms ease,
    transform 180ms ease,
    background-color 180ms ease;
}

select:focus {
  border-color: rgba(255, 199, 119, 0.65);
  transform: translateY(-1px);
}

select option {
  background: #10151e;
  color: #edf3ff;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.45rem;
  padding: 0.1rem 0.35rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.76rem;
}

.scene-shell {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.06), transparent 34%),
    linear-gradient(180deg, #020304 0%, #030508 45%, #040608 100%);
}

.stage,
.stage canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.stage {
  position: absolute;
  inset: 0;
  cursor: default;
  touch-action: none;
}

body.dragging-logo .stage {
  cursor: default;
}

.scene-vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 42%, transparent 0%, transparent 44%, rgba(0, 0, 0, 0.18) 70%, rgba(0, 0, 0, 0.58) 100%),
    linear-gradient(180deg, rgba(2, 3, 4, 0.28), transparent 26%, transparent 72%, rgba(2, 3, 4, 0.34) 100%);
  mix-blend-mode: screen;
}

.scene-vignette::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--overlay-grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--overlay-grid-color) 1px, transparent 1px),
    radial-gradient(circle, var(--overlay-dot-color) 1.1px, transparent 1.9px),
    repeating-linear-gradient(
      180deg,
      var(--overlay-scan-color) 0 1px,
      transparent 1px 5px
    );
  background-size:
    var(--overlay-grid-size) var(--overlay-grid-size),
    var(--overlay-grid-size) var(--overlay-grid-size),
    var(--overlay-dot-size) var(--overlay-dot-size),
    100% 100%;
  background-position: center;
  opacity: 1;
  mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 0.85), transparent 86%);
}

.loading-overlay,
.error-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  pointer-events: none;
  transition:
    opacity 420ms ease,
    visibility 420ms ease;
}

.loading-overlay.hidden,
.error-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-card,
.error-card {
  width: min(92vw, 26rem);
  padding: 1.5rem 1.45rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(7, 11, 18, 0.68);
  backdrop-filter: blur(24px) saturate(140%);
  box-shadow: var(--panel-shadow);
  text-align: center;
}

.loading-ring {
  width: 2.6rem;
  height: 2.6rem;
  display: inline-block;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-top-color: rgba(255, 190, 117, 0.92);
  animation: spin 1s linear infinite;
}

.loading-label,
.error-kicker {
  margin: 1rem 0 0.35rem;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 201, 127, 0.84);
}

.loading-progress,
.error-card p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.6;
  font-size: 0.94rem;
}

.error-card h1 {
  margin: 0 0 0.65rem;
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  font-weight: 600;
}

.error-card code {
  color: rgba(255, 226, 169, 0.96);
}

.control-panel {
  position: absolute;
  right: 1.3rem;
  bottom: 1.3rem;
  width: 2.15rem;
  min-height: 2.15rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02)),
    var(--panel-bg);
  backdrop-filter: blur(24px) saturate(150%);
  box-shadow: var(--panel-shadow);
  overflow: hidden;
  transform: translateZ(0);
  transition:
    transform 280ms ease,
    opacity 240ms ease,
    visibility 240ms ease,
    width 280ms ease,
    min-height 280ms ease,
    border-radius 280ms ease,
    box-shadow 280ms ease;
}

.control-panel[data-hidden="true"] {
  opacity: 0;
  visibility: hidden;
  transform: translate3d(0, 16px, 0);
  pointer-events: none;
}

.control-panel[data-open="true"] {
  width: min(20rem, calc(100vw - 2rem));
  min-height: 0;
  border-radius: 24px;
}

.panel-handle {
  width: 2.15rem;
  height: 2.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  cursor: pointer;
  color: rgba(248, 250, 255, 0.96);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.76rem;
  border-radius: inherit;
}

.panel-handle:hover {
  background: rgba(255, 255, 255, 0.03);
}

.control-panel[data-open="true"] .panel-handle {
  width: 100%;
  height: auto;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.95rem 1rem 0.9rem;
  border-radius: 0;
}

.handle-label {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.control-panel[data-open="true"] .handle-label {
  position: static;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.handle-indicator {
  position: relative;
  width: 0.82rem;
  height: 0.82rem;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 185, 112, 0.92), rgba(255, 108, 62, 0.82));
  box-shadow: 0 0 22px rgba(255, 154, 97, 0.35);
}

.handle-indicator::after {
  content: "";
  position: absolute;
  inset: 0.18rem;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.panel-body {
  display: grid;
  gap: 0.9rem;
  padding: 0 1.1rem 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-0.35rem);
  transition:
    max-height 360ms ease,
    opacity 260ms ease,
    transform 260ms ease,
    padding-top 260ms ease;
}

.control-panel[data-open="true"] .panel-body {
  max-height: 38rem;
  opacity: 1;
  transform: translateY(0);
  padding: 0.15rem 1.1rem 1.1rem;
}

.control-group {
  display: grid;
  gap: 0.42rem;
}

.control-group label,
.toggle-row span {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--text-soft);
}

.action-button {
  width: 100%;
  padding: 0.82rem 0.95rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 197, 116, 0.22);
  background:
    linear-gradient(135deg, rgba(255, 170, 84, 0.22), rgba(255, 117, 64, 0.14)),
    rgba(255, 255, 255, 0.04);
  color: rgba(248, 244, 238, 0.96);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.74rem;
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.action-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 202, 129, 0.38);
  background:
    linear-gradient(135deg, rgba(255, 170, 84, 0.28), rgba(255, 117, 64, 0.18)),
    rgba(255, 255, 255, 0.06);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.12rem 0;
}

.toggle-chip {
  position: relative;
  width: 3.1rem;
  height: 1.85rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--chip-off);
  cursor: pointer;
  transition:
    background 200ms ease,
    border-color 200ms ease;
}

.toggle-chip::after {
  content: "";
  position: absolute;
  top: 0.14rem;
  left: 0.18rem;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(217, 226, 241, 0.92));
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34);
  transition: transform 220ms ease;
}

.toggle-chip[data-active="true"] {
  background: linear-gradient(120deg, rgba(255, 155, 75, 0.3), rgba(255, 208, 111, 0.48));
  border-color: rgba(255, 200, 121, 0.22);
}

.toggle-chip[data-active="true"]::after {
  transform: translateX(1.16rem);
}

.panel-note {
  margin: 0.15rem 0 0;
  color: rgba(214, 223, 242, 0.58);
  font-size: 0.72rem;
  line-height: 1.6;
}

.ui-reveal {
  position: absolute;
  right: 1.3rem;
  bottom: 1.3rem;
  padding: 0.9rem 1.05rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03)),
    rgba(10, 13, 18, 0.62);
  backdrop-filter: blur(24px);
  color: rgba(249, 251, 255, 0.94);
  box-shadow: var(--panel-shadow);
  cursor: pointer;
}

.ui-reveal.hidden {
  display: none;
}

body.motion-paused .loading-ring {
  animation-play-state: paused;
}

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

@media (max-width: 720px) {
  .control-panel,
  .ui-reveal {
    right: 0.85rem;
    bottom: 0.85rem;
  }

  .control-panel[data-open="true"] {
    width: min(19rem, calc(100vw - 1.25rem));
  }

  .control-panel[data-open="true"] .panel-handle {
    padding: 0.95rem 1rem;
  }

  .panel-body {
    padding-inline: 1rem;
  }
}
