:root {
  color-scheme: light;
  --bg: #fff7ff;
  --surface: #ffffff;
  --surface-soft: #f7ecff;
  --ink: #1e266d;
  --muted: #615f7a;
  --line: rgba(30, 38, 109, 0.12);
  --accent: #7347f2;
  --accent-strong: #562fb7;
  --accent-hot: #ee53f8;
  --accent-soft: #f5e7ff;
  --warn: #d1495b;
  --gold: #f9bf00;
  --blue: #533efe;
  --gradient: linear-gradient(95deg, #8c49f3 0%, #d650f7 100%);
  --gradient-reverse: linear-gradient(260deg, #d650f7 0%, #8b49f3 100%);
  --cell-size: clamp(30px, 8.5vw, 38px);
  --hint-width: clamp(78px, 20vw, 124px);
  --hint-height: clamp(72px, 18vw, 118px);
  --radius: 8px;
  --shadow: 0 20px 70px rgba(122, 56, 223, 0.18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background:
    linear-gradient(180deg, rgba(255, 247, 255, 0.86), rgba(255, 255, 255, 0.98) 34rem),
    var(--bg);
  color: var(--ink);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  font-size: 16px;
  line-height: 1.55;
}

a {
  color: inherit;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--gold), white 10%);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 10;
  transform: translateY(-150%);
  border-radius: var(--radius);
  background: var(--ink);
  color: white;
  padding: 0.75rem 1rem;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 45%);
  background: color-mix(in srgb, var(--surface), transparent 10%);
  backdrop-filter: blur(18px);
}

.nav,
.site-footer,
.section-band,
.seo-text,
.faq-section,
.page-intro,
.puzzle-layout,
.guide-layout,
.filters {
  width: min(1180px, calc(100% - 32px));
  margin-inline: auto;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  gap: 1rem;
}

.brand,
.nav-links,
.hero-actions,
.game-toolbar,
.mode-group,
.game-stats,
.breadcrumbs,
.puzzle-facts,
.site-footer {
  display: flex;
  align-items: center;
}

.brand {
  gap: 0.65rem;
  font-weight: 800;
  font-size: 1.1rem;
  text-decoration: none;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(157, 35, 190, 0.22);
}

.brand-dot {
  color: var(--accent-hot);
}

.fa-icon {
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  fill: currentColor;
}

.nav-links {
  gap: clamp(0.6rem, 3vw, 1.4rem);
  color: var(--muted);
  font-size: 0.95rem;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  text-decoration: none;
}

.nav-links a[aria-current="page"],
.nav-links a:hover {
  color: var(--ink);
}

.home-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(360px, 0.86fr) minmax(420px, 1fr);
  gap: clamp(1.25rem, 3.4vw, 3.25rem);
  align-items: center;
  min-height: min(720px, calc(100svh - 68px));
  width: 100%;
  margin-inline: auto;
  padding: clamp(1.1rem, 3vw, 2.4rem) max(16px, calc((100vw - 1280px) / 2));
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 247, 255, 0.96), rgba(255, 255, 255, 0.72)),
    repeating-linear-gradient(90deg, rgba(115, 71, 242, 0.055) 0 1px, transparent 1px 36px),
    repeating-linear-gradient(0deg, rgba(238, 83, 248, 0.042) 0 1px, transparent 1px 36px);
}

.hero-copy {
  max-width: 540px;
  animation: rise-in 520ms ease both;
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.04;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(3rem, 10vw, 7.5rem);
}

.home-hero h1 {
  font-size: clamp(3.25rem, 4.7vw, 4.65rem);
  overflow-wrap: normal;
  white-space: nowrap;
}

.page-intro h1,
.puzzle-copy h1 {
  font-size: clamp(2.45rem, 6vw, 5rem);
}

h2 {
  font-size: clamp(1.9rem, 4vw, 3.1rem);
}

h3 {
  font-size: 1.08rem;
}

