body.catalog,
body.course-page,
body.play-page {
  background: var(--paper);
  color: var(--ink);
}

.course-wrap {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px 40px;
}

.course-top {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.course-top h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
}

.course-top p { margin: 6px 0 0; color: #66788a; }

.home-label {
  margin: 22px 0 10px;
  font-size: 15px;
  letter-spacing: 0.08em;
}

.today-card { background: #fff6d8; }

.course-grid,
.practice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.practice-grid { grid-template-columns: repeat(3, 1fr); }

.course-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 3px solid #2c2118;
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.course-card .kicker {
  color: #1d4f91;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.course-card h2 { margin: 8px 0; font-size: 24px; }
.course-card p { margin: 0; color: #66788a; line-height: 1.6; }
.bar {
  height: 8px;
  margin-top: 18px;
  background: #e8eef5;
  border-radius: 99px;
  overflow: hidden;
}
.bar span { display: block; height: 100%; background: #1d4f91; }
.course-grid > .side-links {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.course-card { height: 100%; }

.unit { margin-top: 14px; }
.unit h2 { margin: 0 0 4px; font-size: 18px; }
.unit .summary { margin: 0 0 10px; color: #66788a; }
.lesson-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border: 3px solid #2c2118;
  border-bottom-width: 0;
  text-decoration: none;
  color: inherit;
}
.lesson-row:first-of-type { border-radius: 22px 22px 0 0; }
.lesson-row:last-of-type { border-bottom: 3px solid #2c2118; border-radius: 0 0 22px 22px; }
.lesson-no {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e8f0fb;
  color: #1d4f91;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}
.lesson-row.done .lesson-no { background: #e5f6ec; color: #157a45; }
.lesson-row strong { flex: 1; }
.lesson-row em { color: #66788a; font-style: normal; font-size: 13px; }

.player {
  width: min(640px, 100%);
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px 40px;
}
.player-top { display: flex; align-items: center; justify-content: space-between; color: #66788a; font-size: 13px; }
.player h1 { margin: 12px 0; font-size: 24px; line-height: 1.4; }
.lesson-art { display: flex; justify-content: center; min-height: 96px; }
.lesson-art .toy { width: 120px; height: 120px; }
.choice-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice-list button {
  min-height: 84px;
  border-radius: 22px;
  border: 3px solid #2c2118;
  background: var(--card);
  font-size: 32px;
  box-shadow: 0 6px 0 #f3d7b8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid #2c2118;
  flex: none;
}
.choice-list button.yes { background: #e5f6ec; border-color: #157a45; }
.choice-list button.no { background: #fde8e4; border-color: #c2410c; }

.mask {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  top: 0;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  box-sizing: border-box;
  background: rgba(44, 33, 24, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding:
    max(16px, env(safe-area-inset-top, 0px))
    max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px))
    max(16px, env(safe-area-inset-left, 0px));
}

.mask::before,
.mask::after {
  content: "";
  flex: 1 0 0px;
  align-self: stretch;
}

.mask > .dialog,
.mask > .sheet {
  flex: 0 0 auto;
  max-width: 100%;
}

body:has(.mask:not([hidden])) {
  overflow: hidden;
}

.dialog {
  width: min(380px, 100%);
  background: var(--card);
  border: 3px solid #2c2118;
  border-radius: 28px;
  padding: 28px 22px 22px;
  box-shadow: var(--shadow);
}

.dialog h2 {
  margin: 0;
  font-size: 28px;
}

.dialog .sub {
  margin: 8px 0 0;
  color: var(--muted);
}

.dialog input {
  display: block;
  width: 100%;
  min-height: 56px;
  margin: 18px 0 14px;
  padding: 0 16px;
  border: 3px solid #2c2118;
  border-radius: 16px;
  background: white;
  font-size: 20px;
}

.dialog input::placeholder { color: #b7a394; }

.dialog .remember {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}
.dialog .remember input {
  width: 22px;
  height: 22px;
  min-height: 22px;
  margin: 0;
  padding: 0;
  border-radius: 6px;
  flex: none;
}
.sheet {
  width: min(400px, 100%);
  background: #fffdf9;
  border: 3px solid #2c2118;
  border-radius: 28px;
  padding: 18px 18px 12px;
  box-shadow: var(--shadow);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 26px; }
.sheet-x {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid #2c2118;
  background: white;
  font-size: 22px;
  line-height: 1;
}
.sheet-meta { margin: 10px 0 0; color: #7a6556; font-size: 15px; }
.sheet-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  margin-top: 14px;
  padding: 0 16px;
  border: 3px solid #2c2118;
  border-radius: 18px;
  background: #fff6d8;
  text-decoration: none;
  font-size: 18px;
  font-weight: 800;
}
.sheet-link span { font-size: 28px; line-height: 1; }
.sheet h3 { margin: 18px 0 10px; font-size: 16px; }
.sheet label { display: grid; gap: 6px; margin-bottom: 10px; color: #7a6556; font-size: 14px; }
.sheet input {
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 0 14px;
  border: 3px solid #2c2118;
  border-radius: 14px;
  background: white;
  font-size: 18px;
}
.sheet-primary {
  width: 100%;
  min-height: 50px;
  margin-top: 4px;
  border: 3px solid #2c2118;
  border-radius: 999px;
  background: var(--orange);
  color: white;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 5px 0 #e15d12;
}
.sheet-quit {
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  border: 0;
  background: transparent;
  color: #c2410c;
  font-size: 16px;
  font-weight: 800;
}

.dialog .btn + .btn { margin-top: 10px; background: white; color: #2c2118; }

.dialog .btn {
  display: block;
  width: 100%;
  min-height: 56px;
  border: 3px solid #2c2118;
  border-radius: 999px;
  background: var(--orange);
  color: white;
  font-size: 20px;
  font-weight: 700;
  box-shadow: 0 6px 0 #e15d12;
}

.replay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}
.replay-btn {
  min-width: 88px;
  height: 56px;
  padding: 0 16px;
  border-radius: 999px;
  border: 3px solid #2c2118;
  background: #ffd36a;
  box-shadow: 0 5px 0 #f3d7b8;
  font-size: 18px;
  font-weight: 800;
}
.replay-count {
  min-width: 56px;
  height: 56px;
  border-radius: 18px;
  border: 3px solid #2c2118;
  background: white;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 800;
}

.glyph-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.glyph {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-height: 92px;
  padding: 10px 6px 8px;
  border-radius: 18px;
  border: 3px solid #2c2118;
  background: var(--card);
  box-shadow: 0 4px 0 #f3d7b8;
}
.glyph strong {
  font-size: 36px;
  line-height: 1;
}
.glyph span {
  color: #7a6556;
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
}
.glyph.on { background: #e5f6ec; }
.map-path { display: grid; gap: 0; margin-top: 8px; }
.map-stop {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}
.map-rail { display: flex; flex-direction: column; align-items: center; }
.map-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid #2c2118;
  background: white;
  flex: none;
}
.map-stop.done .map-dot { background: #ffd36a; }
.map-line { width: 4px; flex: 1; min-height: 28px; background: #f3d7b8; }
.map-stop:last-child .map-line { display: none; }
.map-card {
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 3px solid #2c2118;
  border-radius: 18px;
  background: var(--card);
}
.map-card h2 { margin: 0; font-size: 20px; }
.map-card p { margin: 6px 0 0; color: #7a6556; }
.history { display: grid; gap: 8px; }
.history-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: white;
  border: 3px solid #2c2118;
}
.history-row span { color: #7a6556; }

.glyph-done {
  display: block;
  width: 100%;
  margin-top: 18px;
  min-height: 52px;
  border-radius: 999px;
  border: 3px solid #2c2118;
  background: #ffd36a;
  font-size: 18px;
  font-weight: 800;
}
@media (max-height: 700px) {
  .dialog {
    padding: 16px 16px 14px;
    border-radius: 20px;
  }
  .dialog h2 { font-size: 22px; }
  .dialog .sub { margin-top: 4px; }
  .dialog input {
    min-height: 44px;
    margin: 10px 0 8px;
    font-size: 16px;
  }
  .dialog .remember { margin-bottom: 10px; }
  .dialog .btn {
    min-height: 46px;
    font-size: 18px;
    box-shadow: 0 4px 0 #e15d12;
  }
  .sheet { padding: 14px 14px 10px; }
  .sheet-link { min-height: 48px; margin-top: 10px; }
  .sheet input { min-height: 42px; }
}

@media (min-width: 720px) {
  .glyph-grid { grid-template-columns: repeat(6, 1fr); }
}

@media (max-width: 720px) {
  .course-grid, .practice-grid, .choice-list, .course-grid > .side-links { grid-template-columns: 1fr; }
}
