:root {
  --bg0: #061018;
  --bg1: #0a1a24;
  --ink: #e7f6f8;
  --muted: #8aadb4;
  --accent: #2fd3c8;
  --accent-dim: #1a8f88;
  --stroke: rgba(47, 211, 200, 0.22);
  --panel: rgba(8, 24, 34, 0.72);
  --glow: rgba(47, 211, 200, 0.35);
  --danger: #ff6b6b;
  --font-display: "Fraunces", "Palatino Linotype", Palatino, serif;
  --font-body: "Sora", "Segoe UI", sans-serif;
  --radius: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 60% at 50% 20%, rgba(47, 211, 200, 0.12), transparent 55%),
    radial-gradient(ellipse 70% 50% at 80% 90%, rgba(30, 90, 120, 0.25), transparent 50%),
    linear-gradient(165deg, var(--bg0), var(--bg1) 55%, #041018);
  background-attachment: fixed;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
  opacity: 0;
  transform: translateY(12px);
  animation: rise-in 0.9s var(--ease) forwards;
}

@keyframes rise-in {
  to {
    opacity: 1;
    transform: none;
  }
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.brand-block h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 5vw, 3.1rem);
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
  line-height: 1.1;
}

.brand-block .tagline {
  margin: 0;
  color: var(--muted);
  max-width: 36ch;
  font-size: 0.98rem;
}

.prefs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.field label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

select,
input[type="range"] {
  font: inherit;
  color: var(--ink);
}

select {
  appearance: none;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 0.55rem 2rem 0.55rem 0.75rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 14px) 55%, calc(100% - 9px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  min-width: 9.5rem;
  cursor: pointer;
}

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

.layout {
  display: grid;
  grid-template-columns: 1.35fr 0.95fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.stage {
  position: relative;
  border-radius: calc(var(--radius) + 4px);
  border: 1px solid var(--stroke);
  background: rgba(2, 10, 16, 0.85);
  box-shadow: 0 0 60px var(--glow), inset 0 0 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  max-height: min(72vh, 640px);
}

#lissajous {
  display: block;
  width: 100%;
  height: 100%;
}

.interval-panel {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(8px);
}

.interval-name {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 2rem);
  margin: 0 0 0.65rem;
  color: var(--accent);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 1rem;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.meta-item span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.meta-item strong {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.meta-item-wide {
  grid-column: 1 / -1;
}

.closes-yes {
  color: var(--accent);
}

.closes-no {
  color: #e8a87c;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.1rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(8px);
}

.controls .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 480px) {
  .controls .row {
    grid-template-columns: 1fr;
  }
}

.play-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  padding: 0.9rem 1.2rem;
  border-radius: 999px;
  color: #031016;
  background: linear-gradient(135deg, #5ef0e4, var(--accent) 45%, var(--accent-dim));
  box-shadow: 0 8px 28px rgba(47, 211, 200, 0.35);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), filter 0.25s;
}

.play-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.play-btn[aria-pressed="true"] {
  background: linear-gradient(135deg, #ff8e8e, var(--danger));
  box-shadow: 0 8px 28px rgba(255, 107, 107, 0.3);
  color: #1a0505;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.slider-row .slider-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.slider-row .slider-head output {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-size: 0.9rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 1.4rem;
}

.footer-note {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}
