@font-face {
  font-family: Bricolage;
  src: url(assets/display.woff2) format('woff2');
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url(assets/sans.woff2) format('woff2');
  font-weight: 400 700;
  font-display: swap;
}
:root {
  color-scheme: dark;
  --ink: #f4f2ff;
  --muted: #b5b1c9;
  --lav: #c5b6ff;
  --edge: #383448;
  --page: #11101e;
  --display: Bricolage, system-ui, sans-serif;
  font:
    16px 'DM Sans',
    system-ui,
    sans-serif;
  color: var(--ink);
  background: var(--page);
}
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  background: #111326;
}
h1,
h2,
p {
  margin: 0;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible,
select:focus-visible {
  outline: 3px solid #ffd3aa;
  outline-offset: 3px;
}
button:disabled {
  cursor: default;
}
[hidden] {
  display: none !important;
}
.game-screen {
  --gutter: clamp(16px, 3vw, 50px);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  padding: max(22px, env(safe-area-inset-top))
    max(var(--gutter), env(safe-area-inset-right))
    max(21px, env(safe-area-inset-bottom))
    max(var(--gutter), env(safe-area-inset-left));
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.landscape,
.game-screen::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.landscape {
  z-index: -3;
  background: #101f48 url(assets/first-light.webp) 18% center/cover no-repeat;
  filter: hue-rotate(var(--hue, 0deg));
}
.game-screen::before {
  content: '';
  z-index: -2;
  background: linear-gradient(
    180deg,
    #090c23a8,
    transparent 25%,
    transparent 67%,
    #12112566 85%,
    #111125bd
  );
}
.starlight {
  z-index: -1;
}
.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  column-gap: 8px;
  z-index: 2;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  width: fit-content;
  font: 740 1.55rem/1 var(--display);
  letter-spacing: -0.055em;
  text-shadow: 0 2px 12px #09091ac9;
}
.brand img {
  filter: drop-shadow(0 1px 6px #9883de80);
}
.board-heading {
  text-align: center;
  padding-top: 4px;
  text-shadow: 0 2px 14px #090b24;
}
.eyebrow,
.modal-kicker,
.card-caption {
  color: #d8c7ff;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.eyebrow::before,
.eyebrow::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 1px;
  vertical-align: middle;
  margin: 0 8px;
  background: #c9aefa70;
}
h1 {
  margin: 4px 0 9px;
  font: 710 clamp(2rem, 4.1vw, 3.7rem) / 1 var(--display);
  letter-spacing: -0.055em;
}
h1:focus {
  outline: 0;
}
.readouts,
.utilities,
.dock,
.status-heading,
.remaining,
.action,
.card {
  display: flex;
  align-items: center;
}
.readouts {
  justify-content: center;
  gap: 0;
  color: #cbc9df;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}
.readouts > span {
  white-space: nowrap;
  padding: 0 10px;
}
.readouts > span + span {
  border-left: 1px solid #d4c9fa55;
}
.readouts strong {
  color: #f3efff;
  font-weight: 650;
}
.remaining {
  gap: 4px;
}
.luminous-dot {
  background: #d6c9ff;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 3px;
  box-shadow: 0 0 8px #c1a5ff;
}
.utilities {
  justify-self: end;
  gap: 8px;
}
.round,
.dock,
.action,
dialog {
  border: 1px solid #b9a9e44d;
}
.round {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  background: #1a1a35c4;
  backdrop-filter: blur(12px);
}
.round:hover,
.dock-tool:enabled:hover {
  background: #4e4169db;
}
.round:active,
.dock button:enabled:active {
  transform: scale(0.95);
}

.icon {
  height: 18px;
  width: 18px;
  display: inline-block;
  flex: none;
  vertical-align: middle;
  stroke: currentColor;
  stroke-width: 1.7;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.starlight {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.starlight i {
  position: absolute;
  left: 28%;
  top: 32%;
  width: 5px;
  height: 5px;
  background: #e4d6ff;
  clip-path: polygon(
    50% 0,
    61% 39%,
    100% 50%,
    61% 61%,
    50% 100%,
    39% 61%,
    0 50%,
    39% 39%
  );
  animation: twinkle 5s ease-in-out infinite alternate;
}
.starlight i:nth-child(2) {
  left: 68%;
  top: 27%;
  width: 4px;
  height: 4px;
  animation-delay: -2s;
}
.starlight i:nth-child(3) {
  left: 32%;
  top: 65%;
  animation-delay: -3s;
}
.starlight i:nth-child(4) {
  left: 78%;
  top: 44%;
  width: 7px;
  height: 7px;
  animation-delay: -1s;
}
.starlight i:nth-child(5) {
  left: 16%;
  top: 49%;
  width: 3px;
  height: 3px;
  animation-delay: -4s;
}
@keyframes twinkle {
  0%,
  12% {
    opacity: 0.13;
    transform: scale(0.65);
  }
  60%,
  100% {
    opacity: 0.75;
    transform: scale(1);
  }
}

#playfield {
  position: relative;
  min-height: 0;
  min-width: 0;
  container-type: size;
}
.sight {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(91cqw, 91cqh, 650px);
  aspect-ratio: 1;
  pointer-events: none;
  border-radius: 50%;
  border: 1px solid #cdc5ff23;
}
.sight::before,
.sight::after {
  content: '';
  position: absolute;
  border-radius: 50%;
}
.sight::before {
  inset: 6px;
  border: 1px dashed #c2c4f81f;
}
.sight::after {
  inset: 20%;
  border: 1px solid #cdc5ff10;
}

#lines,
#dots {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#lines {
  pointer-events: none;
}
.node {
  position: absolute;
  padding: 0;
  border: 0;
  width: 44px;
  height: 44px;
  background: transparent;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 1;
}
.orb {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid #eeebff;
  background: radial-gradient(
    circle at 35% 28%,
    #ffffff 0%,
    #e4d6ff 18%,
    #c0a4fc 45%,
    #8b68d7 76%,
    #6046a8 100%
  );
  box-shadow:
    0 0 0 5px #ab85fb26,
    0 0 0 6px #d0b6ff42,
    0 0 20px 5px #ac82f56b,
    inset 0 -2px 3px #7b61cd;
  transition: transform 0.18s;
}
.orb:after {
  content: '';
  position: absolute;
  inset: 5px;
  background: #fff5ff;
  clip-path: polygon(
    50% 0%,
    60% 37%,
    100% 50%,
    60% 60%,
    50% 100%,
    40% 60%,
    0 50%,
    40% 38%
  );
  opacity: 0.9;
}
.node[aria-pressed='true'] .orb {
  background: radial-gradient(
    circle at 30% 20%,
    white,
    #ffe0b5 38%,
    #ffac85 75%,
    #e68584
  );
  border-color: #fff0d3;
  box-shadow:
    0 0 0 5px #ffb18e3d,
    0 0 0 6px #ffc99bb0,
    0 0 22px 6px #ffaf826b;
}
@media (hover: hover) {
  .node:hover .orb {
    transform: scale(1.16);
  }
}
.node.hinted .orb {
  outline: 2px dashed #ffd5a5;
  outline-offset: 8px;
}

#centre-action {
  position: absolute;
  z-index: 2;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: transparent;
}
#centre-action[hidden] {
  display: none;
}
#centre-action span {
  display: grid;
  place-items: center;
  width: min(26px, 100%);
  aspect-ratio: 1;
  color: #ffe6bd;
  border: 1px dashed #ffdaad;
  border-radius: 50%;
  background: #33263edf;
  box-shadow: 0 0 12px #ffc48555;
}
#centre-action:hover span {
  background: #6b4444;
}
.node.candidate .orb {
  background: radial-gradient(
    circle at 30% 22%,
    white,
    #a9ffcf 32%,
    #57d596 65%,
    #29926a
  );
  border-color: #d3ffe4;
  box-shadow:
    0 0 0 5px #61e2a336,
    0 0 0 6px #9dffc2aa,
    0 0 20px 5px #58df985c;
}

