:root {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f5f5ed;
  background: #171b17;
  font-synthesis: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  overflow: hidden;
}

canvas {
  display: block;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}

canvas:focus-visible { outline: 2px solid #f0dab3; outline-offset: -4px; }

.topbar {
  position: fixed;
  z-index: 5;
  top: 28px;
  left: 30px;
  right: 30px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  pointer-events: none;
  text-shadow: 0 1px 12px #0a182c88;
}

.title,
.actions { pointer-events: auto; }

.title { min-width: 0; color: inherit; text-decoration: none; }
.title:focus-visible { outline: 2px solid #f0dab3; outline-offset: 7px; border-radius: 3px; }

.eyebrow {
  color: #dae8eb;
  font-size: 10px;
  letter-spacing: 2.4px;
}

h1 {
  margin: 9px 0 7px;
  font-size: 25px;
  font-weight: 550;
  letter-spacing: 2px;
}

.title p {
  margin: 0;
  color: #e1e7e6;
  font-size: 12px;
}

.actions {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  gap: 7px;
}

button {
  padding: 11px 14px;
  border: 1px solid #d6e8ed30;
  border-radius: 7px;
  color: #f2f4ed;
  background: #14252dc9;
  font: inherit;
  font-size: 12px;
  letter-spacing: .3px;
  cursor: pointer;
  backdrop-filter: blur(14px);
  transition: background .15s, border-color .15s;
}

button:hover {
  border-color: #d6e8ed80;
  background: #253d46e8;
}

button:focus-visible {
  outline: 2px solid #f0dab3;
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

#settings {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(290px, calc(100vw - 32px));
  margin: 0;
  padding: 16px;
  border: 1px solid #d6e8ed38;
  border-radius: 10px;
  background: #13242de8;
  box-shadow: 0 14px 36px #07131b55;
  text-align: left;
  text-shadow: none;
  backdrop-filter: blur(16px);
  max-height: calc(100dvh - 110px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

#settings[hidden] { display: none; }

#settings h2 {
  margin: 0 0 8px;
  color: #f2f4ed;
  font-size: 13px;
  font-weight: 550;
  letter-spacing: .5px;
}

#settings p {
  margin: 0 0 13px;
  color: #c8d3d8;
  font-size: 11px;
  line-height: 1.55;
}

.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.settings-actions button {
  width: 100%;
  padding: 9px 10px;
  text-align: left;
  font-size: 11px;
}

.settings-link {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #d6e8ed30;
  border-radius: 7px;
  color: #f2f4ed;
  background: #14252dc9;
  text-align: left;
  text-decoration: none;
  font-size: 11px;
}
.settings-link:hover { background: #253d46e8; }
.settings-link:focus-visible { outline: 2px solid #f0dab3; outline-offset: 3px; }

.settings-actions button[aria-pressed="true"] {
  border-color: transparent;
  color: #17292d;
  background: #e6ddc8;
}

.quality-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #c8d3d8; font-size: 11px; }
select { padding: 8px; border: 1px solid #d6e8ed40; border-radius: 6px; color: #f2f4ed; background: #25352e; font: inherit; }
select:focus-visible { outline: 2px solid #f0dab3; outline-offset: 2px; }
.look-controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.look-controls button { min-height: 42px; padding: 8px; font-size: 16px; }
.scene-links { border-top: 1px solid #d6e8ed25; padding-top: 12px; margin-top: 12px; }

.notice {
  position: fixed;
  bottom: 14px;
  left: 20px;
  margin: 0;
  color: #ecf1edb0;
  font-size: 9px;
  letter-spacing: .5px;
  text-shadow: 0 1px 5px #000;
}

.loading {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: #16272ef2;
}

.loading[hidden] { display: none; }

.loading h2 {
  margin-top: 24px;
  font-size: 20px;
  font-weight: 450;
  letter-spacing: 3px;
}

.loading p {
  color: #aabbc2;
  font-size: 12px;
}

.spinner {
  width: 35px;
  height: 35px;
  border: 1px solid #e4d9bd30;
  border-top-color: #e4d9bd;
  border-radius: 50%;
  animation: turn 1.5s linear infinite;
}

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

.error {
  position: fixed;
  z-index: 20;
  top: 40%;
  left: 50%;
  max-width: 520px;
  padding: 25px;
  border: 1px solid #bc9f80;
  background: #3d2928f5;
  line-height: 1.7;
  transform: translate(-50%, -50%);
}

#diagnostics {
  position: fixed;
  top: 140px;
  left: 12px;
  padding: 10px;
  color: #caffc9;
  background: #000a;
  font: 11px/1.5 monospace;
  white-space: pre;
  pointer-events: none;
}

@media (max-width: 700px) {
  .topbar {
    top: 20px;
    left: 20px;
    right: 20px;
  }

  .actions { gap: 5px; }

  .actions > button {
    padding: 9px;
    font-size: 10px;
  }

  .eyebrow {
    font-size: 8px;
    letter-spacing: 1.6px;
  }

  h1 { font-size: 20px; }

  .title p { font-size: 10px; }

  .notice {
    bottom: 4px;
    left: 50%;
    font-size: 8px;
    white-space: nowrap;
    transform: translateX(-50%);
  }
}

@media (max-width: 520px) {
  .topbar {
    left: 16px;
    right: 16px;
    gap: 10px;
    flex-direction: column;
  }

  .actions { gap: 4px; align-self: flex-end; }

  .actions > button {
    min-height: 42px;
    min-width: 44px;
    padding: 8px 9px;
    font-size: 11px;
    letter-spacing: .1px;
  }

  .eyebrow {
    font-size: 8px;
    letter-spacing: 1.4px;
  }

  h1 {
    font-size: 19px;
    letter-spacing: 1.2px;
  }

  .title p { font-size: 9px; }

  #settings {
    top: calc(100% + 8px);
    width: min(270px, calc(100vw - 32px));
    max-height: calc(100dvh - 170px);
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none; }
  .spinner { animation: none; }
}
