/* Look and feel (v2). Palette: ink, green, light blue, orange, purple, coral, plus white.
   Every tint below is one of those colors at reduced strength. */
:root {
  --ink: #0C0C0C;
  --green: #4BA95F;
  --blue: #77DDFA;
  --orange: #FEA339;
  --purple: #9985FB;
  --coral: #FF908D;
  --white: #FFFFFF;

  --bg: var(--white);
  --surface: var(--white);
  --text: var(--ink);
  --muted: rgba(12, 12, 12, 0.68);
  --line: rgba(12, 12, 12, 0.1);
  --track: rgba(12, 12, 12, 0.1);
  --focus: var(--ink);
  --shadow: 0 8px 24px rgba(12, 12, 12, 0.1), 0 1px 3px rgba(12, 12, 12, 0.08);

  --radius: 24px;
  --radius-small: 20px;
  --heading: ui-rounded, "SF Pro Rounded", "Nunito", "Arial Rounded MT Bold", system-ui, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: var(--ink);
  --surface: linear-gradient(rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.09)), var(--ink);
  --text: var(--white);
  --muted: rgba(255, 255, 255, 0.74);
  --line: rgba(255, 255, 255, 0.16);
  --track: rgba(255, 255, 255, 0.18);
  --focus: var(--blue);
  --shadow: 0 8px 24px rgba(12, 12, 12, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.1);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
ul, ol { list-style: none; }
h1, h2, h3, .hello, .btn, .star-pill, .tabs button, .resume-title, .resume-text strong, .ring b, .thumb span,
.row strong, .face b, .count, .burst strong, .pair b, .earn b, .new-rewards strong, .treat-waiting strong,
.done-banner strong, .all-words summary { font-family: var(--heading); }
h1 { font-size: 2rem; line-height: 1.12; font-weight: 800; letter-spacing: -0.015em; }
h2 { font-size: 1.3rem; line-height: 1.2; font-weight: 800; }
h3 { font-size: 1rem; font-weight: 700; }
small { font-size: 0.84rem; color: var(--muted); }
svg { display: block; }
.icon { width: 24px; height: 24px; flex: none; }
.sub { color: var(--muted); }

/* Colored surfaces always carry ink text, in both modes. */
.resume, .star-pill, .hero, .thumb, .card.weekly, .total + .card, .pair .card, .pair ~ .card, .card.empty,
.chat-head, .mine .bubble, .reply label, .note, .tracker, .face, .treat-waiting, .treat.ready, .treat.claimed {
  --text: var(--ink);
  --muted: rgba(12, 12, 12, 0.8);
  --surface: var(--white);
  --line: rgba(12, 12, 12, 0.14);
  --focus: var(--ink);
  color: var(--ink);
}

/* One color per conversation, rotating through the palette. */
[data-scene="restaurant"], .thumb[data-id="restaurant"] { --scene: var(--orange); --partner: var(--coral); }
[data-scene="directions"], .thumb[data-id="directions"] { --scene: var(--blue);   --partner: var(--purple); }
[data-scene="friend"], .thumb[data-id="friend"] { --scene: var(--purple); --partner: var(--blue); }
[data-scene="market"], .thumb[data-id="market"] { --scene: var(--coral);  --partner: var(--orange); }
[data-scene="cafe"], .thumb[data-id="cafe"] { --scene: var(--blue);   --partner: var(--orange); }
[data-scene="neighbor"], .thumb[data-id="neighbor"] { --scene: var(--orange); --partner: var(--purple); }
[data-scene="weekend"], .thumb[data-id="weekend"] { --scene: var(--purple); --partner: var(--coral); }
[data-scene="clothes"], .thumb[data-id="clothes"] { --scene: var(--coral);  --partner: var(--blue); }
[data-scene="taxi"], .thumb[data-id="taxi"] { --scene: var(--blue);   --partner: var(--orange); }
[data-scene="beach"], .thumb[data-id="beach"] { --scene: var(--orange); --partner: var(--blue); }
[data-scene="hotel"], .thumb[data-id="hotel"] { --scene: var(--purple); --partner: var(--orange); }
[data-scene="train"], .thumb[data-id="train"] { --scene: var(--coral);  --partner: var(--purple); }
[data-scene="pharmacy"], .thumb[data-id="pharmacy"] { --scene: var(--blue);   --partner: var(--coral); }
[data-scene="tech"], .thumb[data-id="tech"] { --scene: var(--orange); --partner: var(--purple); }

