:root {
  color-scheme: light;
  --ink: #1f2540;
  --muted: #5d657e;
  --line: #cdd7eb;
  --panel: #ffffff;
  --soft: #f5f8ff;
  --blue: #315fa7;
  --blue-soft: #eaf1ff;
  --purple: #7047b8;
  --purple-soft: #f2ebff;
  --green: #24785d;
  --green-soft: #e6f7f0;
  --gold: #976000;
  --gold-soft: #fff3cf;
  --red: #a52a3d;
  --red-soft: #fff0f2;
  font-family: Inter, ui-rounded, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 0;
  margin: 0;
  background: #fbfcff;
  color: var(--ink);
}

body {
  padding: clamp(10px, 2.4vw, 24px);
}

button,
a,
input {
  font: inherit;
}

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

.shape-app {
  display: grid;
  gap: 16px;
  width: min(100%, 1180px);
  margin: 0 auto;
}

.shape-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: clamp(16px, 3vw, 28px);
  border: 1px solid #b8c8e6;
  border-radius: 22px;
  background: linear-gradient(135deg, #eef4ff, #fff 56%, #f5edff);
  box-shadow: 0 16px 38px rgba(37, 60, 104, .1);
}

.shape-intro__text {
  display: grid;
  gap: 7px;
  max-width: 820px;
}

.shape-intro__actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.shape-eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.shape-intro h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 48px);
  line-height: 1.05;
}

.shape-intro p,
.shape-card p,
.shape-proof p,
.shape-info p {
  margin: 0;
  line-height: 1.52;
}

.shape-intro__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid #9eb5df;
  border-radius: 12px;
  background: #fff;
  color: var(--blue);
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}

.shape-intro__link:hover,
.shape-intro__link:focus-visible {
  border-color: var(--blue);
  outline: 3px solid rgba(49, 95, 167, .16);
}

.shape-intro__fullscreen {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  padding: 10px;
  border: 1px solid #9eb5df;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}

.shape-intro__fullscreen:hover,
.shape-intro__fullscreen:focus-visible {
  border-color: var(--blue);
  outline: 3px solid rgba(49, 95, 167, .16);
}

.shape-intro__fullscreen img {
  display: block;
  width: 22px;
  height: 22px;
}

html:fullscreen body,
html:-webkit-full-screen body {
  min-height: 100vh;
  padding: 12px;
  overflow: auto;
}

html:fullscreen .shape-app,
html:-webkit-full-screen .shape-app {
  width: 100%;
  max-width: none;
}

.shape-core-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.shape-core-strip article {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 4px 10px;
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
}

.shape-core-strip span {
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 20px;
  font-weight: 900;
}

.shape-core-strip strong {
  align-self: end;
}

.shape-core-strip small {
  color: var(--muted);
  line-height: 1.4;
}

.shape-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #fff;
}

.shape-tab,
.shape-option,
.shape-replay,
.shape-reset,
.shape-quiz__choice,
.shape-quiz__next {
  min-height: 46px;
  border: 1px solid #b8c7df;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
}

.shape-tab {
  padding: 9px 11px;
}

.shape-tab[aria-selected="true"],
.shape-option.is-active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.shape-tab:focus-visible,
.shape-option:focus-visible,
.shape-replay:focus-visible,
.shape-reset:focus-visible,
.shape-quiz__choice:focus-visible,
.shape-quiz__next:focus-visible {
  outline: 3px solid rgba(49, 95, 167, .2);
  outline-offset: 2px;
}

.shape-panel {
  display: grid;
  gap: 14px;
}

.shape-panel[hidden],
[hidden] {
  display: none !important;
}

.shape-panel__head {
  display: grid;
  gap: 5px;
}

.shape-panel__head h2,
.shape-info h3,
.shape-proof h3,
.shape-quiz h2 {
  margin: 0;
}

.shape-panel__head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.shape-option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.shape-option {
  flex: 1 1 130px;
  padding: 9px 12px;
}

.shape-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .85fr);
  gap: 14px;
  min-width: 0;
}

