/* Karti — calm, tactile, deck-accent themed. No framework, no build step. */

:root {
  --paper: #f7f4ed;
  --paper-deep: #eee9dd;
  --ink: #221d17;
  --ink-soft: #6b6357;
  --line: #ddd6c8;
  --accent: #7c3aed; /* overridden per deck via inline style */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--paper);
  background-image: radial-gradient(
    circle at 50% -20%,
    color-mix(in oklab, var(--accent) 4%, transparent),
    transparent 60%
  );
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.15;
  margin: 0;
  text-wrap: balance;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

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

.page {
  max-width: 64rem;
  margin: 0 auto;
  padding: 2.5rem 1rem 4rem;
}

.page.narrow {
  max-width: 46rem;
}

.page.wide {
  max-width: 72rem;
}

/* ------------------------------------------------------------- header --- */

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-header h1 {
  font-size: clamp(2.25rem, 6vw, 3rem);
  letter-spacing: -0.02em;
}

.site-nav {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.site-nav a,
.back-link {
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: 6px;
  padding: 0.1rem 0.25rem;
}

.site-nav a:hover,
.back-link:hover {
  color: var(--ink);
}

.tagline {
  color: var(--ink-soft);
  font-size: 1.1rem;
  max-width: 36rem;
  margin: 0.75rem 0 0;
}

.muted {
  color: var(--ink-soft);
}

/* ------------------------------------------------------------- top bar --- */

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  padding: 0.55rem 1rem;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  border-radius: 8px;
  padding: 0 0.15rem;
}

.top-filters {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 2px;
}

.top-filters select {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background-color: rgb(255 255 255 / 0.7);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.83rem;
  padding: 0.28rem 1.5rem 0.28rem 0.75rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%236b6357'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  cursor: pointer;
}

.top-filters select.active {
  border-color: var(--ink);
  color: var(--ink);
}

.view-toggle {
  display: flex;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.view-toggle button {
  border: 0;
  background: none;
  color: var(--ink-soft);
  padding: 0.26rem 0.65rem;
  font-size: 0.95rem;
  line-height: 1.2;
}

.view-toggle button[aria-pressed='true'] {
  background: var(--ink);
  color: var(--paper);
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-left: auto;
  font-size: 0.85rem;
  font-weight: 500;
}

.top-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: 6px;
  padding: 0.1rem 0.2rem;
}

.top-nav a:hover {
  color: var(--ink);
}

/* search trigger + ⌘K palette */
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.6);
  color: var(--ink-soft);
  font-size: 0.83rem;
  padding: 0.28rem 0.55rem 0.28rem 0.7rem;
}

.search-trigger:hover {
  color: var(--ink);
}

.search-trigger kbd {
  font-family: var(--font-sans);
  font-size: 0.68rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.05rem 0.3rem;
  background: var(--paper);
}

@media (max-width: 640px) {
  .search-trigger-text,
  .search-trigger kbd {
    display: none;
  }
}

.palette {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgb(28 25 23 / 0.28);
  backdrop-filter: blur(2px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 1rem 1rem;
}

/* `.palette { display: flex }` outranks the UA `[hidden]` rule, so restore it. */
.palette[hidden] {
  display: none;
}

.palette-box {
  width: 100%;
  max-width: 34rem;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 60px -12px rgb(28 25 23 / 0.35);
  overflow: hidden;
}

#palette-input {
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 1.1rem;
  padding: 1rem 1.2rem;
  width: 100%;
}

#palette-input:focus {
  outline: none;
}

#palette-results {
  list-style: none;
  margin: 0;
  padding: 0.4rem;
  overflow-y: auto;
}

.palette-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  cursor: pointer;
}

.palette-item.active {
  background: color-mix(in oklab, var(--accent) 12%, var(--paper));
}

.palette-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.palette-desc {
  color: var(--ink-soft);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.palette-item mark {
  background: color-mix(in oklab, var(--accent) 30%, transparent);
  color: inherit;
  border-radius: 3px;
}

#palette-empty {
  color: var(--ink-soft);
  font-size: 0.9rem;
  text-align: center;
  padding: 1.5rem;
  margin: 0;
}

/* ------------------------------------------------------------ gallery --- */

#deck-count {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin: 1.5rem 0 0.75rem;
}