/* Header */
.top, main { width: 100%; max-width: 640px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.top { display: flex; align-items: center; gap: 10px; padding-top: calc(14px + env(safe-area-inset-top)); padding-bottom: 16px; }
.brand { flex: 1; min-width: 0; }
.hello { font-size: 1.4rem; font-weight: 800; line-height: 1.2; }
.app-name { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.hello span { background: linear-gradient(transparent 66%, var(--orange) 66%, var(--orange) 94%, transparent 94%); padding: 0 2px; }
:root[data-theme="dark"] .hello span { background: none; color: var(--orange); }
main { padding-bottom: calc(116px + env(safe-area-inset-bottom)); }
main > * + *, .result > * + * { margin-top: 18px; }

.star-pill { display: flex; align-items: center; gap: 6px; flex: none; min-height: 46px; padding: 0 18px 0 12px; border-radius: 99px; background: var(--orange); font-weight: 800; font-size: 1.1rem; box-shadow: var(--shadow); }
.star-pill .icon { width: 28px; height: 28px; padding: 5px; border-radius: 50%; background: var(--white); color: var(--ink); }
.round { width: 46px; height: 46px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Buttons */
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 56px; padding: 12px 20px; border-radius: 99px; font-weight: 800; font-size: 1.1rem; text-align: center; transition: transform 0.1s; }
.btn:active, .resume:active, .thumb:active, .round:active { transform: scale(0.97); }
.btn.primary { background: var(--green); color: var(--ink); box-shadow: var(--shadow); }
.btn.secondary { background: var(--surface); color: var(--text); border: 2px solid var(--line); box-shadow: var(--shadow); font-size: 1rem; }
.link { color: var(--text); font-weight: 700; font-size: 0.9rem; text-decoration: underline; text-decoration-color: var(--green); text-decoration-thickness: 3px; text-underline-offset: 4px; min-height: 44px; padding: 0 4px; }
.link.center { display: block; margin: 0 auto; }

.listen { width: 46px; height: 46px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--orange); color: var(--ink); }
.listen.speaking { background: var(--green); animation: pulse 0.8s ease-in-out infinite alternate; }
.listen.big { width: 62px; height: 62px; box-shadow: var(--shadow); }
.listen.big .icon { width: 30px; height: 30px; }
@keyframes pulse { to { transform: scale(1.1); } }

.card { display: block; width: 100%; background: var(--surface); color: var(--text); border-radius: var(--radius); padding: 20px; text-align: left; box-shadow: var(--shadow); }
.card > * + * { margin-top: 12px; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

.meter { height: 16px; border-radius: 99px; background: var(--track); overflow: hidden; }
.card .row + .meter { margin-top: 8px; }
.meter span { display: block; height: 100%; border-radius: 99px; background: var(--orange); transition: width 0.5s; }

/* Progress card */
.resume { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px 14px; width: 100%; padding: 20px; border-radius: var(--radius); background: var(--green); text-align: left; box-shadow: var(--shadow); }
.resume-title { grid-column: 1 / -1; font-size: 1.35rem; font-weight: 800; line-height: 1.2; }
.ring { position: relative; display: grid; place-items: center; width: 76px; height: 76px; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring-track { stroke: rgba(12, 12, 12, 0.22); }
.ring-fill { stroke: var(--white); stroke-linecap: round; }
.ring b { position: relative; font-size: 1.1rem; font-weight: 800; }
.resume-text { display: block; min-width: 0; }
.resume-text strong { display: block; font-size: 1.15rem; line-height: 1.2; }
.resume-text span { display: block; font-size: 0.95rem; }
.resume-text small { display: block; color: var(--ink); font-weight: 600; }
.go { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--ink); color: var(--white); }
.go .icon { width: 28px; height: 28px; }

/* Today's scenario card */
.hero { padding: 18px 16px 20px; border-radius: var(--radius); background: var(--scene, var(--blue)); text-align: center; box-shadow: var(--shadow); }
.hero > * + * { margin-top: 10px; }
.arch { width: 100%; max-width: 360px; margin: 0 auto; aspect-ratio: 8 / 7; border-radius: 999px 999px var(--radius-small) var(--radius-small); overflow: hidden; border: 6px solid var(--white); background: var(--white); }
.arch svg, .banner-scene svg, .thumb svg, .mini svg { width: 100%; height: 100%; }
.hero h1 { padding-top: 8px; font-size: 2.1rem; }
.hero .sub { margin-top: 2px; font-weight: 700; }
.twist { display: inline-block; background: var(--white); border-radius: 99px; padding: 6px 16px; font-weight: 700; font-size: 0.92rem; }
.intro { max-width: 34ch; margin-left: auto; margin-right: auto; }
.goal { display: flex; justify-content: center; align-items: center; gap: 6px; font-size: 0.92rem; font-weight: 600; }
.done-banner { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--radius-small); background: var(--white); text-align: left; }
.done-banner .icon { width: 44px; height: 44px; padding: 9px; border-radius: 50%; background: var(--green); color: var(--ink); }
.done-banner strong { display: block; font-size: 1.2rem; }

/* Streak */
.streak-top { display: flex; align-items: center; gap: 14px; }
.streak-top > .icon { width: 56px; height: 56px; padding: 10px; border-radius: 50%; background: var(--track); color: var(--muted); }
.streak-top > .icon.lit { background: var(--green); color: var(--ink); }
.streak-top p { color: var(--muted); font-size: 0.95rem; }
.streak-top p.streak-count { color: var(--text); font-family: var(--heading); font-weight: 800; font-size: 1.1rem; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; }
.week span { display: block; font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.week b { display: grid; place-items: center; width: 36px; max-width: 100%; aspect-ratio: 1; margin: 4px auto 0; border-radius: 50%; background: var(--track); border: 3px solid transparent; }
.week .now b { border-color: var(--text); }
.week .done b { background: var(--green); color: var(--ink); }
.week .done.now b { border-color: var(--text); }

.card.weekly { background: var(--purple); }
.card.weekly .meter, .total + .card .meter { background: var(--white); }
.card.weekly .meter span, .total + .card .meter span { background: var(--ink); }
.weekly .row { display: flex; }
.weekly .meter { display: block; }

/* Practice again */
.again > p { color: var(--muted); font-size: 0.95rem; margin: 4px 0 14px; }
.thumbs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.thumb { padding: 8px 8px 0; background: var(--scene, var(--blue)); border-radius: var(--radius); box-shadow: var(--shadow); transition: transform 0.1s; }
.thumb svg { aspect-ratio: 8 / 6; height: auto; border-radius: 16px; overflow: hidden; }
.thumb span { display: block; padding: 10px 4px 12px; font-weight: 800; font-size: 0.98rem; }

/* Conversation */
.chat-head { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--radius); background: var(--scene, var(--blue)); box-shadow: var(--shadow); }
.chat-head h1 { font-size: 1.45rem; }
.chat-head p { font-size: 0.95rem; font-weight: 600; }
.banner-scene { height: 210px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
[data-screen="chat"] .banner-scene { border: 6px solid var(--scene, var(--blue)); }
.step-title { text-align: center; }
.note { background: var(--purple); border-radius: var(--radius-small); padding: 14px 18px; font-size: 0.95rem; font-weight: 600; }
.chat > * + *, #current > * + * { margin-top: 14px; }
#current { scroll-margin-top: 16px; }
.turn { display: flex; flex-direction: column; align-items: flex-start; }
.turn.mine { align-items: flex-end; }
.who { font-size: 0.82rem; font-weight: 700; color: var(--muted); padding: 0 10px 4px; }
.bubble { max-width: 88%; background: var(--surface); border-radius: 6px var(--radius) var(--radius) var(--radius); padding: 14px 18px; box-shadow: var(--shadow); overflow-wrap: anywhere; }
.mine .bubble { background: var(--blue); border-radius: var(--radius) 6px var(--radius) var(--radius); }
.bubble p[lang="es"] { font-size: 1.2rem; font-weight: 700; }
.english { color: var(--muted); font-size: 0.95rem; margin-top: 4px; }
.bubble-tools { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.reveal { display: block; width: 100%; min-height: 52px; padding: 8px 12px; border: 2px dashed var(--purple); border-radius: 16px; font-weight: 700; font-size: 0.95rem; }
.dots { display: flex; gap: 8px; }
.dots li { flex: 1; height: 10px; border-radius: 99px; background: var(--track); }
.dots li.here { background: var(--orange); }
.dots li.full { background: var(--green); }

.reply > * + * { margin-top: 12px; }
.reply label { display: block; background: var(--orange); border-radius: var(--radius-small); padding: 14px 18px; }
.reply textarea { display: block; width: 100%; min-height: 80px; resize: vertical; padding: 14px 18px; border: 3px solid var(--green); border-radius: var(--radius-small); background: var(--surface); color: var(--text); font-size: 1.2rem; }
.reply textarea::placeholder { color: var(--muted); font-size: 1rem; }
.accents { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }
.accents button { min-height: 46px; border-radius: 14px; background: var(--surface); border-bottom: 4px solid var(--orange); box-shadow: var(--shadow); font-weight: 700; font-size: 1.15rem; }
.hint { text-align: center; }
.form-note { width: fit-content; max-width: 100%; margin-left: auto; margin-right: auto; padding: 8px 16px; border-radius: 16px; background: var(--coral); color: var(--ink); font-weight: 700; text-align: center; font-size: 0.95rem; }
.form-note:empty { display: none; }

.model { background: rgba(75, 169, 95, 0.2); border: 2px solid var(--green); border-radius: var(--radius); padding: 18px 16px; }
.model > * + * { margin-top: 12px; }
.model-line { display: flex; gap: 12px; align-items: flex-start; }
.model-line p[lang="es"] { font-size: 1.2rem; font-weight: 800; }
.phrases { display: grid; gap: 10px; }
.phrase { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 14px; border-radius: var(--radius-small); background: var(--surface); text-align: left; border: 2px solid transparent; box-shadow: var(--shadow); }
.phrase b, .phrase small { display: block; }
.phrase .icon { width: 34px; height: 34px; padding: 7px; border-radius: 50%; background: var(--orange); color: var(--ink); }
.phrase.used { border-color: var(--green); }
.phrase.used .icon { background: var(--green); }
.phrase.speaking { border-color: var(--orange); }

/* Result */
.result { text-align: center; }
.result .card { text-align: left; }
.burst { position: relative; width: 190px; height: 190px; margin: 8px auto 0; display: grid; place-items: center; animation: pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.burst .icon { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--orange); }
.burst strong { position: relative; font-size: 2.3rem; color: var(--ink); padding-top: 12px; }
@keyframes pop { from { transform: scale(0.2) rotate(-40deg); } to { transform: none; } }
.result .card.new-rewards { text-align: center; }
.new-rewards ul { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.new-rewards li { width: 100px; display: grid; justify-items: center; gap: 8px; font-size: 0.9rem; }

/* Treat tiles */
.tile { display: grid; place-items: center; width: 76px; height: 76px; border-radius: var(--radius); color: var(--ink); box-shadow: var(--shadow); }
.tile .icon { width: 42px; height: 42px; }
.tile.blue { background: var(--blue); }
.tile.orange { background: var(--orange); }
.tile.purple { background: var(--purple); }
.tile.coral { background: var(--coral); }

/* Stars */
.total { display: flex; flex-direction: column; align-items: center; }
.total .icon { width: 108px; height: 108px; color: var(--orange); margin-bottom: 8px; }
.total h1 { font-size: 2.6rem; }
.total p { color: var(--muted); font-weight: 600; }
.total + .card { background: var(--purple); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pair .card { text-align: center; margin: 0; }
.pair .card:first-child { background: var(--green); }
.pair .card:last-child { background: var(--blue); }
.pair b { display: block; font-size: 2.5rem; line-height: 1; }
.pair span { display: block; margin-top: 4px; font-size: 0.92rem; font-weight: 600; }
/* Lindsey's treat shelf */
.treats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 16px; }
.treat { --accent: var(--blue); display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; padding: 16px 12px; border-radius: var(--radius); border: 3px solid var(--accent); text-align: center; box-shadow: var(--shadow); }
.treat.orange { --accent: var(--orange); }
.treat.purple { --accent: var(--purple); }
.treat.coral { --accent: var(--coral); }
.treat.ready, .treat.claimed { background: var(--accent); }
.treat.ready .tile, .treat.claimed .tile { background: var(--white); box-shadow: none; }
.treat h3 { font-size: 1.1rem; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.treat .need { font-size: 0.88rem; font-weight: 600; line-height: 1.3; }
.treat .progress { font-size: 0.82rem; color: var(--muted); }
.treat .meter { width: 100%; height: 10px; margin-top: auto; }
.treat .link { margin-top: -4px; font-size: 0.85rem; }
.treat.ready .link { text-decoration-color: var(--ink); }
.treat .btn.claim { margin-top: auto; min-height: 48px; padding: 8px 10px; font-size: 1rem; background: var(--green); color: var(--ink); }
.treat.ready .btn.claim { background: var(--ink); color: var(--white); }
.treat .ask { margin-top: auto; font-weight: 800; }
.treat .ask + .btn.claim { margin-top: 0; }
.claimed-flag { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: auto; min-height: 48px; width: 100%; padding: 6px 4px; border-radius: 99px; background: var(--white); font-size: 0.85rem; font-weight: 800; line-height: 1.2; }
.claimed-flag .icon { flex: none; width: 18px; height: 18px; }
.treat-form { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; margin-top: auto; }
.treat-form label { font-size: 0.88rem; font-weight: 600; }
.treat-form input { width: 100%; min-height: 48px; padding: 8px 10px; border: 3px solid var(--green); border-radius: 16px; background: var(--white); color: var(--ink); font: inherit; font-size: 1rem; text-align: center; }
.treat.ready .treat-form input { border-color: var(--ink); }
.treat-waiting { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 18px; border-radius: var(--radius); background: var(--coral); text-align: left; box-shadow: var(--shadow); }
.treat-waiting > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.treat-waiting strong, .treat-waiting span span { display: block; }
.treat-waiting strong { font-size: 1.1rem; line-height: 1.25; }
.treat-waiting > .icon:first-child { width: 44px; height: 44px; padding: 9px; border-radius: 50%; background: var(--white); }
.pair ~ .card { background: var(--coral); }
.earn li { display: flex; align-items: center; gap: 14px; }
.earn li + li { margin-top: 10px; }
.earn b { display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 50%; background: var(--white); }
.sync { text-align: center; color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }

/* Word bank */
.tracker { background: var(--orange); border-radius: var(--radius-small); padding: 14px 18px; box-shadow: var(--shadow); }
.tracker p { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 0.95rem; }
.pips { display: flex; gap: 6px; margin-top: 10px; }
.pips i { flex: 1; height: 9px; border-radius: 99px; background: var(--white); }
.pips i.full { background: var(--ink); }
.flash { display: block; width: 100%; height: 300px; perspective: 1200px; border-radius: var(--radius); }
.inner { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.45s; }
.flash.flipped .inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); -webkit-backface-visibility: hidden; backface-visibility: hidden; overflow: hidden; }
.face.front { background: var(--scene, var(--blue)); }
.face.back { background: var(--partner, var(--purple)); transform: rotateY(180deg); }
.face small { color: var(--ink); background: var(--white); border-radius: 99px; padding: 3px 14px; font-weight: 700; }
.face b { font-size: 2.2rem; line-height: 1.15; text-align: center; overflow-wrap: anywhere; }
.face em { font-style: normal; font-weight: 600; font-size: 0.9rem; }
.mini { display: block; width: 112px; height: 86px; border-radius: 16px; overflow: hidden; border: 3px solid var(--white); }
.deck-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.count { font-weight: 800; min-width: 72px; text-align: center; }
.deck-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.deck-options .btn { padding: 8px 10px; font-size: 0.95rem; }
.all-words summary { cursor: pointer; font-weight: 800; min-height: 32px; }
.all-words li { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 2px solid var(--line); }
.all-words li:nth-child(4n+1) .listen { background: var(--blue); }
.all-words li:nth-child(4n+3) .listen { background: var(--purple); }
.all-words li:nth-child(4n+4) .listen { background: var(--coral); }
.all-words li .listen.speaking { background: var(--green); }
.all-words li b, .all-words li small { display: block; }
.card.empty { text-align: center; background: var(--blue); }

/* Bottom tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; box-shadow: 0 -6px 24px rgba(12, 12, 12, 0.12), 0 -1px 0 var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
.tabs div { display: grid; gap: 8px; max-width: 616px; margin: 0 auto; }
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 56px; padding: 6px; border-radius: var(--radius-small); font-size: 0.85rem; font-weight: 800; color: var(--muted); }
.tabs .icon { width: 26px; height: 26px; }
.tabs button[aria-current="page"] { background: var(--green); color: var(--ink); }
.tabs button[data-tab="practice"][aria-current="page"] { background: var(--blue); }
.tabs button[data-tab="stars"][aria-current="page"] { background: var(--orange); }

/* Toast and confetti */
#toast { position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); z-index: 30; width: max-content; max-width: calc(100% - 32px); padding: 12px 20px; border-radius: var(--radius-small); background: var(--ink); color: var(--white); border: 3px solid var(--orange); font-weight: 700; text-align: center; opacity: 0; visibility: hidden; transform: translate(-50%, -12px); transition: 0.25s; pointer-events: none; }
#toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
#confetti { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 20; }
#confetti i { position: absolute; top: -20px; width: 10px; height: 15px; border-radius: 3px; animation: fall linear forwards; }
/* app.js sets confetti colors inline, so the palette needs !important here */
#confetti i:nth-child(5n+1) { background: var(--green) !important; }
#confetti i:nth-child(5n+2) { background: var(--blue) !important; }
#confetti i:nth-child(5n+3) { background: var(--orange) !important; }
#confetti i:nth-child(5n+4) { background: var(--purple) !important; }
#confetti i:nth-child(5n+5) { background: var(--coral) !important; }
@keyframes fall { to { transform: translate(var(--drift), 105vh) rotate(720deg); } }

@media (max-width: 360px) {
  body { font-size: 16px; }
  .hello { font-size: 1.05rem; }
  .app-name { font-size: 0.75rem; }
  .tile { width: 62px; height: 62px; }
  .treats { gap: 10px; }
  .treat { padding: 12px 8px; }
  .accents { gap: 3px; }
  .resume { gap: 10px; padding: 16px; }
  .ring { width: 64px; height: 64px; }
  .go { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Dialect labels and "How they say it" */
.dialect, .thumb span.dialect { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 12px 4px 8px; border-radius: 99px; background: var(--white); color: var(--ink); font-size: 0.78rem; font-weight: 700; line-height: 1.2; text-align: left; }
.dialect > span, .thumb .dialect > span { display: inline; padding: 0; font-size: inherit; font-weight: inherit; }
.dialect svg.flag { flex: none; width: 21px; height: 14px; aspect-ratio: auto; border-radius: 2px; }
.thumb > span:not(.dialect) { padding-bottom: 6px; }
.thumb span.dialect { gap: 5px; margin-bottom: 10px; padding: 4px 8px 4px 6px; font-size: 0.7rem; }
.resume > .dialect { grid-column: 1 / -1; justify-self: start; }
.chat-head .dialect { margin-top: 6px; }
.say-card h2 { font-size: 1.25rem; }
.say-card summary { min-height: 32px; cursor: pointer; font-family: var(--heading); font-weight: 800; }
.say-notes { list-style: none; margin: 12px 0 0; padding: 0; }
.say-notes li { padding: 10px 0 10px 14px; border-left: 4px solid var(--scene, var(--blue)); }
.say-notes li + li { margin-top: 10px; }
.say-notes strong { display: block; font-size: 1.08rem; }
.say-notes span { display: block; font-size: 0.95rem; line-height: 1.45; }
.all-words li small + small { font-size: 0.75rem; font-weight: 700; }

/* Lessons and words */
.resume, .hero, .lesson-next, .page-head, .lesson-card.current, .pattern-card, .prompt, .finished-card, .locked-words, .card.lesson-complete {
  --text: var(--ink);
  --muted: rgba(12, 12, 12, 0.8);
  --surface: var(--white);
  --line: rgba(12, 12, 12, 0.14);
  --focus: var(--ink);
  color: var(--ink);
}
.word-pic { display: block; width: 100%; height: auto; aspect-ratio: 1; border-radius: 18.4%; overflow: hidden; }

.page-head { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--radius); background: var(--purple); box-shadow: var(--shadow); }
.page-head h1 { font-size: 1.45rem; }
.page-head p { font-size: 0.95rem; font-weight: 600; }
.page-head > div { min-width: 0; }
.page-head .dialect { margin-top: 6px; }
[data-screen="word"] .page-head { background: var(--coral); }

.lesson-next { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px 14px 14px; border-radius: var(--radius); background: var(--purple); text-align: left; box-shadow: var(--shadow); }
.lesson-next .lesson-pic { width: 76px; }
.lesson-next > span:not(.lesson-pic) { flex: 1; min-width: 0; }
.lesson-next small, .lesson-next strong, .lesson-next span span { display: block; }
.lesson-next small { color: var(--ink); font-weight: 700; }
.lesson-next strong { font-family: var(--heading); font-size: 1.15rem; line-height: 1.25; }
.lesson-next span span { font-size: 0.9rem; line-height: 1.35; }
.lesson-pic { display: block; flex: none; }
.lesson-pic .word-pic { border: 3px solid var(--white); }

.path > li + li { margin-top: 14px; }
.lesson-card { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 12px; border-radius: var(--radius); border: 3px solid var(--line); background: var(--surface); text-align: left; box-shadow: var(--shadow); }
.lesson-card .lesson-pic { width: 68px; }
.lesson-card.done { border-color: var(--green); }
.lesson-card.current { background: var(--purple); border-color: var(--purple); }
.lesson-card.locked { border-style: dashed; box-shadow: none; }
.lesson-card.locked .lesson-pic { opacity: 0.3; }
.lesson-text { display: block; flex: 1; min-width: 0; }
.lesson-text > small, .lesson-text > strong, .lesson-text > span { display: block; }
.lesson-text > small { font-weight: 700; }
.lesson-text > strong { font-family: var(--heading); font-size: 1.1rem; line-height: 1.25; }
.lesson-text > span { font-size: 0.9rem; line-height: 1.35; }
.lesson-text > span.lesson-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 8px; }
.lesson-meta .dialect { border: 1px solid var(--line); }
.lesson-state { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--track); color: var(--text); }
.lesson-card.done .lesson-state { background: var(--green); color: var(--ink); }
.lesson-card.current .lesson-state { background: var(--ink); color: var(--white); }

.lesson-goal { padding: 0 4px; }
.steps { display: flex; gap: 8px; }
.steps li { flex: 1; min-width: 0; }
.steps button { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 48px; padding: 4px 6px; border-radius: 99px; border: 2px solid var(--line); font-family: var(--heading); font-weight: 800; font-size: 0.95rem; }
.steps b { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--track); font-size: 0.85rem; }
.steps b .icon { width: 16px; height: 16px; }
.steps .finished b { background: var(--green); color: var(--ink); }
.steps button[aria-current="step"] { background: var(--purple); border-color: var(--purple); color: var(--ink); }
.steps button[aria-current="step"] b { background: var(--white); color: var(--ink); }
.steps button:disabled { cursor: default; border-style: dashed; color: var(--muted); }

.card.pattern-card { background: var(--orange); }
.pattern-card li { padding: 12px 14px; border-radius: var(--radius-small); background: var(--white); }
.pattern-card li + li { margin-top: 10px; }
.pattern { font-family: var(--heading); font-weight: 800; font-size: 1.2rem; line-height: 1.7; }
.pattern i, .pattern-peek i { display: inline-block; padding: 0 10px; border-radius: 10px; background: var(--blue); color: var(--ink); font-style: normal; font-size: 0.88em; line-height: 1.5; }
.pattern-card .example { margin-top: 8px; align-items: center; }
.pattern-peek summary { min-height: 32px; cursor: pointer; font-family: var(--heading); font-weight: 800; }
.pattern-peek li { margin-top: 10px; font-weight: 700; line-height: 1.7; }

.example { display: flex; align-items: flex-start; gap: 12px; }
.example > div { min-width: 0; }
.example p[lang="es"] { font-weight: 700; font-size: 1.1rem; line-height: 1.35; }
.entries > li + li { margin-top: 14px; }
.entry-pic { position: relative; display: block; width: 156px; margin: 0 auto; border-radius: var(--radius); }
.entry-pic > span { position: absolute; right: -10px; bottom: -6px; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--orange); color: var(--ink); border: 3px solid var(--white); }
.entry-pic.speaking > span { background: var(--green); }
.entry-name { text-align: center; }
.word-big { font-family: var(--heading); font-weight: 800; font-size: 2rem; line-height: 1.15; overflow-wrap: anywhere; }
.also h3 { margin-bottom: 2px; }
.also li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; padding: 8px 0; border-top: 2px solid var(--line); }
.also li span { color: var(--muted); font-size: 0.95rem; }
.tip { padding: 10px 14px; border-radius: 16px; border: 2px solid var(--blue); background: rgba(119, 221, 250, 0.2); font-size: 0.95rem; }