.lede {
  max-width: 62ch;
  color: var(--muted);
  font-size: clamp(1rem, 1.6vw, 1.16rem);
}

.hero-actions {
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 1.55rem;
}

.theme-note {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 1rem;
  color: var(--muted);
  font-weight: 800;
}

.hero-preview-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 1.25rem;
}

.hero-preview-row a {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem;
  min-height: 58px;
  border: 1px solid rgba(122, 56, 223, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  padding: 0.45rem 0.55rem;
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 10px 32px rgba(122, 56, 223, 0.08);
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.hero-preview-row a:hover {
  transform: translateY(-2px);
  border-color: rgba(238, 83, 248, 0.32);
  background: white;
}

.hero-preview-row img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--surface-soft);
  image-rendering: pixelated;
}

.hero-preview-row span {
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.15;
}

.theme-note img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.primary-button,
.text-button,
.ghost-button,
.mode-button,
.category-link {
  min-height: 44px;
  border-radius: var(--radius);
}

.primary-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
  font-weight: 800;
}

.primary-button {
  background: var(--gradient);
  color: white;
  padding: 0.85rem 1.15rem;
  box-shadow: 0 15px 50px rgba(157, 35, 190, 0.3);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.text-button {
  color: var(--accent-strong);
}

.primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 54px rgba(157, 35, 190, 0.38);
}

.game-shell {
  justify-self: center;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  border: 1px solid rgba(122, 56, 223, 0.16);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface), var(--accent-soft) 14%);
  box-shadow: var(--shadow);
  animation: board-in 620ms ease 120ms both;
  overflow: hidden;
}

.game-toolbar {
  position: sticky;
  top: 68px;
  z-index: 12;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 1px 0 var(--line);
}

.game-shell.is-compact .game-toolbar,
.game-shell.is-compact .game-stats {
  justify-content: center;
}

.game-shell.is-large {
  width: 100%;
}

.game-shell.is-large .game-toolbar,
.game-shell.is-large .game-stats {
  justify-content: flex-start;
}

.mode-group {
  gap: 0.35rem;
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 0.25rem;
}

.mode-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  padding: 0.55rem 0.75rem;
}

.mode-button {
  gap: 0.35rem;
}

.mode-button.is-active {
  background: var(--gradient);
  color: white;
  box-shadow: 0 8px 24px rgba(157, 35, 190, 0.22);
}

.mode-button .fa-icon,
.ghost-button .fa-icon,
.challenge-toggle .fa-icon {
  font-size: 0.95em;
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--surface);
  transition: background 150ms ease, transform 150ms ease;
}

.ghost-button.danger {
  color: var(--warn);
}

.ghost-button:hover {
  background: var(--surface-soft);
  transform: translateY(-1px);
}

.challenge-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  color: var(--muted);
  font-weight: 700;
}

.game-stats {
  position: relative;
  z-index: 1;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.92rem;
}

.game-stats strong {
  color: var(--ink);
}

@media screen {
  .print-sheet {
    display: none;
  }
}

.nonogram-wrap {
  background:
    linear-gradient(135deg, rgba(238, 83, 248, 0.08), transparent 35%),
    var(--surface);
}

.nonogram-scroll {
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0.9rem;
  max-height: min(78svh, 860px);
  width: 100%;
}

.nonogram-board {
  display: grid;
  grid-template-columns: var(--hint-width) repeat(var(--cols), var(--cell-size));
  grid-template-rows: var(--hint-height) repeat(var(--rows), var(--cell-size));
  width: max-content;
  max-width: none;
}

.hint-corner,
.col-hints,
.row-hints {
  position: sticky;
  z-index: 4;
  background: color-mix(in srgb, var(--surface), var(--surface-soft) 35%);
}

.hint-corner {
  top: 0;
  left: 0;
  z-index: 6;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}

.col-hints {
  top: 0;
  display: grid;
  grid-column: 2 / -1;
  border-bottom: 2px solid var(--ink);
}

