:root {
  color-scheme: light;
  --paper: #f5f5f1;
  --ink: #121212;
  --muted: #6b6b66;
  --line: #cecec8;
  --soft: #e7e7e0;
  --white: #ffffff;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family:
    ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 12px clamp(48px, 8vw, 136px);
}

.topbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 52px;
}

.wordmark {
  color: var(--ink);
  font-size: clamp(1.45rem, 3vw, 3.4rem);
  font-weight: 900;
  letter-spacing: 0;
  text-decoration: none;
  text-transform: uppercase;
}

.topbarActions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.openseaLink {
  align-items: center;
  background: var(--white);
  border: 1px solid var(--ink);
  display: grid;
  height: 36px;
  justify-items: center;
  width: 36px;
}

.openseaLink img {
  display: block;
  height: 22px;
  width: 22px;
}

.walletButton {
  background: var(--ink);
  border: 1px solid var(--ink);
  color: var(--paper);
  cursor: pointer;
  min-width: 92px;
  padding: 8px 10px;
  text-align: center;
}

.walletButton:disabled {
  cursor: wait;
  opacity: 0.54;
}

.studio {
  display: grid;
  gap: 10px;
  padding: 12px 0;
}

.controls {
  align-items: stretch;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(180px, 1fr) repeat(2, minmax(112px, auto));
}

.field {
  align-items: center;
  background: var(--white);
  border: 1px solid var(--line);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 48px;
}

.field span {
  border-right: 1px solid var(--line);
  color: var(--muted);
  padding: 0 12px;
  white-space: nowrap;
}

.field input {
  background: transparent;
  border: 0;
  color: var(--ink);
  min-width: 0;
  outline: 0;
  padding: 0 12px;
}

.primary,
.secondary {
  border: 1px solid var(--ink);
  cursor: pointer;
  min-height: 48px;
}

.primary {
  background: var(--ink);
  color: var(--white);
  padding: 0 18px;
  text-transform: uppercase;
}

.secondary {
  background: var(--white);
  color: var(--ink);
  padding: 0 18px;
  text-transform: uppercase;
}

.primary:disabled,
.secondary:disabled {
  cursor: wait;
  opacity: 0.54;
}

.comparison {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  display: grid;
  gap: 8px;
  margin: 0;
  min-width: 0;
}

.plate {
  align-items: center;
  aspect-ratio: 1;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(0, 0, 0, 0.045) 1px, transparent 1px),
    var(--white);
  background-size: 20px 20px;
  border: 1px solid var(--line);
  display: grid;
  justify-items: center;
  overflow: hidden;
  position: relative;
}

.before .plate {
  image-rendering: pixelated;
}

.after .plate {
  box-shadow: var(--shadow);
}