#celebration {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 17px;
  border: 1px solid #ffe5c266;
  border-radius: 25px;
  background: #272038e8;
  color: #ffdfb1;
  font: 600 1rem var(--display);
  white-space: nowrap;
}
#celebration[hidden] {
  display: none;
}

.play-controls {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
}
.instruction {
  width: min(95%, 520px);
  min-height: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 3px;
  text-shadow:
    0 2px 6px #0b0a20,
    0 0 12px #050723;
}
.status-heading {
  justify-content: center;
  gap: 10px;
}
.status-heading strong {
  font: 660 1.17rem/1.15 var(--display);
  letter-spacing: -0.02em;
}
.instruction p {
  color: #f0eafa;
  font-size: 0.89rem;
  line-height: 1.3;
  margin-top: 5px;
}
#selection {
  display: flex;
  gap: 3px;
}
#selection i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #36304e;
  border: 1px solid #ddcfffab;
}
#selection i.lit {
  background: #ffcd9e;
  border-color: #fff1dc;
  box-shadow: 0 0 6px #ffa965;
}
.dock {
  padding: 6px;
  gap: 3px;
  border-radius: 23px;
  background: linear-gradient(130deg, #29273de6, #171b32e8);
  backdrop-filter: blur(20px);
  box-shadow:
    inset 0 1px 0 #ffffff16,
    0 8px 25px #08071a5c;
}
.dock-tool {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 3px;
  min-width: 66px;
  min-height: 51px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: #e6dcfa;
  font-size: 0.76rem;
  font-weight: 600;
}
.dock-tool:disabled {
  color: #aaa1b9;
}
.dock-tool .icon {
  width: 20px;
  height: 20px;
}
.action {
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 19px;
  border-radius: 16px;
  background: linear-gradient(145deg, #e3d0ff, #c2a3fb);
  color: #241738;
  font-weight: 700;
  font-size: 0.92rem;
  box-shadow: inset 0 1px 0 #ffffffe0;
}
.dock .action {
  min-width: 110px;
  margin: 0 2px 0 6px;
}
.action:enabled:hover {
  background: #e2d2ff;
}
.action:disabled {
  opacity: 0.65;
}
.action.hint {
  background: linear-gradient(145deg, #e5d7ff, #c5b0ec);
}
h2 {
  font: 670 1.9rem/1.15 var(--display);
  letter-spacing: -0.04em;
}
dialog {
  width: min(720px, 92vw);
  max-height: 88dvh;
  max-width: 100%;
  padding: 0;
  border-radius: 23px;
  color: var(--ink);
  background: linear-gradient(140deg, #30283e, #1c1a2b);
  box-shadow: 0 25px 100px #080610a8;
  overflow: visible;
}
dialog::backdrop {
  background: #090815a8;
  backdrop-filter: blur(7px);
}
.modal-inner {
  padding: 28px;
  max-height: 87dvh;
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: inherit;
}
.close {
  position: absolute;
  z-index: 1;
  top: 12px;
  right: 14px;
  background: #282238;
}
.modal-kicker {
  margin: 0 54px 6px 0;
}
dialog h2 {
  margin-right: 42px;
}
.atlas-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-top: 18px;
}

.card {
  position: relative;
  text-align: left;
  overflow: hidden;
  min-width: 0;
  gap: 13px;
  border-radius: 12px;
  border: 1px solid #363145;
  background: #1e1b2b;
  padding: 11px 13px;
}
.card:hover {
  background: #2a2439;
  border-color: #736084;
}
.card.current {
  background: linear-gradient(110deg, #30283e, #282235);
  border-color: #aa89dc;
}
.mini {
  width: 61px;
  height: 57px;
  flex: none;
  border-radius: 8px;
  background:
    radial-gradient(ellipse at 35% 80%, var(--mini-cloud), transparent 85%),
    var(--mini-sky);
  border: 1px solid #ffffff16;
}
.card-name {
  display: block;
  font: 620 1rem/1.2 var(--display);
  letter-spacing: -0.02em;
  margin-top: 5px;
}
.card-caption {
  color: #b3a9c3;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
}
.current .card-caption {
  color: #d6b9ff;
}
.card-info {
  min-width: 0;
}
.complete-mark {
  position: absolute;
  right: 7px;
  top: 6px;
  font-size: 0.72rem;
  color: #9ee0cb;
}

.card-best {
  display: block;
  margin-top: 4px;
  color: #bde7d3;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.atlas-grid .card {
  gap: 8px;
  padding: 8px;
}
.atlas-range {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.87rem;
}
.atlas-range select {
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #30293f;
  border: 1px solid #5a4e6b;
  border-radius: 8px;
  padding: 9px 12px;
  min-height: 44px;
}
.atlas-grid .mini {
  width: 42px;
  height: 44px;
}
.help-list {
  list-style: none;
  padding: 0;
  margin: 23px 0;
  display: grid;
  gap: 16px;
}
.help-list li {
  display: flex;
  align-items: center;
  gap: 16px;
}
.help-list li > span {
  display: grid;
  place-items: center;
  color: #ccb4fa;
  background: #373047;
  border-radius: 12px;
  min-width: 54px;
  height: 54px;
}
.help-list li > span .icon {
  width: 29px;
  height: 29px;
}
.help-list p,
.chapter-info {
  color: #c6bfd2;
  font-size: 0.94rem;
  line-height: 1.5;
  margin-top: 3px;
}

@media (max-aspect-ratio: 1/1) {
  .landscape {
    background-image: url(assets/first-light-mobile.webp);
    background-position: 17% center;
  }
}
@media (max-width: 680px) {
  .game-screen {
    --gutter: 12px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .hud {
    grid-template-columns: 1fr auto;
  }
  .brand {
    font-size: 1.32rem;
    gap: 7px;
  }
  .brand img {
    width: 28px;
    height: 28px;
  }
  .utilities {
    grid-area: 1/2;
    gap: 4px;
  }
  .board-heading {
    grid-column: 1/-1;
    padding-top: 10px;
  }
  h1 {
    font-size: clamp(2rem, 8.3vw, 2.8rem);
  }
  .orb {
    width: 22px;
    height: 22px;
  }
  .dock-tool {
    min-width: 52px;
  }
  .dock {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.9fr);
    width: min(100%, 375px);
  }
  .dock .action {
    min-width: 0;
    padding: 8px 6px;
    margin: 0;
    font-size: 0.86rem;
  }
  .instruction {
    width: 100%;
    min-height: 66px;
  }
  .instruction p {
    font-size: 0.85rem;
  }
  dialog {
    width: 100%;
    margin: auto 0 0;
    max-height: 90dvh;
    border-radius: 24px 24px 0 0;
  }
  .modal-inner {
    padding: 24px 16px max(20px, env(safe-area-inset-bottom));
    max-height: 89dvh;
  }
  .atlas-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .help-list li {
    gap: 10px;
  }
}
@media (max-height: 510px) and (min-aspect-ratio: 6/5) {
  .game-screen {
    --gutter: 10px;
    grid-template-columns: clamp(115px, 18vw, 190px) minmax(0, 1fr) clamp(
        122px,
        19vw,
        195px
      );
    grid-template-rows: minmax(0, 1fr);
    padding-top: max(9px, env(safe-area-inset-top));
    padding-bottom: max(9px, env(safe-area-inset-bottom));
  }
  .hud {
    display: contents;
  }
  .brand,
  .utilities {
    position: absolute;
    z-index: 3;
    top: max(5px, env(safe-area-inset-top));
  }
  .brand {
    left: max(var(--gutter), env(safe-area-inset-left));
    font-size: 1.12rem;
    gap: 5px;
  }
  .brand img {
    width: 24px;
    height: 24px;
  }
  .utilities {
    right: max(var(--gutter), env(safe-area-inset-right));
    gap: 2px;
  }
  .board-heading {
    grid-column: 1;
    align-self: center;
    padding: 0;
  }
  .eyebrow {
    font-size: 0.65rem;
  }
  .eyebrow::before,
  .eyebrow::after {
    display: none;
  }
  h1 {
    margin: 7px 0 12px;
    font-size: clamp(1.65rem, 3.4vw, 2.3rem);
  }
  .readouts {
    flex-wrap: wrap;
    gap: 7px;
    font-size: 0.79rem;
  }
  .readouts > span {
    padding: 0 2px;
  }
  .readouts > span + span {
    border: 0;
  }
  .remaining {
    width: 100%;
    justify-content: center;
  }
  #playfield {
    grid-column: 2;
  }
  .play-controls {
    align-self: center;
    grid-column: 3;
    padding-top: 24px;
    gap: 8px;
  }
  .instruction {
    min-height: 0;
    width: 100%;
  }
  .status-heading {
    display: block;
  }
  .status-heading strong {
    font-size: 0.95rem;
  }
  #selection {
    justify-content: center;
    margin-bottom: 4px;
  }
  .instruction p {
    font-size: 0.76rem;
    line-height: 1.2;
  }
  .dock {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 4px;
    border-radius: 18px;
    gap: 2px;
  }
  .dock-tool {
    min-width: 0;
    min-height: 44px;
    gap: 2px;
  }
  .dock .action {
    min-width: 0;
    min-height: 44px;
    margin: 0;
    padding: 3px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 2px;
    font-size: 0.74rem;
  }
  .sight {
    width: min(98cqw, 90cqh);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0s !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  .starlight i {
    animation: none;
    opacity: 0.4;
  }
}
