/* ---------------------------------------------------------------------------
   My English - app styles.
   Design rules that everything below serves:
     - one screen, one job, one obvious action
     - nothing tappable that is not part of the lesson
     - large targets (nothing under 72px), calm colours, no flashing
     - no scrolling on learner screens; nothing can be swiped away by accident
--------------------------------------------------------------------------- */

:root {
  --bg: #fbf6ec;
  --surface: #ffffff;
  --ink: #241f1a;
  --ink-soft: #6b6157;
  --line: #e6dcca;

  --teal: #0e7c6f;
  --teal-dark: #0a5d53;
  --amber: #e08a2e;
  --plum: #7a4fa3;
  --rose: #c8496b;
  --green: #2f9e50;

  --radius: 28px;
  --shadow: 0 6px 0 rgba(0, 0, 0, 0.10);
  --font: 'Segoe UI', system-ui, -apple-system, 'Noto Sans', sans-serif;
  --font-hi: 'Nirmala UI', 'Noto Sans Devanagari', 'Mangal', var(--font);
  --font-emoji: 'Segoe UI Emoji', 'Noto Color Emoji', 'Apple Color Emoji', sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  /* Nothing on a learner screen should be selectable, draggable or zoomable. */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

#root {
  height: 100dvh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
}

.emoji {
  font-family: var(--font-emoji);
  line-height: 1;
}

.hi {
  font-family: var(--font-hi);
}

/* --- screen shell -------------------------------------------------------- */

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2vh, 20px);
  padding: clamp(12px, 2.5vh, 24px);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}

.home-btn {
  width: clamp(64px, 9vh, 88px);
  height: clamp(64px, 9vh, 88px);
  flex: 0 0 auto;
  border-radius: 22px;
  background: var(--surface);
  border: 3px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-size: clamp(30px, 4.5vh, 42px);
  transition: transform 0.08s ease;
}

.home-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
}

/* Star strip: pure feedback, never interactive, never a way to lose. */
.stars {
  flex: 1;
  display: flex;
  gap: clamp(4px, 1vw, 10px);
  align-items: center;
  justify-content: flex-end;
  pointer-events: none;
  min-width: 0;
  overflow: hidden;
  /* Ten stars plus the home button must fit the narrowest phone, so the width
     of the screen caps the size as well as its height. */
  font-size: min(clamp(18px, 3.4vh, 34px), 4.2vw);
}

.stars span {
  opacity: 0.22;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.stars span.on {
  opacity: 1;
  transform: scale(1.12);
}

/* --- home ---------------------------------------------------------------- */

.home {
  justify-content: center;
  gap: clamp(14px, 3vh, 28px);
}

.home-title {
  text-align: center;
  flex: 0 0 auto;
}

.home-title .big {
  font-size: clamp(28px, 5vh, 46px);
  font-weight: 800;
  letter-spacing: -0.5px;
}

.home-title .sub {
  font-size: clamp(17px, 2.6vh, 24px);
  color: var(--ink-soft);
  margin-top: 4px;
}

.tiles {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(12px, 2.4vh, 22px);
}

.tile {
  border-radius: var(--radius);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1.2vh, 12px);
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.16);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  padding: 10px;
  min-height: 108px;
}

.tile:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.16);
}

.tile .ico {
  font-size: clamp(38px, 8vh, 76px);
}

.tile .lab-hi {
  font-family: var(--font-hi);
  font-size: clamp(20px, 3.4vh, 34px);
  font-weight: 700;
}

.tile .lab-en {
  font-size: clamp(13px, 1.9vh, 19px);
  opacity: 0.9;
  letter-spacing: 0.4px;
}

