:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #617080;
  --line: #d8e0e8;
  --paper: #fbfcfd;
  --soft: #eef5f4;
  --brand: #0f766e;
  --brand-dark: #0b5e58;
  --accent: #d97706;
  --blue: #2563eb;
  --rose: #be123c;
  --shadow: 0 18px 45px rgba(28, 43, 56, 0.12);
  font-family:
    Inter, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui,
    sans-serif;
}

* {
  box-sizing: border-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(18px, 5vw, 64px);
  background: rgba(251, 252, 253, 0.92);
  border-bottom: 1px solid rgba(216, 224, 232, 0.9);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.topbar nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar nav a {
  padding: 8px 12px;
  border-radius: 8px;
  color: #344456;
  font-size: 0.94rem;
}

.topbar nav a:hover {
  background: #e7f1ef;
  color: var(--brand-dark);
}

.language-switch {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
}

.lang-btn {
  min-width: 48px;
  min-height: 38px;
  padding: 7px 10px;
}

.lang-btn.active {
  border-color: var(--brand);
  background: #d9f2ed;
  color: var(--brand-dark);
}

.hero {
  min-height: calc(100vh - 76px);
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
  align-items: center;
  gap: clamp(28px, 5vw, 72px);
  padding: clamp(28px, 6vw, 76px) clamp(18px, 5vw, 64px);
  background:
    linear-gradient(90deg, rgba(251, 252, 253, 0.98) 0%, rgba(251, 252, 253, 0.88) 60%),
    repeating-linear-gradient(0deg, rgba(15, 118, 110, 0.08) 0 1px, transparent 1px 44px),
    repeating-linear-gradient(90deg, rgba(217, 119, 6, 0.08) 0 1px, transparent 1px 44px);
}

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

.eyebrow {
  margin: 0 0 10px;
  color: var(--brand-dark);
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  font-size: 0.8rem;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 5.6rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.15;
}

h3 {
  margin: 0 0 10px;
  font-size: 1.18rem;
  line-height: 1.25;
}

.hero-copy > p:not(.eyebrow) {
  max-width: 58ch;
  color: #3d4c5b;
  font-size: 1.08rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.primary,
.secondary,
.primary-btn,
button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 16px;
  background: white;
  color: var(--ink);
  font-weight: 750;
}

.primary,
.primary-btn {
  border-color: var(--brand);
  background: var(--brand);
  color: white;
}

.primary:hover,
.primary-btn:hover {
  background: var(--brand-dark);
}

.secondary:hover,
button:hover {
  border-color: #aac5c1;
  background: #f2faf8;
}

.angle-lab,
.tool-panel,
.game-board,
.game-notes,
.rule-card,
.exam-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.angle-lab {
  padding: 18px;
}

.panel-title,
.game-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.panel-title small {
  display: block;
  color: var(--muted);
}

output {
  min-width: 96px;
  text-align: center;
  border-radius: 8px;
  padding: 10px 14px;
  background: #102a37;
  color: white;
  font-size: 1.4rem;
  font-weight: 900;
}

canvas {
  display: block;
  width: 100%;
  border-radius: 8px;
}

#angleCanvas,
#gameCanvas {
  background: #f7fafc;
  border: 1px solid #dfe8ef;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 6px 12px;
  background: #eef2f7;
  color: #435265;
  font-size: 0.9rem;
  font-weight: 700;
}

.chip.active {
  background: #d9f2ed;
  color: var(--brand-dark);
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.button-grid button {
  min-width: 0;
  padding: 8px;
}

.section {
  padding: clamp(46px, 7vw, 84px) clamp(18px, 5vw, 64px);
}

.section.muted {
  background: var(--soft);
}

.section-heading {
  max-width: 880px;
  margin: 0 auto 28px;
}

.rule-grid,
.exam-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
}

.rule-card,
.exam-card,
.tool-panel,
.game-notes {
  padding: 20px;
}

.rule-card {
  box-shadow: none;
}

.rule-card p,
.exam-card p,
.game-notes li {
  color: #3f4d5c;
}

.rule-card span {
  display: inline-block;
  margin-top: 8px;
  color: var(--brand-dark);
  font-weight: 800;
  font-size: 0.88rem;
}

.mini-canvas {
  height: 150px;
  margin-bottom: 14px;
  background: #f5f8fb;
  border: 1px solid #dfe8ef;
}

.tool-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  max-width: 1120px;
  margin: 0 auto;
}

.glossary-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
}

.glossary-panel,
.vocab-quiz {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 20px;
  box-shadow: var(--shadow);
}

.pdf-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  border-radius: 8px;
  padding: 14px;
  background: #f6fbfa;
  border: 1px solid #cae2de;
}

.pdf-callout strong,
.pdf-callout small {
  display: block;
}

.pdf-callout small {
  color: var(--muted);
}

