/* ============================================================
   Stride — UI chrome around the WebGL stage
   ============================================================ */

:root {
  --ink: #f6f0e7;
  --ink-dim: rgba(246, 240, 231, 0.6);
  --ink-faint: rgba(246, 240, 231, 0.38);
  --glass: rgba(23, 19, 16, 0.52);
  --glass-strong: rgba(23, 19, 16, 0.74);
  --stroke: rgba(246, 240, 231, 0.13);
  --stroke-strong: rgba(246, 240, 231, 0.26);
  --accent: #e8a15c;
  --accent-ink: #201610;
  --accent-soft: rgba(232, 161, 92, 0.16);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
  --radius: 16px;
  --radius-sm: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #171310;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#stage {
  position: fixed;
  inset: 0;
  cursor: grab;
  touch-action: none;
}

#stage:active {
  cursor: grabbing;
}

#stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(130% 95% at 50% 40%, transparent 52%, rgba(9, 7, 5, 0.42) 100%);
  mix-blend-mode: multiply;
}

/* ---------- shared glass panel ---------- */

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
  backdrop-filter: blur(16px) saturate(1.25);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- brand ---------- */

.brand {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  left: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px 11px 12px;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.brand-icon {
  width: 34px;
  height: 34px;
  color: var(--accent);
  flex: none;
  filter: drop-shadow(0 2px 6px rgba(232, 161, 92, 0.35));
}

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--ink-dim);
}

/* ---------- stats ---------- */

.stats {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  right: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.stats #stat-fps {
  color: var(--ink);
}

.stats-sep {
  width: 1px;
  height: 14px;
  background: var(--stroke-strong);
}

/* ---------- hint ---------- */

.hint {
  position: fixed;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%);
  margin: 0;
  padding: 7px 14px;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  background: rgba(23, 19, 16, 0.35);
  border-radius: 999px;
  border: 1px solid rgba(246, 240, 231, 0.07);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.hint kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-dim);
  background: rgba(246, 240, 231, 0.08);
  border: 1px solid rgba(246, 240, 231, 0.12);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  margin: 0 1px;
}

/* ---------- control bar ---------- */

#controls {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  max-width: calc(100vw - 24px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.divider {
  width: 1px;
  height: 26px;
  background: var(--stroke);
  flex: none;
}

.btn,
.segmented button {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-dim);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease,
    transform 0.12s ease;
  -webkit-user-select: none;
  user-select: none;
}

.btn:hover,
.segmented button:hover {
  color: var(--ink);
  background: rgba(246, 240, 231, 0.07);
}

.btn:active,
.segmented button:active {
  transform: scale(0.96);
}

.btn:focus-visible,
.segmented button:focus-visible,
input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#btn-pause {
  min-width: 96px;
  justify-content: center;
}

#btn-pause .icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.segmented {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 13px;
  background: rgba(9, 7, 5, 0.35);
  border: 1px solid rgba(246, 240, 231, 0.07);
}

.segmented button {
  padding: 7px 12px;
  border-radius: 9px;
  font-size: 12px;
}

.segmented button.is-active {
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 4px 14px rgba(232, 161, 92, 0.35);
}

.segmented button.is-active:hover {
  color: var(--accent-ink);
  background: #f0b076;
}

.control {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 2px;
}

.control label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-dim);
  letter-spacing: 0.02em;
}

.control output {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  min-width: 3.6em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 128px;
  height: 22px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--fill, 50%),
    rgba(246, 240, 231, 0.16) var(--fill, 50%),
    rgba(246, 240, 231, 0.16) 100%
  );
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s ease;
}

input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(246, 240, 231, 0.16);
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

input[type="range"]::-moz-range-thumb {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ---------- overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 10;
  background: radial-gradient(90% 90% at 50% 40%, #241d17 0%, #120f0c 100%);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.overlay[hidden] {
  display: none;
}

.overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-card {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 28px 34px;
  text-align: center;
  max-width: min(440px, calc(100vw - 40px));
}

.loader-card h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0.04em;
}

.loader-card p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-dim);
  line-height: 1.55;
}

.loader-card pre {
  margin: 0;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  background: rgba(9, 7, 5, 0.5);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  -webkit-user-select: all;
  user-select: all;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(246, 240, 231, 0.12);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

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

/* ---------- hidden UI state ---------- */

body.ui-hidden .brand,
body.ui-hidden .stats,
body.ui-hidden #controls,
body.ui-hidden .hint {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

body.ui-hidden #controls,
body.ui-hidden .hint {
  transform: translate(-50%, 10px);
}

/* ---------- responsive ---------- */

@media (max-width: 880px) {
  #controls {
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 8px;
    padding: 10px 12px;
  }

  .hint {
    display: none;
  }

  input[type="range"] {
    width: 96px;
  }
}

@media (max-width: 560px) {
  .brand {
    padding: 8px 12px 8px 10px;
    gap: 8px;
    max-width: 42vw;
  }

  .brand-icon {
    width: 26px;
    height: 26px;
  }

  .brand-text h1 {
    font-size: 13.5px;
    letter-spacing: 0.1em;
  }

  .brand-text p {
    display: none;
  }

  .stats {
    font-size: 10px;
    padding: 7px 10px;
    gap: 7px;
    max-width: 54vw;
    overflow: hidden;
  }

  .stats #stat-stride,
  .stats .stats-sep {
    display: none;
  }

  .divider {
    display: none;
  }

  #btn-pause .btn-label {
    display: none;
  }

  #btn-pause {
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }

  * {
    transition-duration: 0.01ms !important;
  }
}