.t-words   { background: var(--teal); }
.t-listen  { background: var(--amber); }
.t-read    { background: var(--plum); }
.t-phrases { background: var(--rose); }
.t-sentences { background: var(--teal-dark); }
.t-money { background: #8a5a2b; }

/* An odd number of tiles would leave a hole, so the last one spans instead. */
.tiles .tile:last-child:nth-child(odd) { grid-column: 1 / -1; }

/* The written-down corner code. Inert by design: pointer-events off means it
   can never open the panel by being tapped, and never eats a corner tap that
   lands on top of it. */
.hint {
  flex: 0 0 auto;
  text-align: center;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  color: var(--ink-soft);
  opacity: 0.62;
  line-height: 1.35;
  padding: 0 6px;
}

.hint-label {
  font-size: clamp(10px, 1.4vh, 12px);
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.hint-steps {
  font-size: clamp(11px, 1.5vh, 13px);
}

.hint-steps b {
  font-weight: 600;
  white-space: nowrap;
}

/* Invisible caregiver corners. No hover, no cursor, no visual trace: a stray
   tap here must produce nothing at all. */
.corner {
  position: fixed;
  width: 60px;
  height: 60px;
  z-index: 40;
  background: transparent;
  cursor: default;
}

/* The bottom two must clear the system gesture strip on Android, which would
   otherwise swallow the tap - but they are STRETCHED down to the real edge
   rather than lifted off it. Lifting them left a 24px dead strip along the
   bottom of the screen, and on a desktop that is exactly where the pointer
   goes: a mouse is aimed at the corner itself, which is an infinitely large
   target, so the click landed on the page and silently reset the sequence.
   A finger taps approximately and lands inside the box, which is why this only
   ever failed with a mouse.

   Extending downward costs nothing on Android: the gesture bar still takes the
   taps inside its own strip, and everything above it lands as before. */
.corner { bottom: auto; }
.corner.tl { top: 0; left: 0; }
.corner.tr { top: 0; right: 0; }
.corner.bl,
.corner.br {
  top: auto;
  bottom: 0;
  height: calc(env(safe-area-inset-bottom) + 84px);
}
.corner.bl { left: 0; }
.corner.br { right: 0; }

/* --- category grid ------------------------------------------------------- */

.grid-cats {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(120px, 26vw, 200px), 1fr));
  grid-auto-rows: 1fr;
  gap: clamp(10px, 1.8vh, 18px);
}

.cat {
  border-radius: 22px;
  background: var(--surface);
  border: 3px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 92px;
  transition: transform 0.08s ease;
}

.cat:active {
  transform: translateY(4px);
}

.cat .ico { font-size: clamp(30px, 5.4vh, 52px); }
.cat .lab-hi { font-family: var(--font-hi); font-size: clamp(16px, 2.4vh, 24px); font-weight: 700; }
.cat .lab-en { font-size: clamp(12px, 1.6vh, 16px); color: var(--ink-soft); }

/* --- word / phrase card -------------------------------------------------- */

.card {
  flex: 1;
  min-height: 0;
  border-radius: var(--radius);
  background: var(--surface);
  border: 4px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.6vh, 18px);
  padding: clamp(10px, 2vh, 24px);
  text-align: center;
  transition: transform 0.09s ease;
}

.card:active { transform: scale(0.99); }

.card .pic {
  font-size: clamp(64px, 22vh, 190px);
}

.card .pic-swatch {
  width: clamp(90px, 20vh, 180px);
  height: clamp(90px, 20vh, 180px);
  border-radius: 50%;
  border: 5px solid rgba(0, 0, 0, 0.14);
}

.card .pic-num {
  font-size: clamp(80px, 24vh, 200px);
  font-weight: 800;
  color: var(--teal);
  line-height: 1;
}

.card .word-en {
  font-size: clamp(34px, 7vh, 74px);
  font-weight: 800;
  letter-spacing: 0.5px;
}

.card .word-en.phrase {
  font-size: clamp(24px, 4.6vh, 48px);
  line-height: 1.2;
}

.card .word-hi {
  font-family: var(--font-hi);
  font-size: clamp(24px, 4.4vh, 46px);
  color: var(--teal-dark);
  font-weight: 600;
}

.card .word-hi.phrase {
  font-size: clamp(19px, 3.2vh, 34px);
}

.sent-pic {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1.4vw, 16px);
  min-width: 0;
  max-width: 100%;
}

/* The verb reads as a modifier of the object, so it sits smaller - but sized
   explicitly, never in em. `.verb` and `.pic`/`.ico` sit on the same element
   and have equal specificity, so a relative size here resolves against the
   inherited body size and collapses the glyph to ~10px. */
