:root {
  color-scheme: light;
  --bg: #f3f5f1;
  --surface: #ffffff;
  --ink: #101512;
  --muted: #5f6862;
  --line: #d6ddd7;
  --accent: #0b8f55;
  --accent-bright: #28e287;
  --viewer: #090d0b;
  --radius: 6px;
  --page-pad: clamp(18px, 4vw, 56px);
  --max-width: 1600px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

body.viewer-open {
  overflow: hidden;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  padding: 10px 14px;
  background: var(--ink);
  color: #fff;
  transform: translateY(-150%);
}

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

.site-header {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
}

.header-inner,
.intro-inner,
.gallery,
.site-footer {
  width: min(100%, var(--max-width));
  margin-inline: auto;
  padding-inline: var(--page-pad);
}

.header-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  width: 24px;
  height: 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 2px;
}

.brand-mark span {
  display: block;
  background: var(--ink);
}

.brand-mark span:nth-child(1) { height: 9px; }
.brand-mark span:nth-child(2) { height: 18px; background: var(--accent); }
.brand-mark span:nth-child(3) { height: 13px; }

.collection-count {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.collection-count span {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.intro {
  border-bottom: 1px solid var(--line);
}

.intro-inner {
  padding-top: clamp(56px, 9vw, 128px);
  padding-bottom: clamp(42px, 7vw, 96px);
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
p {
  letter-spacing: 0;
}

h1 {
  max-width: 880px;
  margin: 0;
  font-size: clamp(42px, 7vw, 92px);
  line-height: 0.98;
  font-weight: 780;
}

.intro-rule {
  height: 8px;
  margin-top: clamp(32px, 5vw, 72px);
  display: grid;
  grid-template-columns: minmax(80px, 18%) 1fr;
  background: var(--ink);
}

.intro-rule span {
  background: var(--accent);
}

.gallery {
  padding-top: 36px;
  padding-bottom: clamp(72px, 10vw, 144px);
}

.gallery-heading {
  margin-bottom: 22px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
}

.gallery-heading h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 750;
}

.gallery-heading span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.maze-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(12px, 1.5vw, 24px);
}

.maze-card {
  min-width: 0;
}

.maze-button {
  width: 100%;
  padding: 0;
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  overflow: hidden;
  cursor: zoom-in;
  text-align: left;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.maze-button:hover {
  border-color: #aeb8b1;
  box-shadow: 0 10px 28px rgba(16, 21, 18, 0.09);
  transform: translateY(-2px);
}

.maze-image-frame {
  position: relative;
  aspect-ratio: 882 / 504;
  background: #080b0a;
  overflow: hidden;
}

.maze-image-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 0 solid var(--accent-bright);
  pointer-events: none;
  transition: border-width 180ms ease;
}

.maze-button:hover .maze-image-frame::after,
.maze-button:focus-visible .maze-image-frame::after {
  border-width: 3px;
}

.maze-image-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: opacity 220ms ease;
}

.maze-image-frame img[data-loading="true"] {
  opacity: 0;
}

.maze-meta {
  min-height: 56px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid #202724;
}

.maze-name {
  font-size: 14px;
  font-weight: 700;
}

.maze-number {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.site-footer {
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.viewer {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--viewer);
  color: #f4f7f5;
  overflow: hidden;
}

.viewer::backdrop {
  background: rgba(4, 7, 5, 0.92);
}

.viewer[open] {
  display: block;
  animation: viewer-in 180ms ease-out;
}

.viewer-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.viewer-header {
  min-height: 72px;
  padding: 10px clamp(12px, 2.5vw, 36px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid #2b332f;
  background: #0c110e;
  z-index: 2;
}

.viewer-heading {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.viewer-heading p {
  margin: 0;
  color: var(--accent-bright);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.viewer-heading h2 {
  margin: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #edf3ef;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.icon-button:hover {
  border-color: #3a453f;
  background: #19201c;
}

.icon-button:disabled {
  color: #657069;
  cursor: not-allowed;
}

.icon-button svg,
.nav-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.zoom-value {
  width: 54px;
  color: #aeb8b2;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.close-button {
  margin-left: 8px;
  border-color: #3a453f;
}

.viewer-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background-color: #070a08;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 24px 24px;
  touch-action: none;
  user-select: none;
}

.image-wrap {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  will-change: transform;
  transform: translate3d(0, 0, 0) scale(1);
}

.viewer-stage.is-draggable {
  cursor: grab;
}

.viewer-stage.is-dragging {
  cursor: grabbing;
}

.viewer-stage img {
  width: min(92vw, calc((100dvh - 160px) * 1.75));
  max-width: none;
  max-height: calc(100dvh - 180px);
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.viewer-nav {
  min-height: 64px;
  padding-inline: clamp(12px, 2.5vw, 36px);
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  border-top: 1px solid #2b332f;
  background: #0c110e;
  z-index: 2;
}

.nav-button {
  min-width: 116px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: #edf3ef;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: color 160ms ease;
}

.nav-button:hover {
  color: var(--accent-bright);
}

@keyframes viewer-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (min-width: 1380px) {
  .maze-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 840px) {
  .maze-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .viewer-header {
    align-items: center;
  }

  .reset-button,
  .zoom-value {
    display: none;
  }
}

@media (max-width: 560px) {
  .header-inner {
    min-height: 62px;
  }

  .collection-count {
    font-size: 12px;
  }

  .maze-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .maze-meta {
    min-height: 52px;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
  }

  .viewer-header {
    min-height: 64px;
    gap: 8px;
  }

  .viewer-heading {
    display: block;
  }

  .viewer-heading h2 {
    margin-top: 3px;
    font-size: 13px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .close-button {
    margin-left: 0;
  }

  .viewer-stage img {
    width: min(96vw, calc((100dvh - 148px) * 1.75));
    max-height: calc(100dvh - 168px);
  }

  .viewer-nav {
    min-height: 58px;
  }

  .nav-button {
    min-width: 104px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
