:root {
  --hue: 38;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #eef5ff;
  --muted: #91a4bd;
  --line: rgba(190, 214, 242, .14);
  --deep: #050b14;
  --link: #7aa6e0;
  --teal: #71e1d6;
  --pass: #5fe3a1;
  --touch: #f2c65c;
  --stick: #ff6474;
  background: var(--deep);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  color: var(--ink);
  background: var(--deep);
}

button {
  color: inherit;
  font: inherit;
}

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

sub {
  font-size: .62em;
  line-height: 0;
  vertical-align: -.14em;
}

/* The header matches the site's other explorers: back link, title, actions. */
.topbar {
  min-height: 64px;
  padding: 8px 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 16, 28, .94);
}

.back {
  justify-self: start;
  color: var(--link);
  font-family: Georgia, "Times New Roman", serif;
  font-size: .9rem;
  text-underline-offset: .2em;
}

.back:visited {
  color: var(--link);
}

.title-block {
  text-align: center;
}

.title-block h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  font-weight: 500;
  letter-spacing: .015em;
}

.title-block p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.top-actions {
  justify-self: end;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .035);
  cursor: pointer;
}

.icon-button:hover {
  border-color: rgba(199, 227, 255, .45);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
  gap: 1px;
  background: var(--line);
}

/* The left column: choose a solid, follow the steps, turn it in 3D. */
.play {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background:
    radial-gradient(circle at 50% 60%, hsl(var(--hue) 45% 42% / .14), transparent 50%),
    linear-gradient(150deg, #0c1a2b, #07111e 62%, #091522);
}

.shapes {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.shapes::-webkit-scrollbar {
  display: none;
}

.shape {
  --hue: 205;
  flex: none;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, .03);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color .18s, background .18s, color .18s, transform .18s;
}

.shape:hover {
  color: var(--ink);
  border-color: hsl(var(--hue) 60% 65% / .5);
}

.shape:active {
  transform: scale(.96);
}

.shape[aria-pressed="true"] {
  color: var(--ink);
  border-color: hsl(var(--hue) 70% 65%);
  background: hsl(var(--hue) 50% 40% / .26);
}

/* C11 leads, C15 follows, and the comparison solids sit after a divider. */
.shape.featured {
  height: 54px;
  min-width: 132px;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  border-color: hsl(var(--hue) 60% 60% / .4);
  color: var(--ink);
  background: hsl(var(--hue) 45% 30% / .16);
  text-align: left;
}

.shape.lead {
  min-width: 168px;
  border-width: 1.5px;
}

.shape.featured[aria-pressed="true"] {
  border-color: hsl(var(--hue) 75% 66%);
  background: hsl(var(--hue) 55% 42% / .38);
  box-shadow: 0 0 0 1px hsl(var(--hue) 75% 66%), 0 6px 22px hsl(var(--hue) 70% 45% / .3);
}

.shape.featured[aria-pressed="false"] {
  background: hsl(var(--hue) 40% 25% / .1);
}

.shape-name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
  font-weight: 400;
  line-height: 1;
}

.shape.lead .shape-name {
  font-size: 27px;
}

.shape-note {
  color: hsl(var(--hue) 65% 74%);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.shape-divider {
  flex: none;
  width: 1px;
  height: 28px;
  margin: 0 6px;
  background: var(--line);
}

.steps {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 8px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.hint {
  flex: 1 1 280px;
  min-width: 0;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #d6e3f1;
  font-size: 14px;
  line-height: 1.35;
}

.step {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #052019;
  background: var(--teal);
  font-size: 12px;
  font-weight: 800;
}

.step:empty {
  display: none;
}

.actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-gap {
  width: 8px;
}

.action {
  height: 38px;
  padding: 0 16px;
  border: 1px solid rgba(198, 220, 245, .22);
  border-radius: 11px;
  color: #d6e3f1;
  background: rgba(10, 23, 38, .72);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  transition: border-color .18s, background .18s, transform .18s;
}

.action:hover {
  border-color: rgba(199, 227, 255, .5);
  background: rgba(29, 54, 78, .82);
}

.action:active {
  transform: scale(.96);
}

/* The next step's button carries the colour, so the eye goes there first. */
.action.primary {
  border-color: var(--teal);
  color: #052019;
  background: var(--teal);
}

.action.primary:hover {
  background: #8cebe1;
}

.action.quiet {
  color: var(--muted);
  background: transparent;
}

.action.quiet:hover {
  color: var(--ink);
}

.action:disabled {
  opacity: .4;
  cursor: default;
}

.scene-card {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
}

.scene-card::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, .018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .018) 1px, transparent 1px);
  background-size: 42px 42px;
  content: "";
  mask-image: radial-gradient(circle at 50% 50%, black, transparent 72%);
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}

canvas:active {
  cursor: grabbing;
}

.scene-copy {
  position: absolute;
  top: 14px;
  left: 16px;
  z-index: 2;
  pointer-events: none;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .65);
}

.scene-copy p,
.scene-copy h2 {
  margin: 0;
}

.status,
.readout-label,
.fit-caption {
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .14em;
  line-height: 1.2;
  text-transform: uppercase;
}

.status {
  color: hsl(var(--hue) 68% 72%);
}