/* A verb glyph may be two emoji (👀⏪). They must read as one unit, so they
   never wrap - the sizes below keep the pair inside a choice tile. */
.sent-pic .verb { opacity: 0.9; white-space: nowrap; }

/* Noun sizes. Width caps the size as well as height, so two pictures always fit
   one tile on a narrow phone. */
.card .sent-pic .pic          { font-size: min(clamp(64px, 22vh, 190px), 34vw); }
.choice .sent-pic .ico        { font-size: min(clamp(34px, 11vh, 100px), 17vw); }
.choices.n3 .sent-pic .ico    { font-size: min(clamp(26px, 8vh, 74px), 11vw); }

/* Verb sizes. These MUST come after the noun rules: `.verb` and `.pic`/`.ico`
   sit on the same element with equal specificity, so source order decides, and
   the verb is meant to read as the smaller modifier. Sizes are absolute, never
   em - a relative size resolves against the inherited body size and collapses
   the glyph to about 10px. */
.card .sent-pic .verb         { font-size: min(clamp(32px, 11vh, 96px), 16vw); }

/* Sized by how many glyphs are in the icon, because they sit side by side and
   an emoji renders about a third wider than its font size. Two glyphs plus the
   object already fills a 360px phone; three overflowed it.

   ORDER MATTERS, exactly as it does above: the verb span is class
   "emoji pic verb", so .pic and .verb both match it at equal specificity and
   whichever is written last wins. The object rules go first and the verb rule
   last, or the verb gets sized like an object and runs off the screen - which
   is the failure these rules were added to fix. */
.card .sent-pic.g2 .pic       { font-size: min(clamp(52px, 18vh, 158px), 30vw); }
.card .sent-pic.g2 .pic-num   { font-size: min(clamp(52px, 18vh, 158px), 30vw); }
.card .sent-pic.g2 .pic-swatch { width: 30vw; height: 30vw; }
.card .sent-pic.g2 .verb      { font-size: min(clamp(26px, 9vh, 76px), 13vw); }

.card .sent-pic.g3 .pic       { font-size: min(clamp(44px, 15vh, 130px), 24vw); }
.card .sent-pic.g3 .pic-num   { font-size: min(clamp(44px, 15vh, 130px), 24vw); }
.card .sent-pic.g3 .pic-swatch { width: 24vw; height: 24vw; }
.card .sent-pic.g3 .verb      { font-size: min(clamp(20px, 7vh, 58px), 9.5vw); }
.choice .sent-pic .verb       { font-size: min(clamp(18px, 5.5vh, 52px), 7vw); }
.choices.n3 .sent-pic .verb   { font-size: min(clamp(14px, 4vh, 36px), 4.6vw); }

.shop-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 3vw, 32px);
}