.card.prompt, .prompt { padding: 16px 20px; border-radius: var(--radius); background: var(--blue); box-shadow: var(--shadow); }
.prompt p { font-size: 0.9rem; font-weight: 600; }
.prompt h2 { margin-top: 4px; font-size: 1.4rem; }
.builder > * + * { margin-top: 14px; }
.answer { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; min-height: 128px; padding: 12px; border: 3px dashed var(--green); border-radius: var(--radius-small); }
.answer p { width: 100%; align-self: center; text-align: center; color: var(--muted); }
.bank { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.word-tile { min-height: 48px; min-width: 48px; padding: 8px 14px; border-radius: 16px; background: var(--surface); border-bottom: 4px solid var(--orange); box-shadow: var(--shadow); font-family: var(--heading); font-weight: 800; font-size: 1.15rem; }
.answer .word-tile { border-bottom-color: var(--green); }
.word-tile:disabled { cursor: default; background: var(--track); border-bottom-color: transparent; box-shadow: none; color: transparent; }
.builder label { display: block; font-weight: 700; }
.builder input { display: block; width: 100%; min-height: 60px; margin-top: 8px; padding: 12px 16px; border: 3px solid var(--green); border-radius: var(--radius-small); background: var(--surface); color: var(--text); font: inherit; font-size: 1.2rem; }
.builder label + input + .accents { margin-top: 12px; }
.builder-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 28px; }