.deck-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .deck-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 960px) {
  .deck-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.deck-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgb(255 255 255 / 0.7);
  text-decoration: none;
  transition: box-shadow 150ms ease;
}

a.deck-card:hover {
  box-shadow: 0 16px 40px -16px color-mix(in oklab, var(--accent) 45%, transparent);
}

.deck-card-cover {
  position: relative;
  height: 7rem;
  border-radius: 24px 24px 0 0;
  display: flex;
  align-items: flex-end;
  padding: 1rem;
}

.format-badge {
  background: rgb(255 255 255 / 0.9);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-18 {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgb(0 0 0 / 0.4);
  color: #fff;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
}

.deck-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1.25rem;
}

.deck-card-body h3 {
  font-size: 1.3rem;
}

.deck-card-body p {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

.deck-card-body .deck-card-meta {
  margin-top: auto;
  padding-top: 1rem;
  font-size: 0.78rem;
}

.deck-card-meta strong {
  color: var(--ink-soft);
}

/* list view */
.deck-grid.list {
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.deck-grid.list .deck-card {
  flex-direction: row;
  align-items: stretch;
}

.deck-grid.list .deck-card-cover {
  width: 5.5rem;
  height: auto;
  min-height: 4.2rem;
  border-radius: 18px 0 0 18px;
  padding: 0.5rem;
  flex-shrink: 0;
  align-items: flex-end;
}

.deck-grid.list .format-badge {
  font-size: 0.55rem;
  padding: 0.15rem 0.45rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.deck-grid.list .deck-frame {
  inset: 5px;
  border-radius: 12px;
}

.deck-grid.list .badge-18 {
  top: 0.35rem;
  right: 0.35rem;
  font-size: 0.55rem;
  padding: 0.1rem 0.4rem;
}

.deck-grid.list .deck-card-body {
  flex-direction: row;
  align-items: baseline;
  gap: 0.35rem 0.9rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.1rem;
}

.deck-grid.list .deck-card-body h3 {
  font-size: 1.05rem;
}

.deck-grid.list .deck-card-body > p:not(.deck-card-meta) {
  flex: 1 1 12rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.85rem;
}

.deck-grid.list .deck-card-meta {
  margin: 0;
  padding: 0;
  margin-left: auto;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .deck-grid.list .deck-card-body > p:not(.deck-card-meta) {
    display: none;
  }
}

#empty-state {
  border: 1px dashed var(--line);
  border-radius: 24px;
  padding: 2.5rem;
  text-align: center;
}

#empty-state p {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

#empty-state h2 {
  font-size: 1.2rem;
}

.site-footer {
  margin-top: 4rem;
  border-top: 1px solid var(--line);
  padding-top: 1.5rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* --------------------------------------------------- deck back / cover --- */

.deck-back {
  background:
    radial-gradient(circle at 20% 15%, rgb(255 255 255 / 0.16), transparent 45%),
    linear-gradient(
      160deg,
      color-mix(in oklab, var(--accent) 82%, #221d17) 0%,
      var(--accent) 45%,
      color-mix(in oklab, var(--accent-2, var(--accent)) 88%, white) 130%
    );
}

.deck-frame {
  position: absolute;
  inset: 12px;
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: 16px;
  pointer-events: none;
}

/* ------------------------------------------------------- play surface --- */

.play-surface {
  /* Theme hooks — overridden by the shape and corner classes and inline vars. */
  --card-h: min(30rem, calc(100dvh - 22rem));
  --card-w: min(23rem, 90vw, calc(var(--card-h) * 0.75));
  --radius-card: 28px;
  --radius-mini: 18px;

  max-width: 46rem;
  margin: 0 auto;
  height: 100dvh;
  padding: 0.8rem 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  overflow: hidden;
  background: var(--paper);
}

.play-surface:fullscreen {
  max-width: none;
  padding: 1.2rem 2rem 1.6rem;
}

.play-surface.shape-wide {
  --card-h: min(20rem, calc(100dvh - 22rem));
  --card-w: min(34rem, 92vw, calc(var(--card-h) * 1.5));
}

.play-surface.shape-square {
  --card-h: min(25rem, calc(100dvh - 22rem));
  --card-w: min(25rem, 90vw, var(--card-h));
}

.play-surface.corner-sharp {
  --radius-card: 10px;
  --radius-mini: 6px;
}

.play-surface.prompt-sans .card-prompt {
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.play-surface.embedded {
  height: auto;
  min-height: 0;
  overflow: visible;
  padding: 1.5rem 1rem;
  --card-h: 24rem;
  --card-w: min(21rem, 90vw, calc(var(--card-h) * 0.75));
}

.play-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.btn-icon {
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1;
  padding: 0.35rem 0.45rem;
  border-radius: 999px;
}

.btn-icon:hover {
  color: var(--ink);
}

.progress {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.card-zone {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
}

.nav-arrow {
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 2rem;
  line-height: 1;
  padding: 1.2rem 0.35rem;
  border-radius: 14px;
  flex-shrink: 0;
  transition: color 120ms ease;
}

.nav-arrow:hover:not(:disabled) {
  color: var(--ink);
}

.nav-arrow:disabled {
  opacity: 0.15;
}

.card-area {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1200px;
}

/* Tapping the card advances the game — kill selection & the mobile tap
   flash so it feels like a control, not text. */
.card-area.tappable {
  cursor: pointer;
}

.card-face,
.deck-cover,
.mini-card {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* The how-to-play intro is reading material — keep it selectable. */
.intro-face,
.intro-face * {
  user-select: text;
  -webkit-user-select: text;
}

.card-face,
.deck-cover {
  height: var(--card-h);
  width: var(--card-w);
  flex-shrink: 0;
  overflow: hidden;
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  padding: 1.75rem;
}

.card-face {
  background: linear-gradient(180deg, #fffdf9 0%, #fbf8f1 100%);
  box-shadow:
    0 1px 2px rgb(28 25 23 / 0.05),
    0 10px 28px rgb(28 25 23 / 0.09),
    0 30px 60px -18px color-mix(in oklab, var(--accent) 28%, transparent);
}

.card-face-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* If a tall card (long prompt + timer) can't fit its face on a short
     viewport, scroll inside the card rather than spilling over the controls. */
  overflow-y: auto;
}

.card-face footer {
  color: var(--ink-soft);
  font-size: 0.75rem;
  margin-top: 1rem;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-prompt {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 4.5vw, 1.7rem);
  line-height: 1.3;
  margin: 0;
  text-wrap: balance;
}

.card-chip {
  color: color-mix(in oklab, var(--accent) 85%, var(--ink));
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 1rem;
}

.type-pill {
  align-self: flex-start;
  color: #fff;
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 1rem;
}

.flash-front {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin: 0 0 1.25rem;
}

/* per-card countdown (Timer: lines) — compact so it fits alongside a prompt */
.card-timer {
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.timer-display {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 1.3rem;
  font-weight: 600;
  color: color-mix(in oklab, var(--accent) 85%, var(--ink));
}

.card-timer.done .timer-display {
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.timer-bar {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--paper-deep);
  overflow: hidden;
}

.timer-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 1s linear;
}

.deck-cover {
  position: relative;
  color: #fff;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.cover-brand {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  opacity: 0.8;
  margin: 0;
}

.deck-cover h2 {
  font-size: 1.9rem;
  margin-top: 0.75rem;
}

.deck-cover p {
  max-width: 24ch;
  font-size: 0.9rem;
  opacity: 0.85;
}

.complete-face {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.complete-face h2 {
  font-size: 1.5rem;
}

/* card entrance — duration scales with the deck's animationSpeed theme */
.card-anim > .card-face,
.card-anim > .deck-cover,
.card-anim > .multi-cards {
  animation: card-in calc(var(--anim, 1) * 380ms) cubic-bezier(0.2, 0.8, 0.25, 1);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: rotateY(-70deg);
  }
  to {
    opacity: 1;
    transform: rotateY(0);
  }
}

/* ---------------------------------------------- multi-card & dice views --- */

.multi-cards {
  width: 100%;
  max-width: 40rem;
  max-height: 100%;
  overflow-y: auto;
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fit, minmax(min(11rem, 45%), 1fr));
  align-items: stretch;
}

.mini-card {
  background: linear-gradient(180deg, #fffdf9 0%, #fbf8f1 100%);
  border-radius: var(--radius-mini, 18px);
  box-shadow:
    0 1px 2px rgb(28 25 23 / 0.05),
    0 8px 20px -6px color-mix(in oklab, var(--accent) 22%, transparent);
  padding: 1.15rem;
  min-height: 8.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.mini-card .card-prompt {
  font-size: 1.08rem;
}

.mini-card .card-chip,
.mini-card .type-pill {
  margin-bottom: 0.55rem;
}

.rolling {
  animation: dice-shake calc(var(--anim, 1) * 500ms) ease-in-out infinite;
}

@keyframes dice-shake {
  0%,
  100% {
    transform: rotate(0);
  }
  25% {
    transform: rotate(-2.5deg) translateY(-3px);
  }
  75% {
    transform: rotate(2.5deg) translateY(3px);
  }
}

/* -------------------------------------------------- intro / rules page --- */

/* The rules are a reading page, not a card: deck name in colour, then the
   rules as flowing rich text (they can be lengthy), scrollable if tall. */
.intro-view {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 40rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.intro-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem 0.25rem 0;
}

.intro-eyebrow {
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin: 0 0 0.4rem;
}

.intro-title {
  font-size: clamp(2.2rem, 9vw, 3.2rem);
  line-height: 1.05;
  margin: 0 0 1.4rem;
  background: linear-gradient(115deg, var(--accent) 15%, var(--accent-2, var(--accent)));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.intro-text p {
  color: var(--ink);
  font-size: 1.06rem;
  line-height: 1.7;
  margin: 0 0 0.95rem;
}

.intro-text em {
  color: var(--ink-soft);
}

.intro-view .btn-draw {
  flex-shrink: 0;
  align-self: center;
}

/* ----------------------------------------------------------- controls --- */

.controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  flex-shrink: 0;
  max-height: 45dvh;
  overflow-y: auto;
}

.controls-hint {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin: 0;
}

.btn-draw {
  width: 100%;
  max-width: 24rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 20px -6px color-mix(in oklab, var(--accent) 65%, transparent);
  transition: transform 120ms ease, filter 120ms ease;
  text-decoration: none;
  text-align: center;
}

.btn-draw:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-draw:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-draw:disabled {
  opacity: 0.4;
  box-shadow: none;
}

.btn-ghost {
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 0.9rem;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  text-decoration: none;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--ink);
}

.btn-ghost:disabled {
  opacity: 0.4;
}

.btn-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--ink-soft);
  padding: 0.45rem 1.1rem;
  font-size: 0.88rem;
  font-weight: 500;
  transition: color 120ms ease, background-color 120ms ease;
}

.btn-pill:hover {
  color: var(--ink);
}

.btn-pill.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-pill.danger {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #b91c1c;
}

.btn-pill.done {
  border-color: #6ee7b7;
  background: #ecfdf5;
  color: #065f46;
}

.btn-pill.skipped {
  border-color: #fcd34d;
  background: #fffbeb;
  color: #92400e;
}

/* leveled */
.level-indicator {
  text-align: center;
  max-width: 26rem;
}

.level-indicator .card-chip {
  margin-bottom: 0.15rem;
}

.level-dots {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.level-dots .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  transition: width 150ms ease;
}

.level-dots .dot.current {
  width: 24px;
  background: var(--accent);
}

.level-dots .dot.done {
  background: var(--accent);
  opacity: 0.4;
}

.level-blurb {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin: 0;
}

.level-remaining {
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  margin: 0.15rem 0 0;
}

/* category */
.cat-grid {
  width: 100%;
  max-width: 26rem;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.cat-btn {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgb(255 255 255 / 0.6);
  text-align: left;
  padding: 0.7rem 1rem;
  transition: background-color 120ms ease;
}

.cat-btn:hover:not(:disabled) {
  background: #fff;
}

.cat-btn:disabled {
  opacity: 0.35;
}

.cat-btn.active {
  background: color-mix(in oklab, var(--accent) 10%, white);
  border-color: color-mix(in oklab, var(--accent) 35%, white);
}

.cat-btn strong {
  display: block;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.cat-btn span {
  display: block;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

/* task */
.task-block {
  border-top: 1px solid var(--line);
  margin-top: 1.5rem;
  padding-top: 1.25rem;
}

.btn-reveal {
  width: 100%;
  border: 1px solid color-mix(in oklab, var(--accent) 35%, white);
  border-radius: 18px;
  background: color-mix(in oklab, var(--accent) 10%, white);
  color: color-mix(in oklab, var(--accent) 85%, var(--ink));
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.task-text {
  margin: 0.25rem 0 0;
  font-size: 1rem;
}

.task-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.tally {
  font-variant-numeric: tabular-nums;
}

/* hybrid */
.pads {
  width: 100%;
  max-width: 26rem;
  display: flex;
  gap: 0.5rem;
}

.pad {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 18px;
  text-align: center;
  padding: 0.6rem 0.5rem;
  transition: transform 100ms ease, border-color 100ms ease, background-color 100ms ease;
}

.pad strong {
  display: block;
  color: var(--pad-color);
  font-size: 0.9rem;
}

.pad span {
  display: block;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.pad.active {
  border-color: var(--pad-color);
  background: color-mix(in oklab, var(--pad-color) 10%, white);
  transform: scale(1.05);
}

.pad.empty {
  opacity: 0.3;
}

.ramp-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
  cursor: pointer;
}

.ramp-toggle input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

/* quiz — statement + agree/disagree scale, and the result */
.quiz-prompt {
  margin-bottom: 1.6rem;
}

.quiz-scale {
  margin-top: auto;
}

.quiz-ends {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-bottom: 0.55rem;
}

.quiz-ends .agree {
  color: #15803d;
}

.quiz-ends .disagree {
  color: #b91c1c;
}

.quiz-dots {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}

.quiz-dot {
  border: 2px solid var(--dot);
  border-radius: 999px;
  background: transparent;
  padding: 0;
  flex-shrink: 0;
  transition: background-color 120ms ease, transform 120ms ease;
}

.quiz-dot:hover,
.quiz-dot:focus-visible {
  background: var(--dot);
  transform: scale(1.1);
}

.quiz-dot.v2 {
  --dot: #16a34a;
  width: 46px;
  height: 46px;
}

.quiz-dot.v1 {
  --dot: #4ade80;
  width: 38px;
  height: 38px;
}

.quiz-dot.v0 {
  --dot: #9ca3af;
  width: 30px;
  height: 30px;
}

.quiz-dot.vm1 {
  --dot: #f87171;
  width: 38px;
  height: 38px;
}

.quiz-dot.vm2 {
  --dot: #dc2626;
  width: 46px;
  height: 46px;
}

.complete-scroll {
  width: 100%;
}

.quiz-result {
  text-align: center;
}

.quiz-code {
  font-family: var(--font-sans);
  font-weight: 800;
  letter-spacing: 0.16em;
  font-size: 2rem;
  color: var(--accent);
  margin: 0 0 0.2rem;
}

.quiz-result h2 {
  font-size: 1.5rem;
  margin-bottom: 0.85rem;
}

.quiz-desc {
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.6;
  margin: 0;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

/* test — graded quiz: question, options, reveal, result + review */
.test-question {
  font-size: clamp(1.15rem, 4vw, 1.5rem);
  margin-bottom: 0.4rem;
}

.test-hint {
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 0.9rem;
}

.test-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.test-opt {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgb(255 255 255 / 0.7);
  color: var(--ink);
  font-size: 0.95rem;
  padding: 0.65rem 0.85rem;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.test-opt .test-mark {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-radius: 999px;
}

.test-opt.selected {
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 10%, white);
}

.test-opt.selected .test-mark {
  border-color: var(--accent);
  background:
    radial-gradient(circle, var(--accent) 0 5px, transparent 6px);
}

.test-opt.correct {
  border-color: #16a34a;
  background: #f0fdf4;
}

.test-opt.correct .test-mark {
  border-color: #16a34a;
  background: #16a34a;
}

.test-opt.wrong {
  border-color: #dc2626;
  background: #fef2f2;
}

.test-opt.wrong .test-mark {
  border-color: #dc2626;
  background: #dc2626;
}

.test-opt:disabled {
  cursor: default;
}

.test-explanation {
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.55;
  margin: 0.9rem 0 0;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
}

.test-badge {
  display: inline-block;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.25rem 0.9rem;
  margin: 0.2rem 0 0;
}

.test-badge.pass {
  background: #ecfdf5;
  color: #065f46;
}

.test-badge.fail {
  background: #fef2f2;
  color: #991b1b;
}

.test-review {
  text-align: left;
  margin-top: 1.2rem;
}

.test-review > summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
  list-style-position: inside;
}

.test-review-q {
  border-top: 1px solid var(--line);
  padding: 0.8rem 0 0.2rem;
}

.test-review-prompt {
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0 0 0.4rem;
}

.test-review-q ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.test-review-opt {
  font-size: 0.85rem;
  color: var(--ink-soft);
  padding-left: 1.1rem;
  position: relative;
}

.test-review-opt.correct {
  color: #15803d;
  font-weight: 600;
}

.test-review-opt.correct::before {
  content: '✓';
  position: absolute;
  left: 0;
}

.test-review-opt.wrong {
  color: #b91c1c;
}

.test-review-opt.wrong::before {
  content: '✗';
  position: absolute;
  left: 0;
}

.test-mark.square {
  border-radius: 6px;
}

/* test surface — a whole-page questionnaire (not the card hero) */
.test-surface {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--paper);
}

.test-header {
  flex-shrink: 0;
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 0.8rem 1rem;
}

.test-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.test-doc {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0.5rem 1rem 4rem;
}

.test-doc-title {
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  line-height: 1.1;
  margin: 0 0 0.9rem;
  background: linear-gradient(115deg, var(--accent) 15%, var(--accent-2, var(--accent)));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.test-intro p {
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.65;
  margin: 0 0 0.8rem;
}

.test-intro p strong {
  color: var(--ink);
}

.test-form {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.test-q {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgb(255 255 255 / 0.7);
  padding: 1.1rem 1.2rem;
}

.test-q.ok {
  border-color: #86efac;
  background: #f6fef9;
}

.test-q.no {
  border-color: #fca5a5;
  background: #fffafa;
}

.test-q-head {
  display: flex;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.3;
  margin: 0 0 0.15rem;
}

.prompt-sans .test-q-head {
  font-family: var(--font-sans);
  font-weight: 600;
}

.test-q-num {
  flex-shrink: 0;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: color-mix(in oklab, var(--accent) 14%, white);
  color: color-mix(in oklab, var(--accent) 80%, var(--ink));
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.test-q-hint {
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0.1rem 0 0.75rem 2.1rem;
}

.test-q-opts {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.test-check {
  margin-top: 0.7rem;
}

.test-q .test-explanation {
  margin-top: 0.8rem;
}

.test-submit-bar {
  position: sticky;
  bottom: 0;
  margin-top: 1.5rem;
  padding: 0.8rem 0;
  background: linear-gradient(to top, var(--paper) 70%, transparent);
  display: flex;
  justify-content: center;
}

.test-submit-bar .btn-draw {
  max-width: 22rem;
}

.test-result-panel {
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, #fffdf9 0%, #fbf8f1 100%);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 12px 30px -12px color-mix(in oklab, var(--accent) 30%, transparent);
}

.test-result-panel .quiz-code {
  margin-top: 0.3rem;
}

/* shared result (opened from a #r=… link) */
.shared-view {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 34rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  text-align: center;
  overflow-y: auto;
}

.shared-view .quiz-result {
  background: linear-gradient(180deg, #fffdf9 0%, #fbf8f1 100%);
  border-radius: var(--radius-card, 24px);
  padding: 1.75rem;
  box-shadow: 0 10px 28px rgb(28 25 23 / 0.08);
}

/* ----------------------------------------------------------- age gate --- */

.gate {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  text-align: center;
  padding: 1.5rem;
}

.gate h1 {
  font-size: 2rem;
  max-width: 24ch;
}

.gate p {
  color: var(--ink-soft);
  font-size: 0.9rem;
  max-width: 38ch;
  margin: 0;
}

.gate .btn-draw {
  max-width: 16rem;
  margin-top: 1.25rem;
}

/* ------------------------------------------------------------- about --- */

.format-list {
  list-style: none;
  margin: 2.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.format-list li {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgb(255 255 255 / 0.7);
  padding: 1.5rem;
}

.format-list h2 {
  display: inline;
  font-size: 1.5rem;
  margin-right: 0.6rem;
}

.format-tag {
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.format-list p {
  color: var(--ink-soft);
  margin: 0.5rem 0 0;
}

.callout {
  border: 1px dashed var(--line);
  border-radius: 24px;
  padding: 1.5rem;
  margin-top: 3rem;
}

.callout h2 {
  font-size: 1.5rem;
}

.callout p {
  color: var(--ink-soft);
  margin: 0.5rem 0 0;
}

/* ------------------------------------------------------------- submit --- */

.mode-tabs {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.mode-tabs button {
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.4rem 1.1rem;
}

.mode-tabs button[aria-selected='true'] {
  background: var(--ink);
  color: var(--paper);
}

/* form editor */
.ed {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.ed-grid {
  display: grid;
  gap: 0.6rem;
}

.ed-grid.two {
  grid-template-columns: 1fr 1.4fr;
}

.ed-grid.four {
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
}

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

.ed-field > span {
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.ed-field.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  align-self: end;
  padding-bottom: 0.45rem;
}

.ed-field.checkbox > span {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
}

.ed input[type='text'],
.ed input[type='number'],
.ed select,
.ed textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgb(255 255 255 / 0.8);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.6rem;
  min-width: 0;
  width: 100%;
}

.ed input[type='color'] {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgb(255 255 255 / 0.8);
  height: 2.35rem;
  width: 100%;
  padding: 0.2rem;
  cursor: pointer;
}

.ed input[type='checkbox'] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.ed-more summary {
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.2rem 0;
}

.ed-more[open] summary {
  margin-bottom: 0.6rem;
}

.ed-sections {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.ed-section {
  border: 1px dashed var(--line);
  border-radius: 16px;
  margin: 0;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.ed-section.flat {
  border: 0;
  padding: 0;
}

.ed-sec-head {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.25rem;
}

.ed-sec-name {
  font-size: 0.95rem;
}

.ed-sec-input {
  font-weight: 600;
}

.ed-sec-input.blurb {
  font-weight: 400;
  flex: 1.4;
}

.ed-card {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.ed-prompt {
  flex: 2.2;
}

.ed-extra {
  flex: 1.4;
}

.ed-timer {
  flex: 0 0 5.2rem;
  font-variant-numeric: tabular-nums;
}

.ed-del {
  flex-shrink: 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.3rem 0.4rem;
  border-radius: 8px;
}

.ed-del:hover {
  color: #b91c1c;
}

.ed-add {
  align-self: flex-start;
  padding-left: 0.25rem;
}

.ed-add-section {
  align-self: flex-start;
}

/* test editor: question blocks with option rows + correct toggles */
.ed-question .ed-sec-head {
  align-items: center;
}

.ed-q-num {
  flex-shrink: 0;
  min-width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  background: color-mix(in oklab, var(--ink) 8%, white);
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ed-opts {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.ed-opt {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ed-correct {
  flex-shrink: 0;
  display: inline-flex;
}

.ed-correct input {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: #16a34a;
  cursor: pointer;
}

.ed-opt .ed-prompt {
  flex: 1;
}

@media (max-width: 640px) {
  .ed-grid.two {
    grid-template-columns: 1fr;
  }

  .ed-card {
    flex-wrap: wrap;
  }

  .ed-prompt {
    flex: 1 1 100%;
  }
}

.submit-grid {
  display: grid;
  gap: 2rem;
  margin-top: 2rem;
}

@media (min-width: 960px) {
  .submit-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.field-label {
  display: block;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

#deck-source {
  width: 100%;
  height: 26rem;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgb(255 255 255 / 0.8);
  padding: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--ink);
}

.status {
  border-radius: 16px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: 1rem;
}

.status.ok {
  border: 1px solid #a7f3d0;
  background: #ecfdf5;
  color: #065f46;
}

.status.err {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

#compile-issues {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgb(255 255 255 / 0.7);
  max-height: 14rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
}

#compile-issues li {
  display: flex;
  gap: 0.5rem;
}

.issue-line {
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.7;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.issue-err {
  color: #b91c1c;
}

.issue-warn {
  color: #b45309;
}

#deck-preview .preview-card {
  max-width: 22rem;
}

#try-deck {
  margin-top: 1.25rem;
}

#preview-play {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgb(255 255 255 / 0.4);
  margin-top: 1.25rem;
}

#publish-steps {
  margin-top: 1.25rem;
}

#publish-steps ol {
  color: var(--ink-soft);
  font-size: 0.9rem;
  padding-left: 1.25rem;
  margin: 0.75rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

code {
  background: var(--paper-deep);
  border-radius: 6px;
  padding: 0.1rem 0.4rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82em;
}

#preview-placeholder {
  border: 1px dashed var(--line);
  border-radius: 24px;
  aspect-ratio: 4 / 3;
  max-width: 22rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* ------------------------------------------------------ 404 & motion --- */

.center-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
  padding: 1.5rem;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