.price {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.price .rupee { font-size: clamp(16px, 2.4vh, 26px); color: var(--ink-soft); }
.price .amount { font-size: min(clamp(44px, 12vh, 110px), 20vw); font-weight: 800; color: var(--teal-dark); }
.price .amount-hi { font-size: clamp(15px, 2.2vh, 24px); color: var(--ink-soft); margin-top: 4px; }

/* The arithmetic, shown plainly above the choices. */
.sum {
  flex: 0 0 auto;
  text-align: center;
  font-size: clamp(26px, 4.6vh, 48px);
  font-weight: 800;
  color: var(--ink-soft);
  letter-spacing: 2px;
}

.money-ask { flex: 0 0 auto; padding: clamp(10px, 2vh, 20px); }
.money-ask .ask-en {
  font-size: clamp(20px, 3.4vh, 36px);
  font-weight: 800;
  text-align: center;
}
.money-ask .ask-hi {
  font-size: clamp(17px, 2.8vh, 30px);
  color: var(--teal-dark);
  text-align: center;
  margin-top: 4px;
}

/* The item picture shares the card with two lines of text, so it cannot claim
   the same height it does on a plain word card. */
.money-card .pic { font-size: min(clamp(48px, 14vh, 130px), 26vw); }

.num-choices .price .amount { font-size: min(clamp(34px, 9vh, 76px), 14vw); }
.num-choices .price .amount-hi { font-size: clamp(13px, 1.8vh, 20px); }

.hidden-en {
  border: 3px dashed var(--line);
  border-radius: 18px;
  padding: clamp(8px, 1.8vh, 18px) clamp(28px, 8vw, 64px);
  font-size: clamp(26px, 4.6vh, 48px);
  opacity: 0.55;
}

.act-reveal { background: var(--plum); }

/* Two clauses means four glyphs, so everything shrinks to fit one line. */
.sent-pic.two { gap: clamp(2px, 0.8vw, 10px); flex-wrap: nowrap; }
.card .sent-pic.two .verb { font-size: min(clamp(20px, 6vh, 54px), 9vw); }
.card .sent-pic.two .pic  { font-size: min(clamp(30px, 9vh, 84px), 14vw); }

.card .example {
  margin-top: clamp(4px, 1.4vh, 14px);
  padding-top: clamp(6px, 1.4vh, 14px);
  border-top: 3px solid var(--line);
  width: min(92%, 760px);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card .ex-en {
  font-size: clamp(17px, 2.8vh, 30px);
  font-weight: 600;
  color: var(--ink);
}

.card .ex-hi {
  font-size: clamp(15px, 2.4vh, 26px);
  color: var(--ink-soft);
}

/* --- action row ---------------------------------------------------------- */

.actions {
  flex: 0 0 auto;
  display: flex;
  gap: clamp(10px, 2vw, 18px);
}

.act {
  flex: 1;
  min-height: clamp(76px, 11vh, 104px);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: clamp(20px, 3vh, 30px);
  font-weight: 700;
  color: #fff;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.16);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.act:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.16);
}

.act .ico { font-size: clamp(24px, 3.6vh, 36px); }

/* A typographic arrow stays crisp and large; the emoji arrow renders as a
   small boxed glyph on Windows. */
.act .arrow {
  font-size: clamp(34px, 5.4vh, 52px);
  font-weight: 700;
  line-height: 1;
}
.act-hear { background: var(--teal); }
.act-hindi { background: var(--amber); font-family: var(--font-hi); }
.act-next { background: var(--green); flex: 1.3; }

/* --- quiz ---------------------------------------------------------------- */

.prompt {
  flex: 0 0 auto;
  border-radius: var(--radius);
  background: var(--surface);
  border: 4px solid var(--line);
  box-shadow: var(--shadow);
  min-height: clamp(96px, 16vh, 170px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vw, 22px);
  padding: 12px 18px;
  transition: transform 0.09s ease;
}

.prompt:active { transform: scale(0.99); }

.prompt .speaker { font-size: clamp(40px, 8vh, 76px); }

.prompt .read-word {
  font-size: clamp(38px, 8vh, 82px);
  font-weight: 800;
  letter-spacing: 1px;
}

/* --- building a sentence -------------------------------------------------- */

.build-prompt {
  flex-direction: column;
  gap: clamp(4px, 1.2vh, 12px);
  min-height: 0;
  padding: 10px 14px;
}

.build-prompt .sent-pic .ico  { font-size: clamp(28px, 6vh, 56px); }
.build-prompt .sent-pic .verb { font-size: clamp(20px, 4.4vh, 42px); }
.build-prompt .sent-pic .num  { font-size: clamp(28px, 6vh, 56px); }
.build-prompt .sent-pic .swatch {
  width: clamp(28px, 6vh, 56px);
  height: clamp(28px, 6vh, 56px);
}

.build-hi {
  font-size: clamp(19px, 3.4vh, 34px);
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
}

/* The line being built. Empty slots are drawn from the start so the length of
   the answer is visible - it is a sentence, not an open-ended pile. */
.build-line {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(5px, 1.4vw, 10px);
  min-height: clamp(48px, 8vh, 76px);
  padding: clamp(6px, 1.4vh, 12px);
  border-radius: var(--radius);
  background: var(--surface);
  border: 4px dashed var(--line);
}

.build-word,
.build-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: clamp(34px, 5.4vh, 52px);
  border-radius: 10px;
  font-size: clamp(17px, 3vh, 30px);
  font-weight: 700;
}

.build-word {
  padding: 4px clamp(8px, 2vw, 16px);
  background: var(--teal);
  color: #fff;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.16);
}

.build-slot {
  width: clamp(38px, 9vw, 62px);
  background: rgba(0, 0, 0, 0.05);
  border: 2px dashed var(--line);
}

.build-tray {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: clamp(7px, 1.8vw, 14px);
  padding: clamp(4px, 1.4vh, 14px) 0;
}

/* Big enough to hit without aiming: the tap target is the point, not density. */
.build-tile {
  padding: clamp(8px, 1.6vh, 16px) clamp(12px, 3vw, 24px);
  border-radius: 14px;
  background: var(--surface);
  border: 4px solid var(--line);
  box-shadow: var(--shadow);
  font-size: clamp(18px, 3.2vh, 32px);
  font-weight: 700;
  min-height: 48px;
  transition: transform 0.09s ease, border-color 0.15s ease, background 0.15s ease;
}

.build-tile:active { transform: translateY(4px); }

.build-tile.wrong {
  border-color: var(--rose);
  background: #fdeef1;
}

.build-actions { justify-content: center; gap: clamp(12px, 4vw, 30px); }

/* Export buttons: two side by side, stacking on a narrow phone. */
.export-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.export-row .btn { flex: 1 1 190px; }

.admin input[type='text'] {
  font-size: 16px;
  min-height: 40px;
  max-width: 58%;
  padding: 6px 10px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

/* --- rupee notes ---------------------------------------------------------- */

/* Drawn, not photographed. The two things that carry the recognition are the
   colour and the length, and both are real: the aspect ratio comes from the
   note's actual millimetres, so a 500 is visibly longer than a 10. */
.rnote {
  background: var(--bg);
  color: var(--ink);
  border-radius: 6px;
  border: 2px solid rgba(0, 0, 0, 0.28);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18), inset 0 0 0 3px rgba(255, 255, 255, 0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* No gap: on the fallback sizing path the two lines plus a 2px gap were
     exactly 2px taller than the note. The line boxes already separate them. */
  gap: 0;
  flex: 0 0 auto;
  overflow: hidden;
}

/* Sized by WIDTH, not height. A note is much wider than it is tall, so
   choosing the height first pushes the width past the tile - which
   `overflow: hidden` on .choice then quietly clips instead of reporting.
   Width is taken as a share of the tile scaled by the note's real length, so
   the ₹500 fills the tile and every other note is shorter in true
   proportion; the aspect ratio supplies the height. */
.rnote-ico { height: clamp(30px, 5.4vh, 50px); }

.rnote-pic {
  width: calc(var(--mm) / 150 * 88%);
  max-width: calc(var(--mm) / 150 * min(88%, 46vh));
  height: auto;
}

.rnote-val {
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.5px;
}

.rnote-rupee { font-weight: 700; opacity: 0.85; }

.rnote-hi { line-height: 1; opacity: 0.92; }

/* The text has to be sized off the NOTE, not off the viewport.
   The note's height comes from its tile's width via the aspect ratio, and the
   type was sized in vh - two quantities with nothing to do with each other, so
   on a tall narrow phone the words were half again taller than the box holding
   them and `overflow: hidden` swallowed the difference in silence.

   cqh is a percentage of the note's own height, which is exactly the right
   unit. The vw values above it are the fallback for browsers without container
   queries, and are deliberately sized for the tightest case - the three-across
   grid - so they are safe everywhere rather than optimal anywhere. */
.rnote { container-type: size; }

.rnote-ico .rnote-val { font-size: min(clamp(10px, 2.4vh, 22px), 4vw); }
.rnote-ico .rnote-hi  { font-size: min(clamp(7px, 1.4vh, 13px), 2.4vw); }
.rnote-pic .rnote-val { font-size: min(clamp(12px, 5.4vh, 54px), 4.8vw); }
.rnote-pic .rnote-hi  { font-size: min(clamp(7px, 2.4vh, 24px), 2.1vw); }

.rnote-ico .rnote-val { font-size: 34cqh; }
.rnote-ico .rnote-hi  { font-size: 19cqh; }
.rnote-pic .rnote-val { font-size: 34cqh; }
.rnote-pic .rnote-hi  { font-size: 19cqh; }

/* A photograph fills the same box the drawing would have occupied, cropped to
   the note's real proportions. Layout is therefore identical whether a note is
   drawn or photographed, and every size measured for the drawings still holds. */
.rnote-photo { padding: 0; }

/* `contain`, not `cover`. The box is the note's real proportions, but a
   photograph rarely is - a scan with a margin round it is wider than 123:63 -
   and `cover` fills the box by cropping the overflow, which takes the ends off
   the note: exactly the part with the denomination printed on it. `contain`
   fits the whole note inside and leaves a band of the drawn note's colour
   behind it, which reads as a mount rather than a mistake. */
.rnote-photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.rcoin {
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #e8e4dc, #a9a49a 72%, #8c877d);
  border: 2px solid rgba(0, 0, 0, 0.3);
  color: #2a2723;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  aspect-ratio: 1;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.16);
}

.rcoin-ico { height: clamp(24px, 4.2vh, 40px); }
.rcoin-pic { height: clamp(48px, 10vh, 96px); }
.rcoin-ico .rcoin-val { font-size: clamp(10px, 1.8vh, 17px); font-weight: 800; }
.rcoin-pic .rcoin-val { font-size: clamp(18px, 4vh, 38px); font-weight: 800; }

/* The money laid out in a hand. Wraps rather than scrolls: ₹50 as five tens
   is five pieces, and they must all stay visible to be counted. */
.tender {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: clamp(3px, 1vw, 8px);
  margin-top: clamp(4px, 1.2vh, 12px);
  max-width: 100%;
}

/* A note is wide, so its tile needs the room a square picture does not. */
.note-choices .choice { padding: 6px; }

/* --- "when?" question ----------------------------------------------------- */

/* The prompt carries the speaker AND the picture, so the picture has to be
   held to a size that leaves the speaker recognisable next to it. */
.when-prompt .sent-pic .ico { font-size: clamp(30px, 6.5vh, 62px); }
.when-prompt .sent-pic .verb { font-size: clamp(22px, 5vh, 46px); }
.when-prompt .sent-pic .num  { font-size: clamp(30px, 6.5vh, 62px); }
.when-prompt .sent-pic .swatch {
  width: clamp(30px, 6.5vh, 62px);
  height: clamp(30px, 6.5vh, 62px);
}

/* A time tile is a glyph over two labels. The Hindi is the one that teaches
   it - बीता कल and आने वाला कल are the only unambiguous way to say which कल
   is meant - so it is the larger of the two. */
.time-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1px, 0.5vh, 5px);
  padding: 8px 6px;
  text-align: center;
}