.row-hints {
  left: 0;
  display: grid;
  grid-row: 2 / -1;
  border-right: 2px solid var(--ink);
}

.row-hint,
.col-hint {
  display: flex;
  gap: 0.18rem;
  color: var(--muted);
  font-size: clamp(0.74rem, 2vw, 0.88rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  user-select: none;
  box-sizing: border-box;
}

.row-hint span,
.col-hint span {
  display: inline-flex;
  justify-content: center;
  min-width: 1.15em;
  line-height: 1;
}

.row-hint {
  align-items: center;
  justify-content: flex-end;
  min-width: var(--hint-width);
  height: var(--cell-size);
  padding-inline: 0.45rem;
  border-bottom: 1px solid var(--line);
}

.col-hint {
  align-items: flex-end;
  justify-content: flex-end;
  flex-direction: column;
  width: var(--cell-size);
  min-height: var(--hint-height);
  padding-block: 0.35rem;
  border-right: 1px solid var(--line);
}

.game-shell.is-large .row-hint,
.game-shell.is-large .col-hint {
  font-size: 0.68rem;
}

.game-shell.is-large .cell {
  font-size: calc(var(--cell-size) * 0.78);
}

.row-hint.is-active,
.col-hint.is-active,
.row-hint.is-done,
.col-hint.is-done {
  color: var(--ink);
  background: var(--accent-soft);
}

.row-hint.is-done,
.col-hint.is-done {
  opacity: 0.72;
}

.cells {
  display: grid;
  grid-column: 2 / -1;
  grid-row: 2 / -1;
  background: var(--ink);
  gap: 1px;
  touch-action: none;
}

.cell {
  display: grid;
  place-items: center;
  width: var(--cell-size);
  height: var(--cell-size);
  border: 0;
  border-radius: 0;
  padding: 0;
  background: var(--surface);
  color: var(--warn);
  font-size: calc(var(--cell-size) * 0.7);
  font-weight: 900;
  line-height: 1;
  transition: background-color 90ms linear;
  user-select: none;
}

.cell:nth-child(5n) {
  box-shadow: inset -1px 0 0 color-mix(in srgb, var(--ink), transparent 35%);
}

.cell.is-filled {
  background: var(--ink);
}

.cell.is-marked {
  background: #fff7f3;
}

.cell.is-active {
  background: color-mix(in srgb, var(--accent-soft), white 35%);
}

.cell.is-filled.is-active {
  background: color-mix(in srgb, var(--ink), var(--accent-hot) 18%);
}

.cell.is-error {
  background: var(--warn);
  color: white;
  animation: shake 180ms ease 2;
}

.is-complete .game-stats {
  background: var(--accent-soft);
}

.loading {
  margin: 0;
  padding: 2rem;
  color: var(--muted);
}

.loading.error {
  color: var(--warn);
}

.theme-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  width: min(980px, calc(100% - 32px));
  margin: -1.6rem auto 1rem;
  position: relative;
  z-index: 2;
}

.theme-metrics div {
  display: grid;
  gap: 0.1rem;
  min-height: 96px;
  align-content: center;
  border-radius: 16px;
  background: var(--surface);
  padding: 1rem 1.2rem;
  box-shadow: 0 15px 50px rgba(157, 35, 190, 0.14);
  border: 1px solid rgba(122, 56, 223, 0.12);
}