.use-words { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.use-words button { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 96px; min-height: 100%; padding: 8px 4px; border-radius: var(--radius-small); background: var(--surface); box-shadow: var(--shadow); border: 2px solid transparent; }
.use-words button.speaking { border-color: var(--green); }
.use-words .word-pic { width: 62px; }
.use-words span { font-size: 0.85rem; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.card.finished-card { background: var(--green); text-align: center; }
.finished-card .icon, .lesson-complete .icon { width: 56px; height: 56px; margin: 0 auto; padding: 12px; border-radius: 50%; background: var(--white); color: var(--ink); }
.result .card.lesson-complete { background: var(--purple); text-align: center; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 44px; padding: 6px 16px; border-radius: 99px; border: 2px solid var(--line); font-weight: 700; font-size: 0.9rem; }
.chips button[aria-pressed="true"] { background: var(--coral); border-color: var(--coral); color: var(--ink); }
.word-group h2 { margin-bottom: 12px; }
.vocab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
.vocab-grid li { display: flex; min-width: 0; }
.vocab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; padding: 10px 8px 12px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); text-align: center; transition: transform 0.1s; }
.vocab:active { transform: scale(0.97); }
.vocab .word-pic { width: 100%; max-width: 128px; margin-bottom: 4px; }
.vocab b { font-family: var(--heading); font-size: 1.15rem; line-height: 1.2; overflow-wrap: anywhere; }
.vocab small { line-height: 1.3; }
.saved-mark { position: absolute; top: 4px; right: 4px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--green); color: var(--ink); border: 3px solid var(--white); }
.saved-mark .icon { width: 16px; height: 16px; }
.card.locked-words { background: var(--blue); text-align: center; }
.locked-words > .icon { width: 52px; height: 52px; margin: 0 auto; padding: 11px; border-radius: 50%; background: var(--white); }