.time-choice .time-ico {
  font-size: clamp(26px, 6.5vh, 62px);
  line-height: 1.1;
}

.time-choice .time-hi {
  font-size: clamp(15px, 2.9vh, 30px);
  font-weight: 700;
  line-height: 1.15;
}

.time-choice .time-en {
  font-size: clamp(11px, 1.9vh, 18px);
  color: var(--ink-soft);
  line-height: 1.15;
}

/* Four times on a narrow phone: two rows of two, and the labels shrink rather
   than the tile growing a scrollbar. */
.choices.n4.time-choices .time-choice .time-hi { font-size: clamp(14px, 2.4vh, 26px); }
.choices.n4.time-choices .time-choice .time-ico { font-size: clamp(22px, 5vh, 50px); }
.choices.n3.time-choices .time-choice .time-hi { font-size: clamp(13px, 2.3vh, 24px); }
.choices.n3.time-choices .time-choice .time-en { font-size: clamp(10px, 1.6vh, 15px); }

.choices {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: grid;
  gap: clamp(10px, 2vh, 18px);
}

.choices.n2 { grid-template-columns: 1fr 1fr; }
.choices.n3 { grid-template-columns: repeat(3, 1fr); }
.choices.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }

.choice {
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  border: 4px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  min-height: 92px;
  transition: transform 0.09s ease, border-color 0.15s ease, background 0.15s ease;
}