.theme-metrics strong {
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.theme-metrics span {
  color: var(--muted);
  font-weight: 800;
}

.section-band,
.seo-text,
.faq-section,
.page-intro,
.guide-layout,
.filters,
.link-strip,
.contents-list,
.puzzle-nav {
  padding-block: clamp(2.5rem, 7vw, 5.5rem);
}

.section-heading {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 1.4rem;
}

@supports (content-visibility: auto) {
  .section-band,
  .seo-text,
  .faq-section,
  .guide-layout,
  .link-strip,
  .contents-list,
  .puzzle-nav {
    content-visibility: auto;
    contain-intrinsic-size: auto 560px;
  }
}

.category-grid,
.puzzle-grid,
.guide-layout,
.section-card-grid {
  display: grid;
  gap: 1rem;
}

.category-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.category-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(122, 56, 223, 0.14);
  background: var(--surface);
  padding: 1rem;
  text-decoration: none;
  font-weight: 800;
  transition: transform 150ms ease, border-color 150ms ease;
  box-shadow: 0 5px 20px rgba(98, 26, 255, 0.05);
}

.category-link::after {
  content: ">";
  color: var(--accent-hot);
}

.category-link:hover,
.puzzle-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent), var(--line) 35%);
}

.puzzle-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.section-card-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.compact-section {
  padding-block: clamp(1.6rem, 4vw, 3.2rem);
}

.puzzle-card {
  display: grid;
  gap: 0.75rem;
  align-content: start;
  border: 1px solid rgba(122, 56, 223, 0.14);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.75rem;
  transition: transform 150ms ease, border-color 150ms ease;
  box-shadow: 0 8px 32px rgba(122, 56, 223, 0.08);
}

.preview-link {
  display: block;
  overflow: hidden;
  border-radius: 6px;
  background:
    linear-gradient(140deg, rgba(115, 71, 242, 0.1), rgba(238, 83, 248, 0.08)),
    var(--surface-soft);
}

.preview-link img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  image-rendering: pixelated;
}

.card-kicker {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: capitalize;
}

.puzzle-card h3 a {
  text-decoration: none;
}

.card-summary {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.card-action {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
  color: var(--accent-strong);
  font-size: 0.88rem;
  font-weight: 900;
  text-decoration: none;
}

.card-action .fa-icon {
  font-size: 0.82rem;
}

.section-card {
  position: relative;
  display: grid;
  gap: 0.35rem;
  min-height: 132px;
  align-content: start;
  border: 1px solid rgba(122, 56, 223, 0.14);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem;
  text-decoration: none;
  box-shadow: 0 8px 32px rgba(122, 56, 223, 0.07);
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.section-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent-hot), var(--line) 35%);
  background: color-mix(in srgb, var(--surface), var(--accent-soft) 18%);
}

.section-card-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.section-card-kicker .fa-icon {
  font-size: 0.92rem;
}

.section-card strong {
  font-size: 1.08rem;
  line-height: 1.15;
}

.section-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.section-card-arrow {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  color: var(--accent);
  opacity: 0.78;
}

.page-intro {
  padding-bottom: 1rem;
}

.breadcrumbs {
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.breadcrumbs a {
  color: var(--accent-strong);
}

.puzzle-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(420px, 1.28fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
  padding-block: clamp(1.5rem, 5vw, 4rem);
}

.puzzle-copy {
  position: sticky;
  top: 94px;
}

.puzzle-facts {
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 2rem 0 0;
}

.puzzle-facts div {
  min-width: 112px;
  border-left: 3px solid var(--accent-hot);
  padding-left: 0.65rem;
}

.puzzle-facts dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.puzzle-facts dd {
  margin: 0.15rem 0 0;
  font-weight: 900;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1.2rem;
}

.tag-list span {
  border: 1px solid rgba(122, 56, 223, 0.14);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface), var(--accent-soft) 35%);
  color: var(--muted);
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 800;
}

.seo-text {
  max-width: 860px;
}

.compact-seo {
  padding-block: clamp(1.6rem, 4vw, 3rem);
}

.seo-text p,
.guide-layout p,
.faq-list p {
  color: var(--muted);
}

.faq-list {
  display: grid;
  gap: 0.75rem;
}

details {
  border: 1px solid rgba(122, 56, 223, 0.14);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem;
  box-shadow: 0 8px 32px rgba(122, 56, 223, 0.06);
}

summary {
  cursor: pointer;
  font-weight: 900;
}

