:root {
  color-scheme: light;
  --ink: #090909;
  --paper: #fffdf7;
  --white: #ffffff;
  --line: #111111;
  --muted: #5f5f5f;
  --yellow: #ffdf3d;
  --red: #ff4b3e;
  --cyan: #21d4d6;
  --green: #66df6b;
  --pink: #ff7ab8;
  --tile-radius: 7px;
  --gap: clamp(8px, 2vw, 14px);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(90deg, rgba(9, 9, 9, 0.035) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(rgba(9, 9, 9, 0.035) 1px, transparent 1px) 0 0 / 34px 34px,
    var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(14px, 4vw, 42px);
}

.tool-board {
  width: min(1120px, 100%);
}

.top-strip {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: var(--gap);
  margin-bottom: var(--gap);
}

.brand-tile,
.micro-tile,
.result-tile,
.control-tile,
.share-tile,
.seo-tile,
.number-tile {
  border: 2px solid var(--line);
  border-radius: var(--tile-radius);
  box-shadow: 5px 5px 0 var(--line);
}

.brand-tile {
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  color: inherit;
  text-decoration: none;
  background: var(--white);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  color: var(--ink);
  background: var(--yellow);
  border: 2px solid var(--line);
  border-radius: 5px;
  font-size: 0.86rem;
  font-weight: 950;
}

.brand-tile strong,
.brand-tile em {
  display: block;
  font-style: normal;
}

.brand-tile strong {
  font-size: clamp(1.18rem, 3vw, 1.65rem);
  line-height: 1;
  font-weight: 950;
}

.brand-tile em {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.micro-tiles {
  display: grid;
  grid-template-columns: repeat(5, minmax(46px, 1fr));
  gap: 8px;
  min-width: min(390px, 42%);
}

.micro-tile {
  display: grid;
  place-items: center;
  min-height: 74px;
  font-size: clamp(1rem, 2vw, 1.45rem);
  font-weight: 950;
}

.mosaic-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(260px, 0.82fr);
  grid-template-areas:
    "result side"
    "controls share"
    "seo seo";
  gap: var(--gap);
}

.result-tile {
  grid-area: result;
  position: relative;
  min-height: clamp(390px, 56vh, 560px);
  overflow: hidden;
  padding: clamp(18px, 4vw, 34px);
  display: grid;
  align-content: space-between;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.78)),
    radial-gradient(circle at 20% 18%, rgba(255, 223, 61, 0.88), transparent 23%),
    radial-gradient(circle at 78% 16%, rgba(33, 212, 214, 0.78), transparent 21%),
    radial-gradient(circle at 70% 80%, rgba(255, 122, 184, 0.72), transparent 25%),
    var(--white);
}

.result-tile::before,
.result-tile::after {
  content: "";
  position: absolute;
  inset: auto;
  z-index: 0;
  border: 2px solid var(--line);
  border-radius: 5px;
}

.result-tile::before {
  width: 72px;
  height: 72px;
  right: 26px;
  top: 86px;
  background: var(--green);
  box-shadow:
    -90px 18px 0 -16px var(--red),
    -146px 112px 0 -24px var(--cyan);
  transform: rotate(5deg);
}

.result-tile::after {
  width: 92px;
  height: 58px;
  left: 34px;
  bottom: 104px;
  background: var(--pink);
  box-shadow:
    118px 34px 0 -12px var(--yellow),
    216px -52px 0 -18px var(--green);
  transform: rotate(-3deg);
}

.range-kicker,
.result-badge,
.number-wrap,
.result-copy {
  position: relative;
  z-index: 1;
}

.range-kicker {
  width: fit-content;
  margin: 0;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 5px;
  background: var(--yellow);
  font-size: clamp(0.82rem, 1.8vw, 0.98rem);
  font-weight: 900;
}