.glossary-search {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.glossary-search label {
  margin: 0;
}

.filter-row,
.choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter {
  min-height: 38px;
  padding: 7px 12px;
}

.filter.active {
  border-color: var(--brand);
  background: #d9f2ed;
  color: var(--brand-dark);
}

.glossary-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.term-card {
  border: 1px solid #dbe5ed;
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.term-card strong,
.term-card span,
.term-card small {
  display: block;
}

.term-card strong {
  color: #102a37;
}

.term-card span {
  color: var(--brand-dark);
  font-weight: 850;
}

.term-card small {
  margin-top: 6px;
  color: #526271;
}

.vocab-quiz {
  align-self: start;
  box-shadow: none;
}

.choice-list {
  display: grid;
}

.choice-list button {
  width: 100%;
  text-align: left;
  font-weight: 760;
}

label {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  color: #354456;
  font-weight: 760;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cdd8e2;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

input[type="number"] {
  appearance: textfield;
}

textarea {
  resize: vertical;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.result-box {
  min-height: 88px;
  margin-top: 16px;
  border-radius: 8px;
  padding: 14px;
  background: #f7fafc;
  border: 1px dashed #b9c7d4;
  color: #2f4052;
}

.result-box strong {
  color: var(--brand-dark);
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
}

.game-board {
  padding: 18px;
}

.game-top {
  flex-wrap: wrap;
  color: #3a4858;
}

.game-top span {
  border-radius: 8px;
  padding: 8px 10px;
  background: #edf3f6;
  font-weight: 760;
}

#questionText {
  margin-top: 18px;
}

.answer-form {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
}

.answer-form input {
  margin: 0;
}

.feedback {
  min-height: 32px;
  font-weight: 800;
}

.feedback.good {
  color: var(--brand-dark);
}

.feedback.bad {
  color: var(--rose);
}

.next-question {
  display: none;
  margin-top: 10px;
}

.next-question.visible {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.game-notes {
  align-self: start;
  box-shadow: none;
}

.game-notes ol {
  padding-left: 22px;
}

.exam-card {
  box-shadow: none;
}

.ads-section {
  background: #fff;
}

.ad-grid,
.legal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
}

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

.ad-card,
.legal-grid details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: white;
}

.ad-card {
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.tuition-ad {
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.1), transparent 42%),
    #ffffff;
}

.notes-ad {
  background:
    linear-gradient(135deg, rgba(217, 119, 6, 0.12), transparent 42%),
    #ffffff;
}

.contact-ad {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  background:
    linear-gradient(135deg, rgba(30, 64, 175, 0.08), transparent 46%),
    #ffffff;
}

.ad-label {
  display: inline-flex;
  margin-bottom: 12px;
  border-radius: 999px;
  padding: 6px 10px;
  background: #e7f1ef;
  color: var(--brand-dark);
  font-weight: 850;
  font-size: 0.86rem;
}

.ad-card p,
.legal-grid p {
  color: #3f4d5c;
}

.legal-grid summary {
  cursor: pointer;
  color: #102a37;
  font-size: 1.12rem;
  font-weight: 850;
}

.legal-grid details[open] summary {
  margin-bottom: 12px;
  color: var(--brand-dark);
}

.ad-card ul {
  margin: 0 0 18px;
  padding-left: 20px;
  color: #334456;
}

.ad-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.exam-card button {
  margin-top: 8px;
}

.solution {
  display: none;
  margin-top: 12px;
  border-left: 4px solid var(--accent);
  padding: 10px 12px;
  background: #fff8ed;
  color: #4b3a1f;
}

.solution.visible {
  display: block;
}

.solution-canvas {
  width: 100%;
  height: 180px;
  margin: 10px 0 12px;
  background: #f7fafc;
  border: 1px solid #dfe8ef;
}

footer {
  padding: 28px clamp(18px, 5vw, 64px);
  background: #102a37;
  color: #edf7f6;
}

.footer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
  margin-top: 12px;
  color: #b9d0d5;
  font-size: 0.94rem;
}

@media (max-width: 960px) {
  .hero,
  .tool-layout,
  .glossary-layout,
  .game-shell {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .rule-grid,
  .glossary-list,
  .ad-grid,
  .legal-grid,
  .exam-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .topbar {
    position: sticky;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
  }

  .topbar nav {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }

  .topbar nav a {
    flex: 0 0 auto;
  }

  .language-switch {
    width: 100%;
  }

  .lang-btn {
    flex: 1;
  }

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

  .hero {
    padding-top: 24px;
  }

  .angle-lab,
  .game-board,
  .tool-panel,
  .glossary-panel,
  .vocab-quiz,
  .rule-card,
  .exam-card {
    padding: 14px;
  }

  #angleCanvas,
  #gameCanvas {
    min-height: 260px;
  }

  .mini-canvas {
    height: 168px;
  }

  .rule-grid,
  .glossary-list,
  .ad-grid,
  .legal-grid,
  .exam-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .contact-ad {
    grid-template-columns: 1fr;
  }

  .answer-form {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .answer-form button {
    grid-column: span 2;
  }
}