.filters {
  display: grid;
  grid-template-columns: 2fr repeat(3, minmax(130px, 1fr)) auto;
  gap: 0.75rem;
  align-items: end;
  padding-bottom: 1rem;
}

.filters label {
  display: grid;
  gap: 0.3rem;
  color: var(--muted);
  font-weight: 800;
}

.filters input,
.filters select {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(122, 56, 223, 0.16);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0.55rem 0.7rem;
}

.filter-count {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.link-strip {
  width: min(1180px, calc(100% - 32px));
  margin-inline: auto;
  display: grid;
  gap: 0.8rem;
  padding-block: clamp(1.3rem, 3vw, 2.2rem);
}

.link-strip strong {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink);
  font-size: 1rem;
}

.link-strip div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.link-strip a,
.contents-list a,
.puzzle-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid rgba(122, 56, 223, 0.14);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent-strong);
  padding: 0.55rem 0.75rem;
  text-decoration: none;
  font-weight: 850;
}

.utility-panel,
.contents-list,
.puzzle-nav {
  width: min(1180px, calc(100% - 32px));
  margin-inline: auto;
}

.utility-panel {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  border: 1px solid rgba(122, 56, 223, 0.14);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface), var(--accent-soft) 28%);
  padding: 0.85rem 1rem;
  color: var(--muted);
}

.utility-panel strong {
  color: var(--ink);
}

.contents-list {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding-block: clamp(1.2rem, 3vw, 2rem);
}

.contents-list strong {
  margin-right: 0.2rem;
}

.guide-layout {
  grid-template-columns: repeat(3, 1fr);
}

.guide-outline {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.guide-layout > div {
  border-top: 3px solid var(--accent-hot);
  padding-top: 1rem;
}

.puzzle-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-block: clamp(1rem, 3vw, 2rem);
}

.empty-note {
  margin: 0;
  border: 1px dashed rgba(122, 56, 223, 0.28);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface), var(--accent-soft) 18%);
  color: var(--muted);
  padding: 1rem;
  font-weight: 800;
}

.site-footer {
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 2rem max(16px, calc((100vw - 1180px) / 2));
  border-top: 1px solid var(--line);
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(255, 247, 255, 0.94), rgba(247, 252, 244, 0.88)),
    repeating-linear-gradient(90deg, rgba(115, 71, 242, 0.045) 0 1px, transparent 1px 48px);
}

.site-footer p {
  margin: 0.25rem 0 0;
}

.site-credit {
  color: var(--muted);
  font-size: 0.9rem;
}

.site-credit a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.site-credit a:hover {
  text-decoration: underline;
}

.site-footer nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-footer nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
}

@media (max-width: 960px) {
  .home-hero,
  .puzzle-layout,
  .guide-layout,
  .filters {
    grid-template-columns: 1fr;
  }

  .home-hero {
    min-height: auto;
    padding-block: 2rem;
  }

  .home-hero h1 {
    font-size: clamp(2.85rem, 9vw, 4.2rem);
  }

  .hero-preview-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 520px;
  }

  .puzzle-copy {
    position: static;
  }

  .filters {
    align-items: stretch;
  }

}

