:root {
  --ink: #173229;
  --muted: #687c74;
  --green: #198b67;
  --green-dark: #0d6e50;
  --green-soft: #e8f5ef;
  --cream: #fbfaf5;
  --coral: #ef785e;
  --yellow: #f3b84b;
  --line: #dde8e2;
  --white: #fff;
  --shadow: 0 18px 55px rgba(24, 50, 41, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 5%, rgba(243, 184, 75, 0.14), transparent 23rem),
    linear-gradient(180deg, #f4faf7, var(--cream) 48%, #f8f3e8);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP",
    "Noto Sans Myanmar", "Noto Sans Devanagari", sans-serif;
}

button, select { color: inherit; font: inherit; }

button:focus-visible, select:focus-visible {
  outline: 3px solid rgba(239, 120, 94, 0.45);
  outline-offset: 3px;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px max(18px, calc((100vw - 920px) / 2));
  border-bottom: 1px solid rgba(221, 232, 226, 0.85);
  background: rgba(251, 250, 245, 0.9);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-home {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.brand-icon {
  display: block;
  width: 43px;
  height: 43px;
  margin-right: 10px;
  border-radius: 14px 14px 14px 5px;
  box-shadow: 0 6px 14px rgba(24, 50, 41, 0.14);
  object-fit: cover;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.brand-home:hover .brand-icon {
  transform: translateY(-1px);
  box-shadow: 0 9px 18px rgba(24, 50, 41, 0.18);
}

.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.header-actions { display: flex; gap: 8px; }

.icon-button, .language-button, .home-button {
  border: 1px solid var(--line);
  background: var(--white);
  cursor: pointer;
}

.home-button {
  padding: 9px 13px;
  border-radius: 999px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: var(--green);
  font-size: 23px;
}

.language-button {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 9px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.app-shell {
  width: min(100% - 32px, 760px);
  margin: 0 auto;
  padding: 30px 0 70px;
}

.home-view {
  display: grid;
  gap: 22px;
}

.home-hero {
  padding: 10px 0 2px;
  text-align: center;
}

.home-hero h1 {
  margin: 0;
  font-size: clamp(32px, 8vw, 52px);
  letter-spacing: 0.03em;
}

.home-hero .eyebrow {
  font-size: clamp(13px, 3.2vw, 17px);
  letter-spacing: 0.08em;
}

.home-prompt {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.home-prompt-translation {
  margin: 5px 0 0;
  color: #7b8d86;
  font-size: 12px;
  line-height: 1.55;
}

.scene-menu {
  display: grid;
  gap: 18px;
}

.scene-tile {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(150px, 28vw, 220px);
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: var(--green-soft);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
}

.scene-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 260ms ease;
}

.scene-tile:hover img { transform: scale(1.035); }

.scene-tile-overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(12, 34, 26, 0.78), rgba(12, 34, 26, 0.2) 58%, rgba(12, 34, 26, 0.08)),
    linear-gradient(0deg, rgba(12, 34, 26, 0.25), transparent 55%);
}

.scene-tile-text {
  position: absolute;
  inset: auto 22px 20px 22px;
  color: white;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.28);
}

.scene-tile-text small,
.scene-tile-text strong {
  display: block;
}

.scene-tile-text small {
  max-width: min(88%, 520px);
  margin-top: 8px;
  font-size: clamp(13px, 3vw, 17px);
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.35;
  opacity: 0.92;
}

.scene-tile-text strong {
  font-size: clamp(26px, 6vw, 42px);
  line-height: 1.15;
}

.meal-tile img { object-position: center 24%; }
.wakeup-tile img { object-position: center 25%; }
.mobility-tile img { object-position: center 42%; }
.toileting-tile img { object-position: center 42%; }
.bathing-tile img { object-position: center center; }

.lesson-view[hidden],
.home-view[hidden] {
  display: none;
}

.title-row { display: flex; gap: 16px; align-items: center; }

.scene-icon {
  display: grid;
  flex: 0 0 66px;
  height: 66px;
  place-items: center;
  border-radius: 22px;
  background: #fff5d8;
  box-shadow: 0 10px 25px rgba(129, 96, 28, 0.09);
  font-size: 31px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lesson-heading h1 { margin: 0; font-size: clamp(27px, 6vw, 38px); }
.lesson-title-translation {
  margin: 5px 0 0;
  color: var(--green-dark);
  font-size: clamp(14px, 3.4vw, 18px);
  font-weight: 850;
  line-height: 1.35;
}

.lesson-heading p#lessonDescription {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.lesson-description-translation {
  margin: 5px 0 0;
  color: #7b8d86;
  font-size: 12px;
  line-height: 1.55;
}

.summary-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 15px;
  align-items: center;
  margin-top: 25px;
  padding: 17px 20px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: rgba(255, 255, 255, 0.8);
}

.summary-card > div:first-child span,
.summary-card > div:first-child strong { display: block; }
.summary-card > div:first-child span { color: var(--muted); font-size: 10px; }
.summary-card > div:first-child strong { margin-top: 2px; }
.summary-card > strong { color: var(--green); }

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 99px;
  background: #e4ece8;
}

.progress-track div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #61ba99);
  transition: width 250ms ease;
}

.practice-card {
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: white;
  box-shadow: var(--shadow);
}

