@font-face {
  font-family: Fredoka;
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/fonts/fredoka-latin-500-normal.woff2) format("woff2");
}

@font-face {
  font-family: Quicksand;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/quicksand-latin-400-normal.woff2) format("woff2");
}

@font-face {
  font-family: Comfortaa;
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(/fonts/comfortaa-latin-300-normal.woff2) format("woff2");
}

/* Layout: one screen. A nebula canvas fills the page. Over it sits either the sky of
   constellations or one puzzle field, with slim pill controls at the edges. */
:root {
  --ink: #07060d;
  --teal: #8ce6dc;
  --lilac: #c9b6f2;
  --blush: #f6c9e8;
  --violet: #7e6bd6;
  --mist: #e9e3fb;
  --panel: rgba(20, 17, 34, 0.74);
  --panel-hover: rgba(62, 53, 92, 0.9);
  --line: rgba(201, 182, 242, 0.3);
  --hover: rgba(201, 182, 242, 0.18);
  --glow: rgba(140, 230, 220, 0.45);
  --font-word: Comfortaa, "Trebuchet MS", sans-serif;
  --font-ui: Fredoka, "Trebuchet MS", sans-serif;
  --font-text: Quicksand, "Trebuchet MS", sans-serif;
  color-scheme: dark;
}

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

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ink);
  color: var(--mist);
  font: 400 15px / 1.5 var(--font-text);
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

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

.defs {
  position: absolute;
}

.app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--ink);
}

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

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: max(16px, env(safe-area-inset-top, 0px));
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  animation: view-in 420ms ease-out;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* Shared controls */

.pill {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--lilac);
  font: 500 15px / 1 var(--font-ui);
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease;
}

.pill:hover {
  background: var(--panel-hover);
  color: var(--mist);
}

.pill svg,
.tray-btn svg {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pill.round {
  width: 44px;
  padding: 0;
  justify-content: center;
}

.pill.primary,
.pill[aria-pressed="true"],
.pill[aria-pressed="true"]:hover {
  border-color: var(--teal);
  background: var(--teal);
  color: var(--ink);
}

.pill.primary:hover {
  border-color: var(--mist);
  background: var(--mist);
}

.sound .wave,
.sound[aria-pressed="true"] .mute {
  display: none;
}

.sound[aria-pressed="true"] .wave {
  display: inline;
}

/* Sky: the level picker */

.view-sky {
  align-items: center;
  gap: 18px;
  overflow-y: auto;
}

.masthead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-top: clamp(8px, 5vh, 44px);
  text-align: center;
}

.word {
  margin: 0;
  font: 300 clamp(24px, 4vw, 38px) / 1.2 var(--font-word);
  letter-spacing: 0.18em;
  text-indent: 0.18em;
}

.teal {
  color: var(--teal);
}

.lilac {
  color: var(--lilac);
}

.lede {
  max-width: 34ch;
  margin: 0;
  color: var(--mist);
  opacity: 0.85;
  text-wrap: balance;
}

.sky-grid {
  flex: 1 0 auto;
  width: 100%;
  max-width: 720px;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: 14px 12px;
}

.sky-grid > li {
  width: clamp(96px, 28vw, 150px);
}

.sky-grid > li:nth-child(odd) {
  translate: 0 5px;
}

.sky-grid > li:nth-child(even) {
  translate: 0 -5px;
}

