:root {
  color-scheme: light;
  --ink: #33271d;
  --muted: #756650;
  --brown: #75470f;
  --brown-deep: #56300a;
  --gold: #c89536;
  --gold-soft: #e3c575;
  --paper: #fffaf0;
  --paper-deep: #f7eedb;
  --line: #e4c98f;
  --green: #3f7134;
  --green-soft: #edf5e8;
  --red: #9b4333;
  --shadow: 0 18px 50px rgba(89, 60, 23, .12);
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 92% 7%, var(--fw-accent-soft), transparent 28%),
    linear-gradient(135deg, var(--fw-card) 0%, var(--fw-canvas) 100%);
  color: var(--ink);
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button, [role="button"], a { touch-action: manipulation; }
a { color: inherit; }
[hidden] { display: none !important; }

.memory-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--fw-line);
  background: var(--fw-card);
  padding: 10px max(22px, calc((100vw - 1180px) / 2));
  box-shadow: 0 7px 24px var(--fw-shadow);
  backdrop-filter: blur(14px);
}
.memory-brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.memory-brand-mark { display: grid; width: 51px; height: 51px; place-items: center; border: 1px solid var(--line); border-radius: 16px; color: var(--brown); font-size: 31px; }
.memory-brand > span:last-child { display: grid; gap: 1px; }
.memory-brand strong { font-size: 20px; }
.memory-brand small { color: var(--muted); font-size: 11px; letter-spacing: .06em; }
.memory-header nav { display: flex; gap: 8px; }
.memory-header nav button, .memory-header nav a {
  border: 1px solid var(--fw-line);
  border-radius: 11px;
  background: var(--fw-card);
  padding: 10px 15px;
  color: var(--fw-text);
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}
.memory-header nav button[data-start-session] { border-color: var(--brown); background: var(--brown); color: var(--fw-on-action); }