.choice:active { transform: translateY(4px); }

.choice .ico { font-size: clamp(46px, 13vh, 118px); }

.choice .swatch {
  width: clamp(58px, 12vh, 120px);
  height: clamp(58px, 12vh, 120px);
  border-radius: 50%;
  border: 5px solid rgba(0, 0, 0, 0.14);
}

.choice .num {
  font-size: clamp(52px, 14vh, 130px);
  font-weight: 800;
  color: var(--teal);
}

.choice.right {
  border-color: var(--green);
  background: #eafaee;
}

.choice.wrong {
  animation: shake 0.4s ease;
  border-color: #e3c6c6;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* --- overlays ------------------------------------------------------------ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(251, 246, 236, 0.92);
  animation: pop 0.25s ease;
}

.overlay .mark {
  font-size: clamp(90px, 26vh, 220px);
}

.overlay .msg {
  font-family: var(--font-hi);
  font-size: clamp(28px, 5vh, 52px);
  font-weight: 800;
  color: var(--green);
  text-align: center;
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Start gate: satisfies the browser's "speech needs a gesture" rule. */
.gate {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  text-align: center;
  padding: 24px;
}

.gate .big-emoji { font-size: clamp(72px, 20vh, 170px); }

.gate .go {
  background: var(--teal);
  color: #fff;
  border-radius: 999px;
  padding: clamp(18px, 3vh, 30px) clamp(40px, 9vw, 84px);
  font-size: clamp(26px, 4.4vh, 44px);
  font-weight: 800;
  font-family: var(--font-hi);
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.18);
}