.constellation {
  width: 100%;
  padding: 6px 4px 8px;
  border: 0;
  border-radius: 18px;
  background: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.mini {
  width: 100%;
  max-width: 124px;
  aspect-ratio: 1;
  overflow: visible;
  transition: transform 260ms cubic-bezier(0.2, 1.2, 0.4, 1);
}

.constellation:hover .mini {
  transform: scale(1.06);
}

.mini line {
  stroke: var(--lilac);
  stroke-width: 1.6;
  stroke-linecap: round;
  opacity: 0;
}

.mini circle {
  fill: var(--mist);
  opacity: 0.5;
  animation: twinkle var(--dur, 3s) ease-in-out var(--delay, 0s) infinite;
}

.constellation[data-state="gathered"] .mini {
  filter: drop-shadow(0 0 5px var(--glow));
}

.constellation[data-state="gathered"] .mini line {
  opacity: 0.75;
}

.constellation[data-state="gathered"] .mini circle {
  fill: var(--teal);
  opacity: 1;
  animation: none;
}

.constellation[data-state="gathered"] .mini circle.alt {
  fill: var(--lilac);
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.28;
  }

  50% {
    opacity: 0.8;
  }
}

.c-name {
  font: 500 15px / 1.2 var(--font-ui);
  color: var(--mist);
  transition: color 180ms ease;
}

.constellation:hover .c-name {
  color: var(--teal);
}

.c-state {
  min-height: 18px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  line-height: 18px;
  color: var(--lilac);
}

.constellation[data-state="next"] .c-state {
  color: var(--teal);
}

.c-state svg,
.status svg,
.finale-sub svg {
  flex: none;
  width: 12px;
  height: 12px;
  fill: var(--blush);
}

.sky-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 16px;
  padding-bottom: 4px;
}

.tally {
  margin: 0;
  font-size: 14px;
  color: var(--lilac);
  font-variant-numeric: tabular-nums;
}

/* Finale: a full sky gathers into one heart, drawn on the canvas */

.lede,
.sky-grid,
.sky-foot {
  transition: opacity 500ms ease;
}

.view-sky[data-mode="finale"] {
  overflow: hidden;
}

.view-sky[data-mode="finale"] .lede,
.view-sky[data-mode="finale"] .sky-grid,
.view-sky[data-mode="finale"] .sky-foot {
  opacity: 0;
  pointer-events: none;
}

.finale {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(20px, 5vh, env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  text-align: center;
  animation: view-in 900ms ease-out 4.8s backwards;
}

.finale-line {
  margin: 0;
  font: 300 clamp(18px, 3vw, 26px) / 1.25 var(--font-word);
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  color: var(--mist);
}

.finale-sub {
  max-width: 38ch;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--lilac);
  text-wrap: balance;
}

/* Play: one constellation */

.view-play {
  gap: 8px;
}

.bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}

.bar > :first-child {
  justify-self: start;
}

.bar > :last-child {
  justify-self: end;
}

.title {
  min-width: 0;
  text-align: center;
}

.level-name {
  margin: 0;
  font: 300 clamp(17px, 2.6vw, 22px) / 1.2 var(--font-word);
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  color: var(--mist);
}

.level-count {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.2;
  color: var(--lilac);
  font-variant-numeric: tabular-nums;
}

.field {
  flex: 1;
  min-height: 0;
  border-radius: 24px;
  outline: none;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.field:focus-visible {
  box-shadow: inset 0 0 0 1px var(--line);
}

.status {
  min-height: 24px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-align: center;
  text-wrap: balance;
}

.tray {
  align-self: center;
  display: flex;
  gap: 2px;
  padding: 4px;
  margin-bottom: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.tray-btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--mist);
  font: 500 15px / 1 var(--font-ui);
  cursor: pointer;
  transition: background-color 180ms ease, opacity 180ms ease;
}

.tray-btn:hover {
  background: var(--hover);
}

.tray-btn:disabled {
  opacity: 0.4;
  cursor: default;
  background: transparent;
}

.tray-btn svg {
  color: var(--teal);
}

.tray-btn[data-act="restart"] svg {
  color: var(--lilac);
}

.tray-btn[data-act="hint"] svg {
  color: var(--blush);
}

.tray-btn.nudge {
  animation: nudge 900ms ease-in-out 2;
}

@keyframes nudge {
  50% {
    background: var(--hover);
  }
}

.done-row {
  align-self: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 4px;
  animation: view-in 420ms ease-out 500ms backwards;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
