@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600&family=Inter:wght@400;500;600&display=swap");

:root {
  --ink: #eaf4f7;
  --muted: #9fb6c0;
  --cyan: #57d8ff;
  --deep: #06131d;
  --panel: rgba(5, 17, 26, 0.72);
  --line: rgba(170, 220, 240, 0.16);
  --serif: "Cinzel", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #02080d;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

#app,
#app canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.brand {
  position: absolute;
  top: 22px;
  left: 26px;
  display: flex;
  align-items: center;
  gap: 13px;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
}

.brand-mark {
  width: 38px;
  height: 38px;
  color: var(--cyan);
  opacity: 0.92;
}

.brand-mark svg {
  width: 100%;
  height: 100%;
}

.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand p {
  margin: 3px 0 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.brand p span {
  display: block;
  margin-top: 2px;
  color: rgba(87, 216, 255, 0.72);
}

.mode-switch {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(4, 14, 22, 0.55);
  backdrop-filter: blur(14px);
  pointer-events: auto;
}

.mode-switch button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 8px 15px;
  font: 500 11px/1 var(--sans);
  letter-spacing: 0.06em;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
}

.mode-switch button:hover {
  color: var(--ink);
}

.mode-switch button.is-active {
  color: #04131c;
  background: linear-gradient(180deg, #8ae7ff, #46c8ef);
}

.stats {
  position: absolute;
  left: 26px;
  bottom: 24px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font: 500 10.5px/1.2 var(--sans);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
}

.credits-link {
  position: absolute;
  left: 26px;
  bottom: 62px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: rgba(180, 215, 228, 0.55);
  font: 500 10px/1 var(--sans);
  letter-spacing: 0.08em;
  cursor: pointer;
  pointer-events: auto;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.credits-link:hover {
  color: var(--cyan);
}

.credits {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(1, 7, 12, 0.78);
  backdrop-filter: blur(12px);
}

.credits[hidden] {
  display: none;
}

.credits-card {
  width: min(640px, 90vw);
  max-height: 82vh;
  overflow-y: auto;
  padding: 30px 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(5, 18, 27, 0.96);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
}

.credits-card h2 {
  margin: 0 0 18px;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
}

.credits-card ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.credits-card li {
  padding: 8px 0;
  border-top: 1px solid rgba(160, 210, 230, 0.1);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
}

.credits-card li b {
  color: var(--ink);
  font-weight: 600;
}

.credits-small {
  margin: 18px 0 22px;
  color: rgba(170, 200, 212, 0.55);
  font-size: 10.5px;
  line-height: 1.6;
}

.credits-card button {
  appearance: none;
  border: 1px solid rgba(120, 220, 250, 0.4);
  border-radius: 4px;
  padding: 8px 18px;
  background: rgba(20, 60, 76, 0.6);
  color: var(--ink);
  font: 500 11px/1 var(--sans);
  letter-spacing: 0.06em;
  cursor: pointer;
}

.credits-card button:hover {
  background: rgba(40, 100, 122, 0.7);
}

.hint {
  position: absolute;
  right: 26px;
  bottom: 24px;
  display: flex;
  gap: 16px;
  color: rgba(190, 215, 225, 0.6);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

.hint b {
  color: rgba(235, 248, 252, 0.9);
  font-weight: 600;
}

#split-ui {
  position: fixed;
  inset: 0;
  z-index: 9;
  pointer-events: none;
}

.split-label {
  position: absolute;
  top: 74px;
  padding: 6px 10px;
  border: 1px solid rgba(100, 220, 255, 0.25);
  border-radius: 4px;
  background: rgba(3, 13, 20, 0.62);
  color: rgba(200, 240, 255, 0.78);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

.split-label--left {
  left: calc(50% - 20px);
  transform: translateX(-100%);
}

.split-label--right {
  left: calc(50% + 20px);
}

#split-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: linear-gradient(180deg, rgba(120, 230, 255, 0), rgba(120, 230, 255, 0.85) 20%, rgba(120, 230, 255, 0.85) 80%, rgba(120, 230, 255, 0));
  cursor: ew-resize;
  pointer-events: auto;
  touch-action: none;
}

#split-handle span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(140, 235, 255, 0.8);
  border-radius: 50%;
  background: rgba(6, 25, 36, 0.85);
  box-shadow: 0 0 24px rgba(70, 200, 239, 0.25);
}

#split-handle span::before,
#split-handle span::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  margin-top: -4px;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

#split-handle span::before {
  left: 8px;
  border-right: 6px solid var(--cyan);
}

#split-handle span::after {
  right: 8px;
  border-left: 6px solid var(--cyan);
}

#loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 50% 120%, rgba(11, 71, 94, 0.55), transparent 60%),
    linear-gradient(180deg, #02080d, #04131c 60%, #020a10);
  transition: opacity 0.8s ease, visibility 0.8s;
}

#loading.is-hidden {
  opacity: 0;
  visibility: hidden;
}

#loading.is-error .loading-bar i {
  background: #ff7070;
  animation: none;
  width: 100%;
}

.loading-inner {
  width: min(520px, 82vw);
  text-align: center;
}

.loading-rule {
  width: 46px;
  height: 1px;
  margin: 0 auto 26px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
}

.eyebrow {
  margin: 0 0 14px;
  color: rgba(120, 225, 255, 0.7);
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

.loading-inner h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(30px, 5vw, 46px);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.loading-sub {
  margin: 16px auto 30px;
  max-width: 400px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.65;
}

.loading-bar {
  width: 180px;
  height: 1px;
  margin: 0 auto 16px;
  background: rgba(150, 215, 235, 0.15);
  overflow: hidden;
}

.loading-bar i {
  display: block;
  width: 40%;
  height: 100%;
  background: var(--cyan);
  animation: loading-sweep 1.6s ease-in-out infinite;
}

#loading-status {
  margin: 0;
  color: rgba(170, 200, 212, 0.6);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.loading-note {
  margin: 22px auto 0;
  max-width: 380px;
  color: rgba(170, 200, 212, 0.55);
  font-size: 11px;
  line-height: 1.6;
}

.loading-note code {
  padding: 2px 5px;
  border: 1px solid rgba(120, 210, 240, 0.2);
  border-radius: 3px;
  color: rgba(150, 230, 255, 0.85);
  font-size: 10px;
}

#loading.is-unsupported .loading-bar {
  display: none;
}

#loading.is-unsupported .loading-inner h2 {
  font-size: clamp(28px, 5vw, 42px);
}

@keyframes loading-sweep {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(460%);
  }
}

/* lil-gui skin */
.lil-gui {
  --background-color: rgba(5, 17, 26, 0.82);
  --widget-color: rgba(22, 51, 66, 0.85);
  --hover-color: rgba(34, 74, 94, 0.9);
  --focus-color: rgba(46, 96, 120, 0.95);
  --number-color: #8ae7ff;
  --string-color: #a8e6c8;
  --font-family: var(--sans);
  --font-size: 10.5px;
  --input-font-size: 10.5px;
  --title-background-color: rgba(8, 27, 39, 0.92);
  --title-text-color: #dff4fa;
  --text-color: #c4d8e0;
  --slider-knob-color: #7fe4ff;
  --slider-input-color: rgba(60, 160, 190, 0.45);
  border: 1px solid var(--line) !important;
  border-radius: 8px !important;
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35) !important;
  top: 18px !important;
  right: 18px !important;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.lil-gui.root > .title {
  font-family: var(--serif);
  letter-spacing: 0.1em;
  font-size: 11px;
}

.lil-gui .title {
  letter-spacing: 0.05em;
}

.lil-gui .controller {
  border-left: 2px solid transparent;
}

.lil-gui .controller:hover {
  border-left-color: rgba(87, 216, 255, 0.35);
}

.lil-gui button {
  border-radius: 4px;
}

.lil-gui.root {
  max-height: calc(100vh - 90px) !important;
}

@media (max-width: 700px) {
  .brand {
    top: 14px;
    left: 14px;
  }
  .brand h1 {
    font-size: 16px;
  }
  .brand p,
  .hint {
    display: none;
  }
  .mode-switch {
    top: auto;
    bottom: 14px;
    padding: 3px;
  }
  .mode-switch button {
    padding: 7px 10px;
    font-size: 10px;
    white-space: nowrap;
  }
  .stats {
    left: 14px;
    bottom: 64px;
  }
  .credits-link {
    left: 14px;
    bottom: 102px;
  }
  .credits-card {
    padding: 22px 20px;
  }
  .lil-gui.root {
    --width: calc(100vw - 20px);
    top: 64px !important;
    right: 10px !important;
    max-height: 58vh !important;
  }
  .lil-gui.root.closed {
    --width: 220px;
  }
  .split-label {
    top: 60px;
    font-size: 8px;
    letter-spacing: 0.08em;
  }
  .split-label--left {
    left: calc(50% - 12px);
  }
  .split-label--right {
    left: calc(50% + 12px);
  }
}

@media (min-width: 701px) and (max-width: 900px) {
  .brand p,
  .hint {
    display: none;
  }
  .mode-switch {
    top: auto;
    bottom: 20px;
  }
  .stats {
    bottom: 70px;
  }
}
