:root {
  --red: #d01012;
  --yellow: #f5cd2f;
  --blue: #0055bf;
  --green: #237841;
  --ink: #1a1a1a;
  --paper: #fff8e7;
  --card: #ffffff;
  --shadow: 0 8px 0 rgba(0, 0, 0, 0.18);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", "Microsoft JhengHei", "PingFang TC", sans-serif;
  color: var(--ink);
  background: #3b9ae1;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.studs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle at 12px 12px, rgba(255, 255, 255, 0.18) 7px, transparent 8px);
  background-size: 36px 36px;
  z-index: 0;
}

.topbar,
main {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #ffd54a;
  border-bottom: 6px solid #e0a800;
}

.brand {
  flex: 1;
  margin: 0;
  text-align: center;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
}

.page-label {
  font-weight: 700;
  min-width: 7rem;
  text-align: right;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-ghost {
  background: #fff;
  color: var(--ink);
}

.btn-primary,
.btn-brick {
  background: var(--red);
  color: #fff;
}

.btn-yellow {
  background: var(--yellow);
  color: var(--ink);
}

.btn-blue {
  background: var(--blue);
  color: #fff;
}

.btn-xl {
  font-size: 1.25rem;
  padding: 0.9rem 1.6rem;
}

main {
  flex: 1;
  display: flex;
  min-height: 0;
}

.screen {
  display: none;
  width: 100%;
  min-height: 0;
}

.screen.is-active {
  display: flex;
  flex-direction: column;
}

#screen-cover {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.cover-card {
  background: var(--paper);
  border-radius: 28px;
  padding: 28px 36px 36px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 560px;
  border: 6px solid #fff;
}

.cover-hero {
  width: 180px;
  height: 180px;
  object-fit: contain;
  background: #7ec8f5;
  border-radius: 24px;
  margin-bottom: 8px;
}

.cover-kicker {
  margin: 8px 0 0;
  font-weight: 700;
  color: var(--blue);
}

.cover-title {
  margin: 4px 0 0;
  font-size: 2.2rem;
}

.cover-sub {
  margin: 0;
  font-size: 1.2rem;
  color: #555;
}

.cover-desc {
  margin: 16px 0 22px;
  line-height: 1.6;
}

#screen-toc {
  padding: 16px 20px 24px;
  overflow: auto;
}

.toc-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

.toc-head h2 {
  margin: 0 0 12px;
}

.toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.toc-card {
  background: var(--card);
  border: 0;
  border-radius: var(--radius);
  padding: 12px;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
  font: inherit;
}

.toc-card strong {
  display: block;
  font-size: 1.05rem;
}

.toc-card span {
  display: block;
  font-size: 0.85rem;
  color: #444;
  margin-top: 4px;
}

.toc-card.is-seen {
  outline: 4px solid var(--green);
}

.toc-card.is-current {
  outline: 4px solid var(--red);
}

.lesson {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.85fr);
  gap: 16px;
  padding: 16px 16px 0;
  flex: 1;
  min-height: 0;
}

.lesson-art {
  margin: 0;
  background: #111;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.lesson-art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #111;
}

.lesson-card {
  background: var(--paper);
  border-radius: 20px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  overflow: auto;
  border: 5px solid #fff;
}

.lesson-kicker {
  margin: 0;
  font-weight: 800;
  color: var(--red);
  letter-spacing: 0.08em;
}

.lesson-verb {
  margin: 4px 0 8px;
  font-size: 2.6rem;
  line-height: 1;
}

.lesson-meaning {
  margin: 0 0 14px;
  font-size: 1.1rem;
  line-height: 1.45;
}

.example {
  margin: 0 0 16px;
  padding: 12px 14px;
  background: #fff;
  border-left: 8px solid var(--blue);
  border-radius: 8px;
}

.example-en {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
}

.example-zh {
  margin: 6px 0 0;
  color: #333;
}

.lesson-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quiz {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 4px dashed #d8c48a;
}

.quiz-prompt,
.quiz-blank {
  margin: 0 0 8px;
}

.quiz-blank {
  font-size: 1.15rem;
  font-weight: 800;
}

.quiz-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quiz-choices .btn {
  min-width: 5.5rem;
}

.quiz-feedback {
  min-height: 1.4em;
  margin: 10px 0 0;
  font-weight: 800;
}

.quiz-feedback.is-ok {
  color: var(--green);
}

.quiz-feedback.is-bad {
  color: var(--red);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 16px 16px;
}

.pager-num {
  color: #fff;
  font-weight: 800;
  min-width: 8rem;
  text-align: center;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

@media (max-width: 900px) {
  .lesson {
    grid-template-columns: 1fr;
  }

  .lesson-art {
    min-height: 42vh;
  }

  .brand {
    font-size: 1rem;
  }

  .page-label {
    display: none;
  }
}