.memory-main { width: min(1180px, calc(100% - 36px)); min-height: calc(100vh - 135px); margin: 28px auto 50px; }
.memory-home { display: grid; gap: 20px; }
.memory-hero, .growth-section, .round-section, .memory-session, .memory-overview article {
  border: 1px solid var(--fw-line);
  background: var(--fw-card);
  box-shadow: var(--shadow);
}
.memory-hero { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 155px; gap: 34px; overflow: hidden; border-radius: 28px; padding: clamp(28px, 5vw, 58px); }
.memory-hero::after { position: absolute; z-index: 0; right: -80px; bottom: -110px; width: 330px; height: 330px; border: 62px solid var(--fw-line); border-radius: 50%; content: ""; pointer-events: none; }
.memory-hero-copy { position: relative; z-index: 2; }
.eyebrow { margin: 0 0 8px; color: var(--fw-accent); font: 800 12px/1.2 Georgia, serif; letter-spacing: .12em; }
.memory-hero h1 { margin: 0; color: var(--fw-text); font-size: clamp(38px, 6vw, 72px); line-height: 1.08; }
.memory-hero-copy > p:not(.eyebrow):not(.memory-status) { max-width: 760px; margin: 18px 0 0; color: var(--fw-muted); font-size: clamp(16px, 2vw, 21px); line-height: 1.8; }
.memory-hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 27px; }
.primary-action, .secondary-action { position: relative; z-index: 3; min-height: 50px; border-radius: 14px; padding: 13px 23px; font-weight: 900; text-decoration: none; }
.primary-action { border: 2px solid var(--fw-success); border-bottom-width: 5px; background: var(--green); color: var(--fw-on-action); cursor: pointer; }
.primary-action:disabled { border-color: var(--fw-line); background: var(--fw-soft); cursor: default; }
.secondary-action { border: 1px solid var(--line); background: var(--fw-card); color: var(--brown); }
.memory-status { margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.memory-status.error { color: var(--red); font-weight: 800; }
.memory-seal { z-index: 1; display: grid; width: 150px; height: 150px; align-self: center; place-items: center; align-content: center; border: 2px solid var(--gold-soft); border-radius: 50%; background: var(--fw-card); box-shadow: inset 0 0 0 10px var(--fw-shadow); color: var(--brown); }
.memory-seal span { color: var(--fw-accent); font-size: 12px; font-weight: 900; letter-spacing: .12em; }
.memory-seal strong { font: 800 48px/1 Georgia, serif; }
.memory-seal small { color: var(--muted); }

.memory-overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.memory-overview article { display: grid; min-height: 125px; align-content: center; gap: 5px; border-radius: 20px; padding: 21px; }
.memory-overview span { color: var(--fw-accent); font-size: 12px; font-weight: 900; }
.memory-overview strong { color: var(--brown); font-size: 29px; }
.memory-overview small { color: var(--muted); line-height: 1.4; }

.growth-section, .round-section { border-radius: 24px; padding: clamp(22px, 4vw, 36px); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.section-heading h2, .round-section h2 { margin: 0; font-size: clamp(26px, 4vw, 38px); }
.section-heading > p, .round-section > div:first-child > p:last-child { margin: 0; color: var(--muted); line-height: 1.65; }
.growth-path { display: grid; grid-template-columns: minmax(100px, 1fr) 28px minmax(100px, 1fr) 28px minmax(100px, 1fr) 28px minmax(100px, 1fr) 28px minmax(100px, 1fr); align-items: center; margin-top: 27px; }
.growth-path > i { height: 3px; background: linear-gradient(90deg, var(--fw-accent-soft), var(--gold)); }
.growth-path button { display: grid; min-height: 155px; place-items: center; align-content: center; gap: 5px; border: 1px solid var(--fw-line); border-bottom-width: 5px; border-radius: 20px; background: var(--fw-card); color: var(--ink); cursor: pointer; }
.growth-path button b { display: grid; width: 37px; height: 37px; place-items: center; border-radius: 50%; background: var(--fw-action); color: var(--fw-on-action); }
.growth-path button span { font-size: 20px; font-weight: 900; }
.growth-path button small { color: var(--muted); }
.growth-path button em { color: var(--green); font-size: 12px; font-style: normal; font-weight: 900; }
.growth-path button.active { border-color: var(--fw-success); background: var(--green-soft); box-shadow: 0 10px 24px var(--fw-shadow); }
.growth-tip { margin: 18px 0 0; border-left: 4px solid var(--gold); background: var(--fw-canvas); padding: 11px 14px; color: var(--fw-muted); line-height: 1.6; }

.round-section { display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, .9fr); align-items: center; gap: 35px; }
.round-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.round-options button { display: grid; min-height: 104px; place-items: center; align-content: center; border: 2px solid var(--fw-line); border-bottom-width: 5px; border-radius: 16px; background: var(--fw-card); color: var(--brown); cursor: pointer; }
.round-options strong { font: 800 31px/1 Georgia, serif; }
.round-options span { font-weight: 900; }
.round-options small { margin-top: 4px; color: var(--muted); }
.round-options button.active { border-color: var(--green); background: var(--green-soft); color: var(--green); }

.memory-session { overflow: hidden; border-radius: 28px; }
.session-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 22px; border-bottom: 1px solid var(--fw-line); background: var(--fw-card); padding: 20px 25px; }
.session-head h2 { margin: 0; font-size: clamp(25px, 4vw, 36px); }
.session-head p:last-child { margin: 5px 0 0; color: var(--muted); }
.session-head > strong { border: 1px solid var(--line); border-radius: 13px; background: var(--fw-card); padding: 10px 13px; color: var(--green); font-size: 21px; }
.back-button { border: 0; background: transparent; color: var(--brown); cursor: pointer; font-weight: 900; }
.memory-question { min-height: 590px; background: linear-gradient(180deg, var(--fw-card), var(--fw-canvas)); padding: clamp(18px, 4vw, 48px); }
.question-card { display: grid; width: min(820px, 100%); min-height: 500px; align-content: start; gap: 17px; margin: 0 auto; border: 1px solid var(--fw-line); border-radius: 25px; background: var(--fw-card); padding: clamp(20px, 5vw, 42px); box-shadow: var(--shadow); }
.question-progress { height: 8px; overflow: hidden; border-radius: 999px; background: var(--fw-soft); }
.question-progress b { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--fw-action), var(--fw-success)); }
.question-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--fw-accent); font-size: 12px; font-weight: 900; }
.question-instruction { margin: 0; color: var(--muted); text-align: center; line-height: 1.6; }
.question-devanagari { margin: 4px 0; color: var(--brown); font-family: "Noto Serif Devanagari", "Noto Serif", serif; font-size: clamp(58px, 11vw, 100px); font-weight: 700; line-height: 1.3; text-align: center; overflow-wrap: normal; word-break: keep-all; }
.question-meaning { border: 2px solid var(--fw-line); border-bottom-width: 6px; border-radius: 20px; background: var(--fw-card); padding: 25px; color: var(--fw-text); font-size: clamp(25px, 5vw, 40px); font-weight: 900; text-align: center; }
.human-audio { justify-self: center; min-height: 43px; border: 1px solid #c59a4e; border-radius: 999px; background: #fff9e9; padding: 9px 17px; color: var(--brown); cursor: pointer; font-weight: 900; }
.human-audio:disabled { border-color: var(--fw-line); color: var(--fw-muted); cursor: default; }
.choice-grid, .recall-grid { display: grid; gap: 10px; }
.choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice-grid button, .recall-grid button { min-height: 60px; border: 2px solid var(--fw-line); border-bottom-width: 5px; border-radius: 15px; background: var(--fw-card); color: var(--fw-text); cursor: pointer; font-weight: 900; }
.choice-grid button.correct { border-color: var(--fw-success); background: var(--fw-success-soft); color: var(--fw-success); }
.choice-grid button.wrong { border-color: var(--fw-danger); background: var(--fw-danger-soft); color: var(--fw-danger); }
.recall-grid { grid-template-columns: repeat(3, 1fr); }
.recall-grid button:first-child { border-color: var(--fw-line); background: var(--fw-danger-soft); color: var(--fw-danger); }
.recall-grid button:last-child { border-color: var(--fw-success); background: var(--fw-success-soft); color: var(--fw-success); }
.spell-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
.spell-form input { min-width: 0; border: 2px solid var(--fw-line); border-radius: 14px; padding: 14px 16px; color: var(--fw-text); font: 700 23px/1.2 Georgia, serif; }
.spell-form button { border: 2px solid var(--fw-success); border-bottom-width: 5px; border-radius: 13px; background: var(--green); padding: 11px 20px; color: var(--fw-on-action); cursor: pointer; font-weight: 900; }
.iast-puzzle { display: grid; gap: 14px; border: 1px solid var(--fw-line); border-radius: 18px; background: var(--fw-card); padding: 16px; }
.iast-puzzle > p { margin: 0; color: var(--fw-muted); font-size: 13px; text-align: center; }
.iast-pattern { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 2px; min-height: 60px; color: var(--brown); font: 800 clamp(27px, 6vw, 42px)/1.35 Georgia, "Noto Serif", serif; letter-spacing: .01em; }
.iast-pattern > span { display: inline-flex; min-height: 50px; align-items: center; }
.iast-gap { display: inline-flex; min-width: 38px; min-height: 50px; align-items: center; justify-content: center; border: 0; border-bottom: 4px solid var(--fw-line); background: var(--fw-canvas); padding: 0 5px; color: var(--fw-accent); cursor: pointer; font: inherit; }
.iast-gap.filled { border-bottom-color: var(--green); background: var(--fw-success-soft); color: var(--fw-success); }
.iast-token-bank { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; }
.iast-token-bank button { min-width: 48px; min-height: 48px; border: 2px solid var(--fw-line); border-bottom-width: 5px; border-radius: 12px; background: var(--fw-card); color: var(--fw-text); cursor: pointer; font: 800 24px/1 Georgia, serif; }
.iast-token-bank button:disabled { border-color: var(--fw-line); background: var(--fw-canvas); color: var(--fw-muted); cursor: default; }
.iast-puzzle-actions { display: grid; grid-template-columns: 1fr 1.5fr; gap: 9px; }
.iast-puzzle-actions button { min-height: 46px; border: 1px solid var(--fw-line); border-radius: 12px; background: var(--fw-card); color: var(--fw-accent); cursor: pointer; font-weight: 900; }
.iast-puzzle-actions button:last-child { border: 2px solid var(--fw-success); border-bottom-width: 5px; background: var(--green); color: var(--fw-on-action); }
.iast-puzzle-actions button.correct { border-color: var(--fw-success); background: var(--green); color: var(--fw-on-action); }
.iast-puzzle-actions button.wrong { border-color: var(--fw-danger); background: var(--fw-danger); color: var(--fw-on-action); }
.iast-puzzle-actions button:disabled { border-color: var(--fw-line); background: var(--fw-soft); color: var(--fw-muted); cursor: default; }
.iast-puzzle-actions button.correct:disabled { border-color: var(--fw-success); background: var(--green); color: var(--fw-on-action); }
.answer-reveal { display: grid; gap: 11px; border: 2px solid var(--fw-line); border-radius: 18px; background: var(--fw-success-soft); padding: 17px; }
.answer-reveal[hidden] { display: none; }
.answer-head { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 5px 14px; }
.answer-head span { grid-row: 1 / 3; color: var(--brown); font-family: "Noto Serif Devanagari", serif; font-size: 48px; }
.answer-head strong { color: var(--brown); font: 800 30px/1.2 Georgia, serif; }
.answer-head b { font-size: 18px; }
.answer-head b.pending-meaning { color: var(--fw-muted); }
.answer-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.answer-tags span { border-radius: 999px; background: var(--fw-canvas); padding: 5px 9px; color: var(--fw-accent); font-size: 12px; font-weight: 800; }
.answer-context { border-left: 4px solid var(--green); background: var(--fw-success-soft); padding: 11px 13px; }
.answer-context.pending { border-color: var(--gold); background: var(--fw-card); }
.answer-context span { color: var(--green); font-size: 11px; font-weight: 900; }
.answer-context p { margin: 5px 0; color: var(--fw-text); font: 700 18px/1.65 Georgia, "Noto Serif Devanagari", serif; }
.answer-context small { color: var(--muted); }
.meaning-quality-note { border-left: 4px solid var(--fw-line); background: var(--fw-canvas); padding: 11px 13px; }
.meaning-quality-note span { color: var(--fw-accent); font-size: 11px; font-weight: 900; }
.meaning-quality-note p { margin: 5px 0 0; color: var(--fw-muted); line-height: 1.6; }
.feedback { border-radius: 13px; background: var(--fw-canvas); padding: 12px 14px; color: var(--fw-muted); line-height: 1.55; }
.feedback.correct { background: var(--fw-success-soft); color: var(--fw-success); font-weight: 800; }
.feedback.wrong { background: var(--fw-danger-soft); color: var(--fw-danger); font-weight: 800; }
.next-button { width: 100%; min-height: 52px; border: 2px solid var(--fw-success); border-bottom-width: 5px; border-radius: 14px; background: var(--green); color: var(--fw-on-action); cursor: pointer; font-weight: 900; }
.next-button:disabled { border-color: var(--fw-line); background: var(--fw-soft); cursor: default; }
.session-empty, .session-summary { display: grid; min-height: 450px; place-items: center; align-content: center; gap: 13px; text-align: center; }
.session-empty > span, .session-summary > span { color: var(--brown); font-family: "Noto Serif Devanagari", serif; font-size: 64px; }
.session-empty h3, .session-summary h3 { margin: 0; font-size: 31px; }
.session-empty p, .session-summary p { max-width: 550px; margin: 0; color: var(--muted); line-height: 1.7; }
.session-summary strong { color: var(--green); font: 800 55px/1 Georgia, serif; }
.summary-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; }