.result-badge {
  position: absolute;
  top: clamp(18px, 4vw, 34px);
  right: clamp(18px, 4vw, 34px);
  margin: 0;
  padding: 8px 10px;
  color: var(--white);
  background: var(--ink);
  border: 2px solid var(--line);
  border-radius: 5px;
  box-shadow: 4px 4px 0 var(--cyan);
  font-size: clamp(0.82rem, 1.8vw, 0.98rem);
  font-weight: 950;
  transform: rotate(2deg);
}

.number-wrap {
  display: grid;
  place-items: center;
  min-height: 230px;
}

.result-number,
.number-shadow {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 0.88;
}

.result-number {
  color: var(--ink);
  font-size: clamp(7.5rem, 26vw, 18.5rem);
  font-weight: 1000;
  text-shadow:
    5px 5px 0 var(--yellow),
    10px 10px 0 var(--cyan),
    15px 15px 0 var(--pink);
}

.number-shadow {
  position: absolute;
  transform: translate(0.11em, 0.1em);
  color: transparent;
  -webkit-text-stroke: 2px rgba(9, 9, 9, 0.14);
  font-size: clamp(7.8rem, 27vw, 19rem);
  font-weight: 1000;
}

.result-copy {
  margin: 0;
  max-width: 17em;
  font-size: clamp(1.26rem, 3vw, 2.1rem);
  font-weight: 950;
  line-height: 1.04;
}

.side-mosaic {
  grid-area: side;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: minmax(92px, 1fr);
  gap: var(--gap);
}

.number-tile {
  display: grid;
  place-items: center;
  min-height: 92px;
  color: var(--ink);
  font-size: clamp(1.5rem, 4vw, 3.4rem);
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  transition:
    transform 160ms ease,
    filter 160ms ease,
    background-color 160ms ease;
}

.number-tile.tall {
  grid-row: span 2;
}

.number-tile.wide {
  grid-column: span 2;
}

.tile-yellow {
  background: var(--yellow);
}

.tile-red {
  background: var(--red);
  color: #ffffff;
}

.tile-cyan {
  background: var(--cyan);
}

.tile-pink {
  background: var(--pink);
}

.tile-green {
  background: var(--green);
}

.tile-black {
  background: var(--ink);
  color: var(--white);
}

.tile-white {
  background: var(--white);
}

.control-tile,
.share-tile,
.seo-tile {
  background: var(--white);
  padding: clamp(14px, 3vw, 22px);
}

.control-tile {
  grid-area: controls;
  display: grid;
  gap: 14px;
}

.roll-button {
  position: relative;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  color: var(--white);
  background: var(--ink);
  border: 2px solid var(--line);
  border-radius: 6px;
  box-shadow: 5px 5px 0 var(--red);
  font-size: clamp(1.22rem, 3vw, 1.75rem);
  font-weight: 950;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background-color 140ms ease;
}

.roll-button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 7px 7px 0 var(--red);
}

.roll-button:active {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 var(--red);
}

.button-spark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--ink);
  background: var(--yellow);
  border: 2px solid var(--white);
  border-radius: 5px;
  font-size: 0.9rem;
  font-weight: 1000;
  font-variant-numeric: tabular-nums;
}

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

.range-form label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.range-form input {
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fffaf0;
  border: 2px solid var(--line);
  border-radius: 5px;
  font-size: 1.2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.range-form input:focus-visible,
button:focus-visible,
.brand-tile:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

.range-hint {
  min-height: 1.3em;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 750;
}

.share-tile {
  grid-area: share;
  display: grid;
  gap: 12px;
  background:
    linear-gradient(90deg, rgba(9, 9, 9, 0.04) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(rgba(9, 9, 9, 0.04) 1px, transparent 1px) 0 0 / 18px 18px,
    var(--yellow);
}

.share-label {
  margin: 0;
  color: rgba(9, 9, 9, 0.74);
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
}

.share-text {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.05rem, 2.5vw, 1.55rem);
  font-weight: 950;
  line-height: 1.08;
}

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

.secondary-button {
  min-height: 46px;
  color: var(--ink);
  background: var(--white);
  border: 2px solid var(--line);
  border-radius: 5px;
  box-shadow: 3px 3px 0 var(--line);
  font-weight: 950;
}

.secondary-button.dark {
  color: var(--white);
  background: var(--ink);
}

.secondary-button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--line);
}