.shape-card,
.shape-info,
.shape-proof,
.shape-quiz {
  min-width: 0;
  padding: clamp(13px, 2.2vw, 20px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(39, 57, 91, .06);
}

.shape-card {
  display: grid;
  align-content: start;
  gap: 12px;
}

.shape-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.shape-card__head h3 {
  margin: 0;
  font-size: 20px;
}

.shape-badge {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.shape-canvas {
  display: grid;
  place-items: center;
  min-height: 330px;
  overflow: hidden;
  border: 1px solid #c6d3e8;
  border-radius: 15px;
  background:
    linear-gradient(rgba(49, 95, 167, .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(49, 95, 167, .06) 1px, transparent 1px),
    #f9fbff;
  background-size: 24px 24px;
}

.shape-canvas svg {
  display: block;
  width: 100%;
  max-height: 390px;
  overflow: visible;
}

.geo-shape {
  fill: rgba(80, 128, 206, .22);
  stroke: var(--blue);
  stroke-linejoin: round;
  stroke-width: 5;
}

.geo-shape--secondary {
  fill: rgba(112, 71, 184, .2);
  stroke: var(--purple);
}

.geo-line,
.geo-height,
.geo-extension,
.geo-diagonal,
.geo-mark,
.geo-angle-arc,
.geo-right-angle,
.geo-side-mark {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.geo-line {
  stroke: var(--ink);
  stroke-width: 4;
}

.geo-height {
  stroke: var(--red);
  stroke-dasharray: 10 7;
  stroke-width: 4;
}

.geo-extension {
  stroke: #7b849a;
  stroke-dasharray: 7 7;
  stroke-width: 3;
}

.geo-diagonal {
  stroke: var(--purple);
  stroke-dasharray: 8 6;
  stroke-width: 3.5;
}

.geo-mark {
  stroke: var(--green);
  stroke-width: 4;
}

.geo-angle-arc,
.geo-right-angle {
  stroke: var(--purple);
  stroke-width: 4;
}

.geo-side-mark {
  stroke: var(--green);
  stroke-width: 4;
}

.geo-label {
  fill: var(--ink);
  font-size: 17px;
  font-weight: 900;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 5px;
}

.geo-angle-label {
  dominant-baseline: middle;
}

.geo-label--height {
  fill: var(--red);
}

.geo-label--soft {
  fill: var(--muted);
  font-size: 14px;
}

.geo-boundary {
  fill: none;
  stroke: var(--red);
  stroke-dasharray: 1100;
  stroke-dashoffset: 1100;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 9;
}

.shape-card.is-tracing .geo-boundary {
  animation: trace-boundary 1.45s ease forwards;
}

.geo-target-rect {
  fill: rgba(36, 120, 93, .06);
  stroke: var(--green);
  stroke-dasharray: 9 7;
  stroke-width: 3;
}

.geo-stage-title,
.geo-target-label {
  fill: var(--green);
  font-size: 14px;
  font-weight: 900;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 5px;
}

.geo-stage-title {
  fill: var(--purple);
}

.geo-source-outline {
  fill: none;
  opacity: .62;
  stroke: var(--blue);
  stroke-dasharray: 7 6;
  stroke-linejoin: round;
  stroke-width: 3;
}

.geo-original-piece,
.geo-animated-piece {
  stroke-linejoin: round;
  stroke-width: 4;
}

.geo-original-piece {
  fill: rgba(80, 128, 206, .26);
  stroke: var(--blue);
}

.geo-original-piece--1,
.geo-original-piece--3 {
  fill: rgba(80, 128, 206, .38);
}

.geo-animated-piece {
  will-change: transform;
}

.geo-copy-piece {
  fill: rgba(112, 71, 184, .48);
  opacity: 0;
  stroke: var(--purple);
}

.geo-cut-piece {
  fill: rgba(241, 179, 46, .58);
  stroke: #9a6100;
}

.geo-rearrange-piece {
  fill: rgba(80, 128, 206, .5);
  stroke: var(--blue);
}

.geo-rearrange-piece--1 {
  fill: rgba(112, 71, 184, .5);
  stroke: var(--purple);
}

.geo-rearrange-piece--2 {
  fill: rgba(36, 120, 93, .48);
  stroke: var(--green);
}

.geo-rearrange-piece--3 {
  fill: rgba(241, 179, 46, .62);
  stroke: #9a6100;
}

.geo-piece-number {
  dominant-baseline: middle;
  fill: var(--ink);
  font-size: 17px;
  font-weight: 900;
  paint-order: stroke;
  pointer-events: none;
  stroke: #fff;
  stroke-width: 5px;
  text-anchor: middle;
}

.geo-grid-row {
  opacity: .18;
  transition: opacity .55s ease .2s;
}

.geo-grid-row--1 {
  transition-delay: .8s;
}

.geo-grid-row--2 {
  transition-delay: 1.4s;
}

.geo-grid-row--3 {
  transition-delay: 2s;
}

.geo-grid-row--4 {
  transition-delay: 2.6s;
}

.shape-card.is-proof-visible .geo-grid-row {
  opacity: 1;
}

.geo-unit-cell {
  fill: rgba(80, 128, 206, .28);
  stroke: var(--blue);
  stroke-width: 2;
}

.shape-info,
.shape-proof {
  display: grid;
  align-content: start;
  gap: 12px;
}

.shape-info__kind {
  justify-self: start;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--purple-soft);
  color: var(--purple);
  font-size: 12px;
  font-weight: 900;
}

.shape-facts,
.shape-steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shape-facts li,
.shape-steps li {
  padding: 9px 10px;
  border: 1px solid #d7dfed;
  border-radius: 11px;
  background: var(--soft);
  line-height: 1.45;
}

.shape-facts li::before {
  margin-right: 7px;
  color: var(--green);
  content: "✓";
  font-weight: 900;
}

.shape-formula {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 13px;
  background: var(--gold-soft);
  color: #6e4900;
  text-align: center;
}

.shape-formula span {
  font-size: 12px;
  font-weight: 800;
}

.shape-formula strong {
  font-size: clamp(19px, 3vw, 26px);
}

.shape-why {
  padding: 11px 12px;
  border-left: 5px solid var(--blue);
  border-radius: 10px;
  background: var(--blue-soft);
  line-height: 1.5;
}

.shape-warning {
  padding: 11px 12px;
  border-left: 5px solid var(--red);
  border-radius: 10px;
  background: var(--red-soft);
  color: #7d2030;
  line-height: 1.5;
}

.shape-replay,
.shape-quiz__next {
  padding: 10px 14px;
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.shape-proof-controls {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(110px, 1fr);
  gap: 9px;
}

.shape-reset {
  padding: 10px 14px;
  border-color: var(--green);
  background: #fff;
  color: var(--green);
}

.shape-replay:not(:disabled):hover,
.shape-reset:not(:disabled):hover,
.shape-quiz__next:hover {
  filter: brightness(.96);
}

.shape-replay:disabled,
.shape-reset:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.shape-proof-status {
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 11px;
  background: var(--purple-soft);
  color: #503083;
  line-height: 1.45;
}

.shape-quiz {
  display: grid;
  gap: 14px;
}

.shape-quiz__progress {
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
}

.shape-quiz__choices {
  display: grid;
  gap: 9px;
}

.shape-quiz__choice {
  padding: 11px 13px;
  text-align: left;
}

.shape-quiz__choice:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.shape-quiz__choice.is-correct {
  border-color: var(--green);
  background: var(--green-soft);
  color: #185b45;
}

.shape-quiz__choice.is-wrong {
  border-color: var(--red);
  background: var(--red-soft);
  color: #7d2030;
}

.shape-quiz__feedback {
  padding: 12px;
  border-radius: 12px;
  background: var(--soft);
  line-height: 1.5;
}

.shape-quiz__feedback.is-hint {
  border-left: 5px solid var(--gold);
  background: var(--gold-soft);
  color: #694500;
}

.shape-quiz__feedback.is-reason {
  border-left: 5px solid var(--green);
  background: var(--green-soft);
  color: #185b45;
}

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

.shape-summary-grid article {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
}

.shape-summary-grid h3 {
  margin: 0 0 5px;
  font-size: 16px;
}

.shape-summary-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

@keyframes trace-boundary {
  to { stroke-dashoffset: 0; }
}

@media (max-width: 820px) {
  .shape-core-strip {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .shape-canvas {
    min-height: 290px;
  }
}

@media (max-width: 560px) {
  body {
    padding: 8px;
  }

  .shape-intro {
    display: grid;
  }

  .shape-intro__actions {
    justify-self: start;
  }

  .shape-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shape-card__head {
    display: grid;
  }

  .shape-badge {
    justify-self: start;
  }

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

  .shape-option {
    flex-basis: 115px;
  }

  .shape-canvas {
    min-height: 240px;
  }
}

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