.card-meta { display: flex; justify-content: space-between; align-items: center; }
.phrase-number {
  padding: 6px 10px;
  border-radius: 99px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 11px;
  font-weight: 900;
}

.favorite-button {
  border: 0;
  color: var(--yellow);
  background: transparent;
  cursor: pointer;
  font-size: 27px;
}

.favorite-button.selected { color: #e9a51d; }

.situation-translation span,
.meaning-grid span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.scene-figure {
  margin: 18px 0 0;
  overflow: hidden;
  border-radius: 20px;
  background: #f1f7f4;
}

.scene-figure img {
  display: block;
  width: 100%;
  height: clamp(240px, 44vw, 360px);
  object-fit: cover;
}

.phrase-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 18px 0 16px;
}

.japanese-block {
  display: grid;
  min-height: 88px;
  place-content: center;
  text-align: left;
}

.reading {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.japanese-block h2 {
  max-width: 620px;
  margin: 0;
  font-size: clamp(21px, 4.5vw, 30px);
  line-height: 1.4;
}

.meaning-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.meaning-grid > div {
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.meaning-grid p { margin: 5px 0 0; font-size: 13px; line-height: 1.55; }
.translation-box { background: var(--green-soft); }

.play-button, .complete-button {
  border-radius: 15px;
  cursor: pointer;
  font-weight: 900;
}

.play-button {
  display: flex;
  width: 100%;
  min-height: 48px;
  gap: 6px;
  align-items: center;
  justify-content: center;
  border: 0;
  color: white;
  background: var(--green);
  box-shadow: 0 9px 20px rgba(25, 139, 103, 0.2);
}

.play-button.playing { background: var(--coral); }
.play-icon { margin-right: 8px; }

.audio-controls {
  display: grid;
  width: 112px;
  gap: 5px;
}

.audio-controls label {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-align: center;
}

.audio-controls select {
  width: 100%;
  padding: 7px 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  font-size: 10px;
}

.complete-button {
  width: 100%;
  min-height: 48px;
  margin-top: 13px;
  border: 1px solid var(--green);
  color: var(--green-dark);
  background: white;
}

.complete-button.completed { color: white; background: var(--green); }

.pagination {
  display: grid;
  grid-template-columns: 90px 1fr 90px;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
}

.pagination > button {
  padding: 9px;
  border: 0;
  color: var(--green-dark);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
}

#paginationDots { display: flex; gap: 5px; justify-content: center; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: #cad8d1; }
.dot.active { width: 19px; border-radius: 99px; background: var(--green); }
.dot.complete { background: #65b596; }

.sheet {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: none;
}

.sheet.open { display: block; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: rgba(12, 28, 22, 0.5);
}

.sheet-dialog {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  max-width: 560px;
  max-height: 88vh;
  margin: auto;
  padding: 12px 20px 28px;
  overflow-y: auto;
  border-radius: 27px 27px 0 0;
  background: white;
}

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 0 auto 18px;
  border-radius: 99px;
  background: #d4ded9;
}

.sheet-dialog h2 { margin: 0 0 17px; font-size: 20px; }
.language-option {
  display: grid;
  width: 100%;
  grid-template-columns: 46px 1fr auto;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: white;
  cursor: pointer;
  text-align: left;
}

.language-option.selected { border-color: var(--green); background: var(--green-soft); }
.language-badge {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: var(--green);
  font-size: 11px;
  font-weight: 900;
}

.language-option strong, .language-option small { display: block; }
.language-option small { color: var(--muted); }
.language-check { color: var(--green); font-weight: 900; }

.report-score {
  display: grid;
  margin-bottom: 18px;
  padding: 20px;
  place-items: center;
  border-radius: 19px;
  background: var(--green-soft);
}

.report-score strong { color: var(--green-dark); font-size: 42px; }
.report-score span { color: var(--muted); font-size: 11px; }
.stage-report { display: grid; gap: 8px; }
.stage-row { display: grid; grid-template-columns: 90px 1fr 42px; gap: 10px; align-items: center; font-size: 12px; }
.stage-bar { height: 7px; overflow: hidden; border-radius: 99px; background: #e5ece8; }
.stage-bar div { height: 100%; background: var(--green); }
.progress-dialog h3 { margin: 23px 0 10px; font-size: 14px; }
.phrase-report { display: grid; gap: 6px; }
.report-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}

.report-status { color: var(--green); font-weight: 900; }

.toast {
  position: fixed;
  z-index: 60;
  bottom: 24px;
  left: 50%;
  padding: 12px 18px;
  border-radius: 99px;
  color: white;
  background: var(--ink);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: 220ms ease;
  font-size: 12px;
  font-weight: 800;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 620px) {
  .topbar { padding: 10px 13px; }
  .brand small { display: none; }
  .language-button { max-width: 138px; }
  #languageLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-shell { width: min(100% - 24px, 760px); padding-top: 22px; }
  .practice-card { padding: 20px; border-radius: 23px; }
  .scene-figure {
    margin-right: -8px;
    margin-left: -8px;
    border-radius: 17px;
  }
  .scene-figure img { height: 260px; }
  .phrase-row { gap: 9px; padding: 15px 0 13px; }
  .audio-controls { width: 94px; }
  .play-button { padding: 0 10px; }
  .meaning-grid { grid-template-columns: 1fr; }
  .japanese-block { min-height: 160px; }
  .summary-card { grid-template-columns: auto 1fr auto; padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