.memory-footer { display: flex; justify-content: center; gap: 20px; border-top: 1px solid var(--fw-line); background: var(--fw-card); padding: 20px max(20px, calc((100vw - 1180px) / 2)); color: var(--muted); font-size: 12px; text-align: center; }

@media (max-width: 900px) {
  .memory-header { position: static; padding: 10px 14px; }
  .memory-brand strong { font-size: 17px; }
  .memory-header nav button:first-child { display: none; }
  .memory-header nav button, .memory-header nav a { padding: 9px 11px; font-size: 12px; }
  .memory-main { width: min(100% - 22px, 760px); margin-top: 14px; }
  .memory-hero { grid-template-columns: minmax(0, 1fr) 105px; gap: 14px; padding: 25px; }
  .memory-seal { width: 100px; height: 100px; }
  .memory-seal strong { font-size: 36px; }
  .memory-overview { grid-template-columns: repeat(2, 1fr); }
  .growth-path { grid-template-columns: 1fr; gap: 8px; }
  .growth-path > i { width: 3px; height: 17px; justify-self: center; }
  .growth-path button { min-height: 88px; grid-template-columns: auto auto 1fr auto; justify-items: start; gap: 9px; padding: 14px; }
  .growth-path button b { grid-row: 1 / 3; }
  .growth-path button small { grid-column: 2 / 4; }
  .growth-path button em { grid-row: 1 / 3; grid-column: 4; align-self: center; }
  .round-section { grid-template-columns: 1fr; gap: 20px; }
}

