:root {
  --bg: #f8fbff;
  --panel: #ffffff;
  --text: #1d2733;
  --muted: #5b6675;
  --line: #d8e1ee;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #15803d;
  --red: #b91c1c;
  --amber: #b45309;
  --soft-blue: #eaf2ff;
  --soft-green: #eaf8ef;
  --soft-yellow: #fff7df;
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
}

body {
  font-size: 18px;
  line-height: 1.65;
}

a {
  color: var(--blue-dark);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.site-header,
.site-footer {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.site-footer {
  margin-top: 48px;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.nav,
.footer-inner,
.container {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
}

.brand {
  color: var(--text);
  font-size: 22px;
  font-weight: 900;
  text-decoration: none;
}

.nav-links,
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
}

.nav-links a,
.footer-links a {
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
}

.hero {
  padding: 34px 0 18px;
}

.hero h1,
.content h1 {
  margin: 0 0 12px;
  font-size: clamp(34px, 8vw, 56px);
  line-height: 1.12;
}

.hero p,
.lead {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 20px;
}

.section {
  padding: 22px 0;
}

.section h2,
.content h2 {
  margin: 0 0 14px;
  font-size: 28px;
  line-height: 1.25;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.card {
  display: block;
  min-height: 132px;
  padding: 18px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(24, 39, 75, 0.06);
}

.card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 22px;
}

.card span {
  color: var(--muted);
  font-size: 16px;
}

.quiz-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
  margin: 24px 0;
}

.quiz-panel,
.side-panel,
.content-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(24, 39, 75, 0.06);
}

.quiz-panel {
  padding: 20px;
}

.side-panel {
  padding: 16px;
}

.mode-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 16px;
  color: #fff;
  background: var(--blue);
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--blue-dark);
}

.mode-button {
  color: var(--text);
  background: var(--soft-blue);
  border: 2px solid transparent;
}

.mode-button[aria-pressed="true"] {
  border-color: var(--blue);
  background: #dbeafe;
}

.secondary {
  color: var(--blue-dark);
  background: var(--soft-blue);
}

.secondary:hover {
  color: #fff;
}

.danger {
  background: var(--red);
}

.quiz-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.question {
  margin: 18px 0 12px;
  font-size: clamp(42px, 12vw, 72px);
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
}

.answer-display {
  display: block;
  width: 100%;
  min-height: 64px;
  margin: 0 auto 14px;
  padding: 8px 14px;
  color: var(--text);
  background: #fff;
  border: 3px solid var(--line);
  border-radius: 8px;
  font-size: 36px;
  font-weight: 900;
  text-align: center;
}

.feedback {
  min-height: 48px;
  margin: 12px 0;
  font-size: 22px;
  font-weight: 900;
  text-align: center;
}

.feedback.correct {
  color: var(--green);
}

.feedback.wrong {
  color: var(--red);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-width: 420px;
  margin: 0 auto;
}

.keypad button {
  min-height: 62px;
  font-size: 28px;
}

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

.result-item {
  padding: 12px;
  background: var(--soft-green);
  border-radius: 8px;
  text-align: center;
}

.result-item strong {
  display: block;
  font-size: 26px;
}

.stars {
  margin: 8px 0;
  color: var(--amber);
  font-size: 30px;
  text-align: center;
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.hidden {
  display: none !important;
}

.ad-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 92px;
  margin: 24px 0;
  color: var(--muted);
  background: #f3f6fb;
  border: 2px dashed #bfccda;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 800;
}

.content {
  padding: 28px 0 0;
}

.content-box {
  padding: 20px;
}

.link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0;
  list-style: none;
}

.link-list a {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  padding: 6px 12px;
  background: var(--soft-yellow);
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
}

.footer-inner {
  padding: 24px 0;
  color: var(--muted);
  font-size: 15px;
}

@media (max-width: 760px) {
  body {
    font-size: 17px;
  }

  .nav {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 0;
  }

  .quiz-shell {
    grid-template-columns: 1fr;
  }

  .quiz-panel,
  .side-panel,
  .content-box {
    padding: 16px;
  }

  .mode-row,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .keypad button {
    min-height: 58px;
  }
}