.status-line {
  min-height: 1.2em;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.seo-tile {
  grid-area: seo;
  display: grid;
  grid-template-columns: minmax(0, 0.55fr) minmax(0, 1fr);
  align-items: center;
  gap: 20px;
}

.seo-tile h1,
.seo-tile p {
  margin: 0;
}

.seo-tile h1 {
  font-size: clamp(1.45rem, 3vw, 2.35rem);
  line-height: 1;
  font-weight: 1000;
}

.seo-tile p {
  color: var(--muted);
  font-size: clamp(0.95rem, 2vw, 1.05rem);
  font-weight: 700;
  line-height: 1.42;
}

.seo-copy {
  display: grid;
  gap: 12px;
}

.query-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.query-chips li {
  padding: 7px 9px;
  color: var(--ink);
  background: #fffaf0;
  border: 2px solid var(--line);
  border-radius: 5px;
  box-shadow: 3px 3px 0 var(--line);
  font-size: 0.78rem;
  font-weight: 950;
  line-height: 1.1;
}

.query-chips a {
  color: inherit;
  text-decoration: none;
}

.query-chips li:nth-child(1) {
  background: var(--yellow);
}

.query-chips li:nth-child(2) {
  background: var(--cyan);
}

.query-chips li:nth-child(3) {
  background: var(--pink);
}

.query-chips li:nth-child(4) {
  background: var(--green);
}

.multi-result-tile {
  gap: clamp(18px, 4vw, 30px);
}

@media (min-width: 851px) {
  .multiple-page .mosaic-grid,
  .no-repeats-page .mosaic-grid {
    grid-template-areas:
      "result controls"
      "result share"
      "side side"
      "seo seo";
  }

  .multiple-page .result-tile,
  .no-repeats-page .result-tile {
    min-height: clamp(330px, 42vh, 455px);
    padding: clamp(18px, 3vw, 28px);
  }

  .multiple-page .side-mosaic,
  .no-repeats-page .side-mosaic {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    grid-auto-rows: minmax(74px, auto);
  }

  .multiple-page .number-tile.tall,
  .no-repeats-page .number-tile.tall {
    grid-row: span 1;
  }

  .multiple-page .number-tile.wide,
  .no-repeats-page .number-tile.wide {
    grid-column: span 1;
  }

  .multiple-page .results-output {
    min-height: 160px;
  }

  .multiple-page .result-pill {
    min-height: clamp(66px, 8vw, 96px);
    font-size: clamp(2.2rem, 5.4vw, 4.2rem);
  }

  .multiple-page .result-copy {
    max-width: 20em;
    font-size: clamp(1.25rem, 2.3vw, 1.75rem);
  }

  .no-repeats-page .number-wrap {
    min-height: 190px;
  }

  .no-repeats-page .result-copy {
    max-width: 20em;
    font-size: clamp(1.25rem, 2.3vw, 1.75rem);
  }
}

.results-output {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(74px, 1fr));
  gap: clamp(8px, 2vw, 14px);
  align-content: center;
  min-height: 230px;
}

.result-pill {
  display: grid;
  place-items: center;
  min-height: clamp(74px, 12vw, 118px);
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: 6px;
  box-shadow: 5px 5px 0 var(--line);
  font-size: clamp(2.2rem, 7vw, 4.8rem);
  font-weight: 1000;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transform: rotate(-1deg);
}

.result-pill:nth-child(2n) {
  transform: rotate(1.5deg);
}

.result-pill:nth-child(3n) {
  transform: rotate(-2.5deg);
}