.flash.word-flash, .flash.has-pic { height: 372px; }
.face .pic { display: block; width: 150px; flex: none; }
.flash.has-pic .face .pic { width: 138px; }
.face .pic .word-pic { border: 4px solid var(--white); }
.flash.has-pic .face { gap: 8px; }
.flash.has-pic .face b { font-size: 1.9rem; }
.word-flash .face.front { background: var(--blue); }
.word-flash .face.back { background: var(--purple); }
.in-deck { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; border-radius: 99px; border: 3px solid var(--green); font-weight: 800; }

/* Five tabs */
.tabs { padding-left: 6px; padding-right: 6px; }
.tabs div { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.tabs button { padding: 6px 0; font-size: 0.76rem; }
.tabs button[data-tab="lessons"][aria-current="page"] { background: var(--purple); }
.tabs button[data-tab="words"][aria-current="page"] { background: var(--coral); }

@media (max-width: 360px) {
  .tabs button { font-size: 0.7rem; }
  .lesson-card { gap: 8px; padding: 12px 8px; }
  .lesson-card .lesson-pic { width: 52px; }
  .lesson-state { width: 32px; height: 32px; }
  .steps button { font-size: 0.85rem; gap: 4px; }
  .vocab-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .word-big { font-size: 1.7rem; }
}