@media (max-width: 560px) {
  .memory-header { gap: 8px; }
  .memory-brand-mark { width: 42px; height: 42px; border-radius: 12px; font-size: 25px; }
  .memory-brand small { display: none; }
  .memory-header nav button[data-start-session] { display: none; }
  .memory-header nav a { white-space: nowrap; }
  .memory-main { width: calc(100% - 14px); }
  .memory-hero { grid-template-columns: 1fr; border-radius: 20px; padding: 22px 17px; }
  .memory-hero h1 { font-size: 40px; }
  .memory-hero-copy > p:not(.eyebrow):not(.memory-status) { font-size: 15px; }
  .memory-seal { position: absolute; top: 20px; right: 16px; width: 84px; height: 84px; opacity: .92; }
  .memory-seal strong { font-size: 30px; }
  .memory-hero-copy { padding-top: 70px; }
  .memory-hero-actions { display: grid; }
  .primary-action, .secondary-action { width: 100%; text-align: center; }
  .memory-overview { gap: 7px; }
  .memory-overview article { min-height: 108px; border-radius: 15px; padding: 14px; }
  .memory-overview strong { font-size: 25px; }
  .growth-section, .round-section { border-radius: 19px; padding: 18px 14px; }
  .section-heading { display: grid; gap: 7px; }
  .growth-path button { grid-template-columns: auto 1fr auto; }
  .growth-path button small { grid-column: 2; }
  .growth-path button em { grid-column: 3; }
  .round-options { gap: 6px; }
  .round-options button { min-height: 88px; padding: 7px 3px; }
  .round-options strong { font-size: 27px; }
  .round-options small { font-size: 10px; }
  .memory-session { border-radius: 0; }
  .session-head { grid-template-columns: 1fr auto; gap: 8px; padding: 13px 14px; }
  .session-head .back-button { grid-column: 1 / -1; justify-self: start; padding: 0; }
  .session-head h2 { font-size: 24px; }
  .session-head p:last-child { font-size: 12px; }
  .memory-question { min-height: calc(100vh - 165px); padding: 10px 7px 22px; }
  .question-card { min-height: calc(100vh - 190px); border-radius: 19px; padding: 20px 14px; }
  .question-devanagari { font-size: clamp(54px, 20vw, 82px); }
  .choice-grid { grid-template-columns: 1fr; }
  .recall-grid { grid-template-columns: 1fr; }
  .spell-form { grid-template-columns: 1fr; }
  .iast-puzzle { padding: 14px 10px; }
  .iast-pattern { font-size: clamp(25px, 8vw, 36px); }
  .iast-token-bank button { min-width: 44px; min-height: 46px; }
  .iast-puzzle-actions { grid-template-columns: 1fr; }
  .answer-head { grid-template-columns: 1fr; text-align: center; }
  .answer-head span { grid-row: auto; }
  .memory-footer { display: grid; padding: 17px; text-align: center; }
}

