/* Genesis: a star nursery. Deep space, glass, and light. */

:root {
  --space: #05010c;
  --space-2: #0b0418;
  --violet: #8a4dff;
  --violet-deep: #5b21d6;
  --magenta: #d13bff;
  --cyan: #38d6ff;
  --amber: #ffc266;
  --lavender: #b9b4ff;
  --text: #f4f1ff;
  --text-muted: rgba(244, 241, 255, 0.74);
  --glass: rgba(20, 12, 38, 0.66);
  --glass-solid: #150c26;
  --line: rgba(190, 170, 255, 0.16);
  --radius: 18px;
  --display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Consolas, 'Liberation Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--space);
  color: var(--text);
  line-height: 1.55;
  overflow: hidden; /* the canvas and panels handle everything */
  -webkit-font-smoothing: antialiased;
}

/* ---- Space ------------------------------------------------------------------------------------------------------- */

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -3;
  background:
    radial-gradient(ellipse 80% 60% at 15% 20%, rgba(91, 33, 214, 0.34), transparent 62%),
    radial-gradient(ellipse 70% 55% at 88% 78%, rgba(56, 214, 255, 0.16), transparent 60%),
    radial-gradient(ellipse 60% 50% at 60% 8%, rgba(209, 59, 255, 0.14), transparent 62%),
    linear-gradient(180deg, #080314 0%, var(--space) 60%, #02000a 100%);
}

.nebula {
  position: fixed;
  z-index: -2;
  width: 62vmax;
  height: 62vmax;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
  pointer-events: none;
  will-change: transform;
}
.nebula.a {
  top: -22vmax; left: -18vmax;
  background: radial-gradient(circle, rgba(138, 77, 255, 0.55), rgba(209, 59, 255, 0.18) 45%, transparent 70%);
  animation: drift-a 70s ease-in-out infinite alternate;
}
.nebula.b {
  bottom: -26vmax; right: -20vmax;
  background: radial-gradient(circle, rgba(56, 214, 255, 0.4), rgba(91, 33, 214, 0.18) 48%, transparent 70%);
  animation: drift-b 90s ease-in-out infinite alternate;
}
@keyframes drift-a { to { transform: translate3d(9vmax, 6vmax, 0) scale(1.08); } }
@keyframes drift-b { to { transform: translate3d(-8vmax, -7vmax, 0) scale(1.06); } }

#nursery-canvas {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* the visible height on a phone, not the one under the browser's own bars */
  z-index: 1;
  cursor: grab;
  touch-action: none; /* a finger drags and pinches the nursery instead of scrolling the page */
}

/* ---- Header ------------------------------------------------------------------------------------------------------ */

header {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px 36px;
  z-index: 10;
  pointer-events: none; /* clicks pass through except on the controls */
}

.logo-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}
.logo-star { filter: drop-shadow(0 0 10px rgba(56, 214, 255, 0.55)); }
.wordmark {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.7rem;
  letter-spacing: 0.01em;
}
.badge {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(56, 214, 255, 0.5);
  color: var(--cyan);
  background: rgba(56, 214, 255, 0.08);
}

.tools {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  pointer-events: auto;
}

.status {
  font-family: var(--sans); /* these are sentences: a plain, readable face, not the monospace */
  font-size: 0.84rem;
  color: var(--text-muted);
  max-width: 28ch;
}

/* ---- Buttons ----------------------------------------------------------------------------------------------------- */

