:root {
  --paper: #f6f2e8;
  --surface: #fffdf8;
  --ink: #15213b;
  --ink-soft: #526079;
  --line: #d8d1c2;
  --blue: #2055d8;
  --blue-dark: #143b9d;
  --orange: #ed5b2a;
  --lime: #d9f36a;
  --danger: #a82416;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(21, 33, 59, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(237, 91, 42, 0.14), transparent 28rem),
    radial-gradient(circle at 94% 12%, rgba(217, 243, 106, 0.32), transparent 24rem),
    var(--paper);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

a {
  color: var(--blue);
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--blue-dark);
}

a:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}

.wrap {
  width: min(1120px, calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(246, 242, 232, 0.88);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem 1.5rem;
  padding-block: 0.9rem;
}

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

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

.brand img {
  border-radius: 9px;
}

.site-header nav,
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.2rem;
}

.site-header nav a {
  color: var(--ink-soft);
  font-size: 0.94rem;
  font-weight: 650;
  text-decoration: none;
}

.site-header nav a:hover,
.site-header nav a[aria-current="page"] {
  color: var(--ink);
}

.site-header nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-color: var(--orange);
  text-decoration-thickness: 3px;
}

.hero {
  padding-block: clamp(2.2rem, 7vw, 5rem) 1.5rem;
}

.hero h1 {
  max-width: 940px;
  margin: 0;
  font-size: clamp(2.15rem, 6vw, 4.4rem);
  line-height: 1.03;
  letter-spacing: -0.055em;
}

.hero-compact h1 {
  max-width: 880px;
  font-size: clamp(2.05rem, 5.2vw, 3.8rem);
}

.eyebrow,
.kicker {
  margin: 0 0 0.55rem;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lede {
  max-width: 720px;
  margin: 1.1rem 0 0;
  color: var(--ink-soft);
  font-size: clamp(1rem, 2vw, 1.18rem);
}

.meta-line {
  margin: 0.9rem 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.tool-section {
  padding-block: 0.5rem 2rem;
}

.tool-card {
  padding: clamp(1rem, 3vw, 2rem);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tool-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin-bottom: 1.35rem;
}

.tool-heading h2 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.tool-heading > p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.field-grid {
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}

.field label {
  font-size: 0.9rem;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 3.2rem;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-size: 1rem;
}

select {
  cursor: pointer;
}

.input-wrap {
  position: relative;
}

.input-wrap input {
  padding-right: 2.8rem;
}

.input-wrap > span {
  position: absolute;
  top: 50%;
  right: 1rem;
  color: var(--ink-soft);
  font-weight: 700;
  transform: translateY(-50%);
}

.field-hint,
.form-note {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.form-error {
  margin: 1rem 0 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgba(168, 36, 22, 0.28);
  border-radius: 10px;
  color: var(--danger);
  background: rgba(168, 36, 22, 0.06);
  font-size: 0.9rem;
  font-weight: 650;
}

.results {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.result {
  display: grid;
  align-content: space-between;
  min-height: 6.3rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #faf7ef;
}

.result span {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.result strong {
  margin-top: 0.35rem;
  font-size: clamp(1.55rem, 4vw, 2.15rem);
  line-height: 1;
  letter-spacing: -0.045em;
}

.result-primary {
  border-color: var(--ink);
  background: var(--ink);
}

.result-primary span {
  color: #cbd3e5;
}

.result-primary strong {
  color: var(--lime);
}

.form-note {
  margin-top: 0.9rem;
}

.section {
  padding-block: clamp(2.8rem, 7vw, 5.5rem);
  border-top: 1px solid var(--line);
}

.section-last {
  padding-bottom: 5rem;
}

.section-heading {
  margin-bottom: 1.5rem;
}

.section-heading h2 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.explain-grid {
  display: grid;
  gap: 1rem;
}

.explain-card,
.worked-example,
.table-card {
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.75);
}

.explain-card h3,
.table-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.06rem;
}

.explain-card p,
.worked-example p {
  margin: 0;
  color: var(--ink-soft);
}

.worked-example {
  margin-top: 1rem;
  border-left: 5px solid var(--orange);
}

.worked-example h3 {
  margin: 0 0 0.45rem;
  font-size: 1.25rem;
}

.assumption-note {
  max-width: 850px;
  margin: 1.25rem 0 0;
  color: var(--ink-soft);
  font-size: 0.94rem;
}

.faq-list {
  display: grid;
  gap: 0.65rem;
}

details {
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

summary {
  cursor: pointer;
  font-weight: 750;
}

details p {
  margin: 0.65rem 0 0;
  color: var(--ink-soft);
}

.game-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 720px;
  padding: 1.2rem 1.35rem;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--lime);
  text-decoration: none;
}

.game-link:hover {
  color: var(--ink);
  background: #cbed42;
}

.game-link span:first-child {
  display: grid;
}

.game-link small {
  color: var(--ink-soft);
}

.game-link span:last-child {
  font-size: 1.6rem;
}

.table-grid {
  display: grid;
  gap: 1rem;
}

.table-card h3 {
  font-size: 1.2rem;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

th,
td {
  padding: 0.62rem 0.35rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--ink-soft);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

th:last-child,
td:last-child {
  text-align: right;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.source-note {
  margin: 1rem 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.tips-list {
  display: grid;
  gap: 0.7rem;
  max-width: 850px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tips-list li {
  padding: 0.85rem 1rem 0.85rem 2.6rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  position: relative;
}

.tips-list li::before {
  content: "\2192";
  position: absolute;
  left: 1rem;
  color: var(--orange);
  font-weight: 800;
}

.back-link {
  margin: 1.3rem 0 0;
  font-weight: 700;
}

.page {
  max-width: 780px;
  min-height: 62vh;
  padding-block: clamp(2.5rem, 7vw, 5rem);
}

.page h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 4rem);
  line-height: 1.04;
  letter-spacing: -0.05em;
}

.prose {
  margin-top: 1.5rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

.prose p {
  margin: 0 0 1rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.55);
}

.footer-inner {
  display: grid;
  gap: 0.75rem;
  padding-block: 1.5rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.footer-inner p {
  margin: 0;
}

.footer-brand {
  color: var(--ink);
  font-weight: 800;
}

.site-footer nav a {
  color: var(--ink-soft);
  font-weight: 650;
}

@media (min-width: 560px) {
  .field-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .result:nth-child(3) {
    grid-column: span 2;
  }
}

@media (min-width: 760px) {
  .results {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .result:nth-child(3) {
    grid-column: auto;
  }

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

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

  .footer-inner {
    grid-template-columns: auto auto 1fr;
    align-items: center;
    justify-content: space-between;
  }

  .footer-inner > p:last-child {
    text-align: right;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