.plate img {
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.loading-plate::after {
  background: var(--ink);
  content: "";
  height: 8px;
  left: var(--progress, -40%);
  position: absolute;
  top: 0;
  transition: left 180ms linear;
  width: 40%;
}

figcaption {
  color: var(--muted);
  min-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.galleryWrap,
.sketchWrap {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.sketchWrap {
  margin-top: 22px;
  padding-bottom: 40px;
}

.sectionTitle {
  align-items: baseline;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sectionTitle h1 {
  font-size: 1rem;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

.sectionTitle span {
  color: var(--muted);
}

.gallery {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tile {
  background: var(--white);
  border: 1px solid var(--line);
  display: grid;
  min-width: 0;
}

.sketchLayout {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.sketchBoard {
  aspect-ratio: 1;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px),
    var(--white);
  background-size: 20px 20px;
  border: 1px solid var(--line);
  grid-column: span 2;
  display: grid;
  overflow: hidden;
}

#sketchCanvas {
  cursor: crosshair;
  display: block;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
  width: 100%;
}

.sketchTools {
  border-left: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-column: span 3;
  grid-template-rows: auto auto auto auto 1fr;
  min-width: 0;
  padding-left: 12px;
}

.sketchModes {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sketchMode {
  background: var(--white);
  border: 1px solid var(--ink);
  color: var(--ink);
  cursor: pointer;
  min-height: 38px;
  text-transform: uppercase;
}

.sketchMode.active {
  background: var(--ink);
  color: var(--white);
}

.sketchPalette {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.sketchColor {
  aspect-ratio: 1;
  background: var(--swatch);
  border: 1px solid var(--ink);
  cursor: pointer;
  min-height: 42px;
}

.sketchColor.active {
  box-shadow:
    inset 0 0 0 3px var(--paper),
    inset 0 0 0 5px var(--ink);
}

.sketchArtist {
  min-height: 44px;
}

.sketchActions {
  display: grid;
  gap: 8px;
}

.tileImages {
  aspect-ratio: 2 / 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tileImageLink,
.tileImages img {
  background: var(--soft);
  border-bottom: 1px solid var(--line);
  display: block;
  height: 100%;
  image-rendering: auto;
  object-fit: cover;
  width: 100%;
}

.tileImageLink + .tileImageLink,
.tileImageLink + img,
img + .tileImageLink {
  border-left: 1px solid var(--line);
}

.tileImageLink img {
  border-bottom: 0;
}

.tileMeta {
  display: grid;
  gap: 2px;
  padding: 8px;
}

.tileMeta strong,
.tileMeta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tileMeta a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.tileMeta span {
  color: var(--muted);
  font-size: 0.78rem;
}

.shake {
  animation: shake 220ms steps(2, end) infinite;
}

.mintOverlay {
  align-items: center;
  background: rgba(18, 18, 18, 0.72);
  display: grid;
  inset: 0;
  justify-items: center;
  padding: 20px;
  position: fixed;
  z-index: 20;
}

.confettiStage {
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  z-index: 0;
}

.confettiPiece {
  animation: confettiBurst var(--duration) cubic-bezier(0.12, 0.78, 0.24, 1) var(--delay) infinite;
  background: var(--tone);
  display: block;
  height: 16px;
  left: var(--start-x);
  opacity: 0;
  position: absolute;
  top: var(--start-y);
  transform: translate3d(0, 0, 0) rotate(0deg);
  width: 7px;
  will-change: opacity, transform;
}

.confettiPiece:nth-child(4n) {
  height: 7px;
  width: 18px;
}

.confettiPiece:nth-child(5n) {
  height: 11px;
  width: 11px;
}

.confettiPiece:nth-child(6n) {
  height: 22px;
  width: 4px;
}

.confettiSpark {
  box-shadow:
    0 0 8px rgba(255, 255, 255, 0.68),
    0 0 14px rgba(255, 255, 255, 0.28);
  height: 5px;
  width: 5px;
}

.mintModal {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(0, 0, 0, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 20px 20px;
  border: 1px solid var(--ink);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
  display: grid;
  gap: 14px;
  justify-items: center;
  max-height: min(90svh, 820px);
  max-width: min(94vw, 560px);
  overflow: auto;
  padding: 28px;
  position: relative;
  width: 100%;
  z-index: 1;
}

.modalClose {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  height: 32px;
  justify-items: center;
  padding: 0;
  position: absolute;
  right: 8px;
  top: 8px;
  width: 32px;
}

.mintModal h2 {
  font-size: clamp(1.2rem, 3vw, 2rem);
  letter-spacing: 0;
  line-height: 1.05;
  margin: 6px 28px 0;
  text-align: center;
  text-transform: uppercase;
}

.mintModal img {
  aspect-ratio: 1;
  background: var(--soft);
  border: 1px solid var(--line);
  display: block;
  max-width: min(74vw, 360px);
  object-fit: contain;
  width: 100%;
}

.mintModal strong {
  font-size: 1rem;
}

.modalActions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
}

.modalActions a {
  background: var(--ink);
  border: 1px solid var(--ink);
  color: var(--white);
  min-height: 44px;
  padding: 12px;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
}

.modalActions a + a {
  background: var(--white);
  color: var(--ink);
}

.modalActions a:nth-child(3) {
  grid-column: 1 / -1;
}

@keyframes shake {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
  25% {
    transform: translate(1px, -2px) rotate(-0.25deg);
  }
  50% {
    transform: translate(-2px, 1px) rotate(0.35deg);
  }
  75% {
    transform: translate(2px, 1px) rotate(-0.15deg);
  }
}

@keyframes confettiBurst {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(0.2);
  }
  8% {
    opacity: 1;
  }
  28% {
    opacity: 1;
    transform: translate3d(var(--burst-x), var(--burst-y), 0) rotate(var(--rotation-mid)) scale(1);
  }
  88% {
    opacity: 0.92;
  }
  100% {
    opacity: 0;
    transform: translate3d(calc(var(--burst-x) + var(--drift)), var(--fall-y), 0) rotate(var(--rotation)) scale(0.72);
  }
}

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

  .sketchLayout {
    grid-template-columns: 1fr;
  }

  .sketchBoard,
  .sketchTools {
    grid-column: auto;
  }

  .sketchTools {
    border-left: 0;
    border-top: 1px solid var(--line);
    grid-template-rows: auto auto auto;
    padding-left: 0;
    padding-top: 12px;
  }

  .sketchPalette {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .shell {
    padding: 10px 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 10px;
  }

  .walletButton {
    width: 100%;
  }

  .controls {
    grid-template-columns: minmax(0, 1fr);
  }

  .primary {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .secondary {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .comparison,
  .gallery {
    grid-template-columns: 1fr;
  }

  .mintModal {
    padding: 24px 16px 18px;
  }

  .modalActions {
    grid-template-columns: 1fr;
  }
}