.scene-copy h2 {
  margin: 3px 0 2px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(26px, 2.8vw, 40px);
  font-weight: 400;
  letter-spacing: -.02em;
  line-height: 1;
}

.scene-copy p:last-child {
  color: var(--muted);
  font-size: 12px;
}

.view-reset {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 3;
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid rgba(198, 220, 245, .22);
  border-radius: 10px;
  color: #d6e3f1;
  background: rgba(10, 23, 38, .78);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.view-reset:hover {
  border-color: rgba(199, 227, 255, .5);
}

.view-reset svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.scene-tip {
  position: absolute;
  left: 16px;
  bottom: 12px;
  z-index: 2;
  max-width: calc(100% - 32px);
  margin: 0;
  color: rgba(214, 227, 241, .55);
  font-size: 11.5px;
  pointer-events: none;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .8);
}

.tip-short {
  display: none;
}

/* The right column: the view straight through the hole. */
.fit-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(170deg, #0a1727, #060e19);
}

.readout {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.readout-label {
  color: var(--teal);
}

.ratio {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(24px, 2.4vw, 38px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1;
}

.verdict {
  margin-left: auto;
  padding: 5px 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.verdict[data-verdict="passes"] {
  color: var(--pass);
}

.verdict[data-verdict="touches"] {
  color: var(--touch);
}

.verdict[data-verdict="sticks"] {
  color: var(--stick);
}

.fit-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, #1f3249, #142438);
}

.fit-caption {
  position: absolute;
  top: 11px;
  left: 13px;
  margin: 0;
  color: rgba(214, 227, 241, .6);
  pointer-events: none;
}

.legend {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  color: var(--muted);
  font-size: 11.5px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 11px;
  height: 11px;
  display: inline-block;
  border-radius: 3px;
}

.swatch.rim {
  border: 1.5px solid rgba(235, 245, 255, .9);
  background: #03070d;
}

.swatch.copy {
  background: hsl(var(--hue) 60% 55%);
}

.swatch.red {
  background: var(--stick);
}

footer {
  min-height: 31px;
  margin: 0;
  padding: 7px 18px;
  overflow: hidden;
  border-top: 1px solid var(--line);
  color: #71859e;
  background: #060d17;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
}

footer a {
  color: var(--link);
  text-underline-offset: .2em;
}

@media (max-width: 1080px) {
  .back {
    font-size: 0;
    text-decoration: none;
  }

  .back::before {
    content: "←";
    font-size: 1.2rem;
  }
}

@media (orientation: portrait) {
  .stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1.45fr) minmax(0, 1fr);
  }
}

@media (max-width: 680px) {
  .topbar {
    min-height: 54px;
    padding: 6px 10px;
  }

  .title-block h1 {
    font-size: 1.1rem;
  }

  .title-block p {
    display: none;
  }

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

  .shapes {
    padding: 10px 10px 2px;
  }

  .shape.featured {
    height: 46px;
    min-width: 104px;
    padding: 0 12px;
  }

  .shape.lead {
    min-width: 124px;
  }

  .shape-name {
    font-size: 20px;
  }

  .shape.lead .shape-name {
    font-size: 23px;
  }

  .steps {
    padding: 6px 10px 8px;
  }

  .hint {
    flex-basis: 100%;
    font-size: 13px;
  }

  .actions {
    flex: 1 1 100%;
  }

  .action {
    flex: 1 1 0;
    min-width: 0;
    height: 36px;
    padding: 0 6px;
    font-size: 12.5px;
  }

  .action-gap {
    display: none;
  }

  .scene-copy {
    top: 10px;
    left: 12px;
  }

  .scene-copy h2 {
    font-size: 24px;
  }

  .scene-tip {
    left: 12px;
    bottom: 8px;
    font-size: 10.5px;
  }

  .tip-long {
    display: none;
  }

  .tip-short {
    display: inline;
  }

  .view-reset span {
    display: none;
  }

  .view-reset {
    width: 34px;
    padding: 0;
    justify-content: center;
  }

  .fit-panel {
    gap: 8px;
    padding: 10px;
  }
}

@media (max-height: 430px) {
  body {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .topbar {
    min-height: 44px;
    padding-top: 3px;
    padding-bottom: 3px;
  }

  .title-block h1 {
    font-size: 1.05rem;
  }

  .title-block p,
  footer,
  #shape-meta,
  .scene-tip,
  .legend {
    display: none;
  }

  .shapes {
    padding: 6px 10px 2px;
  }

  .shape {
    height: 30px;
  }

  .shape.featured {
    height: 38px;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .shape.lead {
    min-width: 0;
  }

  .shape-name,
  .shape.lead .shape-name {
    font-size: 20px;
  }

  .steps {
    flex-wrap: nowrap;
    padding: 4px 10px 6px;
  }

  .hint {
    flex: 1 1 auto;
    font-size: 12px;
  }

  #hint {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .actions {
    flex: none;
  }

  .action {
    flex: none;
    height: 32px;
    padding: 0 10px;
  }

  .scene-copy h2 {
    font-size: 22px;
  }

  .fit-panel {
    gap: 6px;
    padding: 8px;
  }

  .readout {
    min-height: 28px;
  }

  .ratio {
    font-size: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .shape,
  .action {
    transition: none;
  }
}