.btn {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 18px;
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  background: rgba(24, 14, 44, 0.7);
  backdrop-filter: blur(10px);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.25s, transform 0.2s;
}
.btn:hover {
  border-color: rgba(56, 214, 255, 0.7);
  background: rgba(56, 214, 255, 0.1);
  box-shadow: 0 0 22px rgba(56, 214, 255, 0.18);
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  font-weight: 600;
  border-color: transparent;
  background: linear-gradient(135deg, var(--violet-deep), var(--magenta));
  box-shadow: 0 6px 24px rgba(138, 77, 255, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.btn.primary:hover {
  background: linear-gradient(135deg, #6c33f0, #e260ff);
  box-shadow: 0 8px 32px rgba(209, 59, 255, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.btn.quiet { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn.quiet:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); box-shadow: none; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn[disabled]:hover { border-color: var(--line); background: rgba(24, 14, 44, 0.7); box-shadow: none; }
.btn[aria-pressed="true"] {
  border-color: var(--cyan);
  background: rgba(56, 214, 255, 0.16);
  box-shadow: 0 0 20px rgba(56, 214, 255, 0.2);
}
a.btn { text-decoration: none; }
#signin-link[hidden], #delete-btn[hidden] { display: none; }

.hint { margin: 0; font-size: 0.82rem; color: var(--text-muted); }
.hint[hidden] { display: none; }

/* ---- Overlays and the glass card ----------------------------------------------------------------------------------- */

#question-overlay, #forcing-overlay, #settings-overlay, #holes-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-y: auto;
  background: radial-gradient(ellipse at center, rgba(5, 1, 12, 0.55), rgba(5, 1, 12, 0.86));
  backdrop-filter: blur(6px);
  opacity: 1;
  transition: opacity 0.6s ease, backdrop-filter 0.6s ease;
}
#question-overlay.hidden, #forcing-overlay.hidden, #settings-overlay.hidden, #holes-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(0);
}
#forcing-overlay.hidden .card { transform: translateY(40px) scale(0.94); opacity: 0; filter: blur(6px); }
#question-overlay.hidden .card { transform: translateY(18px) scale(0.98); }

.card {
  position: relative;
  width: 100%;
  max-width: 640px;
  display: grid;
  gap: 18px;
  padding: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background:
    linear-gradient(var(--glass), var(--glass)) padding-box,
    linear-gradient(140deg, rgba(138, 77, 255, 0.75), rgba(56, 214, 255, 0.28) 45%, rgba(209, 59, 255, 0.55)) border-box;
  backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 90px rgba(138, 77, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transition: transform 0.5s cubic-bezier(0.2, 0.9, 0.25, 1.05), opacity 0.5s ease, filter 0.5s ease;
}
.card h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  line-height: 1.2;
  letter-spacing: 0.005em;
  color: var(--text);
}
.intro-card { text-align: center; max-width: 660px; margin: auto; }
.intro-card h3 {
  font-size: clamp(1.9rem, 4.6vw, 2.7rem);
  background: linear-gradient(180deg, #ffffff 30%, #cdbdff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
#slide-desc { margin: -6px auto 2px; max-width: 46ch; color: var(--text-muted); font-size: 1.02rem; }

.close-btn {
  position: absolute;
  top: 14px; right: 16px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.close-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }

.known {
  margin: 0;
  padding-left: 14px;
  border-left: 2px solid var(--violet);
  color: var(--text-muted);
  font-size: 0.95rem;
}
.known b {
  display: block;
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lavender);
}

/* ---- Intro: the constellation of steps ---------------------------------------------------------------------------- */

.steps {
  list-style: none;
  margin: 0 auto 4px;
  padding: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
}
.steps li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 92px;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.steps li::before {
  content: "";
  width: 11px; height: 11px;
  border-radius: 50%;
  background: rgba(190, 170, 255, 0.28);
  box-shadow: 0 0 0 3px rgba(190, 170, 255, 0.08);
  transition: background 0.3s, box-shadow 0.3s, transform 0.3s;
}
.steps li::after { /* the thread to the next star */
  content: "";
  position: absolute;
  top: 5px; left: calc(50% + 12px);
  width: calc(100% - 24px); height: 1px;
  background: linear-gradient(90deg, rgba(190, 170, 255, 0.45), rgba(190, 170, 255, 0.12));
}
.steps li:last-child::after { display: none; }
.steps li span { margin-top: 8px; }
.steps li.done::before { background: var(--violet); box-shadow: 0 0 12px rgba(138, 77, 255, 0.8); }
.steps li.current { color: var(--text); }
.steps li.current::before {
  background: #fff;
  transform: scale(1.35);
  box-shadow: 0 0 0 4px rgba(56, 214, 255, 0.25), 0 0 20px rgba(56, 214, 255, 0.95);
}

#slide-content { display: grid; gap: 14px; text-align: left; }
.options { display: grid; gap: 10px; }

.option {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.4;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.25s, transform 0.2s;
}
.option::before { /* a small star that wakes up on hover and when chosen */
  content: "\2726" / "";
  flex: none;
  font-size: 1rem;
  color: rgba(190, 170, 255, 0.55);
  transition: color 0.2s, text-shadow 0.2s, transform 0.3s;
}
.option:hover {
  border-color: rgba(56, 214, 255, 0.55);
  background: rgba(56, 214, 255, 0.07);
  box-shadow: 0 0 28px rgba(56, 214, 255, 0.12);
  transform: translateX(2px);
}
.option:hover::before { color: var(--cyan); text-shadow: 0 0 12px var(--cyan); }
.option[aria-pressed="true"] {
  border-color: var(--violet);
  background: linear-gradient(90deg, rgba(138, 77, 255, 0.22), rgba(209, 59, 255, 0.08));
  box-shadow: 0 0 34px rgba(138, 77, 255, 0.28), inset 0 0 0 1px rgba(138, 77, 255, 0.4);
}
.option[aria-pressed="true"]::before { color: #fff; text-shadow: 0 0 14px var(--magenta), 0 0 4px #fff; transform: rotate(45deg) scale(1.15); }

.reroll-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.reroll::before { content: "\21BB" / ""; font-size: 1.05rem; }

.slide-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ---- Forms and chips ----------------------------------------------------------------------------------------------- */

textarea {
  width: 100%;
  min-height: 118px;
  resize: vertical;
  padding: 14px 16px;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text);
  background: rgba(3, 0, 10, 0.5);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: border-color 0.2s, box-shadow 0.25s;
}
textarea::placeholder { color: rgba(244, 241, 255, 0.5); }
textarea:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(138, 77, 255, 0.25); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.88rem;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.25s;
}
.chip:hover { border-color: rgba(56, 214, 255, 0.6); background: rgba(56, 214, 255, 0.09); box-shadow: 0 0 18px rgba(56, 214, 255, 0.14); }

.exits { display: flex; flex-wrap: wrap; gap: 8px; }
.card-actions { text-align: right; }

/* ---- Focus: the controls reset the browser ring, so draw ours -------------------------------------------------------- */

.btn:focus-visible, .chip:focus-visible, .option:focus-visible, .close-btn:focus-visible,
.q-index-item:focus-visible, #slide-title:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}
#slide-title:focus-visible { border-radius: 6px; outline-offset: 8px; }

/* ---- The star chart (the keyboard and screen-reader route to every star) ------------------------------------------- */

#q-index {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 15;
  width: min(340px, calc(100vw - 48px));
  max-height: 46vh;
  overflow-y: auto;
  padding: 16px 16px 14px;
  border: 1px solid transparent;
  border-radius: 16px;
  background:
    linear-gradient(var(--glass), var(--glass)) padding-box,
    linear-gradient(150deg, rgba(138, 77, 255, 0.55), rgba(56, 214, 255, 0.2)) border-box;
  backdrop-filter: blur(16px) saturate(130%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  scrollbar-width: thin;
  scrollbar-color: rgba(138, 77, 255, 0.5) transparent;
}
#q-index[hidden] { display: none; }
#q-index h2 {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lavender);
}
#q-open-count { font-weight: 400; text-transform: none; letter-spacing: 0.02em; color: var(--text-muted); }
#build-note { margin: 0 0 10px; font-size: 0.85rem; color: var(--text-muted); }
#q-index ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
#delete-btn { margin-top: 12px; }

.q-index-item {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.88rem;
  line-height: 1.35;
  transition: border-color 0.2s, background 0.2s;
}
.q-index-item::before { /* the star's own colour, repeated in the text label as well */
  content: "";
  flex: none;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}
.q-index-item[data-state="answered"]::before { background: var(--violet); box-shadow: 0 0 10px var(--violet); }
.q-index-item[data-state="parked"]::before { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.q-index-item[data-state="mystery"]::before { background: var(--lavender); box-shadow: 0 0 10px var(--lavender); }
.q-index-item:hover { border-color: rgba(56, 214, 255, 0.55); background: rgba(56, 214, 255, 0.07); }
.q-index-item .q-text { flex: 1; }
.q-index-item .q-state {
  flex: none;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.tooltip {
  position: fixed;
  left: 0;
  top: 0; /* placed with a transform from script, so it can follow its star without reflowing */
  z-index: 20;
  width: max-content;
  max-width: 340px;
  padding: 14px 16px 12px;
  border: 1px solid transparent;
  border-radius: 16px;
  background:
    linear-gradient(160deg, rgba(36, 22, 66, 0.62), rgba(14, 8, 30, 0.5)) padding-box,
    linear-gradient(140deg, rgba(185, 160, 255, 0.55), rgba(56, 214, 255, 0.18) 50%, rgba(209, 59, 255, 0.35)) border-box;
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5), 0 0 40px rgba(138, 77, 255, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text);
  pointer-events: none;
  transition: opacity 0.2s ease;
  will-change: transform;
}
.tooltip.hidden { opacity: 0; }
.tooltip:not(.hidden) { pointer-events: auto; } /* it holds a rename control */
.tip { display: grid; gap: 7px; }
.tip-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tip-title { font-family: var(--display); font-weight: 600; font-size: 1.02rem; letter-spacing: 0.005em; color: #fff; }
.tip-state { font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.2); color: var(--text-muted); white-space: nowrap; }
.tip-answered { color: #e0c8ff; border-color: rgba(209, 59, 255, 0.5); }
.tip-open { color: #a8ecff; border-color: rgba(56, 214, 255, 0.5); }
.tip-parked { color: #ffdca0; border-color: rgba(255, 194, 102, 0.5); }
.tip-mystery { color: #d9d4ff; border-color: rgba(185, 180, 255, 0.5); }
.tip-q { margin: 0; color: rgba(255, 255, 255, 0.92); }
.tip-a { margin: 0; color: var(--text-muted); font-style: italic; }
.tip-why { margin: 0; color: #ffe0aa; }
.tip-foot { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; padding-top: 9px; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.tip-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 500; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.14); }
.tip-sym { font-size: 0.8rem; line-height: 1; }
.c-open { color: #a8ecff; } .c-opt { color: #ffdca0; } .c-done { color: #bff0c8; } .c-none { color: var(--text-muted); }
.c-hole { color: #ffb48a; } .c-entry { color: #ffe08a; border-color: rgba(255, 224, 138, 0.45); background: rgba(255, 224, 138, 0.1); }

/* ---- Small screens ------------------------------------------------------------------------------------------------ */

/* Wide screens: the menu's items sit in the header row; the handle and the menu button do not exist. */
.menu-toggle, .chart-toggle { display: none; }
.header-menu { display: contents; }
.chart-head { display: block; }

@media (max-width: 720px) {
  header { padding: calc(10px + env(safe-area-inset-top)) 12px 10px; gap: 8px; }
  .wordmark { display: none; } /* the star and BETA are enough on a phone; the room goes to the actions */
  .tools { flex-wrap: nowrap; gap: 8px; }
  #commit { padding: 0 14px; font-size: 0.9rem; min-height: 44px; }
  .menu-toggle { display: inline-flex; min-height: 44px; }

  /* The menu: a glass sheet under the header, one full-width action per row. */
  .header-menu {
    display: none;
    position: fixed;
    top: calc(64px + env(safe-area-inset-top));
    left: 12px; right: 12px;
    z-index: 40;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px;
    border: 1px solid rgba(185, 160, 255, 0.35);
    border-radius: 16px;
    background: rgba(18, 10, 36, 0.92);
    backdrop-filter: blur(18px) saturate(140%);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  }
  header.menu-open .header-menu { display: flex; }
  .header-menu .btn { width: 100%; justify-content: center; min-height: 48px; }
  .header-menu .status { max-width: none; text-align: center; padding: 4px 0; }

  /* Save state: a quiet line under the header, always visible. */
  #saveState { position: fixed; left: 16px; top: calc(60px + env(safe-area-inset-top)); max-width: 70vw; font-size: 0.76rem; pointer-events: none; z-index: 12; text-shadow: 0 1px 6px #05010c; }

  /* The star chart: a bottom sheet with a handle. Collapsed it is one row; open it takes about half the screen. */
  #q-index { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); width: auto; max-height: none; overflow: visible; padding: 4px 14px 8px; }
  .chart-head { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
  #q-index h2 { margin: 0; }
  .chart-toggle { display: inline-grid; place-items: center; width: 48px; height: 48px; margin-right: -10px; border: 0; background: transparent; color: var(--lavender); font-size: 1.6rem; line-height: 1; cursor: pointer; transition: transform 0.25s ease; }
  #q-index.collapsed .chart-toggle { transform: rotate(180deg); }
  #q-index.collapsed #q-index-body { display: none; }
  #q-index-body { max-height: 52dvh; overflow-y: auto; padding-bottom: 6px; scrollbar-width: thin; }

  /* Map controls float above the chart handle; the hint has no room. */
  #view-controls { right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); }
  .view-hint { display: none; }
  #view-controls .btn { min-height: 44px; }

  /* Dialogs become bottom sheets: easier to reach, and the whole screen is theirs. */
  #question-overlay, #holes-overlay, #settings-overlay { align-items: flex-end; padding: 0; }
  #question-overlay .card, #holes-overlay .card, #settings-overlay .card {
    max-width: none; width: 100%; max-height: 92dvh; overflow-y: auto;
    border-radius: 22px 22px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  }
  #forcing-overlay { padding: 12px; }
  .card { gap: 16px; }
  .steps li { width: 76px; }
  .slide-actions { justify-content: center; }
  #holes-list { max-height: 48dvh; }
  .tooltip { max-width: calc(100vw - 24px); }
}

/* ---- Reduced motion: nothing drifts, glows pulse or slides ---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  #forcing-overlay.hidden .card, #question-overlay.hidden .card { transform: none; filter: none; }
  .option:hover { transform: none; }
}

/* ---- Settings (admins only) ----------------------------------------------------------------------------------------- */
.settings-card { max-width: min(1180px, 96vw); gap: 14px; }
/* Use the room there is: sections sit side by side on a wide screen and stack on a narrow one. */
#settings-body:not([hidden]) { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 430px), 1fr)); gap: 8px 36px; align-items: start; }
#settings-body > section { min-width: 0; }
.settings-card h3 { font-size: 1.6rem; }
.settings-card h4 { margin: 18px 0 6px; font-family: var(--display); font-size: 1.15rem; color: var(--text); }
.settings-card section { display: grid; gap: 8px; padding-top: 4px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.settings-card label { color: var(--text-muted); font-size: 0.92rem; margin-top: 6px; }
.settings-card select, .settings-card input {
  min-height: 44px; padding: 8px 12px; border-radius: 10px; font: inherit; color: var(--text);
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.22);
}
.settings-card select option { color: #14091f; }
.settings-card .row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.settings-card table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.settings-card th, .settings-card td { text-align: left; padding: 6px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.settings-card ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.settings-card li .btn { min-height: 36px; padding: 4px 12px; margin-left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Moving around the nursery ------------------------------------------------------------------------------------- */
#view-controls { position: fixed; right: 16px; bottom: 16px; z-index: 20; display: flex; align-items: center; gap: 8px; }
#view-controls .btn { min-height: 44px; min-width: 44px; padding: 8px 14px; }
.view-hint { color: var(--text-muted); font-size: 0.8rem; margin-right: 6px; }
@media (max-width: 720px) { .view-hint { display: none; } }

/* ---- Black Hole scan list ------------------------------------------------------------------------------------------------ */
.hole-card { display: grid; gap: 8px; padding: 16px 18px; margin: 10px 0; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 14px; background: rgba(255, 255, 255, 0.04); }
.hole-card h4 { margin: 0; font-family: var(--display); font-size: 1.1rem; color: var(--text); }
.hole-card p { margin: 0; }
.hole-card input { min-height: 44px; padding: 8px 12px; border-radius: 10px; font: inherit; color: var(--text); background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.22); }
.hole-where { display: grid; gap: 6px; }
.hole-quote { font-style: italic; margin: 2px 0 0 4px; }
#holes-tabs .btn[aria-pressed="true"] { background: rgba(138, 77, 255, 0.35); border-color: rgba(185, 160, 255, 0.7); }
#holes-list { max-height: 55vh; overflow-y: auto; padding-right: 4px; }

.tip-edit { margin-left: -4px; width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--text-muted); font-size: 0.95rem; cursor: pointer; flex: none; }
.tip-edit:hover { color: #fff; background: rgba(255, 255, 255, 0.12); }
.tip-head .tip-state { margin-left: auto; }
.tip-input { flex: 1; min-width: 0; min-height: 34px; padding: 4px 10px; border-radius: 9px; font: inherit; font-family: var(--display); font-weight: 600; font-size: 1rem; color: #fff; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(185, 160, 255, 0.7); }
.tip-note { margin: 0; font-size: 0.76rem; color: var(--text-muted); }
.field { min-height: 44px; padding: 8px 12px; border-radius: 10px; font: inherit; color: var(--text); background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.22); }

/* Scrollbars follow the dark theme: no bright white track inside a glass card. */
html { color-scheme: dark; }
#holes-list, .card, #q-index-body { scrollbar-width: thin; scrollbar-color: rgba(138, 77, 255, 0.55) transparent; }

.hole-options { display: grid; gap: 10px; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.hole-options .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.hole-draft { width: 100%; min-height: 84px; padding: 10px 12px; border-radius: 10px; font: inherit; color: var(--text); background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.22); resize: vertical; }
.hole-pick { min-height: 44px; padding: 6px 10px; border-radius: 10px; font: inherit; color: var(--text); background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.22); max-width: 100%; }
.hole-pick option { color: #14091f; }

/* Linked holes: one header, one colour, a rail down the side, and buttons that jump between the cards. */
.hole-group { --group: #ffc266; position: relative; margin: 14px 0; padding: 10px 0 2px 16px; border-left: 3px solid var(--group); border-radius: 4px; }
.hole-group::before { content: ""; position: absolute; left: -3px; top: 0; bottom: 0; width: 3px; background: var(--group); filter: blur(5px); opacity: 0.7; }
.hole-group-head { margin: 0 0 4px; font-size: 0.82rem; color: var(--group); }
.hole-group .hole-card { margin: 8px 0; border-color: color-mix(in srgb, var(--group) 38%, transparent); }
.hole-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.hole-links-label { font-size: 0.78rem; color: var(--group, var(--text-muted)); }
.hole-link { min-height: 36px; padding: 4px 12px; font-size: 0.82rem; }
.hole-card.flash { animation: holeFlash 1.4s ease; }
@keyframes holeFlash { 0%, 60% { box-shadow: 0 0 0 2px var(--group, #ffc266), 0 0 26px color-mix(in srgb, var(--group, #ffc266) 55%, transparent); } 100% { box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { .hole-card.flash { animation: none; box-shadow: 0 0 0 2px var(--group, #ffc266); } }
.c-link { color: #ffe08a; }

/* Phone overrides that must come after the base rules above (same specificity, later wins). */
@media (max-width: 720px) {
  #view-controls { right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .view-hint { display: none; }
}
@media (max-width: 720px) { .chart-open #view-controls { display: none; } }

/* ---- AI disclosure and the real-people note ---------------------------------------------------------------------------------------- */
#ai-note { position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 6; margin: 0; max-width: 60vw; text-align: center; font-size: 0.74rem; color: var(--text-muted); text-shadow: 0 1px 8px #05010c; pointer-events: none; }
.ai-note-menu { display: none; }
@media (max-width: 720px) { #ai-note { display: none; } .header-menu .ai-note-menu { display: block; font-size: 0.78rem; } }
.note-card { margin: 0 0 12px; padding: 12px 14px; border-radius: 12px; background: rgba(255, 224, 138, 0.07); border: 1px solid rgba(255, 224, 138, 0.3); }
.note-card h3 { margin: 0 0 6px; font-size: 0.95rem; font-family: var(--display); color: #ffe0aa; }
.note-card p { margin: 0 0 8px; font-size: 0.84rem; color: var(--text-muted); }
.note-card summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; color: var(--text); font-size: 0.88rem; }
.rename-form { display: grid; gap: 6px; padding-top: 6px; }
.rename-form label { font-size: 0.8rem; color: var(--text-muted); }
#intro-ai-note { margin: 0 auto; max-width: 46ch; }

/* The care card: a quiet note, bottom corner, never over the writing box on a phone's first line. */
.care-card { position: fixed; right: 16px; bottom: 44px; z-index: 40; width: min(380px, calc(100vw - 32px)); max-height: 60vh; overflow: auto; padding: 16px 18px 14px; border-radius: 16px;
  background: rgba(24, 14, 44, 0.86); border: 1px solid rgba(255, 255, 255, 0.18); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45); color: var(--text, #f3eefc); }
.care-card.hidden { display: none; }
.care-card h4 { margin: 0 28px 8px 0; font-size: 1rem; }
.care-card p { margin: 0 0 8px; font-size: 0.88rem; line-height: 1.5; }
.care-card ul { margin: 6px 0 0; padding-left: 18px; font-size: 0.88rem; line-height: 1.5; }
.care-card ul:empty { display: none; }
.care-card .close-btn { position: absolute; top: 8px; right: 10px; }
@media (max-width: 720px) { .care-card { left: 16px; right: 16px; width: auto; bottom: 16px; max-height: 45vh; } }

/* Dead stars and the lockdown. */
.dead-tray { position: fixed; left: 16px; bottom: 44px; z-index: 30; }
.dead-tray[hidden] { display: none; }
#dead-dots { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
.dead-dot { width: 8px; height: 8px; border-radius: 50%; background: #5b5568; box-shadow: inset 0 0 0 1px #8b8498; opacity: 0.8; }
.lockdown-banner { position: fixed; left: 50%; top: 72px; transform: translateX(-50%); z-index: 50; width: min(560px, calc(100vw - 32px)); padding: 16px 20px; border-radius: 16px;
  background: rgba(40, 14, 24, 0.92); border: 1px solid rgba(255, 140, 150, 0.45); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); }
.lockdown-banner[hidden] { display: none; }
.lockdown-banner h4 { margin: 0 0 8px; }
.lockdown-banner p { margin: 0 0 8px; font-size: 0.9rem; line-height: 1.5; }
.lockdown-banner a { color: inherit; }
body.locked-down #commit, body.locked-down #scan-btn, body.locked-down #holes-rescan, body.locked-down #rename-go { display: none; }
@media (max-width: 720px) { .dead-tray { bottom: 16px; } .lockdown-banner { top: 56px; } }

.legal-links a { color: inherit; text-decoration: underline; }
