:root {
  color-scheme: light;
  --ink: #183b59;
  --muted: #70889c;
  --night: #f5fbff;
  --panel: #ffffff;
  --panel-soft: #edf7ff;
  --line: rgba(64, 139, 191, 0.2);
  --acid: #67bdf2;
  --coral: #ff9c6b;
  --sky: #83d1f5;
  --green: #73d7a1;
  --yellow: #ffe66a;
  --yellow-deep: #d5a900;
  --violet: #aabaff;
  --radius: 26px;
  --shadow: 0 24px 70px rgba(55, 126, 171, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 92% 8%, rgba(255, 156, 107, 0.13), transparent 27rem),
    linear-gradient(rgba(92, 176, 230, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(92, 176, 230, 0.07) 1px, transparent 1px),
    var(--night);
  background-size: 54px 54px;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 32rem;
  height: 32rem;
  border-radius: 50%;
  filter: blur(130px);
  opacity: 0.22;
  pointer-events: none;
}

.ambient-one {
  top: -12rem;
  right: -8rem;
  background: var(--sky);
}

.ambient-two {
  top: 52rem;
  left: -18rem;
  background: #ffd2bc;
}

.site-header,
main,
footer {
  width: min(1180px, calc(100% - 48px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 25px 0;
  border-bottom: 1px solid var(--line);
}

.site-header p,
footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-decoration: none;
}

.brand-mark {
  display: flex;
  align-items: end;
  gap: 2px;
  height: 17px;
}

.brand-mark i {
  display: block;
  width: 3px;
  border-radius: 4px;
  background: var(--acid);
}

.brand-mark i:nth-child(1),
.brand-mark i:nth-child(5) { height: 6px; }
.brand-mark i:nth-child(2),
.brand-mark i:nth-child(4) { height: 11px; }
.brand-mark i:nth-child(3) { height: 17px; }
.brand-mark i:nth-child(2) { background: var(--green); }
.brand-mark i:nth-child(3) { background: var(--yellow); }
.brand-mark i:nth-child(4) { background: var(--coral); }

.hero {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: clamp(50px, 8vw, 112px);
  align-items: center;
  min-height: 640px;
  padding: 72px 0 86px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 18px;
  color: var(--acid);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow span {
  width: 24px;
  height: 1px;
  background: var(--acid);
}

h1,
h2,
h3,
p {
  text-wrap: balance;
}

h1 {
  margin: 0;
  max-width: 690px;
  font-size: clamp(4rem, 7.7vw, 7.25rem);
  font-weight: 650;
  letter-spacing: -0.075em;
  line-height: 0.82;
}

h1 em {
  color: var(--coral);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
}

.intro {
  max-width: 520px;
  margin: 32px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.65;
}

.input-panel {
  position: relative;
  padding: 30px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.91);
  box-shadow: var(--shadow);
}

.input-panel::before {
  position: absolute;
  top: 0;
  right: 0;
  width: 150px;
  height: 2px;
  background: linear-gradient(90deg, var(--sky), var(--coral));
  content: "";
}

.panel-topline,
.input-meta,
.score-summary,
.section-heading,
figcaption,
.card-heading,
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.panel-topline {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

#digit-count {
  color: var(--acid);
  font-variant-numeric: tabular-nums;
}

.input-shell {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 7px 9px 7px 18px;
  border: 1px solid rgba(103, 189, 242, 0.55);
  border-radius: 15px;
  background: #fafdff;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.input-shell:focus-within {
  border-color: var(--acid);
  box-shadow: 0 0 0 4px rgba(103, 189, 242, 0.13);
}

.prompt-symbol {
  color: var(--acid);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.35rem;
}

#phone-input {
  width: 100%;
  min-width: 0;
  padding: 12px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(1.35rem, 3.1vw, 2.25rem);
  font-weight: 650;
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}

.clear-button {
  padding: 9px 11px;
  border: 0;
  border-radius: 9px;
  background: var(--panel-soft);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.clear-button:hover,
.clear-button:focus-visible {
  background: #dfeffc;
  color: var(--ink);
  outline: none;
}

.input-meta {
  margin-top: 12px;
}

.input-meta p {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

#input-message {
  color: var(--acid);
}

body[data-valid="false"] #input-message {
  color: var(--coral);
}

.reveal-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding: 11px 12px 11px 20px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(120deg, #70c5f5, #8ddeaf);
  box-shadow: 0 13px 30px rgba(70, 165, 224, 0.24);
  color: #123c5c;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.reveal-button b {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  background: var(--yellow);
  color: var(--ink);
  font-size: 1.1rem;
}

.reveal-button:not(:disabled):hover,
.reveal-button:not(:disabled):focus-visible {
  box-shadow: 0 17px 34px rgba(70, 165, 224, 0.32);
  outline: none;
  transform: translateY(-2px);
}

.reveal-button:disabled {
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.42;
}

.samples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.samples span {
  margin-right: 5px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.samples button {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: transparent;
  color: #5f7d94;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
}

.samples button:hover,
.samples button:focus-visible {
  border-color: var(--coral);
  color: #d96f3e;
  outline: none;
}

.scoreboard,
.visuals {
  padding: 88px 0;
  border-top: 1px solid var(--line);
}

.scoreboard {
  scroll-margin-top: 24px;
}

.view[hidden] {
  display: none;
}

.result-view {
  min-height: calc(100vh - 74px);
  padding: 34px 0 84px;
}

.result-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.result-nav button {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-nav button:hover,
.result-nav button:focus-visible {
  border-color: var(--green);
  background: #effcf4;
  outline: none;
}

#result-number {
  overflow: hidden;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(0.9rem, 2vw, 1.2rem);
  letter-spacing: 0.18em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-view .scoreboard {
  padding: 52px 0 64px;
  border-top: 0;
}

.result-view .visuals {
  padding: 58px 0 0;
}

.score-summary,
.section-heading {
  align-items: end;
  margin-bottom: 36px;
}

.section-kicker {
  margin-bottom: 10px;
}

h2 {
  margin: 0;
  font-size: clamp(2.1rem, 4vw, 3.6rem);
  font-weight: 620;
  letter-spacing: -0.055em;
  line-height: 1;
}

.total-score {
  display: flex;
  gap: 14px;
  align-items: center;
}

.total-score > span {
  min-width: 90px;
  color: var(--coral);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 4.7rem;
  line-height: 0.7;
  text-align: right;
}

.total-score strong,
.total-score small {
  display: block;
}

.total-score strong {
  font-size: 0.72rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.total-score small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.71rem;
}

.score-grid,
.rule-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.score-card {
  min-width: 0;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
}

.card-heading > span {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3.8rem;
  line-height: 1;
}

.score-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 1.25rem;
}

.continuity-card .score-icon,
.continuity-card .card-heading > span { color: #4bace8; }
.repeat-card .score-icon,
.repeat-card .card-heading > span { color: #42b979; }
.economy-card .score-icon,
.economy-card .card-heading > span { color: var(--yellow-deep); }

.score-card h3 {
  margin: 26px 0 8px;
  font-size: 1.05rem;
}

.score-card > p {
  min-height: 44px;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.score-track {
  height: 4px;
  margin-top: 24px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(78, 153, 204, 0.11);
}

.score-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: currentColor;
  transition: width 450ms cubic-bezier(0.2, 0.75, 0.25, 1);
}

.continuity-card .score-track { color: var(--acid); }
.repeat-card .score-track { color: var(--green); }
.economy-card .score-track { color: var(--yellow); }

.score-detail {
  min-height: 31px;
  margin-top: 16px;
  color: #55768f;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  line-height: 1.5;
}

.detail-token {
  display: inline-block;
  margin: 0 5px 5px 0;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  white-space: nowrap;
}

.section-heading > p {
  max-width: 390px;
  margin: 0;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.55;
  text-align: right;
}

.chart-card {
  min-width: 0;
  margin: 0;
  padding: 25px 25px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(239, 248, 255, 0.96));
  box-shadow: var(--shadow);
}

.chart-card figcaption {
  padding: 0 6px 20px;
  border-bottom: 1px solid var(--line);
}

.chart-card figcaption > div {
  display: flex;
  gap: 12px;
  align-items: center;
}

.chart-card figcaption span {
  color: var(--acid);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
}

.chart-card h3 {
  margin: 0;
  font-size: 1rem;
}

.chart-card figcaption p {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.chart-card svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 190px;
  overflow: visible;
}

.line-chart-card {
  width: min(820px, 100%);
  margin: 0 auto;
}

.bar-chart-card {
  margin-bottom: 16px;
  border-color: rgba(94, 188, 125, 0.3);
  background:
    radial-gradient(circle at 86% 15%, rgba(255, 230, 106, 0.22), transparent 18rem),
    linear-gradient(145deg, #ffffff, #f2fff7);
}

.bar-chart-card svg {
  min-height: 260px;
}

.compact-heading {
  margin-bottom: 24px;
}

.visuals .score-grid {
  margin: 16px 0;
}

.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.axis-line {
  stroke: rgba(75, 144, 190, 0.15);
  stroke-width: 1;
  stroke-dasharray: 4 7;
}

.axis-label,
.digit-label {
  fill: #7890a4;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.digit-label {
  fill: #315772;
  font-weight: 700;
  text-anchor: middle;
}

.data-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.data-point {
  stroke: #ffffff;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.empty-chart-label {
  fill: #7890a4;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  text-anchor: middle;
}

.rules {
  padding-bottom: 112px;
}

.rule-grid > article {
  position: relative;
  padding: 28px;
  border-top: 1px solid var(--line);
}

.rule-number {
  color: var(--acid);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
}

.rule-grid h3 {
  margin: 30px 0 12px;
  font-size: 1.12rem;
}

.rule-grid p {
  min-height: 90px;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

code {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
}

.formula {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  margin-top: 24px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(111, 194, 242, 0.08);
}

.formula b {
  color: var(--acid);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.formula span {
  color: var(--muted);
  font-size: 0.64rem;
}

.formula strong {
  font-size: 0.72rem;
  white-space: nowrap;
}

footer {
  padding: 28px 0 40px;
  border-top: 1px solid var(--line);
}

body[data-valid="false"] .scoreboard {
  opacity: 0.48;
}

body[data-valid="false"] .scoreboard .score-card,
body[data-valid="false"] .total-score {
  filter: saturate(0);
}

.result-view.is-revealing .scoreboard {
  animation: reveal-up 620ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.result-view.is-revealing .visuals {
  animation: reveal-up 680ms 120ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.result-view.is-revealing .score-card {
  animation: card-in 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.result-view.is-revealing .score-card:nth-child(2) {
  animation-delay: 80ms;
}

.result-view.is-revealing .score-card:nth-child(3) {
  animation-delay: 160ms;
}

.result-view.is-revealing .data-line {
  animation: draw-line 1050ms 180ms cubic-bezier(0.3, 0.7, 0.2, 1) both;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.result-view:not(.is-revealing) .data-line {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.result-view:not(.is-revealing) .data-area,
.result-view:not(.is-revealing) .data-point,
.result-view:not(.is-revealing) #bar-chart rect {
  opacity: 0;
}

.result-view.is-revealing .data-area {
  animation: area-in 620ms 520ms ease-out both;
}

.result-view.is-revealing .data-point {
  animation: point-pop 420ms 760ms ease-out both;
  transform-box: fill-box;
  transform-origin: center;
}

.result-view.is-revealing #bar-chart rect {
  animation: bar-rise 700ms 340ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  transform-box: fill-box;
  transform-origin: center bottom;
}

@keyframes reveal-up {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes draw-line {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

@keyframes point-pop {
  from { opacity: 0; transform: scale(0); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes bar-rise {
  from { opacity: 0; transform: scaleY(0); }
  to { opacity: 0.9; transform: scaleY(1); }
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 430ms;
  animation-timing-function: cubic-bezier(0.22, 0.75, 0.2, 1);
}

html[data-direction="forward"]::view-transition-old(root) {
  animation-name: page-out-left;
}

html[data-direction="forward"]::view-transition-new(root) {
  animation-name: page-in-right;
}

html[data-direction="back"]::view-transition-old(root) {
  animation-name: page-out-right;
}

html[data-direction="back"]::view-transition-new(root) {
  animation-name: page-in-left;
}

.page-enter-forward {
  animation: page-in-right 380ms cubic-bezier(0.22, 0.75, 0.2, 1) both;
}

.page-enter-back {
  animation: page-in-left 380ms cubic-bezier(0.22, 0.75, 0.2, 1) both;
}

@keyframes page-out-left {
  to { opacity: 0; transform: translateX(-7vw) scale(0.98); }
}

@keyframes page-in-right {
  from { opacity: 0; transform: translateX(9vw) scale(0.985); }
}

@keyframes page-out-right {
  to { opacity: 0; transform: translateX(7vw) scale(0.98); }
}

@keyframes page-in-left {
  from { opacity: 0; transform: translateX(-9vw) scale(0.985); }
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 72px 0;
  }

  .hero-copy {
    max-width: 700px;
  }

  h1 {
    font-size: clamp(4rem, 14vw, 7rem);
  }

  .score-grid,
  .rule-grid {
    grid-template-columns: 1fr;
  }

  .score-card > p,
  .rule-grid p {
    min-height: 0;
  }

  .chart-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .site-header,
  main,
  footer {
    width: min(100% - 28px, 1180px);
  }

  .site-header > p {
    display: none;
  }

  .hero {
    gap: 44px;
    padding: 54px 0 64px;
  }

  h1 {
    font-size: clamp(3.7rem, 18vw, 5.5rem);
  }

  .input-panel,
  .score-card,
  .chart-card,
  .rule-grid > article {
    padding: 20px;
  }

  .input-meta p:last-child,
  .chart-card figcaption p {
    display: none;
  }

  .score-summary,
  .section-heading {
    align-items: start;
    flex-direction: column;
  }

  .total-score > span {
    text-align: left;
  }

  .section-heading > p {
    text-align: left;
  }

  .scoreboard,
  .visuals,
  .rules {
    padding: 66px 0;
  }

  .formula {
    grid-template-columns: auto 1fr;
  }

  .formula strong {
    grid-column: 2;
  }
}

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