/* Course origin details follow the shared light, dark and paper palettes. */
.memory-course-words{margin:16px 0;border-block:1px solid var(--fw-line);padding:4px 0;color:var(--fw-text)}
.memory-course-words summary{min-height:44px;padding:10px 0;cursor:pointer;line-height:1.5;overflow-wrap:anywhere}
.memory-course-group{border-top:1px solid var(--fw-line)}
.memory-course-group>summary{font-weight:700}
.memory-course-source{padding-left:10px}
.memory-course-source>summary{display:flex;justify-content:space-between;gap:12px;font-size:15px}
.memory-course-source small{display:block;color:var(--fw-muted);font-size:13px}
.memory-course-items ul{list-style:none;margin:0;padding:0}
.memory-course-items li{border-top:1px solid var(--fw-line);padding:12px 0;overflow-wrap:anywhere}
.memory-course-items a{display:grid;grid-template-columns:auto 1fr;gap:4px 12px;text-decoration:none;min-height:44px}
.memory-course-items a>span{font-size:23px}.memory-course-items a>strong{font-size:18px}.memory-course-items a>small{grid-column:1/-1;font-size:15px}
.memory-course-items button,.memory-status button,.feedback [data-memory-save-retry]{min-height:44px;padding:8px 14px;border:1px solid var(--fw-line);border-radius:8px;background:var(--fw-card);color:var(--fw-text);cursor:pointer;font:inherit}
.memory-course-words :focus-visible{outline:2px solid var(--fw-accent);outline-offset:3px}

/* Remediation replaces the puzzle in place; it never advances the round. */
.memory-review-prompt{margin:0;color:var(--fw-text);font-size:22px}
.memory-review-prompt[hidden],.memory-retry[hidden],[data-memory-task][hidden],.question-instruction[hidden]{display:none}
.memory-retry{min-height:48px;justify-self:stretch;text-align:center}
.answer-head>*{min-width:0;overflow-wrap:anywhere}