.multi-control-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px;
  color: var(--ink);
  background: #fffaf0;
  border: 2px solid var(--line);
  border-radius: 5px;
  font-size: 0.9rem;
  font-weight: 950;
}

.toggle-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--cyan);
}

.no-repeat-result-tile {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.78)),
    radial-gradient(circle at 18% 18%, rgba(102, 223, 107, 0.84), transparent 23%),
    radial-gradient(circle at 78% 18%, rgba(255, 223, 61, 0.78), transparent 21%),
    radial-gradient(circle at 70% 80%, rgba(33, 212, 214, 0.7), transparent 25%),
    var(--white);
}

.d100-result-tile {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.78)),
    radial-gradient(circle at 18% 18%, rgba(255, 75, 62, 0.8), transparent 23%),
    radial-gradient(circle at 78% 18%, rgba(255, 223, 61, 0.82), transparent 21%),
    radial-gradient(circle at 70% 80%, rgba(255, 122, 184, 0.72), transparent 25%),
    var(--white);
}

.no-repeat-controls {
  align-content: start;
}

.d100-controls {
  align-content: start;
}

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

.draw-stats div {
  min-height: 78px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px;
  color: var(--ink);
  background: #fffaf0;
  border: 2px solid var(--line);
  border-radius: 5px;
  box-shadow: 3px 3px 0 var(--line);
}

.draw-stats div:nth-child(1) {
  background: var(--cyan);
}

.draw-stats div:nth-child(2) {
  background: var(--green);
}

.d100-stats div:nth-child(1) {
  background: var(--red);
  color: var(--white);
}

.d100-stats div:nth-child(1) span {
  color: rgba(255, 255, 255, 0.78);
}

.d100-stats div:nth-child(2) {
  background: var(--yellow);
}

.draw-stats span {
  color: rgba(9, 9, 9, 0.72);
  font-size: 0.75rem;
  font-weight: 950;
  text-transform: uppercase;
}

.draw-stats strong {
  font-size: clamp(1.9rem, 4vw, 3rem);
  font-weight: 1000;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
}

.reset-button {
  width: 100%;
}

.pool-empty .roll-button {
  color: var(--ink);
  background: var(--yellow);
  box-shadow: 5px 5px 0 var(--cyan);
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
  margin-top: var(--gap);
}

.guide-tile {
  background: var(--white);
  border: 2px solid var(--line);
  border-radius: var(--tile-radius);
  box-shadow: 5px 5px 0 var(--line);
  padding: clamp(16px, 3vw, 24px);
}

.guide-tile:nth-child(1) {
  background:
    linear-gradient(90deg, rgba(9, 9, 9, 0.035) 1px, transparent 1px) 0 0 / 18px 18px,
    var(--white);
}

.guide-tile:nth-child(2) {
  background:
    linear-gradient(90deg, rgba(9, 9, 9, 0.04) 1px, transparent 1px) 0 0 / 18px 18px,
    var(--cyan);
}

.guide-tile:nth-child(3) {
  background:
    linear-gradient(90deg, rgba(9, 9, 9, 0.04) 1px, transparent 1px) 0 0 / 18px 18px,
    var(--yellow);
}

.guide-tile h2 {
  margin: 0 0 12px;
  font-size: clamp(1.25rem, 2vw, 1.7rem);
  line-height: 1;
  font-weight: 1000;
}

.guide-tile p {
  margin: 0;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.5;
}

