:root {
  color-scheme: light;
  font-family: "Noto Sans Thai", "Tahoma", system-ui, sans-serif;
  --blue: #2563eb;
  --ink: #172033;
  --muted: #5d6b82;
  --paper: #fffdf7;
  --line: #dce6f4;
  --yellow: #ffd166;
  --sky: #7dd3fc;
  --green: #86efac;
  --pink: #fda4af;
  --violet: #c4b5fd;
  --orange: #fdba74;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(125, 211, 252, 0.35), transparent 28rem),
    linear-gradient(180deg, #f8fbff 0%, #fff7ed 100%);
  color: var(--ink);
}

button {
  font: inherit;
}

.app-shell {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 0 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 0.95rem;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 8vw, 4.2rem);
  line-height: 1.05;
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.icon-button {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  font-size: 1.5rem;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.25);
}

.content {
  padding-bottom: 28px;
}

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

.table-card {
  min-height: 132px;
  border: 2px solid rgba(23, 32, 51, 0.08);
  border-radius: 8px;
  padding: 16px;
  background: var(--card-color);
  color: #172033;
  text-align: left;
  box-shadow: 0 8px 18px rgba(23, 32, 51, 0.08);
  cursor: pointer;
}

.table-card strong {
  display: block;
  font-size: 2.3rem;
  line-height: 1;
}

.table-card span {
  display: block;
  margin-top: 10px;
  color: rgba(23, 32, 51, 0.74);
  font-weight: 700;
}

.detail {
  display: grid;
  gap: 14px;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--line);
}

.badge {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  font-size: 2.2rem;
  font-weight: 900;
}

.nav-buttons {
  display: flex;
  gap: 8px;
}

.nav-buttons button,
.back-button,
.tool-row button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: #172033;
  color: white;
  font-weight: 800;
}

.back-button {
  background: #e8eef8;
  color: var(--ink);
}

.tool-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.tool-row button {
  background: #2563eb;
}

.tool-row button:nth-child(2) {
  background: #172033;
}

.tool-row button:nth-child(3) {
  background: #f97316;
}

.tool-row button:nth-child(4) {
  background: #0f766e;
}

.stars {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border: 2px solid #f6c453;
  border-radius: 8px;
  padding: 0 14px;
  background: #fff7d6;
  color: #7c2d12;
  font-weight: 900;
}

.facts-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
  border-radius: 8px;
}

.facts-table th,
.facts-table td {
  padding: 14px;
  font-size: 1.15rem;
  text-align: center;
}

.facts-table th {
  background: #eff6ff;
  border-bottom: 2px solid #bfdbfe;
  color: #1d4ed8;
  font-weight: 900;
}

.facts-table th:first-child {
  border-radius: 8px 0 0 8px;
}

.facts-table th:last-child {
  border-radius: 0 8px 8px 0;
}

.facts-table tbody td {
  background: var(--row-bg);
  border-bottom: 2px solid var(--row-line);
  border-top: 2px solid var(--row-line);
}

.facts-table tbody td:first-child {
  border-left: 2px solid var(--row-line);
  border-radius: 8px 0 0 8px;
  font-weight: 800;
}

.facts-table tbody td:last-child {
  border-right: 2px solid var(--row-line);
  border-radius: 0 8px 8px 0;
  color: #0f766e;
  font-size: 1.35rem;
  font-weight: 900;
}

.facts-table .answer-hidden {
  color: #9a3412;
  font-size: 1.5rem;
  background: repeating-linear-gradient(
    -45deg,
    rgba(253, 186, 116, 0.28),
    rgba(253, 186, 116, 0.28) 8px,
    rgba(255, 247, 214, 0.72) 8px,
    rgba(255, 247, 214, 0.72) 16px
  );
}

.speak-row {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  margin-right: 10px;
  padding: 0 10px;
  background: #172033;
  color: white;
  font-size: 0.95rem;
  font-weight: 900;
}

.quiz-card {
  display: grid;
  gap: 18px;
  padding: 18px;
  border: 2px solid #bfdbfe;
  border-radius: 8px;
  background: white;
  box-shadow: 0 10px 24px rgba(23, 32, 51, 0.08);
}

.quiz-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.quiz-top h2 {
  margin-bottom: 8px;
  font-size: clamp(2.4rem, 10vw, 5.6rem);
  line-height: 1;
}

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

.choice-grid button {
  min-height: 84px;
  border: 2px solid #dbeafe;
  border-radius: 8px;
  background: #eff6ff;
  color: #172033;
  font-size: 2rem;
  font-weight: 900;
}

.choice-grid button:nth-child(2) {
  background: #eafff1;
  border-color: #bbf7d0;
}

.choice-grid button:nth-child(3) {
  background: #fff7d6;
  border-color: #fde68a;
}

.choice-grid button:nth-child(4) {
  background: #fff0f3;
  border-color: #fecdd3;
}

.quiz-message {
  margin: 0;
  border-radius: 8px;
  padding: 12px;
  background: #e7f6ff;
  color: #075985;
  font-weight: 900;
  text-align: center;
}

.facts-table tbody tr:nth-child(6n + 1) {
  --row-bg: #fff7d6;
  --row-line: #f6c453;
}

.facts-table tbody tr:nth-child(6n + 2) {
  --row-bg: #e7f6ff;
  --row-line: #7dd3fc;
}

.facts-table tbody tr:nth-child(6n + 3) {
  --row-bg: #eafff1;
  --row-line: #86efac;
}

.facts-table tbody tr:nth-child(6n + 4) {
  --row-bg: #fff0f3;
  --row-line: #fda4af;
}

.facts-table tbody tr:nth-child(6n + 5) {
  --row-bg: #f3efff;
  --row-line: #c4b5fd;
}

.facts-table tbody tr:nth-child(6n) {
  --row-bg: #fff2e4;
  --row-line: #fdba74;
}

@media (max-width: 560px) {
  .app-shell {
    padding: 14px;
  }

  .hero {
    padding-top: 14px;
  }

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

  .table-card {
    min-height: 112px;
    padding: 14px;
  }

  .detail-head {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .tool-row,
  .quiz-top {
    align-items: stretch;
    flex-direction: column;
  }

  .tool-row button,
  .stars {
    width: 100%;
    justify-content: center;
  }
}
