:root {
  color-scheme: light;
  --ink: #182037;
  --muted: #566174;
  --paper: rgba(250, 249, 246, 0.9);
  --line: rgba(24, 32, 55, 0.14);
  --accent: #c9294f;
  --navy: #252c62;
  --shadow: 0 18px 55px rgba(22, 27, 45, 0.14);
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: "Inter", Arial, sans-serif;
  background: #dce2df;
  color: var(--ink);
}

button,
select,
input { font: inherit; }

.scene {
  position: fixed;
  inset: 0;
  isolation: isolate;
}

.scene::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(180deg, rgba(15, 22, 47, 0.22), transparent 25%),
    linear-gradient(0deg, rgba(16, 23, 43, 0.22), transparent 32%);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.topbar {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px clamp(20px, 4vw, 64px);
  color: #fff;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 5px 14px rgba(0, 0, 0, 0.2));
}

.back-link {
  color: inherit;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
}

.project-copy {
  position: absolute;
  z-index: 3;
  left: clamp(20px, 4vw, 64px);
  bottom: clamp(28px, 5vw, 64px);
  width: min(520px, calc(100vw - 40px));
  color: #fff;
  text-shadow: 0 3px 25px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(38px, 6.2vw, 88px);
  line-height: 0.98;
  font-weight: 600;
  letter-spacing: 0;
}

.project-copy p:last-child {
  max-width: 470px;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: clamp(13px, 1.25vw, 16px);
  line-height: 1.65;
}

.controls {
  position: absolute;
  z-index: 4;
  right: clamp(20px, 4vw, 64px);
  bottom: clamp(28px, 5vw, 64px);
  width: min(318px, calc(100vw - 40px));
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.15);
}

.control-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-row + .control-row { margin-top: 10px; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.58);
}

.segmented button {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  background: var(--navy);
  color: #fff;
}

.icon-button {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}

.select-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.select-wrap span {
  position: absolute;
  top: 7px;
  left: 12px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  pointer-events: none;
}

select {
  width: 100%;
  height: 50px;
  padding: 18px 34px 4px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 50px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.toggle input { accent-color: var(--accent); }

.loading {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: grid;
  place-items: center;
  background: #e9e7df;
  color: var(--navy);
  font-size: 13px;
  font-weight: 700;
  transition: opacity 0.55s ease, visibility 0.55s ease;
}

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

@media (max-width: 980px) {
  .project-copy {
    top: 92px;
    bottom: auto;
  }

  .project-copy p:last-child { display: none; }
}

@media (max-width: 760px) {
  .topbar { padding: 16px 18px; }
  .brand span { display: none; }
  .brand img { width: 36px; height: 36px; }
  .project-copy { top: 78px; left: 18px; }
  h1 { max-width: 330px; font-size: clamp(34px, 12vw, 54px); }

  .controls {
    right: 14px;
    bottom: max(14px, env(safe-area-inset-bottom));
    left: 14px;
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