.guide-tile a {
  color: inherit;
  font-weight: 900;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.guide-tile code {
  padding: 2px 5px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.9em;
  font-weight: 850;
}

.guide-tile p + p {
  margin-top: 12px;
}

.is-rolling .result-number {
  animation: punch-roll 90ms linear infinite;
}

.is-rolling .result-pill {
  animation: tile-shuffle 220ms steps(3, end) infinite;
}

.is-rolling .number-shadow {
  animation: shadow-roll 90ms linear infinite;
}

.is-rolling .number-tile,
.is-rolling .micro-tile {
  animation: tile-shuffle 360ms steps(4, end) infinite;
}

.is-rolling .number-tile:nth-child(2n),
.is-rolling .micro-tile:nth-child(2n) {
  animation-delay: 80ms;
}

.is-rolling .number-tile:nth-child(3n),
.is-rolling .micro-tile:nth-child(3n) {
  animation-delay: 150ms;
}

@keyframes punch-roll {
  0% {
    transform: translate(0, 0) rotate(0deg);
    filter: hue-rotate(0deg);
  }
  33% {
    transform: translate(-4px, 2px) rotate(-1deg);
  }
  66% {
    transform: translate(3px, -3px) rotate(1deg);
  }
  100% {
    transform: translate(0, 0) rotate(0deg);
    filter: hue-rotate(60deg);
  }
}

@keyframes shadow-roll {
  0% {
    transform: translate(0.11em, 0.1em);
  }
  50% {
    transform: translate(0.07em, 0.14em);
  }
  100% {
    transform: translate(0.11em, 0.1em);
  }
}

@keyframes tile-shuffle {
  0% {
    transform: translate(0, 0) rotate(0deg);
    filter: saturate(1);
  }
  25% {
    transform: translate(3px, -4px) rotate(1.8deg);
    filter: saturate(1.3);
  }
  50% {
    transform: translate(-3px, 2px) rotate(-1deg);
    filter: saturate(1.1);
  }
  75% {
    transform: translate(4px, 3px) rotate(1deg);
    filter: saturate(1.45);
  }
  100% {
    transform: translate(0, 0) rotate(0deg);
    filter: saturate(1);
  }
}

@media (max-width: 850px) {
  .app-shell {
    align-items: start;
  }

  .top-strip {
    display: grid;
    justify-content: stretch;
  }

  .brand-tile,
  .micro-tiles {
    width: 100%;
  }

  .micro-tiles {
    min-width: 0;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .micro-tile {
    min-height: 52px;
  }

  .mosaic-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "result"
      "controls"
      "share"
      "side"
      "seo";
  }

  .result-tile {
    min-height: min(62svh, 520px);
  }

  .side-mosaic {
    grid-auto-rows: minmax(72px, 1fr);
  }

  .number-tile {
    min-height: 72px;
  }

  .seo-tile {
    grid-template-columns: 1fr;
  }

  .results-output {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

  .brand-tile,
  .result-tile,
  .control-tile,
  .share-tile,
  .seo-tile,
  .number-tile,
  .micro-tile {
    box-shadow: 4px 4px 0 var(--line);
  }

  .brand-tile {
    min-height: 66px;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
  }

  .micro-tiles {
    gap: 6px;
    padding-right: 5px;
    padding-bottom: 5px;
  }

  .brand-tile em {
    font-size: 0.76rem;
  }

  .result-tile {
    min-height: 430px;
    padding: 16px;
  }

  .result-number {
    font-size: clamp(8.4rem, 36vw, 10rem);
  }

  .number-shadow {
    font-size: clamp(8.6rem, 37vw, 10.3rem);
  }

  .range-form,
  .action-row {
    grid-template-columns: 1fr 1fr;
  }

  .range-form.multi-control-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .range-form.multi-control-form input {
    padding: 8px;
    font-size: 1.08rem;
  }

  .multiple-page .result-tile,
  .no-repeats-page .result-tile {
    min-height: 430px;
  }

  .multiple-page .result-copy {
    max-width: 15em;
  }

  .results-output {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 220px;
  }

  .result-pill {
    min-height: 78px;
    font-size: clamp(2.3rem, 18vw, 4.2rem);
  }

  .result-copy {
    max-width: 13em;
  }

  .result-badge {
    top: auto;
    right: 16px;
    bottom: 95px;
  }
}

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