.gate .go:active { transform: translateY(5px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18); }

/* --- caregiver panel (adults only; never reached by accident) ------------ */

.admin {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  user-select: text;
  -webkit-user-select: text;
  gap: 18px;
}

.admin h1 {
  font-size: 26px;
  margin: 0;
}

.admin h2 {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--ink-soft);
  margin: 18px 0 6px;
}

.admin .panel {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.admin .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 17px;
}

.admin .row:last-child { border-bottom: none; }

.admin select,
.admin input[type='range'] {
  font-size: 16px;
  min-height: 40px;
  max-width: 58%;
}

.admin .level-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 12px 10px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: none;
}

.admin .level-row.on {
  border-color: var(--teal);
  background: #eef7f5;
}

.admin .level-n {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: var(--line);
  color: var(--ink);
}

.admin .level-row.on .level-n { background: var(--teal); color: #fff; }
.admin .level-body { min-width: 0; }
.admin .level-name { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 18px; font-weight: 700; }
.admin .level-en { font-weight: 600; color: var(--ink-soft); font-size: 15px; }
.admin .level-count { font-size: 12px; color: var(--ink-soft); margin-left: auto; }
.admin .level-ready {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: var(--green);
  color: #fff;
  border-radius: 999px;
  padding: 2px 9px;
}
.admin .level-note { font-size: 14px; color: var(--ink-soft); line-height: 1.45; margin-top: 3px; }

.admin .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin .chip {
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 15px;
  font-family: var(--font-hi);
}

.admin .chip.on {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.admin .btn {
  background: var(--teal);
  color: #fff;
  border-radius: 12px;
  padding: 14px 22px;
  font-size: 17px;
  font-weight: 700;
}

.admin .btn.danger { background: var(--rose); }
.admin .note { font-size: 14px; color: var(--ink-soft); line-height: 1.5; }
.admin .warn { color: var(--rose); font-weight: 600; }

/* Landscape phones: keep the card from squeezing the buttons out of view. */
@media (max-height: 460px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .card .pic { font-size: clamp(48px, 26vh, 120px); }

  /* Landscape on a phone has no room for the money card AND the notes under
     it - shrinking them was not enough, the card still ran over. The notes go
     rather than the sentence: the numeral above them still says the amount,
     and this is the orientation nobody learns in anyway. */
  .money-card .tender { display: none; }
}