@media (max-width: 680px) {
  :root {
    --cell-size: 34px;
    --hint-width: 86px;
    --hint-height: 88px;
  }

  .nav {
    align-items: flex-start;
    flex-direction: column;
    padding-block: 0.8rem;
  }

  .site-header {
    position: static;
  }

  .home-hero h1 {
    font-size: clamp(2.25rem, 10vw, 3.35rem);
  }

  .hero-preview-row {
    gap: 0.5rem;
  }

  .hero-preview-row a {
    grid-template-columns: 36px minmax(0, 1fr);
    min-height: 52px;
    padding: 0.4rem 0.48rem;
  }

  .hero-preview-row img {
    width: 36px;
    height: 36px;
  }

  .game-toolbar {
    top: 0;
  }

  .mode-group {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .mode-button {
    justify-content: center;
  }

  .ghost-button,
  .challenge-toggle {
    flex: 1 1 auto;
    justify-content: center;
  }

  .nonogram-scroll {
    padding: 0.55rem;
  }

  .row-hint,
  .col-hint {
    font-size: 0.72rem;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .theme-metrics {
    grid-template-columns: 1fr;
    margin-top: 0;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 9mm;
  }

  :root {
    --ink: #171353;
    --muted: #4f4c68;
    --line: #a8a3d4;
    --surface: #fff;
  }

  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  body {
    min-width: 0;
    background: #fff !important;
    color: var(--ink);
  }

  .site-header,
  .site-footer,
  main > :not(.print-sheet) {
    display: none !important;
  }

  main {
    display: block;
  }

  .print-sheet {
    display: block !important;
    break-inside: avoid;
  }

  .print-sheet-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10mm;
    margin-bottom: 4mm;
    border-bottom: 1px solid #d7d3ef;
    padding-bottom: 3mm;
  }

  .print-brand {
    margin: 0 0 2mm;
    color: #7a38df;
    font-size: 8.5pt;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .print-sheet h2 {
    margin: 0;
    color: var(--ink);
    font-size: 17pt;
    line-height: 1.05;
  }

  .print-sheet-header p:not(.print-brand) {
    margin: 2mm 0 0;
    color: var(--muted);
    font-size: 8.5pt;
    font-weight: 800;
  }

  .print-qr {
    width: 23mm;
    height: 23mm;
    flex: 0 0 auto;
    image-rendering: pixelated;
  }

  .print-board {
    display: grid;
    grid-template-columns: var(--print-row-hints) var(--print-grid-width);
    grid-template-rows: var(--print-col-hints) var(--print-grid-height);
    width: max-content;
    max-width: 100%;
    margin: 0 auto 4mm;
    color: var(--ink);
    page-break-inside: avoid;
  }

  .print-corner {
    border-right: 2px solid var(--ink);
    border-bottom: 2px solid var(--ink);
  }

  .print-col-hints,
  .print-row-hints,
  .print-cells {
    display: grid;
  }

  .print-col-hint,
  .print-row-hint {
    display: grid;
    align-items: stretch;
    justify-items: stretch;
    color: var(--ink);
    font-size: var(--print-hint-font);
    font-weight: 900;
    line-height: 0.92;
    font-variant-numeric: tabular-nums;
  }

  .print-col-hint span,
  .print-row-hint span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
    padding-inline: 0.2mm;
    white-space: nowrap;
  }

  .print-col-hints {
    border-bottom: 2px solid var(--ink);
  }

  .print-row-hints {
    border-right: 2px solid var(--ink);
  }

  .print-cells span {
    border-right: 0.28mm solid var(--line);
    border-bottom: 0.28mm solid var(--line);
    background: #fff;
  }

  .print-notes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6mm;
    border-top: 1px solid #d7d3ef;
    padding-top: 3mm;
  }

  .print-notes h3 {
    margin: 0 0 1.5mm;
    color: var(--ink);
    font-size: 9.5pt;
  }

  .print-notes p {
    margin: 0;
    color: var(--muted);
    font-size: 7.8pt;
    line-height: 1.25;
  }
}

@media screen and (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101129;
    --surface: #191a3d;
    --surface-soft: #252052;
    --ink: #f7f3ff;
    --muted: #c7bfdd;
    --line: rgba(255, 255, 255, 0.14);
    --accent: #9b73ff;
    --accent-strong: #f0a3ff;
    --accent-hot: #ee53f8;
    --accent-soft: #31205a;
    --warn: #ff6b7a;
  }

  .cell.is-filled {
    background: #070b12;
  }

  .cell.is-marked {
    background: #2a2030;
  }
}

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

@keyframes board-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes shake {
  50% {
    transform: translateX(2px);
  }
}
