/* Fun Training — TV / desktop / phone layout, sized in rem that follows the screen.
   Kept to CSS that older TV browsers (LG webOS, Chromium 79+) understand; phone-only rules may use newer features. */

:root {
  --bg1: #2b2170;
  --bg2: #5a3aa8;
  --card: #ffffff;
  --ink: #2a2350;
  --muted: #8a84b0;
  --accent: #ffd23f;
  --good: #2fc48a;
  --bad: #ff4f6d;
  --blue: #4f8cff;
  --focus: #ffd23f;
}

* { box-sizing: border-box; }

html {
  font-size: clamp(14px, calc(1.25vmin + 0.55vmax), 34px);
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  color: #fff;
  font-family: 'Trebuchet MS', 'Segoe UI', Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* The ring shows for keyboard / remote focus; browsers without :focus-visible drop the second rule and always show it. */
button:focus, input:focus {
  outline: 0.22rem solid var(--focus);
  outline-offset: 0.18rem;
}
button:focus:not(:focus-visible), input:focus:not(:focus-visible) { outline: none; }

[hidden] { display: none !important; }

.screen {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  padding: max(1.4rem, env(safe-area-inset-top)) max(2rem, env(safe-area-inset-right)) max(1.4rem, env(safe-area-inset-bottom)) max(2rem, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
}

h1 { margin: 0 0 0.6rem; font-size: 2rem; }
h3 { margin: 0 0 0.5rem; font-size: 1rem; color: #e4dcff; }
.muted { color: #bdb4e6; font-weight: normal; font-size: 0.8em; }

/* ---------- buttons ---------- */

.btnRow {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.btn {
  padding: 0.6rem 1.6rem;
  border-radius: 1rem;
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--accent);
  color: var(--ink);
  box-shadow: 0 0.25rem 0 #c9a00f;
  transition: transform 0.1s;
}
.btn:hover, .btn:focus-visible { transform: translateY(-0.1rem) scale(1.04); }
.btn:active { transform: translateY(0.15rem); box-shadow: 0 0.08rem 0 #c9a00f; }
.btn.secondary {
  background: rgba(255,255,255,0.16);
  color: #fff;
  box-shadow: 0 0.25rem 0 rgba(0,0,0,0.25);
}

/* ---------- players ---------- */

.logo {
  font-size: 3.2rem;
  margin: 1rem 0 0.2rem;
  background: linear-gradient(90deg, #ffd23f, #ff7eb6, #7ee0ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.sub { margin: 0 0 1.6rem; font-size: 1.3rem; color: #e4dcff; }

.playerGrid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.2rem;
  max-width: 60rem;
}
.playerSlot { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.playerCard {
  width: 11rem;
  min-height: 11rem;
  padding: 1rem 0.6rem;
  border-radius: 1.4rem;
  background: var(--card);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  box-shadow: 0 0.35rem 0 rgba(0,0,0,0.25);
  transition: transform 0.12s;
}
.playerCard:hover, .playerCard:focus-visible { transform: scale(1.06); }
.pAvatar { position: relative; font-size: 3.6rem; line-height: 1.1; }
.look.mini { display: block; width: 1.8em; height: 2.3em; }
.hungry { position: absolute; right: -0.15em; top: 0.1em; font-size: 0.35em; font-style: normal; line-height: 1; background: #fff; border-radius: 50%; padding: 0.15em; box-shadow: 0 0.05em 0.2em rgba(0,0,0,0.3); animation: pulse 1.2s infinite; }
.pName { font-size: 1.2rem; font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pMeta { font-size: 0.85rem; color: #6a6390; }
.newCard { background: rgba(255,255,255,0.14); color: #fff; border: 0.15rem dashed rgba(255,255,255,0.5); box-shadow: none; }
.pDelete {
  font-size: 0.75rem;
  padding: 0.2rem 0.7rem;
  border-radius: 0.6rem;
  color: #d8d0ff;
  opacity: 0.7;
}
.pDelete:hover, .pDelete:focus-visible { opacity: 1; background: rgba(255,255,255,0.12); }
.pDelete.armed { background: var(--bad); color: #fff; opacity: 1; }

/* ---------- new player ---------- */

.nameLabel { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; font-size: 1.1rem; margin-top: 1rem; }
#nameInput {
  font: inherit;
  font-size: 1.6rem;
  width: 18rem;
  padding: 0.5rem 1rem;
  border-radius: 1rem;
  border: none;
  text-align: center;
  color: var(--ink);
  user-select: text;
}
.hint { color: #e4dcff; margin: 1.2rem 0 0.6rem; }
.charGrid { display: grid; grid-template-columns: repeat(5, 7.4rem); gap: 0.7rem; }
.charBtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.3rem 0.2rem 0.35rem;
  border-radius: 1.1rem;
  background: rgba(255,255,255,0.12);
  transition: transform 0.1s;
}
.charBtn .look { width: 100%; height: 7.6rem; }
.charName { font-weight: 800; font-size: 0.95rem; }
.charBtn.on { background: #fff; color: var(--ink); transform: scale(1.06); box-shadow: 0 0 0 0.2rem var(--accent); }
.charBtn:hover { transform: scale(1.06); }
.charNote { margin: 0.6rem 0 0; color: #e4dcff; min-height: 1.3em; }

.shake { animation: shake 0.4s; }
@keyframes shake {
  20%, 60% { transform: translateX(-0.4rem); }
  40%, 80% { transform: translateX(0.4rem); }
}

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

.topBar {
  width: 100%;
  max-width: 64rem;
  display: flex;
  align-items: center;
  gap: 1.4rem;
}
.who { display: flex; align-items: center; gap: 0.6rem; font-size: 1.6rem; font-weight: 800; flex: 1; min-width: 0; text-align: left; padding: 0.15rem 0.8rem 0.15rem 0.2rem; border-radius: 1.4rem; transition: background 0.15s; }
.who:hover, .who:focus-visible { background: rgba(255,255,255,0.14); }
.whoText { display: flex; flex-direction: column; min-width: 0; }
.whoText small { font-size: 0.85rem; color: #e4dcff; font-weight: 700; }
.who.needs small { color: var(--accent); }
.bigAvatar { position: relative; font-size: 2.6rem; }
.bigAvatar .look.mini { width: 1.3em; height: 1.4em; }
.coins {
  font-size: 1.4rem;
  background: rgba(0,0,0,0.2);
  padding: 0.3rem 1rem;
  border-radius: 2rem;
}
.coins b { color: var(--accent); }
.coins .gems { margin-left: 0.6rem; }
.coins .gems b { color: #9fe3ff; }
/* The coin icon (ui/coin.js) — drawn, since older phones show the 🪙 emoji as an empty box. */
.coin {
  display: inline-block;
  width: 1.05em;
  height: 1.05em;
  vertical-align: -0.17em;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12.6' r='10.6' fill='%23b8780a'/%3E%3Ccircle cx='12' cy='11.4' r='10.6' fill='%23f7b928' stroke='%23a86d06' stroke-width='1.2'/%3E%3Ccircle cx='12' cy='11.4' r='7.3' fill='%23ffd451' stroke='%23d18f0c' stroke-width='1.1'/%3E%3Cpath d='M12 6.6 L13.4 9.6 L16.6 10 L14.2 12.2 L14.9 15.4 L12 13.8 L9.1 15.4 L9.8 12.2 L7.4 10 L10.6 9.6 Z' fill='%23eaa31a'/%3E%3Cpath d='M5.6 8.2 A7.6 7.6 0 0 1 10.4 4' fill='none' stroke='%23fff6c4' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.topBtns { display: flex; gap: 0.7rem; }
.topBtns .btn { font-size: 0.95rem; padding: 0.5rem 1.1rem; }
.summary { color: #d8d0ff; font-size: 0.9rem; margin: 0.8rem 0 1rem; text-align: center; }
.summary b { color: var(--accent); }

.processList { width: 100%; max-width: 64rem; display: flex; flex-direction: column; gap: 0.8rem; }
.procRow {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.2rem;
  border-radius: 1.3rem;
  background: var(--card);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 0.3rem 0 rgba(0,0,0,0.25);
  transition: transform 0.12s;
}
.procRow.soon { background: rgba(255,255,255,0.1); color: #cfc8f0; box-shadow: none; cursor: default; }
.procIcon { font-size: 2.6rem; width: 3.4rem; text-align: center; }
.procRow.soon .procIcon { filter: grayscale(0.7); opacity: 0.7; }
.procMain { flex: 1; display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.procName { font-size: 1.25rem; font-weight: 800; }
.soonLabel { font-size: 0.9rem; opacity: 0.8; }
.procSide { display: flex; flex-direction: column; align-items: flex-end; gap: 0.2rem; min-width: 7rem; }
.procStep { font-weight: 800; color: var(--blue); }
.procLevel { font-size: 0.85rem; font-weight: 800; color: var(--muted); white-space: nowrap; }
.procLock { font-size: 0.8rem; font-weight: 800; color: #e08a00; text-align: right; }
.procStars { min-height: 1.2rem; }

.track { display: flex; align-items: center; gap: 0.35rem; }
.cell {
  position: relative;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #ece9f8;
  color: #9a93c0;
  font-size: 0.8rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.cell.done { background: var(--good); color: #fff; }
.cell.partial { color: #fff; font-size: 1rem; }
.cell.partial.r2 { background: #f4b400; }
.cell.partial.r1 { background: #ff8a3d; }
.cell.partial.r0 { background: #ff5c6c; }
button.cell { cursor: pointer; transition: transform 0.1s; }
button.cell:not([disabled]):hover, button.cell:focus-visible { transform: scale(1.18); }
button.cell[disabled] { cursor: default; }
.pageBtn {
  width: 1.6rem;
  height: 2rem;
  border-radius: 0.6rem;
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--blue);
  flex: none;
}
.pageBtn:hover { background: #ece9f8; }
.pageBtn.off { visibility: hidden; }
.procFix { font-size: 0.8rem; font-weight: 800; color: #e08a00; }
.cell.current { background: var(--accent); color: var(--ink); animation: pulse 1.2s infinite; }
.cell.boss { border: 0.14rem solid #ff7a8a; }
.cell i { position: absolute; top: -0.65rem; right: -0.45rem; font-size: 0.75rem; font-style: normal; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,210,63,0.8); }
  50% { box-shadow: 0 0 0 0.35rem rgba(255,210,63,0); }
}
/* Level stars: SVG in the level's material (stars.js), sized by font-size. */
.star { width: 1em; height: 1em; font-size: 1.8rem; vertical-align: -0.15em; flex: none; filter: drop-shadow(0 0.06em 0 rgba(0,0,0,0.3)); }
.star.small { font-size: 1.15rem; }
.star.goal { margin-left: 0.3rem; font-size: 2rem; opacity: 0.35; filter: grayscale(0.6); }
.star.goal.earned { opacity: 1; filter: drop-shadow(0 0.06em 0 rgba(0,0,0,0.3)); }
.star.dim { opacity: 0.4; filter: grayscale(0.6); }
.star.huge { font-size: 5rem; animation: starSpin 1.2s 0.6s both; }
@keyframes starSpin { from { transform: scale(0) rotate(-200deg); } 70% { transform: scale(1.2) rotate(10deg); } to { transform: none; } }
.star .spark { transform-origin: 19.5px 5px; animation: twinkle 1.6s infinite; }
@keyframes twinkle { 0%, 60%, 100% { opacity: 0; transform: scale(0.3); } 75% { opacity: 1; transform: scale(1); } }

/* Level-up in the result dialog: the new star and the road of levels from wood to diamond. */
.levelUp { display: flex; align-items: center; justify-content: center; gap: 1rem; text-align: left; }
.ladder { display: flex; justify-content: center; gap: 0.35rem; margin-top: 0.7rem; flex-wrap: wrap; }
.rung { display: flex; flex-direction: column; align-items: center; width: 3.6rem; font-size: 0.7rem; color: var(--muted); }
.rung .star { font-size: 1.7rem; }
.rung.got small { color: var(--ink); font-weight: 800; }
.rung.next .star { animation: pulseStar 1.2s infinite; }
.rung.next small { color: var(--blue); font-weight: 800; }
.rung.later .star { opacity: 0.3; filter: grayscale(1); }
@keyframes pulseStar { 50% { transform: scale(1.25); } }
.more { font-size: 0.8rem; font-weight: 800; margin-left: 0.2rem; }

/* ---------- settings ---------- */

#screenSettings { padding-top: 1rem; padding-bottom: 1rem; }
.setHead { display: flex; flex-direction: column; align-items: center; }
.setHead h1 { font-size: 1.7rem; margin-bottom: 0.4rem; }
.tabs { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.6rem; }
.tab { padding: 0.35rem 1rem; border-radius: 0.8rem 0.8rem 0 0; background: rgba(255,255,255,0.2); font-weight: 800; }
.tab.on { background: #fff; color: var(--ink); }
.tabUse {
  display: none;
  margin-left: 0.4rem;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: var(--good);
  color: #fff;
  font-size: 0.75rem;
  vertical-align: 0.1rem;
  align-items: center;
  justify-content: center;
}
.tab.used .tabUse { display: inline-flex; }
.tabNa { display: none; margin-left: 0.3rem; font-size: 0.85rem; }
.tab.na .tabNa { display: inline; }
.tabPrice { margin-left: 0.4rem; font-size: 0.8rem; color: #e0a800; }
.tab:not(.on) .tabPrice { color: var(--accent); }

/* Price of the current settings: big coins per task and the steps that make it up. */
.priceLine { display: flex; align-items: center; gap: 0.4rem 0.9rem; flex-wrap: wrap; }
.priceBig {
  padding: 0.25rem 0.9rem;
  border-radius: 1rem;
  background: var(--accent);
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 0.2rem 0 #c79a00;
}
.priceBig small { font-size: 0.75rem; }
.priceSteps { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.pStep { background: rgba(255,255,255,0.12); border-radius: 0.7rem; padding: 0.15rem 0.6rem; font-size: 0.85rem; white-space: nowrap; }
.pStep b { color: var(--accent); }
.soon { color: #bdb4e6; font-size: 0.8rem; }

.setBody {
  width: 100%;
  max-width: 62rem;
  background: rgba(0,0,0,0.18);
  border-radius: 1.4rem;
  padding: 0.9rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.pane { display: flex; flex-direction: column; gap: 0.8rem; }
.pane.unused > :not(.useLine):not(.warnNote) { opacity: 0.45; }
.warnNote { margin: 0; padding: 0.5rem 0.9rem; border-radius: 0.9rem; background: rgba(255,79,109,0.2); color: #ffd6dd; font-weight: 700; }
.useLine { display: flex; align-items: center; gap: 0.4rem 1rem; flex-wrap: wrap; }
.useLine .note { margin-top: 0; }
.commonLine { border-top: 0.1rem solid rgba(255,255,255,0.15); padding-top: 0.8rem; }
.setLine { display: flex; gap: 2.4rem; flex-wrap: wrap; }
.setBlock { display: flex; flex-direction: column; align-items: flex-start; }
.setBlock.off { opacity: 0.45; }

.opsRow { display: flex; gap: 1rem; flex-wrap: wrap; }
.opCol { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.opToggle {
  position: relative;
  width: 8.5rem;
  padding: 0.35rem 0.4rem 0.45rem;
  border-radius: 1rem;
  background: rgba(255,255,255,0.12);
  color: #cfc8f0;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.1s, background 0.15s;
}
.opSign { font-size: 2.2rem; font-weight: 800; line-height: 1.1; }
.opName { font-size: 0.8rem; }
.check {
  position: absolute;
  top: -0.4rem;
  right: -0.4rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--good);
  color: #fff;
  font-size: 0.9rem;
  display: none;
  align-items: center;
  justify-content: center;
}
.opCol.on .opToggle { background: #fff; color: var(--ink); }
.opCol.on .check { display: flex; }
.opToggle:hover, .opToggle:focus-visible { transform: scale(1.05); }
.stepper { display: flex; align-items: center; gap: 0.2rem; }
.opCol:not(.on) .stepper { opacity: 0.45; }
.stepBtn {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1;
}
.stepBtn:hover { background: rgba(255,255,255,0.3); }
.stepVal { min-width: 5.4rem; text-align: center; font-weight: 800; font-size: 0.9rem; }

.seg { display: flex; background: rgba(255,255,255,0.12); border-radius: 1rem; padding: 0.2rem; gap: 0.2rem; }
.segBtn { padding: 0.4rem 1rem; border-radius: 0.8rem; font-weight: 800; min-width: 3rem; color: #e4dcff; }
.segBtn.on { background: #fff; color: var(--ink); box-shadow: 0 0.15rem 0 rgba(0,0,0,0.2); }
.segBtn .noVoice { display: none; }
.segBtn.mute .noVoice { display: inline; }
.sizeSeg { flex-wrap: wrap; }
.sizeSeg .segBtn { min-width: 2.6rem; padding: 0.4rem 0.7rem; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.2rem;
  font-weight: 800;
}
.switch .knob {
  position: relative;
  width: 3.4rem;
  height: 1.8rem;
  border-radius: 1rem;
  background: rgba(255,255,255,0.25);
  transition: background 0.2s;
}
.switch .knob::after {
  content: '';
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.switch.on .knob { background: var(--good); }
.switch.on .knob::after { transform: translateX(1.6rem); }
.note { font-size: 0.75rem; color: #bdb4e6; margin-top: 0.3rem; }

/* Speed: a 5-stop gradient track, the chosen stop pops out as a white pill. */
.speedSeg {
  display: flex;
  padding: 0.25rem;
  gap: 0.25rem;
  border-radius: 1.2rem;
  background: linear-gradient(90deg, #3ddc97, #9be15d, #ffd23f, #ff9f43, #ff4f6d);
}
.speedSeg .segBtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 7.2rem;
  padding: 0.3rem 0.3rem;
  color: rgba(40,30,80,0.8);
  transition: transform 0.15s, background 0.15s;
}
.speedSeg .segBtn.on { background: #fff; transform: scale(1.08); box-shadow: 0 0.25rem 0.6rem rgba(0,0,0,0.3); }
.spIcon { font-size: 1.7rem; line-height: 1.2; }
.spName { font-size: 0.8rem; }

.example { margin: 0; color: #d8d0ff; }
.example b { color: #fff; font-size: 1.15rem; }
.listenBtn { margin-left: 0.5rem; padding: 0.2rem 0.8rem; border-radius: 0.8rem; background: rgba(255,255,255,0.18); font-weight: 800; }
.listenBtn:hover:not([disabled]) { background: rgba(255,255,255,0.3); }
.listenBtn[disabled] { opacity: 0.4; }
.scaleExample { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.scaleMini {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 26rem;
  max-width: 100%;
  padding: 0.3rem 0.8rem 0.3rem 0.4rem;
  border-radius: 1rem;
  background: #fff;
  color: var(--ink);
}
.scaleMini .scaleSvg { flex: 1 1 0; min-width: 0; }
.scaleMini b { color: var(--blue); white-space: nowrap; font-size: 1.15rem; }

/* ---------- lesson ---------- */

#screenLesson {
  padding: 0;
  display: grid;
  grid-template-columns: 1fr minmax(20rem, 34vw);
  align-items: stretch;
  overflow: hidden;
}
#sceneWrap { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
#scene { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#readyNote {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0.2rem 0.6rem rgba(0,0,0,0.5);
  animation: popIn 0.4s;
  pointer-events: none;
  width: max-content;
  max-width: 94%;
  text-align: center;
}

#taskPanel {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: max(1.2rem, env(safe-area-inset-top)) max(1.4rem, env(safe-area-inset-right)) 1.2rem 1.4rem;
  background: linear-gradient(180deg, #332784, #241c5e);
  box-shadow: -0.3rem 0 1rem rgba(0,0,0,0.3);
  min-height: 0;
  min-width: 0;
}
.lsTop { display: flex; align-items: center; gap: 0.6rem; font-weight: 800; font-size: 1.1rem; }
#lsProc { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { background: rgba(255,255,255,0.15); padding: 0.15rem 0.7rem; border-radius: 1rem; font-size: 0.9rem; }
.iconBtn { width: 2.4rem; height: 2.4rem; border-radius: 50%; background: rgba(255,255,255,0.15); font-size: 1.1rem; }
.lsBar { height: 0.7rem; border-radius: 1rem; background: rgba(255,255,255,0.15); overflow: hidden; }
#lsProgress { height: 100%; width: 0; background: linear-gradient(90deg, #3ddc97, #9be15d); border-radius: 1rem; transition: width 0.3s; }
.lsStats { display: flex; gap: 1.4rem; font-size: 1.1rem; }
.lsStats .ok b { color: #7dffc4; }
.lsStats .bad { opacity: 0.5; }
.lsStats .bad.some { opacity: 1; }
.lsStats .bad b { color: #ff9aac; }
.lsStats .earned b { color: var(--accent); }
.lsStats .earned small { font-size: 0.8em; opacity: 0.75; }
.lsStats .earned .eaten { color: #ffb3c9; opacity: 1; }
.lsStats .boss { margin-left: auto; color: #ffb3c0; font-weight: 800; }
.lsStats .boss.active { color: #fff; background: #c0304a; padding: 0 0.7rem; border-radius: 1rem; animation: pulse 1.2s infinite; }
#readyNote.boss { color: #ffd23f; font-size: 4rem; text-shadow: 0 0 1rem #c0304a, 0 0.2rem 0.6rem rgba(0,0,0,0.6); white-space: nowrap; text-align: center; }
#readyNote small { display: block; font-size: 1.5rem; color: #fff; }

#taskCard {
  position: relative;
  background: #fff;
  color: var(--ink);
  border-radius: 1.4rem;
  padding: 1rem 1rem 1.1rem;
  text-align: center;
  box-shadow: 0 0.35rem 0 rgba(0,0,0,0.25);
  margin-top: 0.4rem;
}
#taskPrice { position: absolute; top: 0.45rem; right: 0.7rem; font-size: 0.85rem; font-weight: 800; color: #c79a00; }
#taskText { font-size: 3.2rem; font-weight: 800; white-space: nowrap; line-height: 1.2; }
#taskCard[data-len="m"] #taskText { font-size: 2.4rem; }
#taskCard[data-len="s"] #taskText { font-size: 1.8rem; }
.scaleSvg { display: block; width: 100%; height: auto; }
#taskScale .scaleSvg { max-width: 42rem; margin: 0 auto; }
/* Reading: a big speaker button (listen again) instead of the task text. */
#taskRead { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; padding: 0.3rem 0; }
.sayBtn {
  width: 5.4rem;
  height: 5.4rem;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 2.6rem;
  line-height: 1;
  box-shadow: 0 0.3rem 0 rgba(0,0,0,0.25);
  transition: transform 0.1s;
}
.sayBtn:hover, .sayBtn:focus-visible { transform: scale(1.08); }
.sayHint { font-size: 1.1rem; font-weight: 800; color: var(--muted); }
.ansLine { font-size: 2.6rem; font-weight: 800; color: var(--muted); }
#answerBox { color: var(--blue); display: inline-block; min-width: 2ch; }
#answerBox.empty { color: #c5c0e0; }
#answerBox.typing { border-bottom: 0.2rem solid var(--blue); padding: 0 0.3rem; }
#answerBox.typing.empty { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
#taskCard.pop { animation: popIn 0.25s; }
#taskCard.ok { background: #d8ffe9; box-shadow: 0 0.35rem 0 var(--good); }
#taskCard.bad { background: #ffe0e5; box-shadow: 0 0.35rem 0 var(--bad); animation: shake 0.35s; }
@keyframes popIn { from { transform: scale(0.85); opacity: 0.3; } to { transform: scale(1); opacity: 1; } }

#wrongNote { min-height: 1.6rem; text-align: center; font-size: 1.2rem; font-weight: 800; color: #ffb3c0; white-space: pre-line; }
/* Scales explain a mistake in two lines; keep room for both so the answers don't jump. */
.twoLineNote #wrongNote { min-height: 2.9rem; font-size: 1.05rem; line-height: 1.35; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.choice {
  position: relative;
  padding: 0.7rem 0.5rem;
  border-radius: 1.1rem;
  background: #fff;
  color: var(--ink);
  font-size: 2.2rem;
  font-weight: 800;
  box-shadow: 0 0.3rem 0 rgba(0,0,0,0.3);
  transition: transform 0.08s;
}
.choice:hover, .choice:focus-visible { transform: scale(1.04); }
/* Words and phrases: smaller the longer the longest option is; long ones wrap. */
.choice .val { overflow-wrap: anywhere; }
.choices[data-len] .choice { padding-left: 2rem; padding-right: 0.6rem; }
.choices[data-len=""] .choice { padding-left: 0.5rem; padding-right: 0.5rem; }
.choices[data-len="m"] .choice { font-size: 1.8rem; }
.choices[data-len="s"] .choice { font-size: 1.4rem; }
.choices[data-len="xs"] .choice { font-size: 1.1rem; line-height: 1.25; }
.choice.picked { transform: translateY(0.15rem); box-shadow: 0 0.1rem 0 rgba(0,0,0,0.3); }
.choice .key {
  position: absolute;
  top: 0.35rem;
  left: 0.5rem;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 0.4rem;
  background: #ece9f8;
  color: var(--muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* On-screen number pad (typing mode on touch screens). */
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.padKey {
  height: 3.2rem;
  border-radius: 0.9rem;
  background: #fff;
  color: var(--ink);
  font-size: 1.8rem;
  font-weight: 800;
  box-shadow: 0 0.25rem 0 rgba(0,0,0,0.3);
}
.padKey:active { transform: translateY(0.15rem); box-shadow: 0 0.08rem 0 rgba(0,0,0,0.3); }
.padBack { background: #ffe0e5; color: #c0304a; }
.padOk { background: var(--good); color: #fff; }
.typeHint { text-align: center; color: #d8d0ff; font-size: 1rem; }
.typeHint b { color: var(--accent); }

/* ---------- room and shop ---------- */

#screenRoom {
  padding: 0;
  display: grid;
  grid-template-columns: 1fr minmax(22rem, 38vw);
  align-items: stretch;
  overflow: hidden;
}
#roomWrap { position: relative; min-width: 0; min-height: 0; background: #1d1650; }
#roomScene { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: block; }
.charTap { cursor: pointer; }
.roomPop { font-size: 34px; font-weight: 800; text-anchor: middle; fill: #fff; stroke: #3b2f5c; stroke-width: 7px; paint-order: stroke; stroke-linejoin: round; font-family: 'Trebuchet MS', 'Segoe UI', Arial, sans-serif; }
.roomHud {
  position: absolute;
  top: max(0.7rem, env(safe-area-inset-top));
  left: max(0.8rem, env(safe-area-inset-left));
  right: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  pointer-events: none;
}
.roomWho, .tummy { background: rgba(20,12,50,0.6); padding: 0.25rem 0.8rem; border-radius: 1rem; font-size: 0.95rem; }
.roomWho .loves { color: #ffb3c9; font-size: 0.85rem; margin-left: 0.3rem; }
.tummy { display: flex; align-items: center; gap: 0.5rem; }
.tummyBar { width: 6rem; height: 0.7rem; border-radius: 1rem; background: rgba(255,255,255,0.2); overflow: hidden; }
.tummyBar i { display: block; height: 100%; border-radius: 1rem; transition: width 0.6s; }
.tummyBar i.good { background: var(--good); }
.tummyBar i.mid { background: var(--accent); }
.tummyBar i.low { background: var(--bad); }

#shopPanel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: max(0.9rem, env(safe-area-inset-top)) max(1.1rem, env(safe-area-inset-right)) max(0.9rem, env(safe-area-inset-bottom)) 1.1rem;
  background: linear-gradient(180deg, #332784, #241c5e);
  box-shadow: -0.3rem 0 1rem rgba(0,0,0,0.3);
  min-height: 0;
  min-width: 0;
}
.shopTop { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; }
.shopTop .btn { font-size: 0.95rem; padding: 0.45rem 1rem; }
.shopTop .coins { font-size: 1.15rem; }
.shopTabs { display: flex; gap: 0.4rem; }
.shopTab { flex: 1; padding: 0.45rem 0.3rem; border-radius: 0.9rem; background: rgba(255,255,255,0.14); font-weight: 800; font-size: 1rem; white-space: nowrap; }
.shopTab.on { background: #fff; color: var(--ink); }
.slotTabs { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.slotTab { position: relative; padding: 0.2rem 0.55rem; border-radius: 0.8rem; background: rgba(255,255,255,0.1); font-size: 0.85rem; font-weight: 700; color: #e4dcff; }
.slotTab .sIcon { font-size: 1.05rem; margin-right: 0.2rem; }
.slotTab.on { background: var(--accent); color: var(--ink); }
.slotTab .dot { position: absolute; top: -0.15rem; right: -0.15rem; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0.12rem #241c5e; }
.itemGrid {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.4rem, 1fr));
  grid-auto-rows: min-content;
  gap: 0.55rem;
  padding: 0.3rem;
}
.itemCard {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.3rem 0.25rem 0.25rem;
  border-radius: 1rem;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 0.22rem 0 rgba(0,0,0,0.3);
  transition: transform 0.1s;
}
.itemCard:hover, .itemCard:focus-visible { transform: scale(1.05); }
.thumb { display: block; width: 100%; height: 4.3rem; }
.itemTag { font-size: 0.8rem; font-weight: 800; color: #b8860b; white-space: nowrap; }
.itemCard.gem .itemTag { color: #2f86c9; }
.itemCard.cant { background: #e7e3f5; }
.itemCard.cant .thumb { opacity: 0.55; }
.itemCard.cant .itemTag { color: #9a93c0; }
.itemCard.owned .itemTag { color: var(--good); }
.itemCard.on { background: #d8ffe9; box-shadow: 0 0.22rem 0 var(--good); }
.itemCard.on .itemTag { color: #fff; background: var(--good); border-radius: 0.6rem; padding: 0 0.5rem; }
.itemCard.sel { box-shadow: 0 0 0 0.22rem var(--accent), 0 0.22rem 0 rgba(0,0,0,0.3); }
.itemCard .fav { position: absolute; top: 0.15rem; right: 0.3rem; font-style: normal; color: #ff4f7b; font-size: 0.95rem; }
.itemInfo { display: flex; align-items: center; gap: 0.8rem; min-height: 3.6rem; padding: 0.5rem 0.8rem; border-radius: 1rem; background: rgba(0,0,0,0.22); }
.infoText { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.infoText b { font-size: 1.1rem; }
.infoText span { font-size: 0.85rem; color: #d8d0ff; }
.itemInfo .btn { white-space: nowrap; padding: 0.5rem 1.1rem; font-size: 1rem; }
.itemInfo .btn.off { background: #b7b0d6; box-shadow: 0 0.25rem 0 #8a84b0; color: #4d4675; }
.resShop { margin: 0.4rem 0 0; font-weight: 800; color: #7a3fd0; }

/* ---------- dialogs ---------- */

#overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(20,12,50,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.panel {
  background: linear-gradient(180deg, #ffffff, #efeaff);
  color: var(--ink);
  border-radius: 1.8rem;
  padding: 1.6rem 2.4rem;
  min-width: 24rem;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 1rem 3rem rgba(0,0,0,0.4);
  animation: popIn 0.3s;
}
.panel .btn.secondary { background: #e4def8; color: var(--ink); box-shadow: 0 0.25rem 0 #c4bce4; }
.resIcon { font-size: 4.5rem; line-height: 1.1; }
#resultPanel.won .resIcon { animation: bounce 1s infinite; }
@keyframes bounce { 50% { transform: translateY(-0.5rem) scale(1.05); } }
.resText { margin: 0.2rem 0 0.6rem; font-size: 1.15rem; }
.resCoins { display: flex; flex-direction: column; align-items: center; }
.coinBig { font-size: 2.4rem; font-weight: 800; color: #e0a800; }
.gemBig { margin-left: 0.6rem; color: #3a8fd0; }
.coinRule { font-size: 0.85rem; color: var(--muted); }
.resStar { display: flex; flex-direction: column; align-items: center; margin: 0.6rem 0; font-size: 1.2rem; animation: popIn 0.6s 0.8s both; }
.resTrack { display: flex; justify-content: center; margin: 0.8rem 0 0.2rem; }
.cheatNote { color: var(--bad); font-size: 0.9rem; }
.resSlow { margin: 0.5rem 0 0; font-weight: 700; color: #2a7d5a; }
.panel .btn.slower { background: #7fe0b0; color: var(--ink); box-shadow: 0 0.25rem 0 #3fae7c; }

/* ---------- pause: the Coin Muncher (muncher.js) ---------- */

#overlay.overScene { right: auto; bottom: auto; background: rgba(20,12,50,0.45); overflow-y: auto; }
#overlay.overScene .panel { min-width: 0; max-width: calc(100% - 1rem); margin: auto; }

.muncher { display: block; width: min(17rem, 70vw); height: auto; margin: 0.1rem auto 0; overflow: visible; }
.muncher .mnBody, .muncher .mnOpen, .muncher .mnEyes, .muncher .mnPupils, .mnFly, .mnMinus { transform-box: fill-box; transform-origin: center; }
.muncher .mnEyes { animation: lkBlink 4s infinite; }
.muncher .mnOpen { transform-origin: center top; }
.muncher.eating .mnOpen { animation: mnChomp 0.44s ease-in-out infinite; }
@keyframes mnChomp { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.12); } }
.muncher.eating .mnBody { transform-origin: center bottom; animation: mnSquash 0.44s ease-in-out infinite; }
@keyframes mnSquash { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.04, 0.95); } }
.muncher .mnShut, .muncher .mnHappy { display: none; }
.muncher.full .mnOpen, .muncher.full .mnEyes { display: none; }
.muncher.full .mnShut, .muncher.full .mnHappy { display: inline; }
.muncher.full .mnBody { transform-origin: center bottom; animation: mnSquash 2.4s ease-in-out infinite; }
.mnFly { animation: mnFly 0.5s ease-in forwards; }
@keyframes mnFly { 0% { transform: translate(0, 0); } 45% { transform: translate(calc(var(--dx) * 0.45), calc(var(--dy) * 0.45 - 34px)); }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.4); opacity: 0.3; } }
.mnMinus { font: 800 22px 'Trebuchet MS', 'Segoe UI', Arial, sans-serif; fill: #ff4f7b; stroke: #fff; stroke-width: 5px; paint-order: stroke; text-anchor: middle; animation: mnUp 0.8s ease-out forwards; }
@keyframes mnUp { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-26px); opacity: 0; } }
.pauseLeft { margin: 0.1rem 0 0; font-size: 1.6rem; font-weight: 800; }
.pauseLeft b { color: #d99a00; }
.pauseLeft small { font-size: 0.9rem; font-weight: 700; opacity: 0.7; }
.pauseNote { margin: 0.3rem auto 0; max-width: 22rem; font-size: 1rem; }
.pauseNew { margin: 0.3rem 0 0; font-size: 0.9rem; opacity: 0.7; }
.pauseSpeed { display: flex; justify-content: center; gap: 0.6rem; margin-top: 0.7rem; flex-wrap: wrap; }
.panel .btn.speedBtn { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; padding: 0.45rem 0.9rem; font-size: 1rem;
  background: #e4def8; color: var(--ink); box-shadow: 0 0.25rem 0 #c4bce4; }
.panel .btn#slowerBtn { background: #c9f3dd; box-shadow: 0 0.25rem 0 #7fcfa6; }
.panel .btn#fasterBtn { background: #ffe1c7; box-shadow: 0 0.25rem 0 #f0a86b; }
.speedBtn .spAsk { font-weight: 800; }
.speedBtn .spChange { font-size: 0.85rem; font-weight: 700; }
.speedBtn .spChange small { display: block; font-size: 0.8rem; opacity: 0.8; }
.speedBtn .spChange b { color: #b07d00; }
.speedNote { margin: 0.4rem 0 0; font-weight: 700; color: #2a7d5a; font-size: 0.95rem; }

#fx { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 11; }

#banner {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translate(-50%, -150%);
  background: rgba(0,0,0,0.75);
  padding: 0.5rem 1.2rem;
  border-radius: 1rem;
  font-size: 0.9rem;
  z-index: 20;
  transition: transform 0.25s, opacity 0.25s;
  opacity: 0;
  pointer-events: none;
}
#banner.show { transform: translate(-50%, 0); opacity: 1; }

/* Portrait: scene on top, task panel below. */
@media (orientation: portrait) {
  #screenLesson { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  #taskPanel { box-shadow: 0 -0.3rem 1rem rgba(0,0,0,0.3); }
  /* The room fits the width (800 × 500) under its HUD line; the shop takes the rest. */
  #screenRoom { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  #roomWrap { height: calc(62.5vw + 2.6rem); max-height: 50vh; }
  #roomScene { top: 2.6rem; height: calc(100% - 2.6rem); }
  #shopPanel { box-shadow: 0 -0.3rem 1rem rgba(0,0,0,0.3); padding-top: 0.7rem; }
}

/* Touch screens: no sticky hover zoom after a tap. */
@media (hover: none) {
  .btn:hover, .playerCard:hover, .opToggle:hover, .choice:hover, button.cell:not([disabled]):hover, .charBtn:not(.on):hover, .itemCard:hover { transform: none; }
}

/* ---------- phones (reference: Poco X6 Pro, 444 × 987 CSS px) ---------- */

/* Narrow screens (a phone in portrait). */
@media (max-width: 620px) {
  .screen { padding: max(1rem, env(safe-area-inset-top)) max(0.8rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(0.8rem, env(safe-area-inset-left)); }
  h1 { font-size: 1.6rem; }

  .logo { font-size: 2.4rem; margin-top: 0.6rem; }
  .sub { margin-bottom: 1rem; }
  .playerGrid { gap: 0.8rem; }
  .playerCard { width: 9.5rem; min-height: 9.5rem; }
  .pAvatar { font-size: 3rem; }

  #nameInput { width: 100%; max-width: 18rem; }
  .charGrid { grid-template-columns: repeat(5, 1fr); gap: 0.35rem; width: 100%; }
  .charBtn { padding: 0.2rem 0 0.3rem; }
  .charBtn .look { height: 5rem; }
  .charName { font-size: 0.75rem; }
  .roomHud { gap: 0.3rem; }
  .roomWho .loves { display: none; }
  .roomWho, .tummy { font-size: 0.8rem; }
  .slotTab .sName { display: none; }
  .slotTab { padding: 0.25rem 0.5rem; }
  .itemGrid { grid-template-columns: repeat(auto-fill, minmax(4.4rem, 1fr)); gap: 0.4rem; }
  .thumb { height: 3.4rem; }
  .itemInfo { padding: 0.4rem 0.6rem; gap: 0.5rem; }
  .infoText b { font-size: 1rem; }
  .infoText span { font-size: 0.78rem; }

  .topBar { flex-wrap: wrap; gap: 0.6rem; }
  .who { font-size: 1.3rem; }
  .bigAvatar { font-size: 2.2rem; }
  .coins { font-size: 1.2rem; }
  .topBtns { width: 100%; }
  .topBtns .btn { flex: 1; padding: 0.5rem 0.6rem; }
  .summary { font-size: 0.8rem; margin: 0.6rem 0 0.8rem; }

  /* Process row: icon, name and step on top, the track across the whole row below. */
  .procRow {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "icon name side" "track track track";
    align-items: center;
    gap: 0.3rem 0.6rem;
    padding: 0.6rem 0.6rem 0.7rem;
  }
  .procMain { display: contents; }
  .procIcon { grid-area: icon; font-size: 2rem; width: auto; }
  .procName { grid-area: name; font-size: 1.1rem; }
  .procSide { grid-area: side; min-width: 0; font-size: 0.9rem; }
  .procRow .track, .soonLabel { grid-area: track; }
  .processList .track { width: 100%; gap: 0.2rem; }
  .processList .cell { flex: 1 1 0; width: auto; height: auto; min-width: 0; max-width: 2.4rem; aspect-ratio: 1; }
  .processList .pageBtn { width: 1.2rem; }
  .processList .star.goal { font-size: 1.7rem; margin-left: 0.15rem; }
  .resTrack .track { gap: 0.2rem; }
  .resTrack .cell { width: 1.6rem; height: 1.6rem; }
  .resTrack .star.goal { font-size: 1.6rem; }
  .ladder { gap: 0.15rem; flex-wrap: nowrap; }
  .rung { width: 2.2rem; font-size: 0.65rem; }
  .rung .star { font-size: 1.4rem; }
  .rung small { visibility: hidden; white-space: nowrap; }
  .rung.next small { visibility: visible; }
  .levelUp { gap: 0.6rem; font-size: 1rem; }

  .setHead h1 { font-size: 1.4rem; }
  .tabs { flex-wrap: wrap; justify-content: center; gap: 0.3rem 1rem; }
  .setBody { padding: 0.8rem; }
  .setLine { gap: 0.8rem 1.6rem; }
  .opsRow { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem 0.6rem; align-self: stretch; }
  .opToggle { width: 100%; }
  .speedSeg { align-self: stretch; }
  .speedSeg .segBtn { width: auto; flex: 1 1 0; min-width: 0; padding: 0.3rem 0.1rem; }
  .speedSeg .segBtn.on { transform: scale(1.05); }
  .spIcon { font-size: 1.5rem; }
  .spName { font-size: 0.7rem; line-height: 1.1; }

  #taskPanel { gap: 0.5rem; padding: 0.7rem max(0.8rem, env(safe-area-inset-right)) max(0.8rem, env(safe-area-inset-bottom)) max(0.8rem, env(safe-area-inset-left)); }
  #taskCard { margin-top: 0; padding: 0.6rem 0.8rem 0.7rem; }
  .sayBtn { width: 4.2rem; height: 4.2rem; font-size: 2rem; }
  .sizeSeg .segBtn { min-width: 2.2rem; padding: 0.35rem 0.5rem; }
  .padKey { height: 3rem; }
  #readyNote { font-size: 2.2rem; }
  #readyNote.boss { font-size: 3rem; }
  #readyNote small { font-size: 1.1rem; }

  .panel { min-width: 0; width: 92vw; padding: 1.2rem 1rem; }
}

/* Low screens (a phone in landscape): a compact task panel and dialogs. */
@media (max-height: 520px) and (orientation: landscape) {
  .screen { padding-top: max(0.7rem, env(safe-area-inset-top)); padding-bottom: max(0.7rem, env(safe-area-inset-bottom)); }
  .logo { font-size: 2.4rem; margin-top: 0; }
  .sub { margin-bottom: 0.8rem; }
  .procRow { padding: 0.45rem 1rem; }
  .procIcon { font-size: 2.1rem; }

  #screenLesson { grid-template-columns: 1fr minmax(18rem, 36vw); }
  #screenRoom { grid-template-columns: 1fr minmax(19rem, 44vw); }
  #shopPanel { gap: 0.4rem; padding-top: 0.5rem; padding-bottom: 0.5rem; }
  .shopTab { padding: 0.3rem; font-size: 0.9rem; }
  .slotTab .sName { display: none; }
  .thumb { height: 3rem; }
  .itemGrid { grid-template-columns: repeat(auto-fill, minmax(4rem, 1fr)); gap: 0.4rem; }
  .itemInfo { min-height: 2.8rem; padding: 0.3rem 0.6rem; }
  .charGrid { grid-template-columns: repeat(10, 4.6rem); gap: 0.3rem; }
  .charBtn .look { height: 4.6rem; }
  .charName { font-size: 0.7rem; }
  #taskPanel { gap: 0.4rem; padding: 0.6rem max(0.9rem, env(safe-area-inset-right)) 0.6rem 0.9rem; }
  .lsTop { font-size: 0.95rem; }
  .iconBtn { width: 2rem; height: 2rem; font-size: 0.95rem; }
  .lsBar { height: 0.5rem; }
  .lsStats { font-size: 0.95rem; }
  #taskCard { margin-top: 0; padding: 0.35rem 0.6rem 0.45rem; }
  #taskText { font-size: 2.4rem; }
  #taskCard[data-len="m"] #taskText { font-size: 1.9rem; }
  #taskCard[data-len="s"] #taskText { font-size: 1.5rem; }
  #taskScale .scaleSvg { max-width: 28rem; }
  .ansLine { font-size: 1.9rem; }
  #wrongNote { min-height: 1.2rem; font-size: 1rem; }
  .twoLineNote #wrongNote { min-height: 2.4rem; font-size: 0.9rem; line-height: 1.3; }
  .choices { gap: 0.5rem; }
  .choice { font-size: 1.7rem; padding: 0.35rem 0.4rem; }
  .choice .key { width: 1.1rem; height: 1.1rem; font-size: 0.7rem; top: 0.25rem; left: 0.35rem; }
  .choices[data-len="m"] .choice { font-size: 1.4rem; }
  .choices[data-len="s"] .choice { font-size: 1.15rem; }
  .choices[data-len="xs"] .choice { font-size: 0.95rem; }
  .choices[data-len] .choice { padding-left: 1.5rem; padding-right: 0.4rem; }
  .choices[data-len=""] .choice { padding-left: 0.4rem; }
  #taskRead { flex-direction: row; justify-content: center; gap: 0.8rem; padding: 0; }
  .sayBtn { width: 3.4rem; height: 3.4rem; font-size: 1.7rem; }
  .sayHint { font-size: 0.95rem; }
  .numpad { grid-template-columns: repeat(6, 1fr); gap: 0.4rem; }
  .padKey { height: 2.5rem; font-size: 1.4rem; }
  #readyNote { font-size: 2.2rem; }
  #readyNote.boss { font-size: 3rem; }
  #readyNote small { font-size: 1.1rem; }

  #overlay { align-items: flex-start; overflow-y: auto; padding: 0.5rem 0; }
  .panel { padding: 0.8rem 1.6rem; margin: auto 0; }
  .panel h1 { font-size: 1.5rem; margin-bottom: 0.3rem; }
  .resIcon { font-size: 2.8rem; }
  .resText { font-size: 1rem; margin-bottom: 0.3rem; }
  .coinBig { font-size: 1.8rem; }
  .star.huge { font-size: 2.8rem; }
  .rung small { display: none; }
  .ladder { margin-top: 0.3rem; }
  .resStar { margin: 0.3rem 0; }
  .resTrack { margin: 0.4rem 0 0; }
  .muncher { width: 10rem; }
  .pauseLeft { font-size: 1.2rem; }
  .pauseNote { font-size: 0.85rem; }
  .pauseSpeed { margin-top: 0.4rem; }
  .panel .btn.speedBtn { padding: 0.3rem 0.7rem; font-size: 0.9rem; }
  .panel .btnRow { margin-top: 0.6rem; }
}

/* ---------- character and item art (SVG) animations ---------- */

.lk-eyes, .lk-chew, .lk-tear, .lk-steam, .lk-fire, .lk-wag,
.an-bob, .an-sway, .an-spin, .an-twinkle, .an-swim, .an-flicker, .an-pulse,
.an-float, .an-wiggle, .an-glow, .an-blink, .an-rise, .an-fall, .an-drift, .an-jump { transform-box: fill-box; transform-origin: center; }
.lk-eyes { animation: lkBlink 4.5s infinite; }
@keyframes lkBlink { 0%, 95%, 100% { transform: scaleY(1); } 97.5% { transform: scaleY(0.1); } }
.lk-wag { transform-origin: left center; animation: lkWag 1.4s ease-in-out infinite alternate; }
@keyframes lkWag { from { transform: rotate(-5deg); } to { transform: rotate(6deg); } }
.lk-chew { animation: lkChew 0.18s infinite alternate; }
@keyframes lkChew { from { transform: scaleY(0.35); } to { transform: scaleY(1.2); } }
.lk-tear { animation: lkTear 1.8s infinite; }
@keyframes lkTear { 0% { transform: translateY(-4px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(14px); opacity: 0; } }
.lk-steam { animation: lkSteam 0.7s infinite; }
@keyframes lkSteam { from { transform: translateY(4px) scale(0.8); opacity: 1; } to { transform: translateY(-10px) scale(1.15); opacity: 0.2; } }
.lk-fire { transform-origin: left center; animation: lkFire 0.12s infinite alternate; }
@keyframes lkFire { from { transform: scale(0.92, 0.85); } to { transform: scale(1.04, 1.08); } }
.lk-shiver { animation: lkShiver 0.07s infinite alternate; }
@keyframes lkShiver { from { transform: translateX(-2px); } to { transform: translateX(2px); } }

/* For item art: bob up and down, sway from the bottom, spin, twinkle, swim to and fro, flicker (flames), pulse. */
.an-bob { animation: anBob 2s ease-in-out infinite alternate; }
@keyframes anBob { from { transform: translateY(0); } to { transform: translateY(-6px); } }
.an-sway { transform-origin: bottom center; animation: anSway 3s ease-in-out infinite alternate; }
@keyframes anSway { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
.an-spin { animation: anSpin 6s linear infinite; }
@keyframes anSpin { to { transform: rotate(360deg); } }
.an-twinkle { animation: anTwinkle 1.6s ease-in-out infinite; }
@keyframes anTwinkle { 0%, 100% { opacity: 0.2; transform: scale(0.6); } 50% { opacity: 1; transform: scale(1); } }
.an-swim { animation: anSwim 3.2s ease-in-out infinite alternate; }
@keyframes anSwim { from { transform: translateX(-12px); } to { transform: translateX(12px) ; } }
.an-flicker { transform-origin: top center; animation: anFlicker 0.12s infinite alternate; }
@keyframes anFlicker { from { transform: scaleY(0.8); } to { transform: scaleY(1.15); } }
.an-pulse { animation: anPulse 1.2s ease-in-out infinite alternate; }
@keyframes anPulse { from { transform: scale(0.94); } to { transform: scale(1.06); } }
/* More: float (drift up and down with a tilt), wiggle (a quick shake), glow (fades in and out), blink (on / off lights),
   rise (bubbles / steam going up and fading), fall (snow / rain / leaves dropping), drift (slides across and back), jump (hops).
   an-d1…an-d4 delay any of them so neighbours don't move in step. */
.an-float { animation: anFloat 3s ease-in-out infinite alternate; }
@keyframes anFloat { from { transform: translateY(2px) rotate(-3deg); } to { transform: translateY(-8px) rotate(3deg); } }
.an-wiggle { animation: anWiggle 0.9s ease-in-out infinite alternate; }
@keyframes anWiggle { from { transform: rotate(-7deg); } to { transform: rotate(7deg); } }
.an-glow { animation: anGlow 2.2s ease-in-out infinite alternate; }
@keyframes anGlow { from { opacity: 0.35; } to { opacity: 1; } }
.an-blink { animation: anBlink 1.2s steps(1) infinite; }
@keyframes anBlink { 0% { opacity: 1; } 50% { opacity: 0.25; } }
.an-rise { animation: anRise 2.4s ease-in infinite; }
@keyframes anRise { 0% { transform: translateY(0) scale(0.6); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-40px) scale(1.1); opacity: 0; } }
.an-fall { animation: anFall 3s linear infinite; }
@keyframes anFall { 0% { transform: translateY(-30px); opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { transform: translateY(30px); opacity: 0; } }
.an-drift { animation: anDrift 6s ease-in-out infinite alternate; }
@keyframes anDrift { from { transform: translateX(-30px); } to { transform: translateX(30px); } }
.an-jump { transform-origin: bottom center; animation: anJump 1.6s ease-in-out infinite; }
@keyframes anJump { 0%, 60%, 100% { transform: translateY(0) scaleY(1); } 70% { transform: translateY(0) scaleY(0.88); } 82% { transform: translateY(-12px) scaleY(1.05); } }
.an-d1 { animation-delay: -0.4s; } .an-d2 { animation-delay: -0.9s; } .an-d3 { animation-delay: -1.4s; } .an-d4 { animation-delay: -2s; }

/* the mouse cursor, hidden in fullscreen while it is still (core/cursor.js) */
html.cursor-hidden, html.cursor-hidden * { cursor: none !important; }
