:root {
  color-scheme: dark;
  --deep-950: #02030a;
  --deep-900: #040610;
  --deep-850: #0a0d1d;
  --deep-800: #10162b;
  --deep-700: #182044;
  --ink: #e9edff;
  --muted: rgba(233, 237, 255, 0.72);
  --accent-1: #87cfff;
  --accent-2: #b99aff;
  --accent-3: #7de4c8;
  --surface: rgba(10, 12, 26, 0.72);
  --stroke: rgba(136, 147, 198, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 15%, #1b2346, transparent 40%),
    radial-gradient(circle at 80% 10%, #1f0f3b, transparent 35%),
    radial-gradient(circle at 50% 90%, #10302a, transparent 38%),
    var(--deep-950);
  overflow: hidden;
  position: relative;
}

body::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(7, 9, 20, 0.8), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.layout {
  display: flex;
  min-height: 100vh;
  height: 100vh;
  position: relative;
  z-index: 1;
}

.panel {
  width: clamp(260px, 30vw, 380px);
  padding: 26px;
  background: var(--surface);
  border-right: 1px solid var(--stroke);
  box-shadow: 18px 0 40px rgba(2, 5, 18, 0.5);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: hidden;
  z-index: 2;
  animation: rise 1s ease-out both;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#shader {
  z-index: 0;
}

#field {
  z-index: 1;
  touch-action: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(8, 12, 26, 0.8);
  border: 1px solid rgba(136, 147, 198, 0.4);
  font-size: 0.7rem;
  letter-spacing: 0.18rem;
  text-transform: uppercase;
  color: var(--muted);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2rem;
  color: var(--muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--ink);
}

h1 {
  font-family: "Unbounded", "Space Grotesk", sans-serif;
  font-size: clamp(1.6rem, 2.4vw + 1rem, 2.7rem);
  margin: 8px 0 6px;
  letter-spacing: 0.02em;
}

.lede {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  border: 1px solid rgba(135, 207, 255, 0.4);
  background: linear-gradient(135deg, rgba(16, 20, 40, 0.9), rgba(10, 12, 26, 0.8));
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(6, 8, 18, 0.45);
}

button:focus-visible {
  outline: 2px solid var(--accent-1);
  outline-offset: 3px;
}

.stats {
  font-size: 0.85rem;
  color: var(--muted);
}

.toggle {
  font-size: 0.75rem;
  padding: 6px 12px;
}

.instructions {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(6, 9, 18, 0.72);
  border: 1px solid rgba(124, 150, 210, 0.25);
  color: var(--muted);
  font-size: 0.85rem;
  align-self: flex-start;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }

  .panel {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--stroke);
  }

  .instructions {
    align-self: stretch;
    text-align: center;
  }
}

.layout.is-minimized .panel {
  width: 64px;
  padding: 20px 12px;
}

.layout.is-minimized .panel-header {
  justify-content: center;
}

.layout.is-minimized .panel-body,
.layout.is-minimized .badge {
  display: none;
}

.layout.is-minimized .toggle {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

@media (max-width: 900px) {
  .layout.is-minimized .panel {
    width: 100%;
    height: 64px;
  }

  .layout.is-minimized .toggle {
    writing-mode: horizontal-tb;
    transform: none;
  }
}

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

  button {
    transition: none;
  }
}
