  :root {
    --bg1: #a29bfe; --bg2: #74b9ff;
    --card: #ffffff; --ink: #2d3436; --soft: #636e72;
    --purple: #6c5ce7; --green: #00b894; --red: #ff7675;
    --yellow: #fdcb6e; --orange: #e17055; --pink: #fd79a8; --blue: #0984e3;
  }
  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
  button { touch-action: manipulation; -webkit-touch-callout: none; }
  html, body { margin: 0; height: 100%; }
  body {
    font-family: "Baloo 2", "Comic Sans MS", system-ui, sans-serif;
    color: var(--ink);
    background: var(--bg2);
    display: flex; justify-content: center; align-items: flex-start;
    min-height: 100%; overflow-x: hidden;
    padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
             calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
    -webkit-touch-callout: none; overscroll-behavior: none;
    user-select: none; -webkit-user-select: none;
  }
  body::before { content: ""; position: fixed; inset: 0; z-index: -1;
                 background: linear-gradient(160deg, var(--bg1), var(--bg2)); }
  .screen { display: none; width: 100%; max-width: 560px; position: relative; }
  .screen.on { display: block; animation: pop-in .35s ease-out; }
  @keyframes pop { from { transform: scale(.94); opacity: 0 } to { transform: scale(1); opacity: 1 } }
  .card {
    background: var(--card); border-radius: 28px; padding: 20px;
    box-shadow: 0 10px 0 rgba(0,0,0,.12), 0 20px 40px rgba(0,0,0,.15);
    margin-bottom: 18px;
  }
  h1 { font-size: clamp(32px, 8.5vw, 52px); line-height: 1; margin: 6px 0 4px; padding: 0 50px; text-align: center; color: #fff;
       text-shadow: 0 4px 0 rgba(0,0,0,.18); }
  .sub { text-align: center; color: #fff; font-size: 20px; margin: 0 0 16px; opacity: .95; }
  .step { display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 800; margin: 0 0 12px; }
  .step .n { background: var(--purple); color: #fff; width: 40px; height: 40px; border-radius: 50%;
             display: grid; place-items: center; flex: none; }
  .hint { color: var(--soft); font-size: 17px; margin: -6px 0 12px 50px; }

  .nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .num {
    font: inherit; font-size: 30px; font-weight: 800; border: 0; border-radius: 18px;
    padding: 10px 0; cursor: pointer; background: #f1f2f6; color: var(--ink);
    box-shadow: 0 5px 0 #dfe4ea; transition: transform .08s;
  }
  .num:active { transform: translateY(4px); box-shadow: 0 1px 0 #dfe4ea; }
  .num.pick { color: #fff; background: var(--c, var(--green)); box-shadow: 0 5px 0 rgba(0,0,0,.2); }
  .num.pick::after { content: " ✓"; font-size: 20px; }
  .quick { display: flex; gap: 10px; margin-top: 12px; }
  .quick button { flex: 1; font: inherit; font-size: 18px; font-weight: 800; border: 3px dashed #dfe4ea;
                  background: #fff; border-radius: 14px; padding: 6px; cursor: pointer; color: var(--soft); }

  .times { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .time {
    font: inherit; border: 0; border-radius: 18px; padding: 10px 4px; cursor: pointer;
    background: #f1f2f6; box-shadow: 0 5px 0 #dfe4ea; color: var(--ink);
  }
  .time .e { font-size: 38px; display: block; line-height: 1.1; }
  .time .t { font-size: 22px; font-weight: 800; }
  .time .w { font-size: 15px; color: var(--soft); display: block; }
  .time.pick { background: var(--yellow); box-shadow: 0 5px 0 #e1a73b; }
  .time.pick .w { color: var(--ink); }

  .go {
    width: 100%; font: inherit; font-size: 40px; font-weight: 800; color: #fff; border: 0;
    background: var(--green); border-radius: 26px; padding: 14px; cursor: pointer;
    box-shadow: 0 8px 0 #009273, 0 14px 30px rgba(0,0,0,.2);
    animation: wiggle 2.2s infinite;
  }
  .go:active { transform: translateY(6px); box-shadow: 0 2px 0 #009273; }
  .go:disabled { background: #b2bec3; box-shadow: 0 8px 0 #95a5a6; animation: none; }
  @keyframes wiggle { 0%,85%,100% { transform: rotate(0) } 90% { transform: rotate(-2deg) } 95% { transform: rotate(2deg) } }
  .gobar { position: sticky; bottom: 0; z-index: 4; margin: 0;
           padding: 14px 0 calc(14px + env(safe-area-inset-bottom));
           margin-bottom: calc(-16px - env(safe-area-inset-bottom));
           background: linear-gradient(to top, var(--bg2) 55%, transparent); }
  .best { text-align: center; color: #fff; font-size: 20px; margin-top: 14px; }

  /* game */
  .top { padding-right: 58px; display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
  .pill { background: #fff; border-radius: 999px; padding: 4px 14px; white-space: nowrap; font-size: 24px; font-weight: 800;
          box-shadow: 0 4px 0 rgba(0,0,0,.12); }
  .quit { font: inherit; font-size: 18px; font-weight: 800; border: 0; background: rgba(255,255,255,.35);
          color: #fff; border-radius: 999px; padding: 6px 14px; cursor: pointer; }
  .bar { height: 22px; background: rgba(255,255,255,.4); border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
  .bar > div { height: 100%; width: 100%; background: var(--green); border-radius: 999px; transition: width .25s linear, background .3s; }
  .q { text-align: center; font-size: clamp(64px, 20vw, 110px); font-weight: 800; line-height: 1; padding: 10px 0 0; }
  .q .x { color: var(--pink); }
  .ans {
    margin: 8px auto 0; min-height: 90px; width: 70%; border-radius: 22px; background: #f1f2f6;
    font-size: 70px; font-weight: 800; text-align: center; line-height: 90px; color: var(--purple);
    border: 4px solid #dfe4ea;
  }
  .ans.empty::before { content: "?"; color: #b2bec3; }
  .card.good { animation: good .4s; }
  .card.bad { animation: shake .4s; }
  @keyframes good { 50% { background: #d1f7ec; transform: scale(1.03) } }
  @keyframes shake { 20%,60% { transform: translateX(-10px) } 40%,80% { transform: translateX(10px) } }
  .fix { text-align: center; font-size: 26px; min-height: 40px; margin-top: 6px; font-weight: 800; }
  .pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .key {
    font: inherit; font-size: 38px; font-weight: 800; border: 0; border-radius: 20px; padding: 8px 0;
    background: #fff; color: var(--ink); box-shadow: 0 6px 0 rgba(0,0,0,.15); cursor: pointer;
  }
  .key:active { transform: translateY(5px); box-shadow: 0 1px 0 rgba(0,0,0,.15); }
  .key.del { background: var(--red); color: #fff; }
  .key.ok { background: var(--green); color: #fff; }

  /* results */
  .big { font-size: 90px; text-align: center; line-height: 1; margin: 0; }
  .stars { font-size: 60px; text-align: center; letter-spacing: 6px; margin: 6px 0; }
  .res { text-align: center; font-size: 28px; font-weight: 800; margin: 4px 0; }
  .res small { display: block; font-size: 20px; color: var(--soft); font-weight: 600; }
  .newbest { text-align: center; font-size: 26px; font-weight: 800; color: var(--orange); animation: pulse .6s infinite alternate; }
  @keyframes pulse { to { transform: scale(1.08) } }
  .miss { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
  .miss span { background: #ffeaa7; border-radius: 12px; padding: 2px 12px; font-size: 22px; font-weight: 800; }
  .again { display: grid; gap: 12px; }
  .alt { width: 100%; font: inherit; font-size: 24px; font-weight: 800; border: 0; border-radius: 22px; padding: 10px;
         background: #fff; color: var(--purple); cursor: pointer; box-shadow: 0 6px 0 rgba(0,0,0,.15); }

  .sound { position: fixed; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); font-size: 28px; border: 0; background: rgba(255,255,255,.35);
           border-radius: 50%; width: 50px; height: 50px; cursor: pointer; z-index: 5; }
  .count { position: fixed; inset: 0; display: none; place-items: center; font-size: 200px; font-weight: 800; color: #fff;
           text-shadow: 0 8px 0 rgba(0,0,0,.2); background: rgba(108,92,231,.55); z-index: 10; }
  .count.on { display: grid; }
  .count span { animation: zoom .9s ease-out; }
  @keyframes zoom { from { transform: scale(2.5); opacity: 0 } 30% { opacity: 1 } to { transform: scale(1) } }
  .confetti { position: fixed; top: -20px; font-size: 28px; pointer-events: none; z-index: 20; animation: fall linear forwards; }
  @keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

  @media (orientation: landscape) and (min-width: 700px) {
    .screen { max-width: 1000px; }
    .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
    #game.on { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: center; }
    #done.on { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; align-items: center; }
    #done h1 { grid-column: 1 / -1; }
    #done .rcard { margin: 0; }
  }
  @media (orientation: landscape) and (max-height: 500px) {
    h1 { font-size: 30px; } .sub { display: none; }
    .card { padding: 12px 14px; border-radius: 22px; margin-bottom: 12px; }
    .step { font-size: 19px; margin-bottom: 8px; } .step .n { width: 32px; height: 32px; }
    .hint { display: none; }
    .num { font-size: 22px; padding: 4px 0; } .nums { gap: 7px; }
    .time .e { font-size: 26px; } .time .t { font-size: 18px; } .time { padding: 6px 2px; }
    .go { font-size: 30px; padding: 8px; }
    .top { margin-bottom: 6px; } .pill { font-size: 20px; } .bar { height: 14px; margin-bottom: 8px; }
    .q { font-size: 56px; padding-top: 0; }
    .ans { min-height: 60px; line-height: 60px; font-size: 46px; border-width: 3px; }
    .fix { font-size: 20px; min-height: 28px; }
    .pad { gap: 7px; } .key { font-size: 28px; padding: 6px 0; }
    #game .card { margin: 0; }
    #game.on { padding-right: 56px; }
    .big { font-size: 50px; } .stars { font-size: 40px; } .res { font-size: 22px; }
  }
  @media (min-width: 740px) and (min-height: 740px) {
    body { font-size: 120%; }
    .screen:not(#map):not(#house):not(#pethouse):not(#typeGame):not(#drive):not(#planet):not(#farm):not(#farmHouse):not(#lemon):not(#realm):not(#paint):not(#steal):not(#shelter):not(#manor):not(#quest):not(#bhPick):not(#bhPlay), .mcard { zoom: 1.25; }
  }
  @media (orientation: landscape) and (min-width: 1000px) and (min-height: 740px) {
    .screen:not(#map):not(#house):not(#pethouse):not(#typeGame):not(#drive):not(#planet):not(#farm):not(#farmHouse):not(#lemon):not(#realm):not(#paint):not(#steal):not(#shelter):not(#manor):not(#quest):not(#bhPick):not(#bhPlay), .mcard { zoom: 1.4; }
  }
  @media (orientation: portrait) and (min-width: 740px) and (min-height: 1060px) {
    .screen:not(#map):not(#house):not(#pethouse):not(#typeGame):not(#drive):not(#planet):not(#farm):not(#farmHouse):not(#lemon):not(#realm):not(#paint):not(#steal):not(#shelter):not(#manor):not(#quest):not(#bhPick):not(#bhPlay) { max-width: 620px; } .screen:not(#map):not(#house):not(#pethouse):not(#typeGame):not(#drive):not(#planet):not(#farm):not(#farmHouse):not(#lemon):not(#realm):not(#paint):not(#steal):not(#shelter):not(#manor):not(#quest):not(#bhPick):not(#bhPlay), .mcard { zoom: 1.35; }
  }
  @media (orientation: portrait) and (max-height: 700px) {
    .q { font-size: 64px; } .ans { min-height: 70px; line-height: 70px; font-size: 54px; }
    .key { font-size: 30px; padding: 4px 0; } .fix { min-height: 30px; font-size: 22px; }
  }

  /* ---------- home ---------- */
  .modes { display: grid; gap: 18px; margin-top: 10px; }
  .mode {
    font: inherit; border: 0; border-radius: 28px; padding: 18px 20px; cursor: pointer; text-align: left;
    background: #fff; color: var(--ink); display: grid; grid-template-columns: auto 1fr; column-gap: 16px; align-items: center;
    box-shadow: 0 8px 0 rgba(0,0,0,.15), 0 16px 30px rgba(0,0,0,.15);
  }
  .mode:active { transform: translateY(6px); box-shadow: 0 2px 0 rgba(0,0,0,.15); }
  .mode .me { font-size: 64px; grid-row: span 2; line-height: 1; }
  .mode .mt { font-size: 38px; font-weight: 800; line-height: 1.1; color: var(--purple); }
  .mode .md { font-size: 19px; color: var(--soft); line-height: 1.2; }
  .mode.adv .mt { color: var(--green); }
  .back { position: absolute; top: -2px; left: 0; font-size: 26px; border: 0; background: rgba(255,255,255,.35);
          border-radius: 50%; width: 50px; height: 50px; cursor: pointer; z-index: 5; }
  .maps .t { font-size: 19px; }
  @media (orientation: landscape) and (min-width: 700px) {
    .modes { grid-template-columns: repeat(3, 1fr); }
    .mode { grid-template-columns: 1fr; text-align: center; padding: 24px; }
    .mode .me { grid-row: auto; font-size: 80px; }
  }

  /* ---------- adventure map ---------- */
  body[data-screen="map"], body[data-screen="house"], body[data-screen="pethouse"], body[data-screen="typeGame"] { overflow: hidden; }
  #map.on, #house.on, #pethouse.on, #typeGame.on {
    position: fixed; inset: 0; max-width: none; display: flex; flex-direction: column; animation: none;
    padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right))
             calc(12px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  }
  .hud { display: flex; align-items: center; gap: 8px; padding-right: 58px; margin-bottom: 10px; min-height: 50px; }
  .hud .pill { font-size: 22px; padding: 2px 12px; }
  @media (max-width: 480px) {
    .hud { gap: 6px; } .hud .pill, .hbtn { font-size: 19px; padding: 3px 10px; }
    .shopword { display: none; }
  }
  .hbtn { font: inherit; font-size: 22px; font-weight: 800; border: 0; border-radius: 999px; background: rgba(255,255,255,.9);
          padding: 4px 12px; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.12); color: var(--ink); }
  .hbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.12); }
  .shopbtn { margin-left: auto; background: var(--yellow); white-space: nowrap; }
  .view { position: relative; flex: 1; overflow: hidden; border-radius: 22px; background: #4b3f8f;
          box-shadow: inset 0 0 0 4px rgba(255,255,255,.5), 0 10px 30px rgba(0,0,0,.2); }
  .world { position: absolute; left: 0; top: 0; display: grid; transition: transform .25s ease-out; }
  .tile { width: var(--ts); height: var(--ts); display: grid; place-items: center; position: relative; cursor: pointer;
          background: var(--g1); font-size: calc(var(--ts) * .72); line-height: 1; }
  .tile.chk { background: var(--g2); }
  .tile .in { display: grid; place-items: center; }
  .tile .deco { font-size: .6em; opacity: .9; }
  .t-water { background: var(--water) !important;
             background-image: radial-gradient(circle at 30% 35%, rgba(255,255,255,.35) 0 10%, transparent 11%),
                               radial-gradient(circle at 70% 70%, rgba(255,255,255,.25) 0 8%, transparent 9%) !important; }
  .t-gate { background: #d9b382 !important; }
  .t-gate .in { animation: bob 1.6s ease-in-out infinite; }
  .t-gate.open { background: #ead3a8 !important; }
  @keyframes bob { 50% { transform: translateY(-8%) scale(1.06); } }
  .badge { position: absolute; top: 1px; right: 1px; background: var(--purple); color: #fff; font-size: calc(var(--ts) * .24);
           border-radius: 999px; padding: 0 .35em; font-weight: 800; line-height: 1.35; box-shadow: 0 2px 0 rgba(0,0,0,.2); white-space: nowrap; }
  .badge.gold { background: var(--yellow); color: var(--ink); top: auto; bottom: 1px; right: 50%; transform: translateX(50%); }
  .badge.flag { background: none; box-shadow: none; font-size: calc(var(--ts) * .4); top: -4px; }
  .t-castle .in { filter: drop-shadow(0 3px 0 rgba(0,0,0,.2)); }
  .t-castle:not(.done) .in { animation: bob 2.4s ease-in-out infinite; }
  .tile.fog { background: #4b3f8f !important; background-image: none !important; cursor: default; }
  .tile.fog .in { visibility: hidden; }
  .tile.fog::after { content: "☁️"; position: absolute; font-size: calc(var(--ts) * .5); opacity: .28; }
  .tile.wobble .in { animation: shake .3s; }
  .hero, .petc { position: absolute; left: 0; top: 0; width: var(--ts); height: var(--ts); display: grid; place-items: center;
                 transition: transform .15s linear; pointer-events: none; }
  .hero { z-index: 3; }
  .petc { z-index: 2; font-size: calc(var(--ts) * .5); align-items: end; padding-bottom: 2px; transition-duration: .22s; }
  .a-char { font-size: calc(var(--ts) * .8); line-height: 1; filter: drop-shadow(0 3px 0 rgba(0,0,0,.25)); }
  .a-hat { position: absolute; top: calc(var(--ts) * -.3); left: 50%; transform: translateX(-50%); font-size: calc(var(--ts) * .5); line-height: 1; }
  .hero.walk .a-char { animation: hop .3s ease-in-out infinite; }
  @keyframes hop { 50% { transform: translateY(-12%); } }
  .floaty { position: absolute; transform: translateX(-50%); font-size: 24px; font-weight: 800; color: #fff; z-index: 4; pointer-events: none;
            text-shadow: 0 2px 0 rgba(0,0,0,.35); white-space: nowrap; animation: floatup 1.2s ease-out forwards; }
  @keyframes floatup { to { transform: translate(-50%, -60px); opacity: 0; } }
  .toast { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); width: max-content; max-width: 92%;
           background: rgba(45,52,54,.88); color: #fff; font-size: 20px; font-weight: 800; padding: 6px 16px; border-radius: 18px;
           z-index: 6; opacity: 0; transition: opacity .3s; pointer-events: none; text-align: center; }
  .toast.on { opacity: 1; }
  .dpad { position: absolute; right: 10px; bottom: 10px; z-index: 5; display: grid; gap: 4px;
          grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(3, 48px); }
  .dpad button { border: 0; border-radius: 14px; background: rgba(255,255,255,.8); font-size: 22px; cursor: pointer;
                 box-shadow: 0 3px 0 rgba(0,0,0,.2); padding: 0; }
  .dpad button:active { transform: translateY(2px); box-shadow: none; }
  .dpad .up { grid-area: 1 / 2; } .dpad .left { grid-area: 2 / 1; } .dpad .right { grid-area: 2 / 3; } .dpad .down { grid-area: 3 / 2; }
  @media (max-height: 500px) {
    .dpad { grid-template-columns: repeat(3, 40px); grid-template-rows: repeat(3, 40px); }
    .hud { min-height: 40px; margin-bottom: 6px; }
  }

  /* ---------- windows ---------- */
  .modal { position: fixed; inset: 0; z-index: 30; background: rgba(45,52,54,.55); display: flex; align-items: center; justify-content: center;
           padding: calc(10px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right))
                    calc(10px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left)); }
  .modal[hidden] { display: none; }
  .mcard { background: #fff; border-radius: 28px; padding: 16px; width: 100%; max-width: 480px; max-height: 100%; overflow: auto;
           position: relative; animation: pop-in .3s ease-out; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
  @keyframes pop-in { from { transform: scale(.92); } }
  .mclose { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; border-radius: 50%; border: 0;
            background: #f1f2f6; font-size: 20px; cursor: pointer; color: var(--soft); z-index: 2; }
  .chead { display: flex; align-items: center; gap: 12px; padding-right: 48px; min-height: 60px; }
  .cicon { font-size: 54px; line-height: 1; display: inline-block; }
  .cicon.hit { animation: hit .45s; }
  @keyframes hit { 30% { transform: scale(.75) rotate(-12deg); filter: drop-shadow(0 0 10px #ff3b3b); } }
  .ctitle { font-size: 21px; font-weight: 800; line-height: 1.15; }
  .cprog { font-size: 20px; line-height: 1.3; word-break: break-all; }
  .chal .q { font-size: 64px; padding-top: 6px; }
  .vadd { display: inline-block; text-align: right; font-feature-settings: "tnum"; font-variant-numeric: tabular-nums; line-height: 1.02; font-size: 54px; }
  .vadd > div:last-child { border-bottom: 5px solid var(--ink); padding-left: 10px; }
  .vadd .x { margin-right: 6px; }
  .chal .ans { width: 78%; min-height: 76px; line-height: 70px; font-size: 56px; }
  .chal .fix { font-size: 21px; min-height: 30px; line-height: 1.2; }
  .chal .pad { gap: 8px; }
  .chal .key { font-size: 32px; padding: 6px 0; background: #f1f2f6; box-shadow: 0 5px 0 #dfe4ea; }
  .chal .key.del { background: var(--red); box-shadow: 0 5px 0 #d35f5e; }
  .chal .key.ok { background: var(--green); box-shadow: 0 5px 0 #009273; }
  .chal.good { animation: good .4s; }
  .chal.bad { animation: shake .4s; }
  @media (max-height: 720px) and (orientation: portrait) {
    .chal .q { font-size: 52px; } .vadd { font-size: 42px; }
    .chal .ans { min-height: 62px; line-height: 56px; font-size: 46px; }
    .chal .key { font-size: 28px; padding: 3px 0; }
    .cicon { font-size: 44px; } .ctitle { font-size: 19px; }
  }
  @media (orientation: landscape) and (max-height: 600px) {
    .mcard.chal { max-width: 760px; }
    .cbody { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: center; }
    .chal .q { font-size: 46px; } .vadd { font-size: 38px; }
    .chal .ans { min-height: 56px; line-height: 50px; font-size: 42px; }
    .chal .key { font-size: 26px; padding: 2px 0; }
    .chead { min-height: 44px; } .cicon { font-size: 40px; } .ctitle { font-size: 18px; } .cprog { font-size: 16px; }
    .chal .fix { font-size: 17px; min-height: 22px; }
  }

  /* ---------- shop ---------- */
  .shopcard { max-width: 560px; }
  .shophead { display: flex; align-items: center; gap: 16px; padding-right: 48px; margin-bottom: 10px; }
  .shophead .pill { display: inline-block; margin-top: 4px; background: #f1f2f6; box-shadow: none; }
  .avatar { position: relative; width: 90px; height: 90px; display: grid; place-items: center; background: #dff5e1; border-radius: 24px; flex: none; }
  .hero-preview { position: relative; display: grid; place-items: center; --ts: 80px; }
  .pet-preview { position: absolute; right: 2px; bottom: 0; font-size: 34px; }
  .tabs { display: flex; gap: 6px; margin-bottom: 10px; }
  .tab { flex: 1; font: inherit; font-size: 17px; font-weight: 800; border: 0; border-radius: 14px; padding: 8px 4px; cursor: pointer;
         background: #f1f2f6; color: var(--soft); }
  .tab.on { background: var(--purple); color: #fff; }
  .items { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
  .item { font: inherit; border: 0; border-radius: 18px; padding: 8px 4px; cursor: pointer; background: #f1f2f6; box-shadow: 0 5px 0 #dfe4ea;
          display: grid; justify-items: center; color: var(--ink); }
  .item .ie { font-size: 46px; line-height: 1.1; }
  .item .il { font-size: 17px; font-weight: 800; }
  .item.wearing { background: #d1f7ec; box-shadow: 0 5px 0 #7fd8bd; }
  .item.cant { opacity: .5; }
  .item.pending { outline: 4px solid var(--yellow); }
  .buybar { position: sticky; bottom: -16px; margin: 12px -16px -16px; padding: 12px 16px; background: #fff7e0; border-top: 3px solid var(--yellow);
            display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 20px; font-weight: 800; }
  .buybar span { flex: 1 1 100%; }
  .buybar button { flex: 1; }
  .buybar button { font: inherit; font-size: 20px; font-weight: 800; border: 0; border-radius: 14px; padding: 6px 16px; cursor: pointer; }
  .buybar .yes { background: var(--green); color: #fff; box-shadow: 0 4px 0 #009273; }
  .buybar .no { background: #fff; color: var(--soft); box-shadow: 0 4px 0 #dfe4ea; }
  #win .mcard { text-align: center; }

  /* ---------- story ---------- */
  .modal.story { background: radial-gradient(circle at 50% 30%, #8e7cff, #3b2f86); }
  .storycard { text-align: center; max-width: 520px; padding: 22px 20px 16px; }
  .storycard.turn { animation: pop-in .35s ease-out; }
  .sart { font-size: 84px; line-height: 1.1; min-height: 100px; animation: floaty-art 2.4s ease-in-out infinite; }
  @keyframes floaty-art { 50% { transform: translateY(-8px) scale(1.04); } }
  .stext { font-size: 26px; font-weight: 800; line-height: 1.25; margin: 12px 0 14px; min-height: 66px; }
  .stext.stitle { font-size: 34px; color: var(--purple); }
  .sdots { display: flex; justify-content: center; gap: 8px; margin-bottom: 14px; }
  .sdots i { width: 12px; height: 12px; border-radius: 50%; background: #dfe4ea; }
  .sdots i.on { background: var(--purple); }
  .storycard .go { animation: none; font-size: 32px; padding: 10px; }
  .sskip { margin-top: 10px; font: inherit; font-size: 18px; font-weight: 800; border: 0; background: none; color: var(--soft); cursor: pointer; }
  .t-castle.big .in { font-size: 1.15em; filter: drop-shadow(0 0 6px #ffd54a) drop-shadow(0 3px 0 rgba(0,0,0,.2)); }
  .badge.crown { background: none; box-shadow: none; font-size: calc(var(--ts) * .42); top: -6px; right: 50%; transform: translateX(50%); }
  .mapbtn.locked { opacity: .5; }
  .maps { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  @media (orientation: landscape) and (max-height: 500px) {
    .sart { font-size: 54px; min-height: 60px; } .stext { font-size: 20px; min-height: 0; margin: 6px 0 8px; }
    .stext.stitle { font-size: 26px; } .storycard .go { font-size: 24px; padding: 6px; } .storycard { padding: 12px 16px 8px; }
  }

  /* ---------- events and portal ---------- */
  .npc { position: absolute; left: 0; top: 0; width: var(--ts); height: var(--ts); display: grid; place-items: center;
         z-index: 3; pointer-events: none; }
  .npc-e { font-size: calc(var(--ts) * .78); line-height: 1; filter: drop-shadow(0 3px 0 rgba(0,0,0,.25));
           animation: bob 1.2s ease-in-out infinite; }
  .npc-bang { position: absolute; top: calc(var(--ts) * -.28); right: 0; font-size: calc(var(--ts) * .4); animation: pulse .5s infinite alternate; }
  .ctimer { position: relative; height: 26px; background: #f1f2f6; border-radius: 999px; overflow: hidden; margin: 8px 0 0; }
  .ctimer > div { height: 100%; width: 100%; background: var(--green); border-radius: 999px; transition: width .1s linear; }
  .ctimer span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 17px; font-weight: 800; color: var(--ink); }
  .eventcard { text-align: center; max-width: 440px; }
  .eventcard .sart { font-size: 80px; min-height: 90px; }
  .eventcard .res { font-size: 28px; margin: 6px 0; }
  .etext { font-size: 21px; line-height: 1.3; color: var(--soft); font-weight: 600; margin: 0 0 14px; }
  .eventcard .go { font-size: 28px; animation: none; padding: 10px; }
  .badge.swirl { background: none; box-shadow: none; font-size: calc(var(--ts) * .45); top: -6px; right: 50%;
                 transform: translateX(50%); animation: spin 2.4s linear infinite; }
  @keyframes spin { to { transform: translateX(50%) rotate(360deg); } }
  .t-castle.portal .in { filter: drop-shadow(0 0 8px #a29bfe) drop-shadow(0 3px 0 rgba(0,0,0,.2)); }
  @media (orientation: landscape) and (max-height: 500px) {
    .eventcard .sart { font-size: 48px; min-height: 50px; } .eventcard .res { font-size: 22px; }
    .etext { font-size: 17px; margin-bottom: 8px; } .eventcard .go { font-size: 22px; padding: 6px; }
    .eventcard .again { grid-template-columns: 1fr 1fr; }
    .ctimer { height: 20px; margin-top: 4px; }
  }

  /* ---------- avatar extras ---------- */
  .a-hold { position: absolute; right: calc(var(--ts) * -.12); bottom: calc(var(--ts) * .02); font-size: calc(var(--ts) * .42); line-height: 1; }
  .trail { position: absolute; left: 0; top: 0; width: var(--ts); height: var(--ts); display: grid; place-items: center; z-index: 1;
           font-size: calc(var(--ts) * .42); pointer-events: none; animation: trailfade 1.4s ease-out forwards; }
  @keyframes trailfade { from { opacity: .95; } to { opacity: 0; scale: .5; } }
  .tabs { flex-wrap: wrap; }
  .tab { flex: 1 1 28%; }
  .swatch { display: block; width: 52px; height: 46px; border-radius: 12px; border: 3px solid #fff; box-shadow: 0 0 0 2px #dfe4ea; }
  .swatch.mini { display: inline-block; width: 26px; height: 22px; vertical-align: middle; border-width: 2px; }
  .shop-home { font-size: 60px; }
  .t-house .in { filter: drop-shadow(0 3px 0 rgba(0,0,0,.2)); }
  .t-house.entering::after { content: ""; position: absolute; inset: 2px; border-radius: 50%;
    background: conic-gradient(var(--yellow) 0deg, transparent 0deg); animation: enter 1.3s linear forwards; opacity: .75; }
  @property --a { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
  @keyframes enter { from { --a: 0deg; } to { --a: 360deg; } }
  .t-house.entering::after { background: conic-gradient(rgba(253,203,110,.8) var(--a), transparent var(--a)); }

  /* ---------- home ---------- */
  .room { position: relative; flex: 1; display: flex; flex-direction: column; border-radius: 22px; overflow: hidden;
          box-shadow: inset 0 0 0 4px rgba(255,255,255,.6), 0 10px 30px rgba(0,0,0,.2); min-height: 0; }
  .wall { position: relative; flex: 0 0 30%; min-height: 90px; border-bottom: 8px solid #a1745a; }
  .window { position: absolute; left: 50%; top: 14%; transform: translateX(-50%); font-size: min(64px, 12vh); }
  .door { position: absolute; left: 6%; bottom: 0; font-size: min(70px, 13vh); line-height: .9; }
  .room-hero { position: absolute; right: 8%; bottom: 4px; --ts: min(64px, 11vh); width: var(--ts); height: var(--ts);
               display: grid; place-items: center; animation: bob 1.8s ease-in-out infinite; }
  .room-pet { position: absolute; left: -45%; bottom: 0; font-size: calc(var(--ts) * .5); }
  .floor { flex: 1; display: grid; grid-auto-rows: 1fr; gap: 4px; padding: 8px; min-height: 0; }
  .spot { font: inherit; border: 0; border-radius: 12px; background: rgba(255,255,255,.14); cursor: pointer; padding: 0;
          line-height: 1; display: grid; place-items: center; min-height: 0; container-type: size;
          outline: 2px dashed rgba(255,255,255,.35); outline-offset: -2px; }
  .spot .fi { font-size: 78cqmin; }
  .spot.full { background: none; outline: none; filter: drop-shadow(0 4px 0 rgba(0,0,0,.2)); }
  .spot.drop { outline: 3px dashed #fff; background: rgba(255,255,255,.35); }
  .spot.lifted { animation: bob .6s ease-in-out infinite; background: rgba(253,203,110,.6); border-radius: 12px; }
  .roomhint { text-align: center; color: #fff; font-size: 19px; font-weight: 800; margin: 6px 0 4px; min-height: 26px; }
  .tray { background: #fff; border-radius: 22px; padding: 8px 10px; box-shadow: 0 6px 0 rgba(0,0,0,.12); }
  .traytop { display: flex; align-items: center; justify-content: space-between; min-height: 34px; }
  .traylabel { font-size: 18px; font-weight: 800; color: var(--soft); }
  .putaway { font: inherit; font-size: 18px; font-weight: 800; border: 0; border-radius: 12px; padding: 4px 12px; cursor: pointer;
             background: var(--yellow); color: var(--ink); }
  .trayitems { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 6px; min-height: 60px; align-items: center; }
  .thing { font-size: 34px; border: 0; border-radius: 14px; background: #f1f2f6; width: 56px; height: 56px; flex: none; cursor: pointer;
           box-shadow: 0 4px 0 #dfe4ea; padding: 0; }
  .thing.lifted { background: var(--yellow); box-shadow: 0 4px 0 #e1a73b; transform: translateY(-4px); }
  .trayempty { color: var(--soft); font-size: 18px; font-weight: 600; }
  @media (orientation: landscape) and (max-height: 500px) {
    #house.on { flex-direction: column; }
    .wall { flex-basis: 26%; min-height: 60px; border-bottom-width: 5px; }
    .roomhint { display: none; }
    .tray { padding: 4px 8px; } .traytop { min-height: 26px; } .trayitems { min-height: 48px; padding: 2px; }
    .thing { width: 46px; height: 46px; font-size: 28px; }
  }

  /* ---------- enemies ---------- */
  .t-enemy .in { animation: bob 1.4s ease-in-out infinite; filter: drop-shadow(0 3px 0 rgba(0,0,0,.25)); }
  .badge.cage { background: #fff; color: inherit; top: auto; bottom: -2px; right: -4px; font-size: calc(var(--ts) * .3);
                padding: 0 .15em; border: 2px solid #636e72; border-radius: 6px;
                background-image: repeating-linear-gradient(90deg, transparent 0 4px, rgba(99,110,114,.55) 4px 5px); }
  .petbtn { background: #d1f7ec; }

  /* ---------- pet house ---------- */
  .yard { position: relative; flex: 1; min-height: 0; border-radius: 22px; overflow: hidden; touch-action: none;
          background: radial-gradient(circle at 20% 30%, rgba(255,255,255,.18) 0 6%, transparent 7%) 0 0 / 90px 90px,
                      radial-gradient(circle at 70% 80%, rgba(255,255,255,.12) 0 4%, transparent 5%) 0 0 / 70px 70px,
                      linear-gradient(#8fdc7a, #74c965);
          box-shadow: inset 0 0 0 4px rgba(255,255,255,.6), 0 10px 30px rgba(0,0,0,.2); }
  .yard::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 12%;
                  background: repeating-linear-gradient(90deg, #f3e2c3 0 14px, #d9bf92 14px 18px); border-bottom: 5px solid #c9a36b; }
  .yard-empty { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(90%, 420px); margin: 0;
                text-align: center; color: #fff; font-size: 20px; font-weight: 800; text-shadow: 0 2px 0 rgba(0,0,0,.25); pointer-events: none; }
  .ything, .ypet { position: absolute; transform: translate(-50%, -80%); line-height: 1; user-select: none; -webkit-user-select: none; }
  .ything { font-size: min(68px, 8vh, 12vw); cursor: grab; touch-action: none; filter: drop-shadow(0 4px 0 rgba(0,0,0,.2)); }
  .ything.lifting { opacity: .3; }
  .ything.used { animation: wiggle .5s; }
  @keyframes wiggle { 25% { rotate: -12deg; } 75% { rotate: 12deg; } }
  .ypet { pointer-events: none; }
  .ypet .pe { display: inline-block; font-size: min(56px, 6.5vh, 10vw); filter: drop-shadow(0 3px 0 rgba(0,0,0,.2)); }
  .ypet .pb { position: absolute; left: 50%; bottom: 88%; transform: translateX(-50%); font-size: min(24px, 4vh); }
  .ypet .pb:empty { display: none; }
  .ypet.walking .pe { animation: waddle .35s ease-in-out infinite; }
  @keyframes waddle { 50% { translate: 0 -10%; rotate: 6deg; } }
  .ypet.nibble .pe { animation: nibble .35s ease-in-out infinite; }
  @keyframes nibble { 50% { translate: 0 12%; } }
  .ypet.hop .pe, .ypet.meet .pe { animation: hop2 .5s ease-in-out infinite; }
  @keyframes hop2 { 50% { translate: 0 -35%; } }
  .ypet.sleep .pe { rotate: 80deg; opacity: .85; }
  .ypet.splash .pe { animation: splash .6s ease-in-out infinite; }
  @keyframes splash { 25% { rotate: -14deg; } 75% { rotate: 14deg; } }
  .ypet.sniff .pe { animation: sniff .8s ease-in-out infinite; }
  @keyframes sniff { 50% { rotate: 18deg; translate: 0 8%; } }
  .dragghost { position: fixed; z-index: 50; pointer-events: none; transform: translate(-50%, -60%) scale(1.2);
               font-size: min(56px, 9vh, 13vw); filter: drop-shadow(0 8px 6px rgba(0,0,0,.3)); }
  .pettray { margin-top: 10px; }
  .pettray .box { font-size: 30px; }
  .pettray.drop { background: #fff1cf; outline: 3px dashed var(--orange); }
  .pettray .thing { touch-action: none; }
  @media (prefers-reduced-motion: reduce) {
    .ypet .pe, .ything.used { animation: none !important; }
  }
  @media (orientation: landscape) and (max-height: 500px) {
    .pettray { margin-top: 6px; }
    .yard-empty { font-size: 16px; }
  }

  /* Children who turn on "reduce motion" get still buttons. */
  @media (prefers-reduced-motion: reduce) {
    .go, .t-gate .in, .t-castle .in, .t-enemy .in, .npc-e, .npc-bang, .newbest, .sart, .room-hero, .badge.swirl { animation: none !important; }
  }

  /* ---------- batch 1: more math and read aloud ---------- */
  .blank { display: inline-block; min-width: 1.1em; padding: 0 .1em; border-radius: 12px; background: #ffeaa7; color: #e17055; }
  .quick.toggles { flex-wrap: wrap; }
  .quick.toggles button { flex: 1 1 40%; }
  .quick button.pick { border-style: solid; border-color: var(--green); background: var(--green); color: #fff; }
  .quick button.pick::after { content: " ✓"; }
  #qcard, .cq, .storycard { position: relative; }
  .sayq { position: absolute; top: 8px; left: 8px; z-index: 2; width: 44px; height: 44px; border-radius: 50%; border: 0;
          background: #f1f2f6; font-size: 20px; cursor: pointer; }
  .cq .sayq { top: 0; left: 0; }
  .sayq:active { transform: scale(.92); }

  .tricky { position: absolute; top: 12px; right: 12px; z-index: 2; background: #fff1cf; color: #b86e00; font-weight: 800;
            font-size: 15px; border-radius: 999px; padding: 2px 10px; box-shadow: 0 2px 0 rgba(0,0,0,.1); }
  .cq .tricky { top: 4px; right: 0; }
  #advSetup .best { margin: -8px 0 12px; }

  /* ---------- sticker book ---------- */
  .stickerbtn { margin-top: 18px; width: 100%; font: inherit; font-size: 24px; font-weight: 800; border: 0; border-radius: 22px;
                padding: 12px; background: rgba(255,255,255,.9); color: var(--purple); cursor: pointer; box-shadow: 0 6px 0 rgba(0,0,0,.15); }
  .stickerbtn .pill { font-size: 18px; margin-left: 6px; background: var(--yellow); box-shadow: none; }
  .stickergrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .sticker { background: #fff; border-radius: 20px; padding: 12px 8px; text-align: center; display: grid; gap: 2px;
             box-shadow: 0 6px 0 rgba(0,0,0,.12); }
  .sticker .se { font-size: 48px; line-height: 1.1; }
  .sticker b { font-size: 18px; line-height: 1.1; }
  .sticker small { font-size: 14px; color: var(--soft); line-height: 1.2; }
  .sticker.off .se { filter: grayscale(1); opacity: .35; }
  .sticker.off b { color: var(--soft); }
  .gtoast { position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translate(-50%, -150%); z-index: 60;
            background: #fff; color: var(--ink); font-size: 20px; font-weight: 800; padding: 8px 18px; border-radius: 999px;
            box-shadow: 0 8px 24px rgba(0,0,0,.25); transition: transform .35s ease; pointer-events: none; max-width: 92vw; text-align: center; }
  .gtoast.on { transform: translate(-50%, 0); }

  /* ---------- keys, chests, growing pets ---------- */
  .t-chest .in { filter: drop-shadow(0 0 5px #ffd54a) drop-shadow(0 3px 0 rgba(0,0,0,.2)); }
  .ypet .pe { scale: calc(.8 + var(--lv, 1) * .12); }
  .item .il small { font-size: 13px; opacity: .8; }

  /* ---------- fishing ---------- */
  .fishcard { max-width: 520px; text-align: center; }
  .fishq { font-size: 48px; padding: 4px 0 8px; }
  .pond { position: relative; height: 230px; border-radius: 20px; overflow: hidden;
          background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.35) 0 8%, transparent 9%) 0 0 / 80px 80px, linear-gradient(#74b9ff, #0984e3); }
  .fish { position: absolute; left: 0; top: calc(12px + var(--i) * 52px); border: 0; background: none; cursor: pointer; padding: 0;
          display: flex; align-items: center; gap: 2px; font: inherit; animation: swim calc(6s + var(--i) * 1.3s) ease-in-out infinite alternate;
          animation-delay: calc(var(--i) * -1.7s); }
  .fish .fe { font-size: 40px; }
  .fish b { background: #fff; color: var(--ink); border-radius: 999px; padding: 0 10px; font-size: 22px; box-shadow: 0 3px 0 rgba(0,0,0,.2); }
  @keyframes swim { from { transform: translateX(8px); } to { transform: translateX(calc(min(480px, 80vw) - 150px)); } }
  .fish.caught { animation: catch .7s ease-in forwards; }
  @keyframes catch { to { transform: translateY(-260px) rotate(-20deg); opacity: 0; } }
  .fish.nope { opacity: .35; }
  .fish.nope .fe { animation: shake .4s; }

  /* ---------- piano ---------- */
  .pianocard { max-width: 560px; text-align: center; display: grid; gap: 12px; }
  .pianokeys { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; height: 180px; }
  .pkey { border: 0; border-radius: 0 0 12px 12px; background: #fff; box-shadow: inset 0 -8px 0 #dfe4ea, 0 0 0 2px #2d3436;
          font: inherit; font-size: 20px; font-weight: 800; color: var(--soft); display: flex; align-items: flex-end; justify-content: center;
          padding-bottom: 12px; cursor: pointer; touch-action: none; }
  .pkey.down { background: #ffeaa7; box-shadow: inset 0 -3px 0 #e1a73b, 0 0 0 2px #2d3436; }
  @media (prefers-reduced-motion: reduce) { .fish { animation: none; left: calc(10px + var(--i) * 18%); } }
  .fishcard .ctitle, .pianocard .ctitle { padding: 0 48px; }

  /* ---------- save online ---------- */
  .cloudbtn { margin-top: 12px; color: var(--blue); }
  .cloudtext { font-size: 19px; color: var(--soft); margin: 6px 0 12px; line-height: 1.35; }
  .cloudcode { font-size: clamp(26px, 7vw, 38px); font-weight: 800; text-align: center; color: var(--purple); background: #f1f2f6;
               border-radius: 16px; padding: 8px; margin: 0 0 12px; word-break: break-word; user-select: all; -webkit-user-select: all; }
  .cloudor { margin-top: 22px; }
  .cloudform { display: grid; gap: 10px; }
  .cloudform input { font: inherit; font-size: 24px; font-weight: 700; padding: 10px 14px; border-radius: 14px; border: 3px solid #dfe4ea;
                     width: 100%; color: var(--ink); }
  .cloudform input:focus { outline: none; border-color: var(--purple); }
  #cloud .go { animation: none; font-size: 28px; }
  .cloudform input { user-select: text; -webkit-user-select: text; }

  /* ---------- players ---------- */
  .whochip { display: block; margin: 4px auto 10px; font: inherit; font-size: 20px; font-weight: 800; border: 0; border-radius: 999px;
             padding: 4px 16px; background: rgba(255,255,255,.9); color: var(--ink); cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.12); }
  .whochip small { color: var(--soft); font-weight: 600; }
  .players { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 16px; }
  .player { position: relative; }
  .pbtn { width: 100%; font: inherit; border: 0; border-radius: 24px; background: #fff; padding: 14px 8px; cursor: pointer; display: grid;
          justify-items: center; gap: 2px; box-shadow: 0 6px 0 rgba(0,0,0,.14); color: var(--ink); }
  .pbtn .pf { font-size: 64px; line-height: 1.1; }
  .pbtn b { font-size: 22px; line-height: 1.1; word-break: break-word; }
  .pbtn small { font-size: 15px; color: var(--soft); }
  .player.on .pbtn { outline: 4px solid var(--green); }
  .player.on .pbtn small { color: var(--green); font-weight: 800; }
  .pdel { position: absolute; top: 6px; right: 6px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: #f1f2f6;
          font-size: 17px; cursor: pointer; }
  .pask { margin-top: 8px; background: #fff7e0; border-radius: 16px; padding: 10px; display: grid; gap: 8px; font-size: 16px; font-weight: 700; }
  .pask button { font: inherit; font-weight: 800; border: 0; border-radius: 12px; padding: 6px; cursor: pointer; }
  .pask .yes { background: var(--red); color: #fff; } .pask .no { background: #fff; color: var(--soft); }
  .addplayer { margin-bottom: 16px; }
  #addForm { background: none; box-shadow: none; padding: 0; }
  #addPlayer { background: #fff; border-radius: 28px; padding: 20px; box-shadow: 0 10px 0 rgba(0,0,0,.12); }
  .nameinput { font: inherit; font-size: 26px; font-weight: 700; padding: 10px 14px; border-radius: 14px; border: 3px solid #dfe4ea; width: 100%;
               margin-bottom: 16px; color: var(--ink); user-select: text; -webkit-user-select: text; }
  .nameinput:focus { outline: none; border-color: var(--purple); }
  .faces { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 16px; }
  .face { font-size: 34px; border: 0; border-radius: 16px; background: #f1f2f6; padding: 6px 0; cursor: pointer; box-shadow: 0 4px 0 #dfe4ea; }
  .face.pick { background: #d1f7ec; outline: 3px solid var(--green); }
  #profiles .go { animation: none; font-size: 28px; }

  /* ---------- passwords ---------- */
  .plock { position: absolute; top: 8px; left: 10px; font-size: 20px; }
  .ptools { display: grid; gap: 6px; margin-top: 8px; }
  .ptools button, .linkish { font: inherit; font-size: 16px; font-weight: 800; border: 0; border-radius: 12px; padding: 6px 8px; cursor: pointer;
                             background: rgba(255,255,255,.85); color: var(--purple); }
  .pwform { margin-top: 8px; background: #fff; border-radius: 18px; padding: 12px; display: grid; gap: 6px; box-shadow: 0 4px 0 rgba(0,0,0,.1); }
  .pwlabel { font-size: 16px; font-weight: 800; color: var(--ink); }
  .pwrow { display: flex; gap: 6px; }
  .pwinput { font: inherit; font-size: 20px; font-weight: 700; padding: 8px 10px; border-radius: 12px; border: 3px solid #dfe4ea; width: 100%;
             min-width: 0; color: var(--ink); user-select: text; -webkit-user-select: text; }
  .pwinput:focus { outline: none; border-color: var(--purple); }
  .pweye { border: 0; background: #f1f2f6; border-radius: 12px; font-size: 18px; width: 46px; flex: none; cursor: pointer; }
  .pwnote { font-size: 14px; color: var(--soft); margin: 2px 0; line-height: 1.3; }
  .pwmsg { font-size: 15px; font-weight: 800; color: var(--orange); margin: 0; min-height: 1.2em; }
  .pwform .yes { font: inherit; font-size: 18px; font-weight: 800; border: 0; border-radius: 12px; padding: 8px; cursor: pointer;
                 background: var(--green); color: #fff; box-shadow: 0 4px 0 #009273; }
  .pwform .yes.danger { background: var(--red); box-shadow: 0 4px 0 #d35f5e; }
  .pwform .yes:disabled { opacity: .6; }
  .linkish { background: none; color: var(--soft); font-weight: 700; }
  #addPlayer .pwinput { margin-bottom: 8px; }
  .player.open { grid-column: 1 / -1; }
  .player.open .pbtn { grid-template-columns: auto 1fr; justify-items: start; text-align: left; column-gap: 12px; padding: 10px 16px; }
  .player.open .pbtn .pf { grid-row: span 2; font-size: 48px; }

  /* ---------- typing race ---------- */
  .mode.typing .mt { color: #1864ab; }
  body[data-screen="typeSetup"]::before, body[data-screen="typeGame"]::before { background: linear-gradient(160deg, #0b3d6b, #1c7ed6); }
  body[data-screen="typeSetup"], body[data-screen="typeGame"] { background: #0b3d6b; }
  .tp-coachrow { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
  .tp-coach { flex: none; width: 80px; }
  .tp-coach svg { width: 80px; height: 100px; display: block; }
  .tp-bubble { position: relative; flex: 1; margin: 0; background: #fffdf4; color: #243b53; border-radius: 18px; padding: 10px 14px;
               font-size: 18px; font-weight: 600; line-height: 1.3; box-shadow: 0 4px 0 rgba(0,0,0,.2); }
  .tp-bubble::before { content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
                       border: 10px solid transparent; border-right-color: #fffdf4; border-left: 0; }
  .tp-levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .tp-level { position: relative; font: inherit; border: 0; border-radius: 18px; padding: 10px 8px 8px; cursor: pointer; text-align: center;
              background: linear-gradient(#fffdf4, #f1ecd8); color: #243b53; display: grid; justify-items: center; gap: 3px;
              box-shadow: 0 5px 0 #b8ad8a; }
  .tp-level:active { transform: translateY(3px); box-shadow: 0 2px 0 #b8ad8a; }
  .tp-level.locked { opacity: .55; filter: grayscale(.7); cursor: default; }
  .tp-num { position: absolute; top: 6px; left: 8px; font-size: 16px; font-weight: 800; color: #1864ab; }
  .tp-face { width: 56px; height: 56px; }
  .tp-lname { font-size: 15px; font-weight: 800; line-height: 1.1; min-height: 2.2em; }
  .tp-caps { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
  .tp-cap { font: 700 14px "Roboto Mono", ui-monospace, monospace; min-width: 22px; padding: 1px 4px; border-radius: 5px; background: #fff;
            border: 1px solid #adb5bd; box-shadow: 0 2px 0 #adb5bd; }
  .tp-vs { font-size: 13px; color: #52606d; }
  .tp-stars { display: block; height: 24px; }
  .tp-hud { display: flex; align-items: center; gap: 8px; padding-right: 58px; margin-bottom: 8px; flex-wrap: wrap; }
  .tp-lvl { color: #fff; font-weight: 800; font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tp-stat { background: #fffdf4; color: #243b53; border-radius: 999px; padding: 2px 12px; font-size: 16px; font-weight: 700; white-space: nowrap; }
  .tp-stat b { font: 700 18px "Roboto Mono", ui-monospace, monospace; }
  .tp-stage { position: relative; flex: none; width: 100%; max-width: calc(34vh * 800 / 260); margin: 0 auto; aspect-ratio: 800 / 260;
              border-radius: 16px; overflow: hidden; background: #74c0fc;
              box-shadow: inset 0 0 0 4px rgba(255,255,255,.5); }
  #tpScene { width: 100%; height: 100%; display: block; }
  .tp-tag { font: 800 12px "Baloo 2", sans-serif; fill: #243b53; }
  @media (prefers-reduced-motion: no-preference) {
    .tp-cloud { animation: drift 30s linear infinite alternate; } .tp-cloud.slow { animation-duration: 45s; }
  }
  @keyframes drift { to { translate: 120px 0; } }
  .tp-count { position: absolute; inset: 0; display: grid; place-items: center; font: 800 110px "Baloo 2", sans-serif; color: #fff;
              text-shadow: 0 6px 0 rgba(0,0,0,.3); background: rgba(11,61,107,.35); }
  .tp-count[hidden], .tp-result[hidden] { display: none; }
  .tp-result { position: absolute; inset: 8px; display: grid; place-content: center; justify-items: center; gap: 4px; text-align: center;
               background: rgba(11,61,107,.88); border-radius: 14px; color: #fff; padding: 10px; }
  .tp-restitle { margin: 0; font-size: 28px; font-weight: 800; line-height: 1.1; }
  .tp-resstats { margin: 0; font: 700 18px "Roboto Mono", ui-monospace, monospace; }
  .tp-resnote { margin: 0; font-size: 16px; opacity: .9; }
  .tp-resbtns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
  .tp-btn { font: inherit; font-size: 18px; font-weight: 800; border: 0; border-radius: 12px; padding: 6px 14px; cursor: pointer;
            background: #fffdf4; color: #1864ab; box-shadow: 0 4px 0 #b8ad8a; }
  .tp-btn.go2 { background: #40c057; color: #fff; box-shadow: 0 4px 0 #2b8a3e; }
  .tp-text { margin: 8px 0 2px; background: #fffdf4; border-radius: 14px; padding: 8px 12px; white-space: pre; overflow: hidden; text-align: center;
             font: 500 clamp(22px, 5.2vw, 36px) "Roboto Mono", ui-monospace, monospace; color: #9aa5b1; box-shadow: inset 0 3px 0 rgba(0,0,0,.08); }
  .tp-text .done { color: #2b8a3e; }
  .tp-text .now { color: #0b3d6b; background: #ffe066; border-radius: 6px; outline: 2px solid #f59f00; font-weight: 700; }
  .tp-text .now.bad { background: #ffc9c9; outline-color: #fa5252; }
  .tp-finger { margin: 2px 0 4px; color: #fff; font-weight: 800; font-size: 17px; text-align: center; min-height: 1.4em; }
  .tp-finger i { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -1px; border: 2px solid #fff; }
  #tpKeys { flex: 1 1 32%; min-height: 0; width: 100%; display: block; }
  .tp-key { cursor: pointer; }
  .tp-key text { font: 700 20px "Roboto Mono", ui-monospace, monospace; fill: #243b53; pointer-events: none; }
  .tp-key.off text { fill: #adb5bd; }
  .tp-key.off { cursor: default; }
  .tp-key.next rect:first-child { stroke: #fff; stroke-width: 5; }
  @media (prefers-reduced-motion: no-preference) { .tp-key.next { animation: keypulse .8s ease-in-out infinite; } }
  @keyframes keypulse { 50% { opacity: .65; } }
  .tp-key.hit rect:first-child { fill: #40c057; }
  .tp-key.miss rect:first-child { fill: #fa5252; }
  @media (orientation: landscape) and (max-height: 500px) {
    .tp-stage { max-width: calc(30vh * 800 / 260); } #tpKeys { flex-basis: 30%; } .tp-text { margin: 4px 0 0; padding: 4px 10px; font-size: 22px; }
    .tp-finger { font-size: 14px; margin: 0 0 2px; } .tp-hud { margin-bottom: 4px; }
  }
  .tp-rotate { display: none; margin: 0; text-align: center; color: rgba(255,255,255,.8); font-size: 15px; font-weight: 700; }
  @media (orientation: portrait) and (max-width: 520px) { .tp-rotate { display: block; } }

  /* ---------- strategy dojo ---------- */
  .mode.dojo .mt { color: #e8590c; }
  .dj-sensei { display: flex; align-items: center; gap: 14px; margin: 4px 0 16px; }
  .dj-face { font-size: 64px; line-height: 1; flex: none; filter: drop-shadow(0 4px 0 rgba(0,0,0,.15)); }
  .dj-bubble { position: relative; margin: 0; background: #fff; border-radius: 22px; padding: 12px 16px; font-size: 19px;
               line-height: 1.25; font-weight: 600; box-shadow: 0 6px 0 rgba(0,0,0,.12); }
  .dj-bubble::before { content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
                       border: 12px solid transparent; border-right-color: #fff; border-left: 0; }
  .dj-belts { display: grid; gap: 10px; margin-bottom: 16px; }
  .dj-beltrow { font: inherit; border: 0; border-radius: 20px; background: #fff; padding: 8px 14px; display: flex; align-items: center;
                gap: 12px; cursor: pointer; text-align: left; box-shadow: 0 6px 0 rgba(0,0,0,.13); color: var(--ink); }
  .dj-beltrow:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.13); }
  .dj-beltrow.locked { opacity: .55; cursor: default; }
  .dj-beltrow.won { background: #fff9db; }
  .dj-bname { flex: 1; display: grid; line-height: 1.15; }
  .dj-bname b { font-size: 22px; }
  .dj-bname span { font-size: 16px; color: var(--soft); }
  .dj-bstate { font-size: 18px; font-weight: 800; color: var(--orange); white-space: nowrap; }
  .dj-trick { text-align: center; }
  .dj-tricktitle { font-size: 30px; font-weight: 800; margin: 4px 0; color: var(--purple); }
  .dj-tricktext { font-size: 22px; margin: 0 0 8px; line-height: 1.3; }
  .dj-new { font-size: 18px; color: var(--soft); margin: 0; }
  .dj-qq { font-size: clamp(46px, 13vw, 76px); padding-top: 0; }
  .dj-pic { margin: 8px 0 4px; display: flex; justify-content: center; }
  .dj-pic[hidden], .dj-steps[hidden] { display: none; }
  .dj-array { width: 100%; max-width: 420px; max-height: 32vh; }
  .dj-lbl { font: 800 20px "Baloo 2", system-ui, sans-serif; fill: #495057; }
  .dj-samel { fill: var(--purple); }
  .dj-caption { text-align: center; font-size: 24px; font-weight: 800; min-height: 64px; margin: 6px 0; line-height: 1.25; }
  .dj-dots { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
  .dj-dots i { width: 12px; height: 12px; border-radius: 50%; background: rgba(0,0,0,.12); transition: transform .2s; }
  .dj-dots i.past { background: var(--green); }
  .dj-dots i.miss { background: var(--orange); }
  .dj-dots i.on { background: var(--purple); transform: scale(1.3); }
  .dj-progress i { background: rgba(255,255,255,.55); }
  .dj-steps { display: grid; gap: 6px; margin: 4px 0; }
  .dj-step { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 10px; border-radius: 16px;
             padding: 4px 10px; background: #f8f9fa; }
  .dj-slabel { font-size: 17px; color: var(--soft); font-weight: 600; }
  .dj-expr { font-size: 28px; font-weight: 800; white-space: nowrap; }
  .dj-expr b { display: inline-block; min-width: 58px; text-align: center; border-radius: 12px; padding: 0 8px; margin-left: 4px;
               background: #fff; border: 3px solid #dfe4ea; color: #b2bec3; }
  .dj-step.now { background: #fff3bf; box-shadow: inset 0 0 0 3px var(--yellow); }
  .dj-step.now b { color: var(--purple); border-color: var(--purple); }
  .dj-step.done b { color: var(--green); border-color: var(--green); }
  .dj-step.done b.wrong { color: var(--orange); border-color: var(--orange); }
  .dj-step.later { opacity: .45; }
  .dj-fix { font-size: 21px; min-height: 34px; line-height: 1.2; }
  .dj-beltpill { display: inline-flex; align-items: center; gap: 6px; font-size: 18px; }
  .dj-doneicon { text-align: center; }
  .dj-miss { display: grid; gap: 6px; margin-top: 8px; }
  .dj-miss div { background: #ffeaa7; border-radius: 12px; padding: 4px 12px; text-align: center; }
  .dj-miss b { font-size: 22px; display: block; }
  .dj-miss small { font-size: 16px; color: var(--soft); }
  .dj-grid { display: grid; grid-template-columns: repeat(11, 1fr); gap: 3px; }
  .dj-h { display: grid; place-items: center; font-weight: 800; color: var(--purple); font-size: 16px; aspect-ratio: 1; }
  .dj-cell { position: relative; font: inherit; font-weight: 800; font-size: clamp(11px, 3vw, 17px); border: 0; padding: 0;
             border-radius: 8px; aspect-ratio: 1; background: #f1f3f5; color: transparent; cursor: pointer; }
  .dj-cell.on { background: var(--bc); color: var(--bi); box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
  .dj-mark { position: absolute; top: -4px; right: -3px; font-size: 11px; font-style: normal; }
  .dj-cellinfo { text-align: center; font-size: 19px; font-weight: 600; margin: 12px 0 0; min-height: 50px; }
  @media (orientation: landscape) and (min-width: 700px) {
    .modes { grid-template-columns: repeat(2, 1fr); }
    #djPlay.on { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; align-items: center; }
    #djPlay .card { margin: 0; }
    .dj-belts { grid-template-columns: 1fr 1fr; }
  }
  @media (orientation: landscape) and (max-height: 500px) {
    .dj-array { max-height: 36vh; } .dj-face { font-size: 44px; } .dj-bubble { font-size: 16px; }
    .dj-expr { font-size: 22px; } .dj-slabel { font-size: 15px; } .dj-qq { font-size: 40px; }
    .dj-caption { font-size: 19px; min-height: 0; }
  }
  @media (orientation: portrait) and (max-height: 760px) {
    .dj-array { max-height: 20vh; } .dj-expr { font-size: 23px; } .dj-slabel { font-size: 14px; } .dj-qq { font-size: 44px; }
    .dj-fix { font-size: 18px; min-height: 26px; } .dj-step { padding: 2px 8px; }
    #djPlay .key { font-size: 30px; padding: 4px 0; } #djPlay .pad { gap: 7px; }
  }

  /* ---------- learn ×: hub and shared pieces ---------- */
  .mode.learnmode .mt { color: #e8590c; }
  .lr-path { display: grid; gap: 12px; margin-bottom: 8px; }
  .lr-game { font: inherit; border: 0; border-radius: 24px; background: #fff; color: var(--ink); cursor: pointer; text-align: left;
             display: flex; align-items: center; gap: 12px; padding: 12px 16px; box-shadow: 0 7px 0 rgba(0,0,0,.14); }
  .lr-game:active { transform: translateY(5px); box-shadow: 0 2px 0 rgba(0,0,0,.14); }
  .lr-n { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--purple); color: #fff; font-weight: 800;
          font-size: 20px; display: grid; place-items: center; }
  .lr-e { font-size: 44px; line-height: 1; flex: none; }
  .lr-t { flex: 1; display: grid; line-height: 1.15; }
  .lr-t b { font-size: 26px; }
  .lr-t small { font-size: 16px; color: var(--soft); }
  .lr-p { font-weight: 800; color: var(--green); font-size: 18px; white-space: nowrap; }
  .lr-licon { font-size: 32px; line-height: 1; flex: none; width: 52px; text-align: center; }
  .lr-title { font-size: 18px; }
  .lr-prompt { text-align: center; font-size: 22px; font-weight: 800; margin: 2px 40px 8px; line-height: 1.25; }
  .lr-prompt small { display: block; font-size: 16px; color: var(--soft); font-weight: 600; }
  .lr-fix { font-size: 20px; min-height: 30px; line-height: 1.2; }
  .pad.off { opacity: .3; pointer-events: none; }
  @media (max-width: 700px) { .lr-play .pad.off { display: none; } }

  /* frog hops */
  .fr-pond { margin: 0 -8px; }
  .fr-svg { width: 100%; display: block; }
  .fr-num { font: 800 19px "Baloo 2", system-ui, sans-serif; fill: #1864ab; }
  .fr-num.ask { fill: #e8590c; font-size: 22px; }
  .fr-plus { font: 800 15px "Baloo 2", system-ui, sans-serif; fill: #1971c2; }

  /* cookie shop */
  .ck-order { display: flex; align-items: center; gap: 10px; margin: 0 36px 6px 0; }
  .ck-who { font-size: 46px; line-height: 1; flex: none; }
  .ck-text { margin: 0; font-size: 18px; font-weight: 600; background: #fff9db; border-radius: 16px; padding: 8px 12px; line-height: 1.25; }
  .ck-pile { display: flex; flex-wrap: wrap; justify-content: center; gap: 0; font-size: 17px; line-height: 1.1;
             background: #ffe8cc; border-radius: 16px; padding: 6px 8px; margin: 6px 0; }
  .ck-pile[hidden] { display: none; }
  .ck-pilecount { width: 100%; text-align: center; font-weight: 800; font-size: 15px; color: #d9480f; }
  .ck-boxes { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 6px 0; }
  .ck-box { font: inherit; border: 3px solid #d9a066; background: #fff4e6; border-radius: 12px; padding: 5px 5px 2px; cursor: pointer;
            display: grid; justify-items: center; gap: 2px; color: var(--ink); box-shadow: 0 4px 0 #e8b17a; }
  .ck-box:disabled { cursor: default; }
  .ck-box:not(:disabled) { animation: ckwobble 1.6s ease-in-out infinite; }
  @keyframes ckwobble { 0%, 100% { transform: rotate(0) } 50% { transform: rotate(-2deg) } }
  .ck-box.full { background: #fff; }
  .ck-in { display: grid; grid-template-columns: repeat(var(--cols), 18px); gap: 1px; }
  .ck-c { font-size: 15px; line-height: 18px; text-align: center; animation: ckdrop .3s ease-out; }
  @keyframes ckdrop { from { transform: translateY(-14px); opacity: 0 } }
  .ck-slot { width: 14px; height: 14px; margin: 2px; border-radius: 50%; border: 2px dashed #e8b17a; }
  .ck-tag { font-weight: 800; font-size: 16px; color: #d9480f; min-height: 20px; line-height: 20px; }
  .ck-act { display: grid; gap: 8px; margin: 4px 0; }
  .ck-act:empty { display: none; }
  .ck-choice { font-size: 30px; padding: 6px; }
  .ck-choice.right { background: var(--green); color: #fff; }
  .ck-choice.wrong { background: var(--red); color: #fff; }
  .ck-deal { font-size: 24px; }

  /* array garden */
  .gd-wrap { display: flex; justify-content: center; margin: 4px 0 8px; }
  .gd-bed { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 3px; width: min(100%, calc(var(--n) * 36px));
            transition: width .3s; }
  .gd-bed:not(.tappable) { width: min(72%, calc(var(--n) * 25px)); }
  .gd-cell { aspect-ratio: 1; border: 0; padding: 0; border-radius: 6px; background: #b08968; font-size: var(--fs); line-height: 1;
             display: grid; place-items: center; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); color: inherit; }
  .gd-bed:not(.tappable) .gd-cell { font-size: calc(var(--fs) * .7); }
  .gd-bed.tappable .gd-cell { cursor: pointer; }
  .gd-bed.tappable .gd-cell:active { transform: scale(.88); }
  .gd-cell.p { background: #b2f2bb; }
  .gd-cell.q { background: #ffec99; }
  .gd-cell.cut { box-shadow: inset 0 4px 0 #e03131, inset 0 -3px 0 rgba(0,0,0,.18); }
  .gd-bed.turning { transform: rotate(90deg) scale(.85); transition: transform .6s ease-in-out; }
  .gd-turn { font-size: 30px; padding: 10px; }

  @media (orientation: landscape) and (min-width: 700px) {
    .lr-path { grid-template-columns: 1fr 1fr; }
    .lr-play.on { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; align-items: center; }
    .lr-play .card { margin: 0; }
  }
  @media (orientation: landscape) and (max-height: 500px) {
    .lr-prompt { font-size: 18px; } .lr-e { font-size: 34px; } .lr-t b { font-size: 21px; }
    .ck-who { font-size: 34px; } .ck-text { font-size: 15px; }
  }
  @media (prefers-reduced-motion: reduce) {
    .ck-box:not(:disabled), .ck-c { animation: none; }
    .gd-bed.turning { transition: none; }
  }

  /* ---------- Math Drive ---------- */
  .mode.drivemode .mt { color: var(--orange); }
  .dv-garage { display: flex; align-items: center; gap: 16px; }
  .dv-carpic { flex: none; width: 96px; height: 96px; border-radius: 26px; display: grid; place-items: center; font-size: 60px;
               background: var(--paint, #e74c3c); box-shadow: inset 0 -8px 0 rgba(0,0,0,.15); }
  .dv-gstats { flex: 1; display: grid; gap: 4px; min-width: 0; }
  .dv-coinline { font-size: 28px; font-weight: 800; line-height: 1.1; }
  .dv-bar { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 8px; font-size: 17px; font-weight: 800; color: var(--soft); }
  .dv-pips { display: flex; gap: 4px; min-width: 60px; }
  .dv-pips i { flex: 1; height: 12px; border-radius: 6px; background: #dfe4ea; }
  .dv-pips i.on { background: var(--green); }

  body[data-screen="drive"] { overflow: hidden; }
  body[data-screen="drive"]::before { background: #9fd9ff; }
  #drive.on { position: fixed; inset: 0; max-width: none; padding: 0; animation: none; overflow: hidden;
              touch-action: none; -webkit-user-select: none; user-select: none; }
  #drive [hidden] { display: none !important; }
  #dvCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
  .dv-hud { position: absolute; z-index: 3; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; pointer-events: none;
            top: calc(10px + env(safe-area-inset-top)); left: calc(10px + env(safe-area-inset-left)); right: calc(160px + env(safe-area-inset-right)); }
  .dv-hud > * { pointer-events: auto; }
  .dv-hud .pill { font-size: 22px; padding: 2px 12px; }
  .dv-race { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
  .dv-race button { border: 0; background: #f1f2f6; border-radius: 50%; width: 30px; height: 30px; font-size: 14px; cursor: pointer; color: var(--soft); }
  .dv-mini { position: absolute; z-index: 3; top: calc(68px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right));
             width: 140px; height: 140px; border-radius: 20px; border: 4px solid rgba(255,255,255,.9); background: #3d9fd6;
             box-shadow: 0 6px 16px rgba(0,0,0,.25); cursor: pointer; touch-action: manipulation; }
  .dv-toast, .dv-help { position: absolute; z-index: 4; left: 50%; transform: translateX(-50%); width: max-content; max-width: min(92%, 640px);
             background: rgba(45,52,54,.86); color: #fff; font-size: 21px; font-weight: 800; padding: 6px 18px; border-radius: 18px;
             text-align: center; opacity: 0; transition: opacity .3s; pointer-events: none; }
  .dv-toast { top: calc(66px + env(safe-area-inset-top)); }
  .dv-help { bottom: calc(96px + env(safe-area-inset-bottom)); background: rgba(9,132,227,.9); font-size: 19px; }
  #dvFull svg { display: block; margin: 3px 0; }
  #drive.dv-busy .dv-gauge, #drive.dv-busy .dv-btns, #drive.dv-busy .dv-stick, #drive.dv-busy .dv-help, #drive.dv-busy .dv-mini { display: none; }
  @media (orientation: landscape) and (min-width: 700px) {
    #dvMath .mcard.chal { zoom: 1.1; max-width: 800px; }
    #dvMath .cbody { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: center; }
  }
  .dv-toast.on, .dv-help.on { opacity: 1; }
  .dv-gauge { position: absolute; z-index: 3; left: 50%; transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom));
              background: rgba(45,52,54,.78); color: #fff; border-radius: 18px; padding: 2px 16px 6px; text-align: center; min-width: 96px;
              pointer-events: none; font-variant-numeric: tabular-nums; }
  .dv-gauge b { display: block; font-size: 32px; line-height: 1.05; }
  .dv-gauge small { font-size: 13px; opacity: .85; font-weight: 800; }
  .dv-fuel { height: 7px; margin-top: 3px; background: rgba(255,255,255,.25); border-radius: 4px; overflow: hidden; }
  .dv-fuel > div { height: 100%; width: 100%; background: #ff9f1a; }
  .dv-fuel.empty > div { background: #d63031; }
  .dv-stick { position: absolute; z-index: 3; width: 150px; height: 150px; margin: -75px 0 0 -75px; border-radius: 50%; pointer-events: none;
              background: rgba(255,255,255,.22); border: 4px solid rgba(255,255,255,.75); box-shadow: 0 6px 20px rgba(0,0,0,.18); }
  .dv-stick.rest { left: calc(105px + env(safe-area-inset-left)); top: calc(100% - 105px - env(safe-area-inset-bottom)); opacity: .6; }
  .dv-knob { position: absolute; left: 50%; top: 50%; width: 68px; height: 68px; margin: -34px 0 0 -34px; border-radius: 50%;
             background: rgba(255,255,255,.95); box-shadow: 0 4px 10px rgba(0,0,0,.3); }
  .dv-stick.rest .dv-knob::after { content: "🚗"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; }
  #planet .dv-stick.rest .dv-knob::after { content: "👟"; }
  .dv-btns { position: absolute; z-index: 3; right: calc(18px + env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom));
             display: flex; align-items: flex-end; gap: 14px; }
  .dv-btns button { border: 0; border-radius: 50%; cursor: pointer; touch-action: none; padding: 0; }
  .dv-turbo { position: relative; overflow: hidden; width: 104px; height: 104px; font-size: 48px;
              background: radial-gradient(circle at 40% 35%, #ffd08a, #ff7f00); box-shadow: 0 7px 0 #b85c00, 0 12px 24px rgba(0,0,0,.25); }
  .dv-turbo::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: calc((1 - var(--fuel, 1)) * 100%);
                     background: rgba(45,52,54,.45); pointer-events: none; }
  .dv-turbo.on { transform: translateY(5px) scale(.96); box-shadow: 0 2px 0 #b85c00; }
  .dv-turbo.locked { filter: grayscale(1); opacity: .55; }
  .dv-horn { width: 68px; height: 68px; font-size: 32px; margin-bottom: 4px; background: rgba(255,255,255,.92); box-shadow: 0 5px 0 rgba(0,0,0,.18); }
  .dv-small { display: flex; flex-direction: column-reverse; gap: 10px; align-items: center; }
  .dv-drift { background: #d6f3ff; } .dv-jump { background: #e8ffe0; }
  .dv-drift.on, .dv-jump.on { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
  .dv-job { max-width: min(62vw, 520px); }
  .dv-job span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; }
  .dv-horn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
  .dv-enter { position: absolute; z-index: 4; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom));
              font: inherit; font-size: 28px; font-weight: 800; color: #fff; border: 0; border-radius: 999px; padding: 8px 28px; cursor: pointer;
              background: var(--shop, var(--green)); box-shadow: 0 6px 0 rgba(0,0,0,.25), 0 0 0 5px rgba(255,255,255,.85); white-space: nowrap; }
  @media (prefers-reduced-motion: no-preference) { .dv-enter { animation: dvpulse .8s ease-in-out infinite alternate; } }
  @keyframes dvpulse { to { transform: translateX(-50%) scale(1.07); } }
  .dv-loading { position: absolute; inset: 0; z-index: 6; display: grid; place-content: center; text-align: center; color: #fff;
                background: linear-gradient(160deg, #74b9ff, #a29bfe); font-size: 26px; font-weight: 800; padding: 20px; }
  .dv-loading div { font-size: 100px; line-height: 1; }
  @media (prefers-reduced-motion: no-preference) { .dv-loading div { animation: dvdrive 1s ease-in-out infinite alternate; } }
  @keyframes dvdrive { from { transform: translateX(-40px); } to { transform: translateX(40px); } }
  @media (max-width: 560px), (max-height: 500px) {
    .dv-mini { width: 104px; height: 104px; border-width: 3px; border-radius: 16px; }
    .dv-hud { right: calc(124px + env(safe-area-inset-right)); }
    .dv-toast, .dv-help { font-size: 17px; }
    .dv-turbo { width: 84px; height: 84px; font-size: 38px; }
    .dv-horn { width: 56px; height: 56px; font-size: 26px; }
    .dv-stick { width: 128px; height: 128px; margin: -64px 0 0 -64px; }
    .dv-stick.rest { left: calc(88px + env(safe-area-inset-left)); top: calc(100% - 88px - env(safe-area-inset-bottom)); }
    .dv-enter { font-size: 22px; bottom: calc(78px + env(safe-area-inset-bottom)); }
    .dv-gauge { min-width: 78px; padding: 2px 10px 5px; }
    .dv-gauge b { font-size: 26px; }
    .dv-btns { flex-direction: column; align-items: flex-end; gap: 10px; right: calc(14px + env(safe-area-inset-right)); }
    .dv-small { flex-direction: row; gap: 8px; }
    .dv-job span { font-size: 15px; }
    .dv-horn { margin-bottom: 0; }
  }
  @media (max-height: 500px) {
    .dv-mini { top: calc(10px + env(safe-area-inset-top)); right: calc(70px + env(safe-area-inset-right)); width: 92px; height: 92px; }
    .dv-hud { right: calc(170px + env(safe-area-inset-right)); }
    .dv-toast { top: calc(56px + env(safe-area-inset-top)); } .dv-help { bottom: calc(76px + env(safe-area-inset-bottom)); }
  }

  /* The shop sits at the side (or the bottom) so you can see your car. */
  .modal.dv-side { background: transparent; justify-content: flex-end; align-items: stretch; pointer-events: none; }
  .modal.dv-side .mcard { zoom: 1; pointer-events: auto; width: min(460px, 50vw); max-width: none; max-height: none;
                          display: flex; flex-direction: column; padding: 14px; border: 4px solid var(--shop, #fff); }
  @media (orientation: portrait) {
    .modal.dv-side { align-items: flex-end; justify-content: center; }
    .modal.dv-side .mcard { width: 100%; max-width: 640px; height: 58%; }
  }
  .dv-shophead { display: flex; align-items: center; gap: 12px; padding-right: 48px; }
  .dv-shopicon { font-size: 50px; line-height: 1; }
  .dv-hello { font-size: 17px; color: var(--soft); font-weight: 600; line-height: 1.2; }
  .dv-shopcoins { margin: 8px 0; }
  .dv-items { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px;
              align-content: start; padding: 2px 2px 8px; -webkit-overflow-scrolling: touch; }
  .dv-group { grid-column: 1 / -1; font-size: 18px; font-weight: 800; color: var(--purple); margin-top: 4px; }
  .dv-item { font: inherit; border: 3px solid transparent; border-radius: 18px; background: #f1f2f6; box-shadow: 0 4px 0 #dfe4ea;
             padding: 8px 4px 6px; cursor: pointer; display: grid; justify-items: center; gap: 2px; color: var(--ink); }
  .dv-item .dv-ie { font-size: 36px; line-height: 1.1; }
  .dv-item .dv-swatch { width: 42px; height: 42px; border-radius: 50%; box-shadow: inset 0 -5px 0 rgba(0,0,0,.18); }
  .dv-item .dv-in { font-size: 16px; font-weight: 800; line-height: 1.1; text-align: center; }
  .dv-item .dv-ip { font-size: 16px; font-weight: 800; color: var(--orange); }
  .dv-item .dv-pips { width: 80%; }
  .dv-item.got .dv-ip, .dv-item.wearing .dv-ip, .dv-item.owned .dv-ip { color: var(--green); }
  .dv-item.later { opacity: .55; }
  .dv-item.sel { border-color: var(--shop, var(--purple)); background: #fff; }
  .dv-buybar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px -14px -14px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
               background: #fff7e0; border-top: 3px solid var(--yellow); min-height: 62px; }
  .dv-buybar .dv-selname { font-size: 20px; font-weight: 800; flex: 1 1 auto; }
  .dv-buybar .dv-tip { font-size: 18px; font-weight: 700; color: var(--soft); flex: 1 1 auto; }
  .dv-buybar .dv-how { flex: 1 1 100%; order: 3; font-size: 16px; font-weight: 700; color: var(--purple); line-height: 1.2; }
  .dv-buybar button { font: inherit; font-size: 21px; font-weight: 800; border: 0; border-radius: 14px; padding: 6px 16px; cursor: pointer; flex: 0 1 auto; }
  .dv-buybar .yes { background: var(--green); color: #fff; box-shadow: 0 4px 0 #009273; }
  .dv-buybar .earn { background: var(--purple); box-shadow: 0 4px 0 #4b3fb8; }
  .dv-buybar .alt { width: auto; font-size: 19px; }
  .dv-medals { display: flex; justify-content: center; gap: 10px; margin: 6px 0 10px; }
  .dv-medal { display: grid; justify-items: center; background: #f1f2f6; border-radius: 16px; padding: 6px 12px; opacity: .55; }
  .dv-medal span { font-size: 38px; line-height: 1.1; }
  .dv-medal b { font-size: 18px; }
  .dv-medal small { font-size: 14px; color: var(--soft); font-weight: 800; }
  .dv-medal.got { opacity: 1; background: #fff3c4; }
  .dv-medal.now { outline: 3px solid var(--orange); opacity: 1; }
  .dv-prizes { display: grid; gap: 2px; margin: 0 auto 8px; max-width: 340px; font-size: 18px; font-weight: 700; }
  .dv-prizes:empty { display: none; }
  @media (orientation: landscape) and (min-width: 700px) { #dvRace .mcard { zoom: 1.1; } }
  #dvRace.results .sart { font-size: 60px; min-height: 0; }
  @media (max-height: 600px) {
    #dvRace.results .dv-medals, #dvRace.results .sart { display: none; }
    .dv-prizes { font-size: 16px; gap: 0; } .dv-prizes .total { font-size: 18px; }
  }
  .dv-prizes div { display: flex; justify-content: space-between; gap: 12px; }
  .dv-prizes b { color: var(--green); white-space: nowrap; }
  .dv-prizes .total { border-top: 3px solid #f1f2f6; margin-top: 2px; padding-top: 2px; font-size: 21px; font-weight: 800; }
  .dv-prizes .total b { color: var(--orange); }
  .dv-mapcard { text-align: center; max-width: 560px; }
  .dv-mapcard .ctitle { margin: 4px 48px 10px; }
  #dvBigMap { border-radius: 16px; display: block; margin: 0 auto 10px; }
  .dv-places { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
  .dv-place { font: inherit; font-size: 18px; font-weight: 800; border: 0; border-radius: 999px; padding: 6px 14px; cursor: pointer;
              background: #f1f2f6; box-shadow: 0 3px 0 #dfe4ea; color: var(--ink); }
  .dv-place.pick { background: var(--yellow); box-shadow: 0 3px 0 #e1a73b; }

  /* ---------- Tiny Planet: paper and ink, like a comic ---------- */
  .mode.planetmode .mt { color: #2a9d8f; }
  .pl-namecard { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
  .pl-namecard label { font-weight: 800; font-size: 20px; }
  .pl-namecard input { flex: 1; min-width: 160px; font: inherit; font-size: 22px; font-weight: 800; padding: 8px 14px; border-radius: 14px; border: 3px solid #dfe4ea; background: #f8f9fc; color: var(--ink, #2d3436); }
  .pl-namecard input:focus { outline: none; border-color: #2a9d8f; background: #fff; }
  .pl-progress { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; font-weight: 800; }
  .pl-progress b { display: block; font-size: 30px; line-height: 1.1; }
  .pl-progress small { color: var(--soft); font-size: 15px; }
  body[data-screen="planet"] { overflow: hidden; }
  body[data-screen="planet"]::before { background: #63c7c0; }
  #planet.on { position: fixed; inset: 0; max-width: none; padding: 0; animation: none; overflow: hidden; touch-action: none; -webkit-user-select: none; user-select: none; }
  #planet [hidden] { display: none !important; }
  #plCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
  .pl-btn { width: 56px; height: 56px; border-radius: 10px; border: 3px solid #2b2d3c; background: #f8f5ec; font-size: 26px; padding: 0;
            box-shadow: 4px 4px 0 #2b2d3c; cursor: pointer; display: grid; place-items: center; color: #2b2d3c; }
  .pl-btn:active { translate: 3px 3px; box-shadow: 1px 1px 0 #2b2d3c; }
  .pl-btn.off { opacity: .5; }
  .pl-top { position: absolute; z-index: 3; top: calc(12px + env(safe-area-inset-top)); left: calc(12px + env(safe-area-inset-left)); display: flex; gap: 12px; align-items: center; }
  .pl-coins { font-family: "Bungee", "Baloo 2", sans-serif; font-size: 21px; background: #f8f5ec; border: 3px solid #2b2d3c; border-radius: 10px;
              padding: 6px 12px; box-shadow: 4px 4px 0 #2b2d3c; transform: rotate(-2deg); color: #2b2d3c; }
  .pl-side { position: absolute; z-index: 3; right: calc(14px + env(safe-area-inset-right)); top: calc(76px + env(safe-area-inset-top)); display: grid; gap: 12px; }
  .pl-side .pl-btn:nth-child(odd) { transform: rotate(2deg); }
  .pl-side .pl-btn:nth-child(even) { transform: rotate(-2deg); }
  .pl-place { position: absolute; z-index: 3; left: calc(18px + env(safe-area-inset-left)); bottom: calc(22px + env(safe-area-inset-bottom)); max-width: 62vw;
              font-family: "Bungee", "Arial Black", sans-serif; font-size: clamp(26px, 5vw, 48px); line-height: 1.05; color: #f8f5ec; pointer-events: none;
              text-shadow: 3px 3px 0 #2b2d3c, -2px -2px 0 #2b2d3c, 2px -2px 0 #2b2d3c, -2px 2px 0 #2b2d3c; opacity: 0; transition: opacity .8s; }
  .pl-place.on { opacity: 1; }
  .pl-toast { position: absolute; z-index: 4; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translateX(-50%) rotate(-1deg); width: max-content;
              max-width: min(70vw, 560px); background: #f8f5ec; border: 3px solid #2b2d3c; border-radius: 10px; box-shadow: 4px 4px 0 #2b2d3c; padding: 6px 16px;
              font-family: "Patrick Hand", "Baloo 2", sans-serif; font-size: 22px; text-align: center; opacity: 0; transition: opacity .3s; pointer-events: none; color: #2b2d3c; }
  .pl-toast.on { opacity: 1; }
  .pl-act { position: absolute; z-index: 4; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); transform: translateX(-50%) rotate(-1.5deg);
            font-family: "Bungee", "Arial Black", sans-serif; font-size: 19px; background: #f5c84c; color: #2b2d3c; border: 3px solid #2b2d3c; border-radius: 12px;
            box-shadow: 5px 5px 0 #2b2d3c; padding: 10px 22px; cursor: pointer; white-space: nowrap; }
  .pl-act:active { translate: 3px 3px; box-shadow: 2px 2px 0 #2b2d3c; }
  @media (prefers-reduced-motion: no-preference) { .pl-act { animation: plbob 1.2s ease-in-out infinite alternate; } }
  @keyframes plbob { to { transform: translateX(-50%) rotate(1deg) scale(1.04); } }
  .pl-talk { position: absolute; z-index: 5; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(92vw, 740px);
             background: #fbfaf5; border: 3px solid #2b2d3c; border-radius: 6px; box-shadow: 6px 6px 0 #2b2d3c; padding: 26px 22px 14px; }
  .pl-name { position: absolute; top: -27px; left: 18px; background: #5aa9e6; color: #fff; font-family: "Bungee", "Arial Black", sans-serif; font-size: 18px;
             padding: 6px 16px; border: 3px solid #2b2d3c; transform: rotate(-2deg); box-shadow: 3px 3px 0 #2b2d3c; }
  .pl-say { margin: 0; font-family: "Patrick Hand", "Comic Sans MS", sans-serif; font-size: 27px; line-height: 1.25; color: #2b2d3c; min-height: 2.5em; }
  .pl-talkbtns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
  .pl-talkbtns button { font-family: "Bungee", "Arial Black", sans-serif; font-size: 16px; border: 3px solid #2b2d3c; border-radius: 8px; padding: 8px 16px;
                        background: #f8f5ec; box-shadow: 3px 3px 0 #2b2d3c; cursor: pointer; color: #2b2d3c; }
  .pl-talkbtns button:active { translate: 2px 2px; box-shadow: 1px 1px 0 #2b2d3c; }
  .pl-talkbtns .yes { background: #7ee08a; }
  .pl-talkbtns .next { background: #5aa9e6; color: #fff; min-width: 70px; }
  .pl-paper { background: #fbfaf5; border: 3px solid #2b2d3c; border-radius: 8px; box-shadow: 7px 7px 0 #2b2d3c; }
  .modal.pl-modal { background: rgba(30, 50, 60, .35); }
  .pl-title { font-family: "Bungee", "Arial Black", sans-serif; font-size: 22px; margin: 4px 50px 10px 4px; color: #2b2d3c; }
  .pl-quest { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; padding: 10px 6px; border-top: 2px dashed #c9c4b4; align-items: center;
              font-family: "Patrick Hand", sans-serif; font-size: 20px; color: #2b2d3c; }
  .pl-quest .qe { font-size: 30px; grid-row: span 2; }
  .pl-quest b { font-family: "Baloo 2", sans-serif; font-size: 19px; }
  .pl-quest small { color: #666; font-size: 18px; }
  .pl-quest.done { opacity: .55; }
  .pl-trip { display: grid; grid-template-columns: auto 1fr auto; gap: 0 12px; padding: 10px 6px; border-top: 2px dashed #c9c4b4; align-items: center; }
  .pl-trip .qe { font-size: 34px; grid-row: span 2; }
  .pl-trip b { font-family: "Baloo 2", sans-serif; font-size: 20px; }
  .pl-trip small { color: #666; font-size: 16px; grid-column: 2; }
  .pl-trip button { grid-row: span 2; grid-column: 3; font-size: 18px; padding: 8px 14px; border-radius: 14px; border: 3px solid #2b2d3c; background: #ffd84d; font-weight: 800; cursor: pointer; }
  .pl-trip.here button, .pl-trip.locked button { background: #e9e4d8; color: #8a8478; cursor: default; }
  .pl-trip.locked { opacity: .6; }
  .pl-launch { position: absolute; left: 50%; bottom: 12%; transform: translateX(-50%); z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 12px 26px; border-radius: 22px; border: 3px solid #2b2d3c; background: #fffaf0; font-size: 24px; cursor: pointer; }
  .pl-launch small { font-size: 14px; color: #666; }
  .pl-quest.done b { text-decoration: line-through; }
  .pl-gates { font-family: "Patrick Hand", sans-serif; font-size: 21px; padding: 8px 6px 2px; border-top: 2px dashed #c9c4b4; color: #2b2d3c; }
  .pl-hint { font-family: "Patrick Hand", sans-serif; font-size: 19px; margin: 0 0 8px 4px; color: #555; }
  .pl-boost { background: #fff1a8; transform: rotate(2deg); }
  @media (prefers-reduced-motion: no-preference) { .pl-boost { animation: plbob 1s ease-in-out infinite alternate; } }
  /* Jump: a round button bottom right. */
  .pl-jump { position: absolute; z-index: 4; right: calc(22px + env(safe-area-inset-right)); bottom: calc(26px + env(safe-area-inset-bottom)); width: 74px; height: 74px;
             border-radius: 50%; border: 3px solid #2b2d3c; background: #8fd3c4; box-shadow: 4px 4px 0 #2b2d3c; font-size: 36px; font-weight: 900; color: #2b2d3c;
             cursor: pointer; display: grid; place-items: center; touch-action: none; }
  .pl-jump:active { translate: 3px 3px; box-shadow: 1px 1px 0 #2b2d3c; }
  #planet.indoors .pl-jump, #planet.mirroring .pl-jump { display: none; }
  @media (max-width: 560px), (max-height: 500px) { .pl-jump { width: 62px; height: 62px; font-size: 30px; } }
  /* Your house: the decorate button shows inside; the mirror and the guide do not. */
  #plDecor { display: none; }
  #planet.indoors #plMapBtn { display: none; }
  /* The map: the whole planet, with labels pinned to places on it. */
  .pl-map { position: absolute; inset: 0; z-index: 4; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
  .pl-map:active { cursor: grabbing; }
  .pl-map-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
  .pl-ml { position: absolute; left: 0; top: 0; white-space: nowrap; font-weight: 800; font-size: 15px; line-height: 1.2; padding: 3px 10px; border-radius: 12px;
           background: #fffdf6; color: #2d3436; border: 2px solid #2b2d3c; box-shadow: 0 2px 0 #2b2d3c; }
  .pl-ml::after { content: ""; position: absolute; left: 50%; bottom: -8px; margin-left: -6px; border: 6px solid transparent; border-top-color: #2b2d3c; border-bottom: 0; }
  .pl-ml.place { background: none; border: 0; box-shadow: none; padding: 0; font-family: "Bungee", "Arial Black", sans-serif; font-size: clamp(16px, 2.6vw, 24px); color: #f8f5ec;
                 text-shadow: 2px 2px 0 #2b2d3c, -2px -2px 0 #2b2d3c, 2px -2px 0 #2b2d3c, -2px 2px 0 #2b2d3c; }
  .pl-ml.place::after { display: none; }
  .pl-ml.you { background: #e05a5a; color: #fff; z-index: 3; font-size: 17px; }
  .pl-ml.help { background: #f6d55c; z-index: 2; }
  .pl-ml.goal { background: #2a9d8f; color: #fff; z-index: 2; }
  .pl-ml.gate { background: #e9e3f6; font-size: 13px; }
  .pl-ml.home { background: #fde7c8; font-size: 13px; }
  .pl-map-title { position: absolute; top: calc(18px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); margin: 0; pointer-events: none; white-space: nowrap;
                  font-family: "Bungee", "Arial Black", sans-serif; font-size: clamp(20px, 3.4vw, 32px); color: #f8f5ec;
                  text-shadow: 3px 3px 0 #2b2d3c, -2px -2px 0 #2b2d3c, 2px -2px 0 #2b2d3c, -2px 2px 0 #2b2d3c; }
  .pl-map-x { position: absolute; top: calc(76px + env(safe-area-inset-top)); right: calc(14px + env(safe-area-inset-right)); }
  @media (max-height: 500px) { .pl-map-x { top: calc(10px + env(safe-area-inset-top)); right: calc(70px + env(safe-area-inset-right)); } .pl-map-title { top: calc(10px + env(safe-area-inset-top)); } }
  .pl-map-hint { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); margin: 0; pointer-events: none; white-space: nowrap;
                 background: rgba(255, 253, 246, .92); color: #2d3436; padding: 7px 16px; border-radius: 14px; font-weight: 700; font-size: 15px; }
  #planet.mapping .pl-side, #planet.mapping .pl-place, #planet.mapping .dv-stick, #planet.mapping .pl-act, #planet.mapping .pl-jump, #planet.mapping .pl-toast, #planet.mapping .pl-coins { display: none !important; }
  #planet.indoors #plDecor { display: grid; }
  #planet.indoors #plWearBtn, #planet.indoors #plGuide { display: none; }
  .pl-homecard { display: flex; flex-direction: column; padding: 14px; }
  .pl-hrows { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 6px; padding: 2px 4px 8px; }
  .pl-hrow { display: grid; grid-template-columns: 34px minmax(70px, auto) 44px 1fr 44px; align-items: center; gap: 6px; padding: 6px 4px; border-top: 2px dashed #c9c4b4; }
  .pl-hrow.focus { background: #fff6d6; border-radius: 8px; }
  .pl-he { font-size: 26px; text-align: center; }
  .pl-hn { font-family: "Bungee", "Arial Black", sans-serif; font-size: 14px; color: #2b2d3c; line-height: 1.1; }
  .pl-hv { font-family: "Patrick Hand", "Baloo 2", sans-serif; font-size: 19px; color: #2b2d3c; text-align: center; line-height: 1.1; }
  .pl-hv small { display: block; font-size: 14px; color: #888; }
  .pl-hrow .pl-marr { width: 42px; height: 42px; font-size: 17px; cursor: pointer; color: #2b2d3c; }
  .pl-hrow.locked { opacity: .72; }
  .pl-hl { grid-column: 3 / span 3; font-family: "Patrick Hand", "Baloo 2", sans-serif; font-size: 17px; color: #6a6a6a; line-height: 1.15; }
  /* The mirror: arrows each side of you, like Messenger's switcher. */
  #planet.mirroring .pl-side, #planet.mirroring .pl-place, #planet.mirroring .dv-stick, #planet.mirroring .pl-act { display: none !important; }
  .pl-mirror { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; gap: 8px; pointer-events: none;
               padding: calc(74px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left)); }
  .pl-mirror button { pointer-events: auto; cursor: pointer; color: #2b2d3c; }
  .pl-mtabs { display: flex; gap: 12px; justify-content: center; }
  .pl-mtab { font-family: "Bungee", "Arial Black", sans-serif; font-size: 17px; border: 3px solid #2b2d3c; border-radius: 10px; background: #f8f5ec;
             box-shadow: 3px 3px 0 #2b2d3c; padding: 8px 18px; }
  .pl-mtab.on { background: #5aa9e6; color: #fff !important; transform: rotate(-2deg); }
  .pl-mrows { flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; min-height: 0; }
  .pl-mrow { display: grid; grid-template-columns: 1fr auto var(--gap, 220px) auto 1fr; align-items: center; gap: 8px; }
  .pl-mname { justify-self: end; text-align: right; font-family: "Bungee", "Arial Black", sans-serif; font-size: 16px; line-height: 1.1; color: #f8f5ec;
              text-shadow: 2px 2px 0 #2b2d3c, -2px -2px 0 #2b2d3c, 2px -2px 0 #2b2d3c, -2px 2px 0 #2b2d3c; }
  .pl-mval { justify-self: start; font-family: "Patrick Hand", "Baloo 2", sans-serif; font-size: 19px; line-height: 1.15; color: #2b2d3c; background: #fbfaf5;
             border: 2px solid #2b2d3c; border-radius: 8px; box-shadow: 2px 2px 0 #2b2d3c; padding: 2px 9px; transform: rotate(-1deg); }
  .pl-mval b { font-family: "Baloo 2", sans-serif; color: #c9503f; white-space: nowrap; }
  .pl-mswatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #2b2d3c; vertical-align: -2px; margin-right: 5px; }
  .pl-marr { width: 50px; height: 50px; border: 3px solid #2b2d3c; border-radius: 10px; background: #f8f5ec; box-shadow: 3px 3px 0 #2b2d3c; font-size: 20px; padding: 0; }
  .pl-marr:active, .pl-mtab:active, .pl-mbar button:active { translate: 2px 2px; box-shadow: 1px 1px 0 #2b2d3c; }
  .pl-mbar { align-self: center; display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; max-width: min(94vw, 760px);
             background: #fbfaf5; border: 3px solid #2b2d3c; border-radius: 8px; box-shadow: 5px 5px 0 #2b2d3c; padding: 8px 12px; pointer-events: auto; }
  .pl-mnote { margin: 0; font-family: "Patrick Hand", "Baloo 2", sans-serif; font-size: 20px; color: #2b2d3c; text-align: center; }
  .pl-mbar button { font-family: "Bungee", "Arial Black", sans-serif; font-size: 16px; border: 3px solid #2b2d3c; border-radius: 8px; padding: 8px 16px; box-shadow: 3px 3px 0 #2b2d3c; }
  .pl-mbuy { background: #f5c84c; }
  .pl-mbuy.short { background: #e9e4d6; }
  .pl-mdone { background: #7ee08a; }
  @media (max-width: 560px) {
    .pl-mrow { gap: 4px; }
    .pl-marr { width: 42px; height: 42px; font-size: 17px; }
    .pl-mname { font-size: 12px; }
    .pl-mval { font-size: 15px; padding: 1px 6px; }
    .pl-mnote { font-size: 17px; }
    .pl-mbar button { font-size: 14px; padding: 6px 12px; }
  }
  @media (max-height: 500px) {
    .pl-mirror { padding-top: calc(8px + env(safe-area-inset-top)); gap: 4px; }
    .pl-mtabs { justify-content: center; }
    .pl-mtab { font-size: 14px; padding: 4px 12px; }
    .pl-marr { width: 36px; height: 36px; font-size: 15px; }
    .pl-mval { font-size: 15px; }
    .pl-mbar { padding: 4px 10px; }
    .pl-mnote { font-size: 16px; }
  }
  .modal.pl-side-modal { justify-content: flex-end; align-items: stretch; background: transparent; pointer-events: none; }
  .modal.pl-side-modal .mcard { pointer-events: auto; width: min(420px, 50vw); max-width: none; max-height: none; zoom: 1; }
  @media (orientation: portrait) {
    .modal.pl-side-modal { align-items: flex-end; justify-content: center; }
    .modal.pl-side-modal .mcard { width: 100%; max-width: 640px; height: 52%; }
  }
  #plMath .ctitle { font-family: "Patrick Hand", sans-serif; font-size: 24px; font-weight: 400; }
  @media (orientation: landscape) and (min-width: 700px) {
    #plMath .mcard.chal { zoom: 1.1; max-width: 800px; }
    #plMath .cbody { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: center; }
  }
  @media (max-width: 560px), (max-height: 500px) {
    .pl-btn { width: 46px; height: 46px; font-size: 21px; border-radius: 8px; }
    .pl-side { top: calc(64px + env(safe-area-inset-top)); gap: 9px; }
    .pl-say { font-size: 21px; }
    .pl-act { font-size: 15px; padding: 8px 16px; }
    .pl-toast { font-size: 18px; }
  }
  @media (max-height: 500px) { .pl-side { top: calc(10px + env(safe-area-inset-top)); right: calc(70px + env(safe-area-inset-right)); grid-auto-flow: column; } }
  /* The clock, and a heart that pops up when someone likes you more. */
  .pl-clock { font-size: 16px; padding: 7px 10px; transform: rotate(1.5deg); white-space: nowrap; }
  .pl-heartpop { position: absolute; z-index: 4; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translate(-50%, 10px) rotate(1deg); pointer-events: none;
                 font-family: "Bungee", "Arial Black", sans-serif; font-size: 16px; background: #ffe1ec; color: #2b2d3c; border: 3px solid #2b2d3c; border-radius: 10px;
                 box-shadow: 4px 4px 0 #2b2d3c; padding: 6px 14px; opacity: 0; transition: opacity .3s, transform .3s; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
  .pl-heartpop.on { opacity: 1; transform: translate(-50%, 0) rotate(1deg); }
  #planet.mapping .pl-heartpop, #planet.mapping .pl-clock { display: none !important; }
  /* Night: the screen goes dark while you sleep, and the morning card says what's new. */
  .pl-night { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; background: #141a33; opacity: 0; transition: opacity 1.4s ease; padding: 16px; }
  .pl-night.on { opacity: 1; }
  .pl-night.morning { background: linear-gradient(#f6c48f, #f8e3b5 60%, #bfe6dc); transition: background 1.2s, opacity .7s; }
  .pl-nightcard { text-align: center; color: #f8f5ec; font-family: "Patrick Hand", "Baloo 2", sans-serif; font-size: 24px; max-width: 520px; }
  .pl-night.morning .pl-nightcard { background: #fbfaf5; color: #2b2d3c; border: 3px solid #2b2d3c; border-radius: 10px; box-shadow: 7px 7px 0 #2b2d3c; padding: 16px 22px; }
  .pl-nightcard h2 { font-family: "Bungee", "Arial Black", sans-serif; font-size: 34px; margin: 0; }
  .pl-nightcard p { margin: 6px 0; }
  .pl-nightcard .pl-nnews { font-size: 21px; text-align: left; border-top: 2px dashed #c9c4b4; padding-top: 6px; }
  .pl-nightcard button { margin-top: 10px; font-family: "Bungee", "Arial Black", sans-serif; font-size: 18px; border: 3px solid #2b2d3c; border-radius: 8px; padding: 10px 22px; box-shadow: 3px 3px 0 #2b2d3c; cursor: pointer; }
  .pl-zz { font-size: 64px; line-height: 1.1; }
  @media (prefers-reduced-motion: no-preference) { .pl-night.on:not(.morning) .pl-zz { animation: plbob 1.4s ease-in-out infinite alternate; } }
  /* A friend's sums, told as a story. */
  .pl-mstory { margin: 0 0 6px 40px; font-family: "Patrick Hand", "Baloo 2", sans-serif; font-size: 21px; line-height: 1.2; color: #2b2d3c; background: #fff6d6; border-radius: 10px; padding: 6px 10px; }
  /* The friends window: everyone down the side, the one you pick on the right. */
  .pl-friendscard { width: min(880px, 96vw); max-width: none; max-height: 92vh; display: flex; flex-direction: column; padding: 14px; }
  .pl-fwrap { display: grid; grid-template-columns: 200px 1fr; gap: 14px; min-height: 0; flex: 1; overflow: hidden; }
  .pl-flist { display: flex; flex-direction: column; gap: 6px; overflow: auto; padding: 2px 4px 6px 2px; }
  .pl-frow { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px; text-align: left; background: #f8f5ec; border: 3px solid #2b2d3c; border-radius: 10px;
             padding: 4px 8px 4px 4px; box-shadow: 3px 3px 0 #2b2d3c; cursor: pointer; color: #2b2d3c; font: inherit; }
  .pl-frow.on { background: #ffe1ec; transform: rotate(-1deg); }
  .pl-frow:active { translate: 2px 2px; box-shadow: 1px 1px 0 #2b2d3c; }
  .pl-fav { width: 44px; height: 44px; border-radius: 50%; border: 2px solid #2b2d3c; background: #d9eef0; display: grid; place-items: center; font-size: 24px; object-fit: cover; }
  img.pl-fav { background: radial-gradient(circle at 50% 35%, #fff8e6, #bfe6dc); }
  .pl-fav.big { width: 84px; height: 84px; font-size: 44px; border-width: 3px; flex: none; }
  .pl-fname { font-family: "Bungee", "Arial Black", sans-serif; font-size: 14px; line-height: 1.1; }
  .pl-fdot { font-style: normal; color: #e0567f; }
  .pl-fmini { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 15px; white-space: nowrap; }
  .pl-fdetail { overflow: auto; padding: 2px 6px 8px 2px; color: #2b2d3c; }
  .pl-fhead { display: flex; gap: 12px; align-items: center; }
  .pl-fhead small { display: block; font-family: "Patrick Hand", sans-serif; font-size: 18px; color: #555; }
  .pl-fbig { font-family: "Bungee", "Arial Black", sans-serif; font-size: 22px; line-height: 1.1; }
  .pl-status { display: inline-block; margin-top: 4px; font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 15px; padding: 1px 10px; border-radius: 20px; border: 2px solid #2b2d3c; background: #f8f5ec; }
  .pl-status.s-dating, .pl-status.s-engaged { background: #ffc8db; }
  .pl-status.s-married { background: #f6d55c; }
  .pl-status.s-bestfriend, .pl-status.s-closefriend { background: #c9f0d9; }
  .pl-hearts { display: flex; flex-wrap: wrap; gap: 1px; margin: 10px 0 4px; font-size: 22px; line-height: 1; }
  .pl-hearts i { font-style: normal; }
  .pl-hearts i.locked { opacity: .45; font-size: 16px; align-self: center; }
  .pl-hbar { height: 8px; border-radius: 6px; background: #ece6d6; border: 2px solid #2b2d3c; overflow: hidden; max-width: 300px; }
  .pl-hbar i { display: block; height: 100%; background: #e0567f; }
  .pl-todays { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 2px; }
  .pl-today { font-family: "Patrick Hand", sans-serif; font-size: 18px; padding: 2px 10px; border-radius: 14px; background: #ece6d6; color: #6a6a6a; }
  .pl-today.done { background: #c9f0d9; color: #2b2d3c; }
  .pl-fsec { font-family: "Bungee", "Arial Black", sans-serif; font-size: 15px; margin: 12px 0 4px; border-top: 2px dashed #c9c4b4; padding-top: 8px; }
  .pl-fsec small { font-family: "Patrick Hand", sans-serif; font-size: 16px; color: #666; }
  .pl-likes { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 3px 0; }
  .pl-lk { font-family: "Patrick Hand", sans-serif; font-size: 18px; min-width: 128px; }
  .pl-chip { font-family: "Baloo 2", sans-serif; font-weight: 700; font-size: 15px; background: #fff; border: 2px solid #2b2d3c; border-radius: 14px; padding: 0 10px; white-space: nowrap; }
  .pl-chip.unknown { border-style: dashed; color: #888; background: transparent; }
  .pl-next { margin-top: 12px; background: #fff6d6; border-radius: 10px; padding: 4px 12px; font-family: "Patrick Hand", sans-serif; font-size: 18px; }
  .pl-next p { margin: 4px 0; }
  @media (max-width: 640px) {
    .pl-fwrap { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .pl-flist { flex-direction: row; overflow-x: auto; padding-bottom: 8px; }
    .pl-frow { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 4px 6px; min-width: 70px; gap: 2px; }
    .pl-fname { font-size: 12px; }
    .pl-fmini { font-size: 13px; }
    .pl-lk { min-width: 100%; }
  }
  @media (max-height: 500px) { .pl-friendscard { max-height: 96vh; padding: 8px 12px; } .pl-fav.big { width: 60px; height: 60px; } .pl-friendscard .pl-title { margin-bottom: 4px; } }
  /* Gifts to give, and Tess's gift corner. */
  .pl-giftcard { width: min(520px, 94vw); padding: 14px; }
  .pl-gifts { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
  .pl-gift { position: relative; display: grid; justify-items: center; gap: 2px; background: #f8f5ec; border: 3px solid #2b2d3c; border-radius: 10px; box-shadow: 3px 3px 0 #2b2d3c;
             padding: 8px 6px; cursor: pointer; color: #2b2d3c; font: inherit; }
  .pl-gift:active, .pl-srow button:active { translate: 2px 2px; box-shadow: 1px 1px 0 #2b2d3c; }
  .pl-ge { font-size: 34px; line-height: 1.1; }
  .pl-gn { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 15px; line-height: 1.1; text-align: center; }
  .pl-gift small { font-family: "Patrick Hand", sans-serif; font-size: 16px; color: #666; }
  .pl-gt { position: absolute; top: -10px; right: -8px; font-style: normal; font-size: 22px; }
  .pl-shop { display: flex; flex-direction: column; gap: 8px; }
  .pl-srow { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; border-top: 2px dashed #c9c4b4; padding-top: 8px; }
  .pl-sn { font-family: "Patrick Hand", sans-serif; font-size: 17px; color: #555; line-height: 1.2; }
  .pl-sn b { font-family: "Baloo 2", sans-serif; font-size: 18px; color: #2b2d3c; }
  .pl-sn small { display: block; font-size: 16px; }
  .pl-sn .pl-own { display: inline; color: #2a9d8f; }
  .pl-srow button { font-family: "Bungee", "Arial Black", sans-serif; font-size: 16px; border: 3px solid #2b2d3c; border-radius: 8px; padding: 8px 12px; box-shadow: 3px 3px 0 #2b2d3c; cursor: pointer; white-space: nowrap; }
  /* Naming your baby. */
  .pl-babycard { width: min(440px, 94vw); padding: 16px; text-align: center; display: grid; gap: 10px; }
  #plBabyName { font: inherit; font-size: 24px; font-weight: 800; text-align: center; padding: 8px 14px; border-radius: 10px; border: 3px solid #2b2d3c; background: #fff; color: #2b2d3c; }
  .pl-babyideas { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
  .pl-babyideas button { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 17px; border: 2px solid #2b2d3c; border-radius: 16px; padding: 2px 14px; background: #ffe1ec; cursor: pointer; color: #2b2d3c; }
  .pl-babycard .pl-mdone { justify-self: center; font-family: "Bungee", "Arial Black", sans-serif; font-size: 17px; border: 3px solid #2b2d3c; border-radius: 8px; padding: 10px 18px; box-shadow: 3px 3px 0 #2b2d3c; cursor: pointer; }


/* A coin drawn with CSS, for computers with no 🪙 emoji (see coins.js). */
.coin { display: inline-block; width: 1em; height: 1em; border-radius: 50%; vertical-align: -.14em; font-style: normal;
        background: radial-gradient(circle at 36% 32%, #fff3b0 0 14%, #ffd84a 15% 52%, #e9a908 53% 100%);
        box-shadow: inset 0 0 0 .07em #b97f00, inset 0 0 0 .15em #ffd84a, inset 0 0 0 .2em #d99a00; }

  /* ---------- Honeybee Farm ---------- */
  :root { --fm-wood: #8a5a33; --fm-wood-dark: #5e3b1f; --fm-paper: #fbf3df; --fm-paper-dark: #efe0bd; --fm-ink: #4a3423;
          --fm-green: #3f8f3a; --fm-red: #c8453b; --fm-gold: #f4cf55; --fm-pixel: "Pixelify Sans", "Baloo 2", sans-serif; }
  body[data-screen="farmSetup"]::before { background: linear-gradient(#bfe8ff, #fff3d6 60%, #d8f0b8); }
  body[data-screen="farm"]::before, body[data-screen="farmHouse"]::before { background: #2e7430; }
  body[data-screen="farm"], body[data-screen="farmHouse"] { overflow: hidden; background: #2e7430; }
  #farmSetup h1 { font-family: var(--fm-pixel); color: #fff; text-shadow: 0 3px 0 var(--fm-wood-dark), 0 0 12px rgba(94,59,31,.5); }
  #farmSetup .sub, #farmSetup .best { color: var(--fm-ink); text-shadow: none; }
  .fm-hero { display: block; width: min(100%, 460px); margin: 0 auto 10px; aspect-ratio: 12 / 5; image-rendering: pixelated;
             border: 4px solid var(--fm-wood); border-radius: 14px; box-shadow: 0 6px 0 var(--fm-wood-dark); }
  .fm-newfarm { margin: 6px 0 10px; }
  .fm-newask p { margin: 0 0 10px; font-size: 18px; color: var(--fm-ink); }

  #farm.on, #farmHouse.on { position: fixed; inset: 0; max-width: none; padding: 0; display: block; animation: none; }
  #fmCanvas, #fmHouseCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; image-rendering: pixelated; }
  .fm-top { position: absolute; left: 0; right: 0; top: 0; z-index: 3; display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
            padding: calc(8px + env(safe-area-inset-top)) calc(66px + env(safe-area-inset-right)) 0 calc(8px + env(safe-area-inset-left)); pointer-events: none; }
  .fm-top > * { pointer-events: auto; }
  .fm-btn, .fm-pill { font: 700 16px var(--fm-pixel); color: var(--fm-ink); background: var(--fm-paper); border: 3px solid var(--fm-wood);
                      border-radius: 10px; padding: 3px 10px; box-shadow: 0 3px 0 var(--fm-wood-dark); display: inline-flex; align-items: center; gap: 6px; min-height: 36px; }
  .fm-btn { cursor: pointer; }
  .fm-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--fm-wood-dark); }
  .fm-gold { background: var(--fm-gold); }
  .fm-pill img { width: 22px; height: 22px; image-rendering: pixelated; }
  .fm-pill small { font: 600 13px var(--fm-pixel); }
  .fm-ebar { width: 70px; height: 12px; border-radius: 6px; background: #d9c9a5; border: 2px solid var(--fm-wood-dark); overflow: hidden; display: inline-block; }
  .fm-ebar i { display: block; height: 100%; background: linear-gradient(#8fe06b, #4caf3a); transition: width .3s; }
  .fm-ebar i.low { background: linear-gradient(#ffb36b, #e06a3a); }
  .fm-toast { position: absolute; left: 50%; top: calc(60px + env(safe-area-inset-top)); transform: translate(-50%, -8px); z-index: 4; opacity: 0;
              max-width: min(92vw, 520px); text-align: center; font: 700 17px var(--fm-pixel); color: var(--fm-ink); background: var(--fm-paper);
              border: 3px solid var(--fm-wood); border-radius: 12px; padding: 6px 14px; box-shadow: 0 4px 0 var(--fm-wood-dark); transition: opacity .25s, transform .25s; pointer-events: none; }
  .fm-toast.on { opacity: 1; transform: translate(-50%, 0); }
  .fm-bottom { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: grid; justify-items: center; gap: 6px;
               padding: 0 calc(8px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left)); pointer-events: none; }
  .fm-bottom > * { pointer-events: auto; }
  .fm-hint { margin: 0; max-width: min(96vw, 640px); text-align: center; font: 600 15px var(--fm-pixel); color: var(--fm-ink);
             background: rgba(251,243,223,.92); border: 2px solid var(--fm-wood); border-radius: 10px; padding: 4px 12px; }
  .fm-hint:empty { display: none; }
  .fm-tools { display: flex; gap: 6px; background: var(--fm-wood); border: 3px solid var(--fm-wood-dark); border-radius: 14px; padding: 6px;
              box-shadow: 0 4px 0 rgba(0,0,0,.25); max-width: 100%; }
  .fm-tool { position: relative; width: 84px; display: grid; justify-items: center; gap: 1px; padding: 4px 2px 6px; cursor: pointer;
             background: var(--fm-paper-dark); border: 3px solid var(--fm-wood-dark); border-radius: 10px; font: 700 12px var(--fm-pixel); color: var(--fm-ink); }
  .fm-tool img { width: 44px; height: 44px; image-rendering: pixelated; }
  .fm-tool span { line-height: 1.1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 78px; }
  .fm-tool.on { background: #fff8d8; border-color: var(--fm-gold); box-shadow: 0 0 0 3px var(--fm-gold); transform: translateY(-3px); }
  .fm-meter { position: absolute; left: 8px; right: 8px; bottom: 2px; height: 4px; border-radius: 2px; background: #c9b78f; overflow: hidden; }
  .fm-meter b { display: block; height: 100%; background: #4aa3df; }
  .fm-tray { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; background: var(--fm-wood); border: 3px solid var(--fm-wood-dark);
             border-radius: 14px; padding: 6px; min-height: 40px; max-width: 100%; }
  .fm-thing { width: 56px; height: 56px; padding: 4px; cursor: pointer; background: var(--fm-paper-dark); border: 3px solid var(--fm-wood-dark); border-radius: 10px; }
  .fm-thing img { width: 100%; height: 100%; image-rendering: pixelated; }
  .fm-thing.on { border-color: var(--fm-gold); box-shadow: 0 0 0 3px var(--fm-gold); }
  .fm-store, .fm-trayempty { font: 700 15px var(--fm-pixel); color: var(--fm-ink); }
  .fm-trayempty { color: var(--fm-paper); align-self: center; padding: 0 8px; }
  .fm-store { background: var(--fm-paper); border: 3px solid var(--fm-wood-dark); border-radius: 10px; padding: 6px 12px; cursor: pointer; }

  .fm-modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(40,28,18,.45);
              padding: calc(10px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left)); }
  .fm-modal[hidden] { display: none; }
  .fm-board { position: relative; width: 100%; max-width: 640px; max-height: 100%; overflow: auto; background: var(--fm-paper); color: var(--fm-ink);
              border: 6px solid var(--fm-wood); border-radius: 18px; box-shadow: inset 0 0 0 3px var(--fm-paper-dark), 0 10px 0 var(--fm-wood-dark), 0 20px 40px rgba(0,0,0,.35);
              padding: 14px 16px 16px; animation: pop-in .25s ease-out; }
  .fm-board h2 { margin: 0 44px 8px 0; font: 700 24px var(--fm-pixel); color: var(--fm-wood-dark); line-height: 1.15; }
  .fm-x { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border-radius: 10px; border: 3px solid var(--fm-wood); background: var(--fm-paper-dark);
          font: 700 18px var(--fm-pixel); color: var(--fm-wood-dark); cursor: pointer; }
  .fm-body button { font: 700 15px var(--fm-pixel); color: var(--fm-ink); background: #fff8e4; border: 3px solid var(--fm-wood); border-radius: 10px;
                    padding: 5px 10px; cursor: pointer; box-shadow: 0 3px 0 var(--fm-wood-dark); }
  .fm-body button:disabled { opacity: .5; cursor: default; }
  .fm-body button:not(:disabled):active { transform: translateY(2px); box-shadow: 0 1px 0 var(--fm-wood-dark); }
  .fm-big { display: grid; gap: 2px; justify-items: center; width: 100%; margin-top: 8px; font: 700 19px var(--fm-pixel) !important; padding: 10px !important;
            background: #8fd06b !important; color: #1f3d14 !important; border-color: #4f8a35 !important; box-shadow: 0 4px 0 #3c6e27 !important; }
  .fm-big small { font: 600 13px var(--fm-pixel); color: #2d5520; }
  .fm-big:disabled { background: #d9d2bf !important; border-color: #b5ab92 !important; box-shadow: 0 4px 0 #9c937c !important; color: #6b604c !important; }
  .fm-big:disabled small { color: #6b604c; }
  .fm-soft { background: #fff8e4 !important; color: var(--fm-ink) !important; border-color: var(--fm-wood) !important; box-shadow: 0 4px 0 var(--fm-wood-dark) !important; }
  .fm-danger { background: #f19a8e !important; color: #5a1a12 !important; border-color: #b8463b !important; box-shadow: 0 4px 0 #8c3229 !important; }
  .fm-story { font-size: 17px; line-height: 1.35; margin: 6px 0; }
  .fm-weather img, .fm-have img { width: 28px; height: 28px; vertical-align: middle; image-rendering: pixelated; }
  .fm-have { font: 600 16px var(--fm-pixel); margin: 0 0 10px; }
  .fm-note { font-size: 14px; color: #7a6450; margin: 10px 0 0; }
  .fm-row { display: flex; gap: 8px; }
  .fm-row > * { flex: 1; }
  .fm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .fm-card { display: grid; justify-items: center; align-content: start; gap: 3px; text-align: center; background: #fff8e4; border: 3px solid var(--fm-paper-dark);
             border-radius: 12px; padding: 8px; font-family: var(--fm-pixel); }
  .fm-card img { width: 48px; height: 48px; image-rendering: pixelated; }
  .fm-card b { font-size: 16px; } .fm-card small { font-size: 13px; color: #7a6450; }
  .fm-card .fm-row { width: 100%; margin-top: 4px; }
  .fm-card.fm-wide { grid-column: 1 / -1; }
  .fm-pick { cursor: pointer; } .fm-pick.on { border-color: var(--fm-gold); }
  .fm-ok { color: var(--fm-green) !important; font-weight: 700; }
  .fm-choices { display: grid; gap: 4px; }
  .fm-list { display: grid; gap: 6px; }
  .fm-line { display: grid; grid-template-columns: 40px 1fr auto auto; align-items: center; gap: 8px; background: #fff8e4; border-radius: 10px; padding: 4px 8px; font-family: var(--fm-pixel); }
  .fm-line img { width: 36px; height: 36px; image-rendering: pixelated; }
  .fm-line span { display: grid; } .fm-line small { color: #7a6450; font-size: 13px; }
  .fm-tree { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
  .fm-branch { background: #f6ead0; border-radius: 14px; padding: 8px; }
  .fm-branch h3 { margin: 0; font: 700 18px var(--fm-pixel); color: var(--fm-wood-dark); text-align: center; }
  .fm-does { margin: 2px 0 8px; font-size: 13px; text-align: center; color: #7a6450; }
  .fm-node { position: relative; display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: center; background: #fff8e4;
             border: 3px solid var(--fm-paper-dark); border-radius: 12px; padding: 6px; margin-bottom: 14px; font-family: var(--fm-pixel); }
  .fm-node:not(:last-child)::after { content: ""; position: absolute; left: 26px; bottom: -17px; width: 4px; height: 14px; background: var(--fm-wood); border-radius: 2px; }
  .fm-node img { width: 44px; height: 44px; image-rendering: pixelated; }
  .fm-node div { display: grid; gap: 2px; } .fm-node small { font-size: 12px; color: #7a6450; }
  .fm-node.have { border-color: #8fd06b; } .fm-node.next { border-color: var(--fm-gold); box-shadow: 0 0 0 2px var(--fm-gold); }
  .fm-node.later { opacity: .55; }
  .fm-node button { font-size: 13px; padding: 4px 6px; }
  .fm-mathboard { max-width: 460px; text-align: center; }
  .fm-dots { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 4px 0 6px; }
  .fm-dots i { width: 16px; height: 16px; border-radius: 50%; background: #e6d7b4; border: 2px solid var(--fm-wood); }
  .fm-dots i.on { background: #6cbf45; border-color: #3c6e27; }
  .fm-qrow { position: relative; min-height: 40px; }
  .fm-say { position: absolute; left: 0; top: 0; width: 40px; height: 40px; border-radius: 10px; border: 3px solid var(--fm-wood); background: var(--fm-paper-dark); cursor: pointer; font-size: 18px; }
  .fm-qrow .tricky { top: 6px; right: 0; }
  .fm-mathboard .q { font-size: 56px; } .fm-mathboard .ans { width: 70%; min-height: 64px; line-height: 58px; font-size: 46px; margin: 4px auto; }
  .fm-fix { min-height: 22px; margin: 2px 0 8px; font: 700 16px var(--fm-pixel); }
  .fm-mathboard .key { font-size: 28px; padding: 4px 0; background: #fff8e4; box-shadow: 0 4px 0 var(--fm-paper-dark); }
  .fm-mathboard .key.del { background: #f19a8e; } .fm-mathboard .key.ok { background: #8fd06b; }
  .fm-night { position: fixed; inset: 0; z-index: 60; display: grid; place-content: center; justify-items: center; gap: 10px; opacity: 0;
              background: radial-gradient(circle at 70% 25%, #2b3f7a, #10173a 70%); color: #fdf3cf; font: 700 26px var(--fm-pixel); }
  .fm-night[hidden] { display: none; }
  .fm-night.go { animation: night 2.6s ease-in-out forwards; }
  @keyframes night { 0% { opacity: 0; } 30%, 70% { opacity: 1; } 100% { opacity: 0; } }
  .fm-moon { width: 64px; height: 64px; border-radius: 50%; background: #fdf3cf; box-shadow: -14px 0 0 0 #10173a inset, 0 0 30px rgba(253,243,207,.5); }
  .fm-night::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(#fff 1px, transparent 1.5px), radial-gradient(#fdf3cf 1px, transparent 1.5px);
                      background-size: 90px 70px, 130px 110px; background-position: 10px 20px, 50px 60px; opacity: .7; }
  /* Honeybee Town: health, the bag, people, shops, styling, fishing and battles. */
  .fm-pill[hidden], .fm-btn[hidden] { display: none; }
  .fm-hbar i { background: linear-gradient(#ff8a9a, #e8455a); } .fm-hbar i.low { background: linear-gradient(#ffb36b, #e06a3a); }
  .fm-tool.fm-bagbtn { background: #f3e1b8; }
  .fm-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
  .fm-tabs button { flex: 1 1 auto; font: 700 15px var(--fm-pixel); padding: 6px 10px; box-shadow: none; }
  .fm-tabs button.on { background: var(--fm-gold); border-color: var(--fm-wood-dark); }
  .fm-bag { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; }
  .fm-body .fm-slot { position: relative; aspect-ratio: 1; padding: 4px; box-shadow: none; background: #fff8e4; border-color: var(--fm-paper-dark); }
  .fm-body .fm-slot.on { border-color: var(--fm-gold); box-shadow: 0 0 0 3px var(--fm-gold); }
  .fm-slot img { width: 100%; height: 100%; image-rendering: pixelated; }
  .fm-slot b { position: absolute; right: 3px; bottom: 1px; font: 700 13px var(--fm-pixel); color: var(--fm-ink); text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
  .fm-info { display: grid; grid-template-columns: 48px 1fr; gap: 8px; align-items: center; margin-top: 10px; background: #f6ead0; border-radius: 12px; padding: 8px; font-family: var(--fm-pixel); }
  .fm-info img { width: 48px; height: 48px; image-rendering: pixelated; } .fm-info div { display: grid; } .fm-info small { color: #7a6450; font-size: 13px; }
  .fm-info .fm-big { grid-column: 1 / -1; margin-top: 2px; }
  .fm-skills, .fm-friends { display: grid; gap: 8px; }
  .fm-skill, .fm-friend { display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: start; background: #fff8e4; border-radius: 12px; padding: 8px; font-family: var(--fm-pixel); }
  .fm-skill img, .fm-friend img { width: 52px; height: 52px; image-rendering: pixelated; border-radius: 10px; }
  .fm-skill div, .fm-friend div { display: grid; gap: 2px; } .fm-skill small, .fm-friend small { color: #7a6450; font-size: 13px; }
  .fm-skill ul { margin: 2px 0 0; padding-left: 18px; font-size: 13px; color: #9a8670; } .fm-skill li.fm-ok { color: var(--fm-green); }
  .fm-xp { display: block; height: 10px; border-radius: 5px; background: #e6d7b4; border: 2px solid var(--fm-wood); overflow: hidden; }
  .fm-xp b { display: block; height: 100%; background: linear-gradient(#8fe06b, #4caf3a); }
  .fm-hearts { display: flex; flex-wrap: wrap; gap: 1px; } .fm-hearts img { width: 20px; height: 20px; image-rendering: pixelated; }
  .fm-person { display: grid; grid-template-columns: 72px 1fr; gap: 10px; align-items: center; font-family: var(--fm-pixel); }
  .fm-person > img { width: 72px; height: 72px; image-rendering: pixelated; border-radius: 12px; border: 3px solid var(--fm-wood); background: #f6e7c8; }
  .fm-person div { display: grid; gap: 2px; } .fm-person b { font-size: 19px; } .fm-person small { color: #7a6450; font-size: 13px; }
  .fm-person > img.fm-kidpic { object-fit: contain; padding: 6px; }
  .fm-speech { position: relative; margin: 10px 0 6px; padding: 10px 14px; background: #fff; border: 3px solid var(--fm-paper-dark); border-radius: 14px; font: 600 17px/1.35 var(--fm-pixel); }
  .fm-keeper { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 2px dashed var(--fm-paper-dark); }
  .fm-keeper .fm-person > img { width: 56px; height: 56px; } .fm-keeper .fm-person { grid-template-columns: 56px 1fr; }
  .fm-love { background: #f7b6c8 !important; border-color: #c4587a !important; box-shadow: 0 4px 0 #9a3c5a !important; color: #5a1a32 !important; }
  .fm-love small { color: #7a2a48 !important; }
  .fm-sub { margin: 14px 0 6px; font: 700 18px var(--fm-pixel); color: var(--fm-wood-dark); }
  .fm-card.fm-unknown img { filter: brightness(0) opacity(.35); }
  .fm-floors { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; } .fm-floors .fm-big { margin-top: 0; }
  .fm-houses { display: grid; gap: 8px; margin-bottom: 8px; }
  .fm-house { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: center; background: #fff8e4; border: 3px solid var(--fm-paper-dark); border-radius: 12px; padding: 6px; font-family: var(--fm-pixel); }
  .fm-house img { width: 96px; height: 72px; image-rendering: pixelated; } .fm-house div { display: grid; gap: 2px; } .fm-house small { color: #7a6450; font-size: 13px; }
  .fm-house.have { border-color: #8fd06b; } .fm-house.next { border-color: var(--fm-gold); box-shadow: 0 0 0 2px var(--fm-gold); } .fm-house.later { opacity: .6; }
  .fm-build { background: #f6ead0; border-radius: 12px; padding: 10px; text-align: center; font-family: var(--fm-pixel); }
  .fm-note-card { background: #fff8e4; border: 3px dashed var(--fm-paper-dark); border-radius: 12px; padding: 4px 12px; font-size: 16px; }
  .fm-name { width: 100%; box-sizing: border-box; font: 700 22px var(--fm-pixel); padding: 8px 12px; margin: 6px 0; border: 3px solid var(--fm-wood); border-radius: 10px; background: #fff; color: var(--fm-ink); }
  .fm-wedding { display: flex; align-items: center; justify-content: center; gap: 10px; }
  .fm-wedding img { width: 96px; height: 96px; image-rendering: pixelated; border-radius: 14px; border: 3px solid var(--fm-wood); }
  .fm-wedding img.fm-wheart { width: 40px; height: 40px; border: 0; animation: beat 1s ease-in-out infinite; }
  @keyframes beat { 50% { transform: scale(1.2); } }
  .fm-style { display: grid; gap: 8px; }
  .fm-stylepic { display: flex; gap: 10px; align-items: center; justify-content: center; }
  .fm-stylepic canvas { width: 240px; height: 144px; image-rendering: pixelated; border-radius: 12px; border: 3px solid var(--fm-wood); }
  .fm-stylecats button { flex: 0 1 auto; font-size: 13px; padding: 4px 8px; }
  .fm-styleopts { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
  .fm-body .fm-styleopt { display: grid; justify-items: center; gap: 1px; padding: 4px; box-shadow: none; background: #fff8e4; border-color: var(--fm-paper-dark); font-size: 12px; }
  .fm-styleopt img { width: 40px; height: 52px; image-rendering: pixelated; } .fm-styleopt small { font-size: 11px; color: #a0522d; }
  .fm-body .fm-styleopt.on { border-color: var(--fm-gold); box-shadow: 0 0 0 3px var(--fm-gold); } .fm-styleopt.locked img { opacity: .75; }
  .fm-body .fm-swatch { width: 100%; aspect-ratio: 1; padding: 0; border-radius: 50%; box-shadow: none; border: 3px solid var(--fm-wood); }
  .fm-body .fm-swatch.on { box-shadow: 0 0 0 3px var(--fm-gold); border-color: #fff; }
  .fm-styleopts:has(.fm-swatch) { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
  .fm-msub { margin: -4px 0 6px; font: 600 14px var(--fm-pixel); color: #7a6450; }
  .fm-mart { height: 150px; margin: 0 0 6px; border-radius: 12px; overflow: hidden; border: 3px solid var(--fm-wood); }
  .fm-mart canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
  .fm-x.fm-run { width: auto; padding: 0 10px; font-size: 15px; background: #f19a8e; }
  .fm-fish { background: rgba(20,40,60,.35); touch-action: none; user-select: none; -webkit-user-select: none; }
  .fm-fishboard { max-width: 300px; text-align: center; touch-action: none; }
  .fm-fishboard h2 { margin: 0 0 6px; }
  #fmFishC { width: 170px; height: min(360px, 52vh); display: block; margin: 0 auto; image-rendering: pixelated; }
  @media (max-height: 800px) {
    .fm-battle .fm-mart { height: 92px; } .fm-battle .fm-mathboard .q { font-size: 42px; }
    .fm-battle .fm-mathboard .ans { min-height: 50px; line-height: 46px; font-size: 36px; }
    .fm-battle .fm-fix { min-height: 18px; margin: 0 0 4px; } .fm-battle .fm-mathboard .key { padding: 0; }
    .fm-battle .fm-dots { margin: 2px 0; } .fm-battle .fm-qrow { min-height: 34px; } .fm-battle .fm-say { width: 34px; height: 34px; font-size: 15px; }
  }
  /* Seasons, the kitchen, animals and festivals. */
  .fm-seasonline img { width: 28px; height: 28px; vertical-align: middle; image-rendering: pixelated; }
  .fm-festline { background: #fde9c8; border-radius: 10px; padding: 6px 10px; }
  .fm-late { color: #b8452e !important; font-weight: 700; }
  .fm-card.fm-off { opacity: .6; }
  .fm-recipes { display: grid; gap: 8px; }
  .fm-recipe { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; background: #fff8e4; border: 3px solid var(--fm-paper-dark); border-radius: 12px; padding: 8px; font-family: var(--fm-pixel); }
  .fm-recipe > img { width: 48px; height: 48px; image-rendering: pixelated; }
  .fm-recipe > div { display: grid; gap: 3px; } .fm-recipe small { color: #7a6450; font-size: 13px; }
  .fm-recipe button { display: grid; justify-items: center; font-size: 15px; padding: 6px 10px; } .fm-recipe button small { font-size: 11px; color: inherit; }
  .fm-recipe.fm-unknown { grid-template-columns: 48px 1fr; opacity: .75; } .fm-recipe.fm-unknown > img { filter: brightness(0) opacity(.35); }
  .fm-needs { display: flex; flex-wrap: wrap; gap: 4px; }
  .fm-need { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; background: #eaf6dc; border-radius: 8px; padding: 1px 6px; }
  .fm-need img { width: 20px; height: 20px; image-rendering: pixelated; } .fm-need.short { background: #fbe0d8; color: #9a3a22; }
  .fm-grange { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; margin-bottom: 10px; padding: 6px; background: #c8a06a; border-radius: 10px; }
  .fm-body .fm-slot.fm-empty { display: block; aspect-ratio: 1; background: #e8d4a8; border: 3px dashed #b08a5a; border-radius: 10px; }
  .fm-learn { background: #e3f4d2; border: 2px solid #8fd06b; }
  .fm-animal > img { object-fit: contain; background: #e3f0cf; padding: 4px; box-sizing: border-box; }
  .fm-fade { position: fixed; inset: 0; z-index: 35; background: #1c140e; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .fm-fade.on { opacity: 1; }
  @media (max-width: 520px) {
    .fm-tools { gap: 4px; padding: 4px; }
    .fm-tool { width: 58px; padding: 3px 1px 5px; } .fm-tool img { width: 32px; height: 32px; } .fm-tool span { max-width: 54px; font-size: 10px; }
    .fm-person { grid-template-columns: 60px 1fr; } .fm-person > img { width: 60px; height: 60px; }
    .fm-stylepic canvas { width: 200px; height: 120px; }
    .fm-keeper { grid-template-columns: 1fr; } .fm-keeper .fm-hearts img { width: 16px; height: 16px; }
    .fm-btn, .fm-pill { font-size: 14px; padding: 2px 8px; min-height: 32px; } .fm-ebar { width: 50px; }
    .fm-hint { font-size: 13px; }
  }
  @media (orientation: landscape) and (max-height: 500px) {
    /* Short screens: tools in a column on the right, the hint at the bottom left. */
    #farm .fm-bottom { display: block; inset: 0; padding: 0; }
    #farm .fm-tools { position: absolute; right: calc(8px + env(safe-area-inset-right)); top: 50%; transform: translateY(-40%);
                      display: grid; grid-auto-flow: column; grid-template-rows: repeat(3, auto); gap: 4px; padding: 4px; }
    .fm-mart { height: 90px; } #fmFishC { height: 62vh; } .fm-fishboard { padding: 6px 10px; } .fm-fishboard h2 { font-size: 18px; }
    #farm .fm-hint { position: absolute; left: calc(8px + env(safe-area-inset-left)); bottom: calc(8px + env(safe-area-inset-bottom));
                     max-width: calc(100vw - 130px); text-align: left; font-size: 12px; padding: 2px 8px; }
    .fm-tool { width: 66px; padding: 2px; } .fm-tool img { width: 26px; height: 26px; } .fm-tool span { font-size: 10px; max-width: 62px; }
    #farm .fm-hint { max-width: calc(100vw - 180px); }
    .fm-mathboard { max-width: 760px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; align-items: center;
                    grid-template-areas: "title pad" "sub pad" "art pad" "dots pad" "qrow pad" "q pad" "ans pad" "fix pad"; }
    .fm-mathboard .fm-msub { grid-area: sub; } .fm-mathboard .fm-mart { grid-area: art; }
    .fm-mathboard h2 { grid-area: title; margin-right: 0; font-size: 20px; } .fm-mathboard .fm-dots { grid-area: dots; }
    .fm-mathboard .fm-qrow { grid-area: qrow; min-height: 0; } .fm-mathboard .q { grid-area: q; font-size: 40px; }
    .fm-mathboard .ans { grid-area: ans; min-height: 48px; line-height: 42px; font-size: 34px; } .fm-mathboard .fm-fix { grid-area: fix; }
    .fm-mathboard .pad { grid-area: pad; margin-top: 40px; } .fm-mathboard .key { font-size: 22px; padding: 2px 0; }
    .fm-board { padding: 10px 12px; }
  }

  /* ---------- Lemonade Lane ---------- */
  /* Pixelify Sans draws 5 like S and 2 like Z, so the digits come from Handjet, a dot-matrix font with clear
     numbers and real bold weights (one variable file, 400-800). */
  @font-face { font-family: "Lemon Digits"; src: url(https://fonts.gstatic.com/s/handjet/v23/oY108eXHq7n1OnbQrOY_2FrEwYEMLlcdP1mCtZaLaTutCwcIhGZemE3FkN7vPA.woff2) format("woff2");
               unicode-range: U+0030-0039; font-weight: 400 800; size-adjust: 112%; font-display: swap; }
  :root { --lm-wood: #b5763c; --lm-wood-dark: #7e4d22; --lm-paper: #fffaf0; --lm-paper-dark: #f6e7c4; --lm-ink: #4a3423;
          --lm-lemon: #ffd93b; --lm-lemon-dark: #e8b020; --lm-green: #4f9e3d; --lm-red: #d4544b; --lm-pixel: "Lemon Digits", "Pixelify Sans", "Baloo 2", sans-serif;
          --lm-bar: #c98500; --lm-bar-on: #7a4e00; --lm-grid: #ece4d2; }
  .mode.lemonmode .mt { color: #d99a0b; }
  body[data-screen="lemonSetup"]::before { background: linear-gradient(#9fdcff, #fff6c8 55%, #ffe27a); }
  body[data-screen="lemon"]::before { background: var(--lm-wood-dark); }
  body[data-screen="lemon"] { overflow: hidden; background: var(--lm-wood-dark); }
  #lemonSetup h1 { font-family: var(--lm-pixel); color: #fff; text-shadow: 0 3px 0 var(--lm-lemon-dark), 0 0 12px rgba(160,100,0,.45); }
  #lemonSetup .sub, #lemonSetup .best { color: var(--lm-ink); text-shadow: none; }
  .lm-hero { display: block; width: min(100%, 480px); margin: 0 auto 10px; aspect-ratio: 24 / 13; image-rendering: pixelated;
             border: 4px solid var(--lm-wood); border-radius: 14px; box-shadow: 0 6px 0 var(--lm-wood-dark); }
  .lm-new { margin: 6px 0 10px; }
  .lm-newask p { margin: 0 0 10px; font-size: 18px; color: var(--lm-ink); }
  .lm-row { display: flex; gap: 8px; }

  /* The stand: the street on one side, the plan or the questions on the other. */
  #lemon.on { position: fixed; inset: 0; max-width: none; padding: 0; animation: none; display: grid;
              grid-template-columns: minmax(0, 1fr) clamp(300px, 36vw, 420px); font-family: var(--lm-pixel); color: var(--lm-ink); }
  .lm-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #8fd3ff; }
  #lmCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; touch-action: none; }
  .lm-top { position: absolute; left: 0; right: 0; top: 0; z-index: 3; display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
            padding: calc(8px + env(safe-area-inset-top)) 8px 0 calc(8px + env(safe-area-inset-left)); pointer-events: none; }
  .lm-top > * { pointer-events: auto; }
  .lm-btn, .lm-pill { font: 700 16px var(--lm-pixel); color: var(--lm-ink); background: var(--lm-paper); border: 3px solid var(--lm-wood);
                      border-radius: 10px; padding: 3px 10px; box-shadow: 0 3px 0 var(--lm-wood-dark); display: inline-flex; align-items: center; gap: 6px; min-height: 36px; }
  .lm-btn { cursor: pointer; }
  .lm-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--lm-wood-dark); }
  .lm-btn.off { opacity: .55; text-decoration: line-through; }
  .lm-pill img { width: 22px; height: 22px; image-rendering: pixelated; }
  /* While the stand is open: the time left, cups sold and coins, along the bottom of the street. */
  .lm-dayinfo { position: absolute; z-index: 3; left: calc(8px + env(safe-area-inset-left)); right: 8px; top: calc(52px + env(safe-area-inset-top));
                display: flex; gap: 6px; align-items: center; }
  .lm-clock { flex: 1; min-width: 60px; height: 18px; background: rgba(74,52,35,.4); border: 3px solid var(--lm-wood); border-radius: 10px; overflow: hidden; box-shadow: 0 3px 0 var(--lm-wood-dark); }
  .lm-clock i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff9a6a, var(--lm-lemon)); transition: width .2s linear; }
  .lm-dayinfo .lm-pill { white-space: nowrap; }
  .lm-fast.on { background: var(--lm-lemon); }
  .lm-toast { position: absolute; z-index: 4; left: 50%; bottom: 14px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
              max-width: min(92%, 520px); text-align: center; font: 700 17px var(--lm-pixel); background: var(--lm-paper); border: 3px solid var(--lm-wood);
              border-radius: 12px; padding: 6px 14px; box-shadow: 0 4px 0 var(--lm-wood-dark); transition: opacity .25s, transform .25s; }
  .lm-toast.on { opacity: 1; transform: translate(-50%, 0); }
  .lm-banner { position: absolute; z-index: 4; left: 50%; top: 34%; transform: translate(-50%, -50%); pointer-events: none; opacity: 0; white-space: nowrap;
               font: 700 clamp(28px, 6vw, 52px) var(--lm-pixel); color: #fff; text-shadow: 0 4px 0 var(--lm-wood-dark), 3px 0 0 var(--lm-wood-dark), -3px 0 0 var(--lm-wood-dark), 0 -3px 0 var(--lm-wood-dark); }
  .lm-banner.go { animation: lm-banner 1.8s ease-out; }
  .lm-banner.lm-b-rush { color: var(--lm-lemon); } .lm-banner.lm-b-gold { color: #ffe066; } .lm-banner.lm-b-bad { color: #ffd0c8; }
  #lemon [hidden], .lm-modal [hidden] { display: none !important; }
  @keyframes lm-banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.4); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
                         25% { transform: translate(-50%, -50%) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -70%); } }

  .lm-side { position: relative; overflow-y: auto; overscroll-behavior: contain; background: var(--lm-paper); border-left: 6px solid var(--lm-wood);
             box-shadow: inset 0 0 0 3px var(--lm-paper-dark); padding: calc(12px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) 12px; }
  /* The sound button sits in the top corner of the side, so the first row leaves room for it. */
  .lm-forecast, .lm-rush { margin-right: 54px; }
  .lm-ic { width: 40px; height: 40px; image-rendering: pixelated; flex: none; }
  .lm-ics { width: 26px; height: 26px; image-rendering: pixelated; flex: none; vertical-align: middle; }
  .lm-ci { width: 16px; height: 16px; image-rendering: pixelated; vertical-align: -2px; }
  .lm-plan p { margin: 0 0 8px; }
  .lm-forecast { display: flex; align-items: center; gap: 8px; font-size: 22px; margin-bottom: 8px; }
  .lm-forecast .lm-ic { width: 48px; height: 48px; }
  .lm-forecast small { display: block; font-size: 14px; color: #8a6a4a; }
  .lm-line { display: flex; gap: 8px; align-items: center; font-size: 16px; line-height: 1.25; }
  .lm-news { display: flex; gap: 8px; align-items: center; background: #fff3b8; border: 2px dashed var(--lm-lemon-dark); border-radius: 10px; padding: 6px 8px; font-size: 15px; }
  .lm-warn { background: #ffe1da; border: 2px solid #f0a090; color: #8a2a20; border-radius: 10px; padding: 5px 8px; font-size: 14px; }
  .lm-stars { color: #f2b51c; letter-spacing: 1px; white-space: nowrap; }
  .lm-stars i { color: #ddcfb0; font-style: normal; }
  .lm-acts { display: grid; grid-template-columns: repeat(auto-fit, minmax(50px, 1fr)); gap: 5px; margin: 10px 0 8px; }
  .lm-acts .lm-ic { width: 34px; height: 34px; }
  .lm-act { display: grid; justify-items: center; gap: 2px; padding: 6px 1px; font: 700 13px var(--lm-pixel); color: var(--lm-ink); cursor: pointer; min-width: 0;
            background: var(--lm-paper-dark); border: 3px solid var(--lm-wood); border-radius: 12px; box-shadow: 0 3px 0 var(--lm-wood-dark); }
  .lm-act:active, .lm-goal:active, .lm-open:active, .lm-big:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--lm-wood-dark); }
  .lm-goal { display: block; width: 100%; text-align: left; font: 600 14px var(--lm-pixel); color: var(--lm-ink); background: #fff; border: 2px solid var(--lm-wood);
             border-radius: 10px; padding: 5px 8px; margin-bottom: 10px; cursor: pointer; }
  .lm-goal small { color: #8a6a4a; white-space: nowrap; }
  .lm-open { display: block; width: 100%; font: 700 26px var(--lm-pixel); color: #fff; background: #5cbf48; border: 4px solid #3d8a2e; border-radius: 16px;
             padding: 10px; cursor: pointer; box-shadow: 0 5px 0 #2e6a22; text-shadow: 0 2px 0 #3d8a2e; animation: lm-bob 2s ease-in-out infinite; }
  .lm-open:disabled { background: #c9bda4; border-color: #a8987a; box-shadow: 0 5px 0 #8a7a5a; animation: none; text-shadow: none; }
  @keyframes lm-bob { 50% { transform: translateY(-3px); } }

  .lm-quiz { display: flex; flex-direction: column; gap: 8px; text-align: center; }
  .lm-rush { background: var(--lm-paper-dark); border: 3px solid var(--lm-wood); border-radius: 12px; padding: 4px 6px; }
  .lm-rush.on { background: #fff3a0; border-color: var(--lm-lemon-dark); animation: lm-glow .5s ease-in-out infinite alternate; }
  @keyframes lm-glow { to { box-shadow: 0 0 14px 2px var(--lm-lemon); } }
  .lm-rushdots { display: flex; gap: 6px; justify-content: center; }
  .lm-rushdots img { width: 30px; height: 30px; image-rendering: pixelated; filter: grayscale(1) opacity(.35); transition: filter .2s, transform .2s; }
  .lm-rushdots img.on { filter: none; transform: scale(1.15); }
  .lm-rush small { font-size: 13px; color: #8a6a4a; }
  .lm-qcard { position: relative; background: #fff; border: 3px solid var(--lm-wood); border-radius: 16px; padding: 6px 8px; }
  .lm-qcard.good { animation: good .4s; }
  .lm-quiz .q { font-family: "Baloo 2", sans-serif; font-size: 52px; padding: 0; }
  .lm-quiz .ans { font-family: "Baloo 2", sans-serif; width: 70%; min-height: 58px; line-height: 52px; font-size: 44px; margin: 4px auto 0; border-width: 3px; }
  .lm-say { width: 36px; height: 36px; border-color: var(--lm-wood); background: var(--lm-paper-dark); }
  .lm-qcard .fm-qrow { position: absolute; top: 6px; left: 6px; right: 6px; min-height: 0; }
  .lm-fix { min-height: 22px; margin: 4px 0 0; font-size: 15px; line-height: 1.2; }
  .lm-fix.good { color: var(--lm-green); } .lm-fix.bad { color: var(--lm-red); }
  .lm-quiz .key { font-family: "Baloo 2", sans-serif; font-size: 30px; padding: 4px 0; background: #fff8e4; box-shadow: 0 4px 0 var(--lm-paper-dark); border: 2px solid #ead8b0; }
  .lm-quiz .key.del { background: #f19a8e; } .lm-quiz .key.ok { background: #8fd06b; }
  .lm-quiz .pad { gap: 7px; }
  .lm-quiz.closed .pad, .lm-quiz.closed .lm-qcard { opacity: .4; pointer-events: none; }

  /* Windows. */
  .lm-modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(60,38,20,.45);
              padding: calc(12px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left)); }
  .lm-modal[hidden] { display: none; }
  .lm-board { position: relative; display: flex; flex-direction: column; width: 100%; max-width: 640px; max-height: 100%; background: var(--lm-paper); color: var(--lm-ink);
              border: 6px solid var(--lm-wood); border-radius: 18px; box-shadow: inset 0 0 0 3px var(--lm-paper-dark), 0 10px 0 var(--lm-wood-dark), 0 20px 40px rgba(0,0,0,.35);
              padding: 14px 16px; font-family: var(--lm-pixel); animation: pop .25s ease-out; }
  .lm-board.lm-wide { max-width: 1120px; }
  .lm-board h2 { margin: 0 44px 8px 0; font: 700 24px var(--lm-pixel); color: var(--lm-wood-dark); line-height: 1.15; }
  .lm-body { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
  .lm-x { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border-radius: 10px; border: 3px solid var(--lm-wood); background: var(--lm-paper-dark);
          font: 700 18px var(--lm-pixel); color: var(--lm-wood-dark); cursor: pointer; z-index: 2; }
  .lm-body button { font-family: var(--lm-pixel); color: var(--lm-ink); cursor: pointer; }
  .lm-body button:disabled { cursor: default; }
  .lm-big { display: grid; gap: 2px; justify-items: center; width: 100%; margin-top: 8px; font: 700 19px var(--lm-pixel); color: var(--lm-ink); padding: 10px;
            background: #bfe89a; border: 3px solid #5a9a3a; border-radius: 12px; box-shadow: 0 4px 0 #3d7a2a; cursor: pointer; }
  .lm-big small { font: 600 13px var(--lm-pixel); color: #2d5520; }
  .lm-big:disabled { background: #e6dcc8; border-color: #b8a888; box-shadow: 0 4px 0 #9a8a6a; }
  .lm-big:disabled small { color: #8a6a4a; }
  .lm-soft { background: var(--lm-paper-dark); border-color: var(--lm-wood); box-shadow: 0 4px 0 var(--lm-wood-dark); }
  .lm-danger { background: #f6b0a6; border-color: #b8463c; box-shadow: 0 4px 0 #8a2a20; }
  .lm-note { font-size: 15px; line-height: 1.3; color: #6a5038; margin: 8px 0; }
  .lm-good { color: var(--lm-green); }

  .lm-supplies { display: grid; gap: 8px; }
  .lm-sup { display: grid; grid-template-columns: auto 1fr; gap: 4px 8px; align-items: center; background: #fff; border: 2px solid #ead8b0; border-radius: 12px; padding: 6px 8px; }
  .lm-supname b { display: block; font-size: 18px; } .lm-supname small { font-size: 14px; color: #8a6a4a; }
  .lm-packs { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .lm-packs button { display: grid; justify-items: center; padding: 4px; background: #fff8e4; border: 3px solid var(--lm-wood); border-radius: 10px; box-shadow: 0 3px 0 var(--lm-wood-dark); }
  .lm-packs button b { font-size: 18px; } .lm-packs button small { font-size: 13px; }
  .lm-packs button:not(:disabled):active { transform: translateY(2px); box-shadow: 0 1px 0 var(--lm-wood-dark); }
  .lm-packs button:disabled { opacity: .45; }
  .lm-sum { text-align: center; font-size: 18px; margin: 10px 0 0; }

  .lm-flavors { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
  .lm-flavor { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 6px; align-items: center; text-align: left; padding: 4px 6px;
               background: #fff; border: 3px solid #ead8b0; border-radius: 12px; }
  .lm-flavor .lm-ic { grid-row: span 2; } .lm-flavor b { font-size: 15px; } .lm-flavor small { font-size: 12px; color: #8a6a4a; }
  .lm-flavor.on { border-color: var(--lm-lemon-dark); background: #fff6c8; box-shadow: 0 0 0 2px var(--lm-lemon); }
  .lm-flavor:disabled { opacity: .55; }
  /* With more than one flavor, each card has a checkbox: is it on today's menu? */
  .lm-flavorwrap { display: flex; align-items: stretch; gap: 0; }
  .lm-flavorwrap .lm-flavor { flex: 1; min-width: 0; border-radius: 12px 0 0 12px; border-right-width: 0; }
  .lm-menutog { flex: none; width: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px;
                background: #f4ecd8; border: 3px solid #ead8b0; border-radius: 0 12px 12px 0; color: #8a6a4a; }
  .lm-menutog span { width: 24px; height: 24px; border: 3px solid var(--lm-wood); border-radius: 6px; background: #fff; font: 700 18px/18px var(--lm-pixel); color: #3d7a2a; }
  .lm-menutog small { font-size: 10px; line-height: 1.1; text-align: center; }
  .lm-onmenu .lm-menutog { background: #dff3c8; border-color: #8fc46a; color: #3d7a2a; }
  .lm-onmenu .lm-menutog span { border-color: #5a9a3a; }
  .lm-menutog:disabled { opacity: 1; }
  @media (max-width: 560px) { .lm-flavors.lm-withmenu { grid-template-columns: minmax(0, 1fr); } }
  .lm-flavorwrap:has(.lm-flavor.on) .lm-menutog { border-color: var(--lm-lemon-dark); box-shadow: 0 0 0 2px var(--lm-lemon); clip-path: inset(-3px -3px -3px 0); }
  .lm-taste.lm-advice { margin-top: 8px; background: #eaf6dc; border-color: #b8dc98; }
  .lm-menuline .lm-menuchip { display: inline-flex; align-items: center; gap: 2px; margin-right: 6px; }
  .lm-menuline .lm-menuchip b { font-size: 1.05em; }
  .lm-steps { display: grid; gap: 6px; margin: 10px 0; }
  .lm-step { display: grid; grid-template-columns: auto 1fr 44px 42px 44px; gap: 6px; align-items: center; background: #fff; border: 2px solid #ead8b0; border-radius: 12px; padding: 4px 8px; font-size: 16px; }
  .lm-step button { height: 40px; font: 700 24px var(--lm-pixel) !important; background: var(--lm-paper-dark); border: 3px solid var(--lm-wood); border-radius: 10px; box-shadow: 0 3px 0 var(--lm-wood-dark); }
  .lm-step button:disabled { opacity: .35; }
  .lm-step b { text-align: center; font-size: 24px; }
  .lm-taste { display: flex; gap: 10px; align-items: center; background: #fff6d8; border: 2px solid #ead8b0; border-radius: 12px; padding: 6px 10px; }
  .lm-taste p { margin: 2px 0; font-size: 15px; line-height: 1.3; }
  .lm-fixrow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
  .lm-fixbtn { font: 700 14px var(--lm-pixel) !important; padding: 5px 10px; background: #bfe89a; border: 3px solid #5a9a3a; border-radius: 10px; box-shadow: 0 3px 0 #3d7a2a; }
  .lm-fixbtn { display: inline-flex; align-items: center; gap: 6px; }
  .lm-fixbtn.lm-soft { background: var(--lm-paper-dark); border-color: var(--lm-wood); box-shadow: 0 3px 0 var(--lm-wood-dark); }
  .lm-fixbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 #3d7a2a; }
  .lm-flavornote { margin: 6px 0 0; font-size: 13px; }
  .lm-flavor small b { font-size: 13px; }
  .lm-grandma .lm-ic { width: 56px; height: 56px; }
  .lm-big-stars { font-size: 24px; }

  .lm-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
  .lm-chip { display: inline-flex; align-items: center; gap: 3px; font: 700 13px var(--lm-pixel) !important; padding: 2px 8px 2px 3px;
             background: color-mix(in srgb, var(--bc) 25%, #fff); border: 2px solid var(--bc); border-radius: 999px; }
  .lm-chip img { width: 22px; height: 22px; image-rendering: pixelated; }
  .lm-tree { position: relative; display: flex; gap: 10px; overflow-x: auto; overscroll-behavior-x: contain; padding: 4px 2px 10px; }
  .lm-branch { flex: none; background: #fff; border: 3px solid var(--bc); border-radius: 14px; padding: 4px 4px 0; }
  .lm-branch h3 { margin: 0 0 2px; font: 700 15px var(--lm-pixel); text-align: center; color: var(--lm-ink); background: color-mix(in srgb, var(--bc) 30%, #fff); border-radius: 8px; padding: 2px 4px; }
  .lm-branch h3 small { color: #8a6a4a; }
  .lm-bwrap { position: relative; }
  .lm-bwrap svg { position: absolute; inset: 0; }
  .lm-bwrap path { fill: none; stroke: #e2d6bc; stroke-width: 4; stroke-dasharray: 2 5; stroke-linecap: round; }
  .lm-bwrap path.on { stroke-dasharray: none; }
  .lm-node { position: absolute; width: 60px; height: 82px; padding: 0; background: none; border: 0; display: grid; justify-items: center; align-content: start; gap: 0; }
  .lm-node img { width: 52px; height: 52px; image-rendering: pixelated; background: var(--lm-paper-dark); border: 3px solid #cdbb98; border-radius: 12px; }
  .lm-node span { font: 600 10px/1.05 var(--lm-pixel); text-align: center; margin-top: 1px; max-width: 66px; }
  .lm-node em { position: absolute; top: 40px; right: -4px; font: 700 10px var(--lm-pixel); font-style: normal; background: #fff; border: 2px solid #cdbb98; border-radius: 8px; padding: 0 3px; }
  .lm-node .lm-link { position: absolute; top: -4px; left: -2px; width: 16px; height: 16px; font: 700 12px/12px var(--lm-pixel); font-style: normal; color: #fff; background: #8a6fd6; border: 2px solid #fff; border-radius: 50%; }
  .lm-node.owned img { background: color-mix(in srgb, var(--bc) 35%, #fff); border-color: var(--bc); }
  .lm-node.owned em { background: var(--bc); border-color: var(--bc); color: #fff; }
  .lm-node.open img { border-color: #5cbf48; animation: lm-glow2 1s ease-in-out infinite alternate; }
  .lm-node.open em { border-color: #5cbf48; color: #2d6a22; }
  @keyframes lm-glow2 { to { box-shadow: 0 0 10px 2px #9be07c; } }
  .lm-node.poor em { color: #a0463c; }
  .lm-node.locked img { filter: grayscale(.9) opacity(.55); }
  .lm-node.locked span { opacity: .6; }
  .lm-node.pick img { outline: 3px solid var(--lm-lemon-dark); outline-offset: 2px; }
  .lm-info { position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; background: var(--lm-paper-dark); border: 3px solid var(--lm-wood); border-radius: 12px; padding: 6px 10px; min-height: 76px; }
  .lm-info > img { width: 64px; height: 64px; image-rendering: pixelated; flex: none; }
  .lm-info > div { flex: 1; } .lm-info b { font-size: 18px; } .lm-info p { margin: 2px 0; font-size: 14px; line-height: 1.25; } .lm-info small { font-size: 12px; }
  .lm-info .lm-note { margin: 0; }
  .lm-buy { display: grid; justify-items: center; flex: none; font: 700 17px var(--lm-pixel) !important; padding: 8px 12px; background: #bfe89a; border: 3px solid #5a9a3a; border-radius: 12px; box-shadow: 0 4px 0 #3d7a2a; }
  .lm-buy small { font-size: 11px; max-width: 140px; }
  .lm-buy:disabled { background: #e6dcc8; border-color: #b8a888; box-shadow: 0 4px 0 #9a8a6a; }
  .lm-owned { flex: none; font-size: 16px; color: var(--lm-green); font-weight: 700; }

  .lm-places { display: grid; gap: 8px; }
  .lm-place { display: grid; grid-template-columns: 160px 1fr; gap: 6px 10px; align-items: center; background: #fff; border: 3px solid #ead8b0; border-radius: 12px; padding: 6px; }
  .lm-place > img { width: 160px; height: 120px; image-rendering: pixelated; border-radius: 8px; grid-row: span 2; }
  .lm-place b { font-size: 18px; } .lm-place p { margin: 2px 0; font-size: 14px; line-height: 1.25; } .lm-place small { font-size: 12px; color: #8a6a4a; }
  .lm-place.on { border-color: var(--lm-lemon-dark); background: #fff8d8; }
  .lm-place.shut > img { filter: saturate(.5); }
  .lm-place button, .lm-here { justify-self: start; display: inline-grid; justify-items: center; font: 700 15px var(--lm-pixel) !important; padding: 4px 12px;
                               background: #fff8e4; border: 3px solid var(--lm-wood); border-radius: 10px; box-shadow: 0 3px 0 var(--lm-wood-dark); }
  .lm-place button.lm-gold { background: var(--lm-lemon); }
  .lm-place button:disabled { opacity: .6; } .lm-place button small { font-size: 11px; }
  .lm-places { grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); }

  /* The skill tree: one branch at a time, with tabs; the info box beside it on wide screens. */
  .lm-chip { position: relative; cursor: pointer; }
  .lm-chip small { font-size: 11px; color: #7a5a3a; margin-left: 2px; }
  .lm-chip.on { background: var(--bc); color: #fff; box-shadow: 0 2px 0 rgba(0,0,0,.25); } .lm-chip.on small { color: #fff; }
  .lm-dot { position: absolute; top: -3px; right: -3px; width: 11px; height: 11px; border-radius: 50%; background: #5cbf48; border: 2px solid #fff; }
  .lm-treewrap { display: grid; gap: 8px; }
  /* On a phone the tabs make one row that scrolls sideways. */
  @media (max-width: 600px), (max-height: 500px) {
    .lm-chips[role="tablist"] { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; padding: 4px 2px 6px; scrollbar-width: thin; }
    .lm-chips[role="tablist"] .lm-chip { flex: none; }
  }
  .lm-treewrap .lm-tree { justify-content: center; }
  @media (min-width: 820px) and (min-height: 520px) {
    .lm-treewrap { grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); align-items: start; }
    .lm-treewrap .lm-info { position: sticky; top: 0; flex-direction: column; text-align: center; align-items: center; }
  }

  /* Your stands. */
  .lm-stands { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
  .lm-stand { display: grid; gap: 4px; background: #fff; border: 3px solid #b8e0c8; border-radius: 12px; padding: 6px; }
  .lm-standpic { width: 100%; height: 110px; object-fit: cover; object-position: center 30%; image-rendering: pixelated; border-radius: 8px; }
  .lm-standhead { display: flex; gap: 8px; align-items: center; }
  .lm-standhead img { width: 48px; height: 48px; image-rendering: pixelated; background: var(--lm-paper-dark); border-radius: 10px; flex: none; }
  .lm-standhead b { font-size: 17px; } .lm-standhead small { display: block; font-size: 12px; line-height: 1.2; color: #7a5a3a; }
  .lm-sum3 { display: grid; gap: 1px; font-size: 14px; background: var(--lm-paper); border-radius: 8px; padding: 4px 8px; }
  .lm-sum3 small { font-size: 11px; color: #8a6a4a; } .lm-bad { color: var(--lm-red); }
  .lm-ups { display: flex; flex-wrap: wrap; gap: 5px; }
  .lm-upbtn { display: grid; justify-items: center; flex: 1 1 140px; font: 700 13px var(--lm-pixel) !important; padding: 4px 8px; background: #bfe89a; border: 3px solid #5a9a3a;
              border-radius: 10px; box-shadow: 0 3px 0 #3d7a2a; color: var(--lm-ink); cursor: pointer; }
  .lm-upbtn small { font-size: 11px; display: inline-flex; align-items: center; gap: 3px; } .lm-upbtn:disabled { opacity: .55; }
  .lm-upbtn.lm-soft { background: var(--lm-paper-dark); border-color: var(--lm-wood); box-shadow: 0 3px 0 var(--lm-wood-dark); }
  .lm-h3 { font: 700 18px var(--lm-pixel); color: var(--lm-wood-dark); margin: 10px 0 4px; }
  .lm-mgrs { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 5px; margin-bottom: 6px; }
  .lm-mgr { display: grid; justify-items: center; gap: 1px; padding: 4px; background: #fff; border: 3px solid #ead8b0; border-radius: 10px; font-family: var(--lm-pixel); color: var(--lm-ink); cursor: pointer; }
  .lm-mgr img { width: 40px; height: 40px; image-rendering: pixelated; } .lm-mgr small { font-size: 11px; line-height: 1.15; text-align: center; }
  .lm-mgr.on { border-color: #3fae8c; background: #e4f6ec; box-shadow: 0 0 0 2px #3fae8c; }
  .lm-openrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; border-top: 2px dashed #ead8b0; }
  .lm-openrow .lm-upbtn { flex: 0 0 auto; }

  /* Counting the tills. */
  .lm-tillq { text-align: center; background: #fff; border: 3px solid #ead8b0; border-radius: 12px; padding: 6px; }
  .lm-tillwho { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; }
  .lm-tillq .q { font-family: "Baloo 2", sans-serif; font-size: 34px; font-weight: 800; }
  .lm-tillq .ans { font-family: "Baloo 2", sans-serif; font-size: 30px; font-weight: 800; min-height: 40px; border-bottom: 3px dashed #ead8b0; margin: 0 auto; max-width: 140px; }
  .lm-tillpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 320px; margin: 8px auto 0; }
  .lm-tillpad .key { font-family: "Baloo 2", sans-serif; font-size: 26px; padding: 2px 0; background: #fff8e4; box-shadow: 0 4px 0 var(--lm-paper-dark); border: 2px solid #ead8b0; border-radius: 10px; }
  .lm-tillpad .key.del { background: #f19a8e; } .lm-tillpad .key.ok { background: #8fd06b; }

  /* Lemonade Land. */
  .lm-landtop { display: grid; grid-template-columns: minmax(0, 320px) 1fr; gap: 10px; align-items: center; }
  .lm-landtop > img, .lm-landbig { width: 100%; image-rendering: pixelated; border-radius: 10px; border: 3px solid var(--lm-wood); }
  .lm-landbar { height: 16px; background: var(--lm-paper-dark); border: 3px solid var(--lm-wood); border-radius: 999px; overflow: hidden; margin: 4px 0; }
  .lm-landbar i { display: block; height: 100%; background: linear-gradient(var(--lm-lemon), var(--lm-lemon-dark)); }
  .lm-pieces { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; margin: 8px 0; }
  .lm-piece { display: grid; justify-items: center; gap: 1px; background: #fff; border: 3px solid #ead8b0; border-radius: 10px; padding: 4px; text-align: center; }
  .lm-piece img { width: 100%; image-rendering: pixelated; border-radius: 6px; filter: saturate(.4) brightness(.95); }
  .lm-piece.done img { filter: none; } .lm-piece.done { border-color: var(--lm-lemon-dark); background: #fff8d8; }
  .lm-piece.next { border-color: #5cbf48; } .lm-piece b { font-size: 13px; line-height: 1.1; } .lm-piece small { font-size: 11px; color: #8a6a4a; }
  @media (max-width: 560px) { .lm-landtop { grid-template-columns: 1fr; } }
  .lm-here { background: #d8f0c0; border-color: #5a9a3a; box-shadow: none; }

  .lm-goals { display: grid; gap: 4px; }
  .lm-goalrow { display: grid; grid-template-columns: 24px 1fr auto; gap: 6px; align-items: center; background: #fff; border: 2px solid #ead8b0; border-radius: 10px; padding: 4px 8px; font-size: 15px; }
  .lm-goalrow span { color: var(--lm-green); font-weight: 700; } .lm-goalrow.done { opacity: .6; } .lm-goalrow.done b { text-decoration: line-through; }
  .lm-how { padding-left: 0; list-style: none; display: grid; gap: 6px; margin: 10px 0; }
  .lm-how li { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; line-height: 1.3; }
  .lm-sumgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
  .lm-sumgrid > div { display: grid; justify-items: center; background: #fff; border: 2px solid #ead8b0; border-radius: 12px; padding: 4px; }
  .lm-sumgrid b { font-size: 24px; } .lm-sumgrid small { font-size: 12px; color: #8a6a4a; text-align: center; }
  .lm-said { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
  .lm-said span { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 2px solid #ead8b0; border-radius: 10px; padding: 2px 8px; font-size: 14px; }
  .lm-tip { display: flex; gap: 8px; align-items: center; background: #fff6d8; border: 2px solid #ead8b0; border-radius: 12px; padding: 6px 8px; font-size: 15px; margin: 6px 0; }
  .lm-goaldone { background: #e2f6d0; border: 2px solid #8fd06b; border-radius: 10px; padding: 4px 8px; font-size: 15px; margin: 4px 0; }
  .lm-row .lm-salesbtn { flex: 0 0 auto; width: auto; grid-auto-flow: column; align-items: center; gap: 6px; padding: 10px 14px; }

  /* The sales chart: one amber column a day on a white card, the chosen day darker. */
  .lm-tabs { display: flex; gap: 6px; margin-bottom: 6px; }
  .lm-tabs button { display: inline-flex; align-items: center; gap: 6px; font: 700 15px var(--lm-pixel) !important; padding: 4px 12px 4px 6px;
                    background: var(--lm-paper-dark); border: 3px solid var(--lm-wood); border-radius: 10px; }
  .lm-tabs button[aria-selected="true"] { background: #fff3b8; border-color: var(--lm-lemon-dark); box-shadow: 0 0 0 2px var(--lm-lemon); }
  .lm-charttitle { margin: 2px 0 4px; font-size: 15px; color: #6a5038; }
  .lm-chart { display: flex; gap: 4px; background: #fff; border: 2px solid #ead8b0; border-radius: 12px; padding: 10px 8px 4px 4px; }
  .lm-yaxis { position: relative; flex: none; width: 34px; height: 160px; margin-top: 14px; font-size: 12px; color: #8a6a4a; font-variant-numeric: tabular-nums; }
  .lm-yaxis span { position: absolute; right: 0; transform: translateY(-50%); }
  .lm-yaxis span:nth-child(1) { top: 0; } .lm-yaxis span:nth-child(2) { top: 50%; } .lm-yaxis span:nth-child(3) { top: 100%; }
  .lm-plot { flex: 1; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; padding-top: 14px; }
  .lm-bars { position: relative; display: flex; height: 182px; min-width: 100%; }
  .lm-grid { position: absolute; left: 0; right: 0; top: 0; height: 160px; pointer-events: none; }
  .lm-grid i { position: absolute; left: 0; right: 0; height: 1px; background: var(--lm-grid); }
  .lm-grid i:first-child { background: #cbb894; }
  .lm-bar { position: relative; flex: 0 0 24px; height: 182px; padding: 0; background: none; border: 0; display: flex; flex-direction: column; cursor: pointer; }
  .lm-bar:focus-visible { outline: 2px solid var(--lm-wood); outline-offset: -2px; border-radius: 6px; }
  .lm-col { position: relative; height: 160px; width: 100%; }
  .lm-col i { position: absolute; left: 5px; right: 5px; min-height: 2px; }
  .lm-col i.lm-seggap { border-top: 2px solid #fff; }
  .lm-col i.lm-segtop { border-radius: 4px 4px 0 0; }
  .lm-bar:hover .lm-col i { filter: brightness(1.08); }
  .lm-bar.on .lm-col { background: #fff3c4; border-radius: 6px 6px 0 0; box-shadow: inset 0 0 0 2px #f2d07a; }
  .lm-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0 0 6px; font-size: 13px; }
  .lm-legend span { display: inline-flex; align-items: center; gap: 5px; }
  .lm-legend i { width: 12px; height: 12px; border-radius: 3px; }
  .lm-dcsales { display: grid; gap: 3px; margin: 6px 0; }
  .lm-dcrow { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-size: 14px; background: #fff; border: 2px solid #ead8b0; border-radius: 10px; padding: 2px 8px; }
  .lm-dcrow i { width: 12px; height: 12px; border-radius: 3px; flex: none; }
  .lm-dcrow span { color: #6a5038; }
  .lm-dcrow span.lm-stars { color: #f2b51c; }
  .lm-dcmenu .lm-dcsold1 { margin-left: auto; color: #3a2a1a; font-weight: 700; }
  .lm-chipv small { font-size: 11px; color: #8a6a4a; }
  .lm-col em { position: absolute; left: 50%; transform: translate(-50%, -2px); font: 700 12px var(--lm-pixel); font-style: normal; color: var(--lm-ink); white-space: nowrap; }
  .lm-bar.on .lm-col em { font-size: 13px; }
  .lm-bar small { height: 22px; line-height: 22px; font-size: 12px; color: #8a6a4a; text-align: center; }
  .lm-bar.on small { color: var(--lm-ink); font-weight: 700; }
  .lm-daycard { margin-top: 8px; background: var(--lm-paper-dark); border: 3px solid var(--lm-wood); border-radius: 12px; padding: 6px 10px; }
  .lm-dchead { display: flex; align-items: center; gap: 8px; }
  .lm-dchead > div { flex: 1; text-align: center; } .lm-dchead b { font-size: 20px; display: block; }
  .lm-dchead small { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; color: #6a5038; }
  .lm-dcnav { width: 40px; height: 40px; flex: none; font: 700 18px var(--lm-pixel) !important; background: #fff8e4; border: 3px solid var(--lm-wood); border-radius: 10px; box-shadow: 0 3px 0 var(--lm-wood-dark); }
  .lm-dcnav:disabled { opacity: .35; }
  .lm-dcrecipe { display: flex; flex-wrap: wrap; gap: 4px 6px; justify-content: center; margin: 6px 0; }
  .lm-dcflavor { flex-basis: 100%; display: inline-flex; justify-content: center; align-items: center; gap: 6px; font-size: 16px; }
  .lm-chipv { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 2px solid #ead8b0; border-radius: 10px; padding: 1px 8px 1px 3px; font-size: 14px; }
  .lm-chipv b { font-size: 17px; }
  .lm-dcsold, .lm-dcsaid { margin: 4px 0; font-size: 14px; line-height: 1.3; text-align: center; }
  .lm-dcsaid { color: #6a5038; }
  .lm-table { margin-top: 8px; font-size: 14px; }
  .lm-table summary { cursor: pointer; color: var(--lm-wood-dark); font-weight: 700; }
  .lm-tablewrap { max-height: 220px; overflow: auto; margin-top: 4px; background: #fff; border: 2px solid #ead8b0; border-radius: 10px; }
  .lm-table table { border-collapse: collapse; width: 100%; font-size: 13px; }
  .lm-table th, .lm-table td { padding: 3px 6px; text-align: left; border-bottom: 1px solid var(--lm-grid); white-space: nowrap; }
  .lm-table th { position: sticky; top: 0; background: var(--lm-paper-dark); }
  .lm-table td:nth-child(n+5) { text-align: right; font-variant-numeric: tabular-nums; }

  /* Phones and tablets held upright: the street on top, the plan or the questions below. */
  @media (orientation: portrait) {
    #lemon.on { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
    .lm-top { padding-right: calc(66px + env(safe-area-inset-right)); }
    .lm-forecast, .lm-rush { margin-right: 0; }
    .lm-dayinfo { right: calc(70px + env(safe-area-inset-right)); top: calc(48px + env(safe-area-inset-top)); }
    .lm-side { border-left: 0; border-top: 6px solid var(--lm-wood); padding: 10px calc(12px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left)); max-height: 62vh; }
    .lm-quiz { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; align-items: center; }
    .lm-quiz[hidden] { display: none; }
    .lm-rush { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; justify-content: center; padding: 2px 6px; }
    .lm-rushdots img { width: 24px; height: 24px; }
    .lm-quiz .q { font-size: 40px; } .lm-quiz .ans { min-height: 46px; line-height: 40px; font-size: 34px; width: 80%; }
    .lm-quiz .key { font-size: 24px; padding: 2px 0; } .lm-quiz .pad { gap: 5px; }
    .lm-fix { font-size: 13px; min-height: 32px; }
  }
  @media (orientation: portrait) and (min-width: 600px) {
    .lm-side { max-height: 52vh; }
    .lm-quiz .q { font-size: 52px; } .lm-quiz .key { font-size: 30px; padding: 6px 0; }
  }
  /* Short landscape phones: smaller pieces so it all fits. */
  @media (orientation: landscape) and (max-height: 500px) {
    #lemon.on { grid-template-columns: minmax(0, 1fr) clamp(260px, 40vw, 340px); }
    .lm-quiz { gap: 4px; }
    .lm-quiz .q { font-size: 34px; } .lm-quiz .ans { min-height: 40px; line-height: 34px; font-size: 30px; }
    .lm-quiz .key { font-size: 20px; padding: 0; } .lm-quiz .pad { gap: 4px; }
    .lm-rushdots img { width: 22px; height: 22px; } .lm-rush small { display: none; }
    .lm-fix { min-height: 16px; font-size: 12px; margin: 2px 0 0; }
    .lm-qcard { padding: 2px 6px; } .lm-say { width: 30px; height: 30px; font-size: 14px; }
    .lm-btn, .lm-pill { font-size: 14px; min-height: 30px; padding: 1px 7px; } .lm-pill img { width: 18px; height: 18px; }
    .lm-forecast { font-size: 18px; } .lm-forecast .lm-ic { width: 36px; height: 36px; }
    .lm-line { font-size: 14px; } .lm-acts .lm-ic { width: 28px; height: 28px; } .lm-act { font-size: 11px; padding: 3px 1px; }
    .lm-open { font-size: 20px; padding: 6px; }
    .lm-board { padding: 8px 12px; } .lm-board h2 { font-size: 20px; margin-bottom: 4px; }
  }
  @media (max-width: 480px) {
    .lm-top { gap: 4px; }
    .lm-btn, .lm-pill { font-size: 14px; min-height: 30px; padding: 1px 6px; gap: 4px; border-width: 2px; } .lm-pill img { width: 16px; height: 16px; }
    .lm-clock { height: 14px; border-width: 2px; }
  }
  @media (max-width: 560px) {
    .lm-sumgrid { grid-template-columns: repeat(2, 1fr); }
    .lm-place { grid-template-columns: 120px 1fr; } .lm-place > img { width: 120px; height: 90px; }
    .lm-flavor { padding: 3px 4px; column-gap: 4px; } .lm-flavor .lm-ic { width: 30px; height: 30px; }
    .lm-flavor b { font-size: 13px; } .lm-flavor small { font-size: 11px; }
  }
  @media (prefers-reduced-motion: reduce) { .lm-open, .lm-node.open img, .lm-rush.on, .lm-board { animation: none; } }

  /* ---------- Rainbow Realm ---------- */
  :root { --rr-ink: #4b2f6b; --rr-soft: #8a6aa8; --rr-paper: #fff8fd; --rr-paper-dark: #f6e6fb; --rr-edge: #c9a2e8; --rr-edge-dark: #9a6cc4;
          --rr-pink: #ff8fc7; --rr-green: #3fa66a; --rr-red: #d4544b; }
  .mode.realmmode .mt { color: #b25fd6; }
  body[data-screen="realmSetup"]::before { background: linear-gradient(#e4d4ff, #ffe3f3 55%, #c9f3d7); }
  body[data-screen="realm"]::before { background: #9fe0a8; }
  body[data-screen="realm"] { overflow: hidden; background: #9fe0a8; }
  #realmSetup h1 { color: #fff; text-shadow: 0 3px 0 var(--rr-edge-dark), 0 0 14px rgba(178,95,214,.5); }
  #realmSetup .sub, #realmSetup .best { color: var(--rr-ink); text-shadow: none; }
  .rr-hero { display: block; width: min(100%, 480px); aspect-ratio: 24 / 13; margin: 0 auto 10px; border: 4px solid var(--rr-edge); border-radius: 18px;
             box-shadow: 0 6px 0 var(--rr-edge-dark); background: #9fe0a8; object-fit: cover; }
  .rr-new { margin: 6px 0 10px; }
  .rr-newask p { margin: 0 0 10px; font-size: 18px; color: var(--rr-ink); }
  .rr-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
  .rr-big { flex: 1; min-width: 120px; font: 800 18px "Baloo 2", sans-serif; color: #fff; background: #b25fd6; border: 3px solid #8a3fb0; border-radius: 14px;
            padding: 8px 12px; box-shadow: 0 4px 0 #6a2a8c; cursor: pointer; }
  .rr-big:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #6a2a8c; }
  .rr-big:disabled { background: #d8cbe2; border-color: #bba8cc; box-shadow: 0 4px 0 #a593b5; color: #f8f4fb; cursor: default; }
  .rr-soft { background: var(--rr-paper-dark); color: var(--rr-ink); border-color: var(--rr-edge); box-shadow: 0 4px 0 var(--rr-edge-dark); }
  .rr-danger { background: var(--rr-red); border-color: #a83a32; box-shadow: 0 4px 0 #7a2620; }

  /* The realm: the map on one side, the goal and questions on the other. */
  #realm.on { position: fixed; inset: 0; max-width: none; padding: 0; animation: none; display: grid;
              grid-template-columns: minmax(0, 1fr) clamp(290px, 32vw, 400px); font-family: "Baloo 2", sans-serif; color: var(--rr-ink); }
  #realm [hidden], .rr-modal[hidden], .rr-modal [hidden] { display: none !important; }
  .rr-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #9fe0a8; }
  /* A Rainbow Rush puts a glowing rainbow round the map. */
  .rr-stage::after { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; transition: opacity .4s; border: 8px solid transparent;
                     border-image: linear-gradient(135deg, #ff6b8b, #ffa45c, #ffe066, #7ee08a, #6cc6ff, #b28cff) 1; }
  .rr-stage.rush::after { opacity: 1; animation: rr-pulse .6s ease-in-out infinite alternate; }
  @keyframes rr-pulse { to { opacity: .55; } }
  #rrCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
  .rr-top { position: absolute; left: 0; right: 0; top: 0; z-index: 3; display: flex; gap: 6px; align-items: center;
            padding: calc(6px + env(safe-area-inset-top)) 8px 0 calc(8px + env(safe-area-inset-left)); pointer-events: none; }
  .rr-top > * { pointer-events: auto; }
  .rr-res { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; min-width: 0; }
  .rr-btn, .rr-pill { font: 800 16px "Baloo 2", sans-serif; color: var(--rr-ink); background: var(--rr-paper); border: 3px solid var(--rr-edge); border-radius: 12px;
                      padding: 0 9px; box-shadow: 0 3px 0 var(--rr-edge-dark); display: inline-flex; align-items: center; gap: 4px; min-height: 34px; white-space: nowrap; }
  .rr-btn { cursor: pointer; } .rr-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--rr-edge-dark); }
  #rrSkills { background: #fff3a8; border-color: #e8c24a; box-shadow: 0 3px 0 #c49a20; }
  .rr-toast { position: absolute; z-index: 4; left: 50%; bottom: 14px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; max-width: min(92%, 520px);
              text-align: center; font: 700 17px "Baloo 2", sans-serif; background: var(--rr-paper); border: 3px solid var(--rr-edge); border-radius: 14px; padding: 6px 14px;
              box-shadow: 0 4px 0 var(--rr-edge-dark); transition: opacity .25s, transform .25s; }
  .rr-toast.on { opacity: 1; transform: translate(-50%, 0); }
  .rr-banner { position: absolute; z-index: 4; left: 50%; top: 36%; transform: translate(-50%, -50%); pointer-events: none; opacity: 0; white-space: nowrap;
               font: 800 clamp(30px, 6vw, 56px) "Baloo 2", sans-serif; color: #fff; text-shadow: 0 4px 0 var(--rr-edge-dark), 0 0 18px rgba(178,95,214,.7); }
  .rr-banner.go { animation: lm-banner 1.8s ease-out; }
  .rr-banner.rr-b-rush { background: linear-gradient(90deg, #ff6b8b, #ffa45c, #ffe066, #7ee08a, #6cc6ff, #b28cff); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none;
                         filter: drop-shadow(0 3px 0 #fff) drop-shadow(0 4px 0 var(--rr-edge-dark)); }

  .rr-side { position: relative; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; overscroll-behavior: contain; background: var(--rr-paper);
             border-left: 6px solid var(--rr-edge); padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) 12px; }
  .rr-goal, .rr-plans { margin-right: 50px; }   /* room for the sound button in the corner */
  .rr-goal { display: block; width: calc(100% - 50px); text-align: left; font: 700 15px "Baloo 2", sans-serif; color: var(--rr-ink); background: #fff; border: 2px solid var(--rr-edge);
             border-radius: 12px; padding: 5px 9px; cursor: pointer; line-height: 1.25; }
  .rr-goal small { display: block; font-size: 12px; color: var(--rr-soft); text-transform: uppercase; letter-spacing: .5px; }
  .rr-goal span { color: #c49a20; white-space: nowrap; }
  .rr-plans { display: flex; gap: 8px; align-items: center; background: #fff3a8; border: 3px dashed #e8c24a; border-radius: 14px; padding: 5px 8px; }
  .rr-planhead { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 0; line-height: 1.15; }
  .rr-planhead img { width: 48px; height: 48px; flex: none; }
  .rr-plandots { display: flex; gap: 5px; margin-top: 3px; }
  .rr-plandots i, .rr-dots i { width: 16px; height: 16px; border-radius: 50%; background: #e6d8ef; border: 2px solid var(--rr-edge); }
  .rr-plandots i.on { background: #ffd34d; border-color: #c49a20; }
  .rr-cancel { font: 700 14px "Baloo 2", sans-serif; color: var(--rr-ink); background: #fff; border: 2px solid var(--rr-edge); border-radius: 10px; padding: 3px 8px; cursor: pointer; }
  .rr-spark { background: var(--rr-paper-dark); border: 3px solid var(--rr-edge); border-radius: 14px; padding: 4px 6px; }
  .rr-spark.on { background: #fff6c8; border-color: #e8c24a; }
  .rr-spark.rush { animation: rr-glow .5s ease-in-out infinite alternate; }
  @keyframes rr-glow { to { box-shadow: 0 0 16px 3px #ffb0e0; } }
  .rr-sparkbar { position: relative; height: 24px; background: #fff; border-radius: 10px; overflow: hidden; }
  .rr-sparkbar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #ff8fc7, #ffd34d, #8fd8ff); transition: width .25s linear; }
  .rr-sparkbar span { position: relative; display: block; text-align: center; font-size: 14px; font-weight: 800; line-height: 24px; }
  .rr-dots { display: flex; gap: 6px; justify-content: center; align-items: center; margin-top: 4px; }
  .rr-dots i.on { background: var(--rr-pink); border-color: #d0569a; }
  .rr-dots small { font-size: 12px; color: var(--rr-soft); }
  .rr-qcard { position: relative; background: #fff; border: 3px solid var(--rr-edge); border-radius: 16px; padding: 6px 8px; text-align: center; }
  .rr-qcard.good { animation: good .4s; }
  .rr-qcard .fm-qrow { position: absolute; top: 6px; left: 6px; right: 6px; min-height: 0; }
  .rr-say { width: 36px; height: 36px; border-color: var(--rr-edge); background: var(--rr-paper-dark); }
  .rr-story { margin: 0 40px; min-height: 36px; font-size: 14px; line-height: 1.25; color: var(--rr-soft); display: flex; align-items: center; justify-content: center; }
  .rr-qcard .q { font-size: 50px; padding: 0; }
  .rr-qcard .ans { width: 70%; min-height: 56px; line-height: 50px; font-size: 42px; margin: 4px auto 0; border-width: 3px; }
  .rr-fix { min-height: 22px; margin: 4px 0 0; font-size: 15px; line-height: 1.2; }
  .rr-fix.good { color: var(--rr-green); } .rr-fix.bad { color: var(--rr-red); }
  .rr-pad { gap: 7px; }
  .rr-pad .key { font-size: 30px; padding: 4px 0; background: #fdf3ff; box-shadow: 0 4px 0 var(--rr-paper-dark); border: 2px solid #e8d4f2; }
  .rr-pad .key.del { background: #f7a6c4; } .rr-pad .key.ok { background: #9fdcab; }

  /* Windows. */
  .rr-modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(75,47,107,.45);
              padding: calc(12px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left)); }
  .rr-board { position: relative; display: flex; flex-direction: column; width: 100%; max-width: 620px; max-height: 100%; background: var(--rr-paper); color: var(--rr-ink);
              border: 6px solid var(--rr-edge); border-radius: 22px; box-shadow: 0 10px 0 var(--rr-edge-dark), 0 20px 40px rgba(0,0,0,.3);
              padding: 14px 16px; font-family: "Baloo 2", sans-serif; animation: pop .25s ease-out; }
  .rr-board.rr-wide { max-width: 1100px; }
  .rr-board h2 { margin: 0 44px 6px 0; font-size: 24px; line-height: 1.15; color: #8a3fb0; }
  .rr-body { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
  .rr-body p { margin: 0 0 6px; line-height: 1.3; }
  .rr-x { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border-radius: 12px; border: 3px solid var(--rr-edge); background: var(--rr-paper-dark);
          font: 800 18px "Baloo 2", sans-serif; color: var(--rr-ink); cursor: pointer; z-index: 2; }
  .rr-say-row { display: flex; gap: 12px; align-items: flex-start; }
  .rr-say-row > img { width: 88px; height: 88px; flex: none; background: var(--rr-paper-dark); border-radius: 50%; border: 3px solid var(--rr-edge); }
  .rr-list { display: grid; gap: 8px; }
  .rr-item { display: grid; grid-template-columns: 72px 1fr auto; gap: 10px; align-items: center; background: #fff; border: 2px solid var(--rr-edge); border-radius: 14px; padding: 6px 10px; margin-bottom: 8px; }
  .rr-list .rr-item { margin: 0; }
  .rr-item > img { width: 72px; height: 72px; }
  .rr-item p { font-size: 14px; margin: 0; }
  .rr-item small { color: var(--rr-soft); }
  .rr-item .rr-big { min-width: 96px; }
  .rr-item.off > img { filter: grayscale(.6) opacity(.7); }
  .rr-item.rr-head { grid-template-columns: 72px 1fr; background: var(--rr-paper-dark); }
  .rr-costs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
  .rr-cost { font-size: 14px; font-weight: 800; background: var(--rr-paper-dark); border-radius: 8px; padding: 0 6px; }
  .rr-cost.short { background: #ffe1da; color: #a83a32; }
  .rr-why { font-size: 13px !important; color: #a83a32; }
  .rr-here { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  .rr-here span { background: var(--rr-paper-dark); border-radius: 10px; padding: 1px 8px; font-weight: 700; }
  .rr-sub { color: var(--rr-soft); }
  .rr-room { background: var(--rr-paper-dark); border-radius: 10px; padding: 3px 8px; }
  .rr-room.full { background: #fff3a8; }
  .rr-dustpill { font-size: 16px; background: #fff3a8; border-radius: 10px; padding: 1px 8px; color: var(--rr-ink); vertical-align: middle; }
  .rr-tree { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .rr-branch { display: flex; flex-direction: column; gap: 6px; background: var(--rr-paper-dark); border-radius: 14px; padding: 6px; }
  .rr-branch h3 { margin: 0; font-size: 16px; text-align: center; }
  .rr-skill { position: relative; display: grid; gap: 1px; text-align: left; font: 600 13px "Baloo 2", sans-serif; color: var(--rr-ink); background: #fff;
              border: 3px solid var(--rr-edge); border-radius: 12px; padding: 5px 8px; cursor: pointer; line-height: 1.2; }
  .rr-skill + .rr-skill::before { content: ""; position: absolute; left: 50%; top: -9px; width: 3px; height: 6px; background: var(--rr-edge); }
  .rr-skill b { font-size: 15px; } .rr-skill small { color: var(--rr-soft); }
  .rr-skill span { font-weight: 800; color: #c49a20; }
  .rr-skill.can { border-color: #e8c24a; background: #fffbe0; animation: lm-bob 2s ease-in-out infinite; }
  .rr-skill.got { border-color: #7ee08a; background: #effbef; } .rr-skill.got span { color: var(--rr-green); }
  .rr-skill.off { opacity: .6; }
  @media (orientation: portrait) {
    #realm.on { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
    .rr-side { border-left: 0; border-top: 6px solid var(--rr-edge); max-height: 60vh; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; align-content: start;
               padding: 8px calc(12px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left)); }
    .rr-goal, .rr-plans, .rr-spark { grid-column: 1 / -1; }
    .rr-goal, .rr-plans { margin-right: 0; } .rr-goal { width: 100%; }
    .rr-top { padding-right: calc(62px + env(safe-area-inset-right)); }
    .rr-goal { padding: 3px 8px; font-size: 14px; }
    .rr-story { margin: 0 34px; font-size: 12px; min-height: 30px; }
    .rr-qcard .q { font-size: 38px; } .rr-qcard .ans { min-height: 44px; line-height: 38px; font-size: 32px; width: 80%; }
    .rr-pad .key { font-size: 24px; padding: 2px 0; } .rr-pad { gap: 5px; align-self: center; }
    .rr-fix { font-size: 13px; min-height: 32px; }
    .rr-sparkbar { height: 20px; } .rr-sparkbar span { line-height: 20px; font-size: 13px; }
  }
  @media (orientation: portrait) and (min-width: 600px) {
    .rr-side { max-height: 50vh; }
    .rr-qcard .q { font-size: 50px; } .rr-pad .key { font-size: 30px; padding: 6px 0; }
  }
  /* Tall screens: a bigger question and number pad, to fill the side. */
  @media (orientation: landscape) and (min-height: 700px) {
    .rr-goal { font-size: 17px; } .rr-story { font-size: 16px; }
    .rr-qcard .q { font-size: 64px; } .rr-qcard .ans { min-height: 68px; line-height: 62px; font-size: 52px; }
    .rr-pad { gap: 10px; } .rr-pad .key { font-size: 36px; padding: 14px 0; }
  }
  @media (orientation: landscape) and (max-height: 500px) {
    #realm.on { grid-template-columns: minmax(0, 1fr) clamp(250px, 38vw, 330px); }
    .rr-side { gap: 4px; padding-top: calc(6px + env(safe-area-inset-top)); }
    .rr-goal { font-size: 13px; padding: 2px 8px; } .rr-goal small { display: none; }
    .rr-story { min-height: 0; font-size: 12px; margin: 0 34px; }
    .rr-qcard { padding: 2px 6px; } .rr-say { width: 30px; height: 30px; font-size: 14px; }
    .rr-qcard .q { font-size: 32px; } .rr-qcard .ans { min-height: 38px; line-height: 32px; font-size: 28px; }
    .rr-pad .key { font-size: 20px; padding: 0; } .rr-pad { gap: 4px; }
    .rr-fix { min-height: 16px; font-size: 12px; margin: 2px 0 0; }
    .rr-dots small { display: none; } .rr-dots i, .rr-plandots i { width: 12px; height: 12px; }
    .rr-sparkbar { height: 18px; } .rr-sparkbar span { line-height: 18px; font-size: 12px; }
    .rr-btn, .rr-pill { font-size: 14px; min-height: 28px; padding: 0 6px; }
    .rr-board { padding: 8px 12px; } .rr-board h2 { font-size: 20px; }
    .rr-item { grid-template-columns: 52px 1fr auto; } .rr-item > img { width: 52px; height: 52px; }
  }
  @media (max-width: 520px) {
    .rr-btn, .rr-pill { font-size: 13px; min-height: 28px; padding: 0 5px; border-width: 2px; gap: 2px; }
    .rr-item { grid-template-columns: 52px 1fr; } .rr-item > img { width: 52px; height: 52px; } .rr-item .rr-big { grid-column: 1 / -1; }
  }
  @media (prefers-reduced-motion: reduce) { .rr-skill.can, .rr-spark.rush, .rr-board, .rr-stage.rush::after { animation: none; } }

  /* ---------- Paint Studio ---------- */
  /* The windows of Paint the World: easel, stall, gallery, career and plane. They float over everything. */
  :root { --ps-ink: #3d3350; --ps-soft: #7a6c8c; --ps-paper: #fffaf0; --ps-paper-dark: #fbeedb; --ps-edge: #f2a65a; --ps-edge-dark: #c9772d;
          --ps-teal: #2bb3a3; --ps-teal-dark: #1d8679; --ps-red: #c8453c; --ps-green: #2f9e5a; }
  .ps-modal[hidden], .ps-modal [hidden] { display: none !important; }
  body.ps-open { overflow: hidden; }
  .ps-modal { position: fixed; inset: 0; z-index: 45; display: flex; align-items: center; justify-content: center; background: rgba(61,51,80,.5);
              padding: calc(10px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
              font-family: "Baloo 2", sans-serif; color: var(--ps-ink); user-select: none; -webkit-user-select: none; }
  .ps-board { position: relative; display: flex; flex-direction: column; width: 100%; max-width: 760px; max-height: 100%; min-width: 0; background: var(--ps-paper);
              border: 6px solid var(--ps-edge); border-radius: 22px; box-shadow: 0 10px 0 var(--ps-edge-dark), 0 20px 40px rgba(0,0,0,.3); padding: 8px 14px 14px; animation: pop .25s ease-out; }
  .ps-board.ps-full { max-width: 1240px; height: 100%; }
  .ps-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; min-width: 0; }
  .ps-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 22px; line-height: 1.2; color: #c25e1c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ps-purse { display: flex; gap: 5px; flex: none; }
  .ps-purse span { background: var(--ps-paper-dark); border: 2px solid #f6d3ac; border-radius: 10px; padding: 0 7px; font-weight: 800; font-size: 15px; white-space: nowrap; }
  .ps-x { flex: none; width: 40px; height: 40px; border-radius: 12px; border: 3px solid var(--ps-edge); background: var(--ps-paper-dark); font: 800 18px "Baloo 2", sans-serif;
          color: var(--ps-ink); cursor: pointer; }
  .ps-body { overflow-y: auto; overscroll-behavior: contain; min-height: 0; flex: 1 1 auto; }
  .ps-full .ps-body { overflow: hidden; display: flex; flex-direction: column; }
  .ps-body p { margin: 0 0 6px; line-height: 1.3; }
  .ps-sub { color: var(--ps-soft); }
  .ps-why { color: var(--ps-red); font-size: 14px; }
  .ps-banner { background: #fff3c4; border: 2px dashed #e8b84a; border-radius: 12px; padding: 4px 10px; color: var(--ps-ink); }
  .ps-h3 { margin: 12px 0 6px; font-size: 18px; color: #c25e1c; }
  .ps-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
  .ps-big { flex: 1; min-width: 110px; font: 800 18px "Baloo 2", sans-serif; color: #fff; background: var(--ps-teal); border: 3px solid var(--ps-teal-dark); border-radius: 14px;
            padding: 6px 12px; box-shadow: 0 4px 0 #136058; cursor: pointer; }
  .ps-big:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #136058; }
  .ps-big:disabled { background: #ddd5cb; border-color: #c9bfb2; box-shadow: 0 4px 0 #ada194; color: #fbf8f4; cursor: default; }
  .ps-soft { background: var(--ps-paper-dark); color: var(--ps-ink); border-color: var(--ps-edge); box-shadow: 0 4px 0 var(--ps-edge-dark); }
  .ps-soft:active:not(:disabled) { box-shadow: 0 2px 0 var(--ps-edge-dark); }
  .ps-stars { color: #f0a417; font-size: 20px; letter-spacing: 1px; white-space: nowrap; } .ps-stars i { font-style: normal; color: #e3d9cc; }
  .ps-toast { position: absolute; z-index: 2; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
              max-width: min(92%, 520px); text-align: center; font: 700 17px "Baloo 2", sans-serif; background: var(--ps-paper); border: 3px solid var(--ps-edge); border-radius: 14px;
              padding: 6px 14px; box-shadow: 0 4px 0 var(--ps-edge-dark); transition: opacity .25s, transform .25s; }
  .ps-toast.on { opacity: 1; transform: translate(-50%, 0); }
  /* A new colour found: a card that pops in at the bottom. */
  .ps-newcol { position: absolute; z-index: 3; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px) scale(.9); opacity: 0; pointer-events: none;
               display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; width: max-content; max-width: min(92vw, 440px); box-sizing: border-box; font-family: "Baloo 2", sans-serif;
               background: var(--ps-paper); border: 3px solid var(--ps-edge); border-radius: 16px; padding: 10px 16px; box-shadow: 0 5px 0 var(--ps-edge-dark); transition: opacity .3s, transform .3s; }
  .ps-newcol.on { opacity: 1; transform: translate(-50%, 0) scale(1); }
  .ps-newcol b { font-size: 19px; } .ps-newcol small { grid-column: 2; font-size: 14px; color: var(--ps-soft); }
  .ps-newcol[hidden] { display: none; }
  .ps-newsw { grid-row: span 2; display: flex; gap: 4px; }
  .ps-newsw i { width: 40px; height: 40px; border-radius: 50%; border: 3px solid rgba(0,0,0,.18); animation: ps-pop .6s ease-out; }
  @keyframes ps-pop { 0% { transform: scale(.3) rotate(-40deg); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }

  /* Picture cards: pictures to paint, paintings at the stall and in the gallery. */
  .ps-pics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .ps-pic { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; text-align: center; font: 600 14px "Baloo 2", sans-serif; color: var(--ps-ink);
            background: #fff; border: 3px solid #f6d3ac; border-radius: 14px; padding: 6px; cursor: pointer; line-height: 1.2; }
  .ps-pic:active:not([aria-disabled]) { transform: translateY(2px); }
  .ps-pic img { width: 100%; aspect-ratio: 4 / 3; border-radius: 8px; border: 2px solid #eadfce; background: #fffdf8; object-fit: cover; }
  .ps-pic b { font-size: 16px; } .ps-pic small { color: var(--ps-soft); font-size: 12.5px; }
  .ps-pic.off { opacity: .6; cursor: default; } .ps-pic.off img { filter: grayscale(.5); }
  .ps-pic[aria-disabled] { cursor: default; }
  .ps-free { border-color: var(--ps-teal); background: #effaf7; justify-content: center; }
  .ps-freeicon { font-size: 54px; line-height: 1.3; aspect-ratio: 4 / 3; display: grid; place-items: center; width: 100%; }
  .ps-gcard { cursor: default; }
  .ps-eye { color: #c25e1c !important; font-weight: 800; }

  /* Lists of things to buy or do. */
  .ps-list { display: grid; gap: 8px; }
  .ps-item { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: center; background: #fff; border: 2px solid #f6d3ac; border-radius: 14px; padding: 6px 10px; }
  .ps-item b { font-size: 16px; } .ps-item small { display: block; color: var(--ps-soft); font-size: 13.5px; line-height: 1.25; }
  .ps-item .ps-big { min-width: 96px; flex: none; }
  .ps-item.off .ps-cityicon, .ps-item.off .ps-swatches { opacity: .55; }
  .ps-item.here { border-color: var(--ps-teal); background: #effaf7; }
  .ps-cityicon { font-size: 34px; text-align: center; line-height: 1; }
  .ps-mini { width: 52px; height: 39px; border-radius: 6px; border: 2px solid #eadfce; }
  .ps-got { font-weight: 800; color: var(--ps-green); white-space: nowrap; }
  .ps-swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; width: 44px; }
  .ps-swatches i { height: 18px; border-radius: 6px; border: 2px solid rgba(0,0,0,.15); }

  /* Painting: the picture on one side, the question and number pad on the other. */
  .ps-paint { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 330px); gap: 12px; }
  .ps-canvas-wrap { min-width: 0; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; }
  .ps-canvas { display: block; border-radius: 10px; background: #fff; touch-action: none; cursor: pointer;
               box-shadow: 0 0 0 4px #fff, 0 0 0 7px #8a5a34, 0 6px 14px rgba(0,0,0,.2); }
  .ps-fcanvas { cursor: crosshair; }
  .ps-side { display: flex; flex-direction: column; gap: 8px; min-height: 0; min-width: 0; justify-content: center; }
  .ps-progress { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; white-space: nowrap; }
  .ps-bar { position: relative; flex: 1; height: 14px; background: #f1e6d6; border-radius: 99px; overflow: hidden; display: block; }
  .ps-bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #ff8fa3, #ffd23f, #6cd4a8); border-radius: 99px; transition: width .3s; }
  .ps-qcard { background: #fff; border: 3px solid var(--ps-edge); border-radius: 16px; padding: 6px 8px; text-align: center; }
  .ps-qcard.good { animation: good .4s; }
  .ps-story { margin: 0 !important; min-height: 24px; font-size: 15px; line-height: 1.25; color: var(--ps-soft); }
  .ps-story b { color: var(--ps-ink); }
  .ps-badge { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #ff9f1c; color: #fff; font-weight: 800; font-size: 13px; vertical-align: middle; }
  .ps-q { font-size: 46px; padding: 0; }
  .ps-ans { min-height: 50px; line-height: 46px; font-size: 38px; margin: 4px auto 0; border-width: 3px; }
  .ps-fix { min-height: 22px; margin: 4px 0 0 !important; font-size: 15px; font-weight: 800; }
  .ps-fix.good { color: var(--ps-green); } .ps-fix.bad { color: var(--ps-red); }
  .ps-pad { gap: 7px; }
  .ps-pad .key { font-size: 28px; padding: 4px 0; background: #fffaf0; border: 2px solid #f6d3ac; box-shadow: 0 4px 0 #f0d9bb; }
  .ps-pad .key.del { background: #f7a6a0; } .ps-pad .key.ok { background: #8fdcb4; }
  .ps-ask { max-width: 380px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }

  /* Free painting tools. */
  .ps-tools { justify-content: flex-start; }
  .ps-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
  .ps-swatch { aspect-ratio: 1; min-height: 34px; border-radius: 50%; border: 3px solid rgba(0,0,0,.18); cursor: pointer; font-size: 18px; padding: 0; background: #fff; }
  .ps-swatch.on { outline: 4px solid var(--ps-ink); outline-offset: 1px; }
  .ps-swatch.ps-locked { opacity: .45; filter: grayscale(.6); font-size: 14px; border-style: dashed; }
  .ps-swatches i.ps-locked { opacity: .45; filter: grayscale(.6); border-style: dashed; }
  .ps-swatch.ps-fx { box-shadow: 0 0 0 2px #fff inset, 0 0 6px rgba(255, 220, 120, .9); }
  .ps-palette.ps-many { grid-template-columns: repeat(auto-fill, minmax(32px, 1fr)); gap: 5px; }
  .ps-palette.ps-many .ps-swatch { min-height: 30px; }
  .ps-sizes { display: flex; gap: 8px; }
  .ps-size { flex: 1; height: 44px; display: grid; place-items: center; background: #fff; border: 3px solid #f6d3ac; border-radius: 12px; cursor: pointer; }
  .ps-size i { display: block; border-radius: 50%; background: var(--ps-ink); }
  .ps-size.on { border-color: var(--ps-teal); background: #effaf7; }
  .ps-toolrow { margin-top: 0; } .ps-toolrow .ps-big { font-size: 16px; min-width: 0; }
  .ps-label { display: block; font-weight: 800; margin: 4px 0; }
  .ps-input { width: 100%; font: 700 20px "Baloo 2", sans-serif; color: var(--ps-ink); border: 3px solid var(--ps-edge); border-radius: 12px; padding: 4px 10px; background: #fff;
              user-select: text; -webkit-user-select: text; }
  .ps-chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .ps-chip { font: 700 14px "Baloo 2", sans-serif; color: var(--ps-ink); background: #fff; border: 2px solid #f6d3ac; border-radius: 99px; padding: 2px 10px; cursor: pointer; }
  .ps-chip.on { background: var(--ps-teal); border-color: var(--ps-teal-dark); color: #fff; }

  /* A finished painting, a buyer's thoughts, a sale. */
  .ps-done { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; align-items: center; }
  .ps-bigthumb { aspect-ratio: 4 / 3; border-radius: 8px; background: #fff; box-shadow: 0 0 0 4px #fff, 0 0 0 8px #8a5a34, 0 8px 16px rgba(0,0,0,.2); margin: 8px; width: calc(100% - 16px); }
  .ps-title { font-size: 22px; font-weight: 800; }
  .ps-done .ps-stars { font-size: 30px; }
  .ps-hearts { font-size: 30px; letter-spacing: 2px; } .ps-hearts i { font-style: normal; opacity: .5; }
  .ps-quote { font-size: 17px; font-style: italic; }
  .ps-offer { font-size: 19px; background: #fff3c4; border-radius: 12px; padding: 4px 10px; }
  .ps-gain { font-size: 20px; font-weight: 800; } .ps-gain small { font-weight: 600; font-size: 14px; color: var(--ps-soft); }
  .ps-say { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 8px; }
  .ps-face { flex: none; width: 72px; height: 72px; display: grid; place-items: center; font-size: 42px; background: var(--ps-paper-dark); border: 3px solid var(--ps-edge); border-radius: 50%; }
  .ps-coins { display: flex; justify-content: space-between; gap: 8px; font-size: 18px; font-weight: 800; margin-bottom: 8px; background: var(--ps-paper-dark); border-radius: 12px; padding: 4px 10px; }
  .ps-coins b { color: var(--ps-green); }
  .ps-stallpics { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }

  /* The career book. */
  .ps-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
  .ps-tab { flex: 1; font: 800 16px "Baloo 2", sans-serif; color: var(--ps-ink); background: var(--ps-paper-dark); border: 3px solid #f6d3ac; border-radius: 12px; padding: 4px 6px; cursor: pointer; }
  .ps-tab.on { background: var(--ps-edge); border-color: var(--ps-edge-dark); color: #fff; }
  .ps-ladder { display: grid; gap: 6px; }
  .ps-rung { display: flex; gap: 10px; align-items: center; background: #fff; border: 2px solid #f6d3ac; border-radius: 14px; padding: 4px 10px; opacity: .7; }
  .ps-rung p { margin: 0 !important; font-size: 13.5px; color: var(--ps-soft); }
  .ps-rung-e { font-size: 30px; }
  .ps-rung.done { opacity: .9; background: #f2fbf5; }
  .ps-rung.now { opacity: 1; border: 3px solid var(--ps-teal); background: #effaf7; }
  .ps-you { background: var(--ps-teal); color: #fff; border-radius: 99px; padding: 0 8px; font-size: 13px; font-weight: 800; }
  .ps-meter { display: flex; flex-direction: column; gap: 3px; margin: 10px 0 4px; font-weight: 800; font-size: 15px; }
  .ps-meter .ps-bar { flex: none; height: 18px; }
  .ps-goal { background: #fff; border: 2px solid var(--ps-edge); border-radius: 12px; padding: 4px 10px; font-weight: 700; margin: 6px 0; }
  .ps-goal small { display: block; font-size: 12px; color: var(--ps-soft); text-transform: uppercase; letter-spacing: .5px; } .ps-goal span { color: #c49a20; white-space: nowrap; }
  .ps-statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; } .ps-statgrid span { background: var(--ps-paper-dark); border-radius: 10px; padding: 2px 8px; }
  .ps-bank { display: flex; gap: 10px; align-items: center; background: #fff3c4; border: 3px solid #e8c24a; border-radius: 14px; padding: 6px 10px; }
  .ps-bank > div { flex: 1; min-width: 0; } .ps-bank b { font-size: 18px; } .ps-bank small { display: block; color: var(--ps-soft); }
  .ps-bank .ps-big { flex: none; }
  .ps-votes { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 10px; }
  .ps-votes span { display: grid; place-items: center; width: 74px; font-size: 30px; background: #fff; border: 3px solid #f6d3ac; border-radius: 14px; padding: 2px; opacity: .55; }
  .ps-votes span.on { opacity: 1; border-color: var(--ps-teal); background: #effaf7; }
  .ps-votes small { font-size: 12px; font-weight: 800; }
  .ps-win .ps-face { animation: lm-bob 1.2s ease-in-out infinite; }

  @media (orientation: portrait) {
    .ps-paint { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 8px; }
    .ps-tools .ps-palette { grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); }
  }
  @media (orientation: landscape) and (max-height: 520px) {
    .ps-board { padding: 4px 10px 8px; border-width: 4px; } .ps-head h2 { font-size: 18px; } .ps-x { width: 34px; height: 34px; }
    .ps-q { font-size: 32px; } .ps-ans { min-height: 38px; line-height: 34px; font-size: 28px; } .ps-pad .key { font-size: 20px; padding: 0; } .ps-pad { gap: 4px; }
    .ps-story { font-size: 13px; min-height: 0; } .ps-fix { font-size: 13px; min-height: 16px; }
  }
  @media (orientation: landscape) and (min-height: 700px) {
    .ps-q { font-size: 56px; } .ps-ans { min-height: 60px; line-height: 56px; font-size: 46px; } .ps-pad .key { font-size: 32px; padding: 10px 0; } .ps-pad { gap: 9px; }
    .ps-story { font-size: 17px; }
  }
  @media (max-width: 560px) {
    .ps-board { padding: 6px 8px 10px; border-width: 4px; border-radius: 18px; }
    .ps-head h2 { font-size: 18px; } .ps-purse span { font-size: 13px; padding: 0 5px; } .ps-x { width: 34px; height: 34px; }
    .ps-pics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .ps-done { grid-template-columns: minmax(0, 1fr); gap: 4px; } .ps-done .ps-bigthumb { max-width: 340px; justify-self: center; }
    .ps-item { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 8px; padding: 5px 8px; } .ps-item .ps-big { min-width: 0; padding: 4px 8px; font-size: 16px; } .ps-cityicon { font-size: 26px; }
    .ps-item small { font-size: 12.5px; } .ps-mini { width: 34px; height: 26px; } .ps-toast { font-size: 14px; padding: 4px 10px; }
    .ps-bank { flex-wrap: wrap; } .ps-bank .ps-big { flex: 1; }
    .ps-q { font-size: 34px; } .ps-ans { min-height: 40px; line-height: 36px; font-size: 30px; width: 60%; }
    .ps-pad .key { font-size: 22px; padding: 2px 0; } .ps-pad { gap: 5px; }
    .ps-story { font-size: 13px; min-height: 0; } .ps-fix { font-size: 13px; min-height: 18px; }
    .ps-qcard { padding: 3px 6px; } .ps-side { gap: 5px; } .ps-progress { font-size: 13px; }
    .ps-face { width: 56px; height: 56px; font-size: 32px; }
  }
  @media (prefers-reduced-motion: reduce) { .ps-board, .ps-win .ps-face { animation: none; } }

  /* ---------- Paint the World ---------- */
  /* The start screen (zoomed like the others) and the town: full screen like Tiny Planet, and never zoomed, so taps land where you aim. */
  /* The map (Tiny Planet's map styles): hide the town's buttons while it's open. */
  #paint.mapping .pl-side, #paint.mapping .pl-place, #paint.mapping .dv-stick, #paint.mapping .pl-act, #paint.mapping .pl-jump,
  #paint.mapping .pl-toast, #paint.mapping .pl-coins, #paint.mapping .pt-goal { display: none !important; }
  #ptGuide.off { opacity: .55; }
  .mode.paintmode .mt { color: #e9577a; }
  body[data-screen="paintSetup"]::before { background: linear-gradient(#bfe6f2, #fde7ef 55%, #fff2c9); }
  #paintSetup h1 { color: #fff; text-shadow: 0 3px 0 #c9406a, 0 0 14px rgba(233,87,122,.45); }
  #paintSetup .sub, #paintSetup .best { color: #4b3a4f; text-shadow: none; }
  .pt-hero { display: block; width: min(100%, 480px); aspect-ratio: 24 / 13; margin: 0 auto 10px; border: 4px solid #2b2d3c; border-radius: 14px;
             box-shadow: 5px 5px 0 #2b2d3c; background: #bfe6f2; object-fit: cover; }
  .pt-new { margin: 6px 0 10px; }
  .pt-newask p { margin: 0 0 10px; font-size: 18px; color: #2b2d3c; }
  .pt-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
  .pt-big { flex: 1; min-width: 120px; font: 800 18px "Baloo 2", sans-serif; color: #fff; background: #e9577a; border: 3px solid #2b2d3c; border-radius: 12px;
            padding: 8px 12px; box-shadow: 3px 3px 0 #2b2d3c; cursor: pointer; }
  .pt-big:active { translate: 2px 2px; box-shadow: 1px 1px 0 #2b2d3c; }
  .pt-soft { background: #f8f5ec; color: #2b2d3c; }
  .pt-danger { background: #d4544b; }
  body[data-screen="paint"] { overflow: hidden; }
  body[data-screen="paint"]::before { background: #93cfe6; }
  #paint.on { position: fixed; inset: 0; max-width: none; padding: 0; animation: none; overflow: hidden; touch-action: none; -webkit-user-select: none; user-select: none; }
  #paint [hidden] { display: none !important; }
  #ptCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
  #paint .dv-stick.rest .dv-knob::after { content: "🎨"; }
  .pt-fame { background: #fff1a8; transform: rotate(2deg); }
  .pt-stage { font-size: 15px; background: #fde7ef; }
  /* What to do next, under the coins. */
  .pt-goal { position: absolute; z-index: 3; top: calc(78px + env(safe-area-inset-top)); left: calc(12px + env(safe-area-inset-left)); max-width: min(46vw, 360px);
             background: rgba(251, 250, 245, .94); border: 3px solid #2b2d3c; border-radius: 10px; box-shadow: 3px 3px 0 #2b2d3c; padding: 5px 12px;
             font-family: "Patrick Hand", "Baloo 2", sans-serif; font-size: 19px; line-height: 1.2; color: #2b2d3c; pointer-events: none; }
  /* Flying to another city. */
  .pt-fly { position: absolute; inset: 0; z-index: 7; display: grid; place-content: center; text-align: center; background: linear-gradient(#93cfe6, #fde7ef);
            font-family: "Bungee", "Arial Black", sans-serif; color: #2b2d3c; font-size: clamp(22px, 4vw, 36px); }
  .pt-fly div { font-size: 110px; line-height: 1; }
  @media (prefers-reduced-motion: no-preference) { .pt-fly div { animation: ptfly 1.6s ease-in-out infinite alternate; } }
  @keyframes ptfly { from { transform: translate(-40px, 10px) rotate(-6deg); } to { transform: translate(40px, -10px) rotate(6deg); } }
  .pt-loading { background: linear-gradient(#93cfe6, #fde7ef); }
  @media (max-width: 560px), (max-height: 500px) {
    .pt-stage { display: none; }
    .pt-goal { top: calc(70px + env(safe-area-inset-top)); font-size: 16px; max-width: 52vw; }
  }

  /* ---------- Them Stealing ---------- */
  :root { --st-ink: #2a1f3d; --st-soft: #6a5a86; --st-paper: #fff9ec; --st-paper-dark: #f3e8d2; --st-edge: #3d2f63; --st-gold: #ffd34d;
          --st-purple: #6a4ab8; --st-red: #e0455a; --st-green: #2fa36b; }
  .mode.stealmode .mt { color: #6a4ab8; }
  body[data-screen="stealSetup"]::before { background: linear-gradient(#1d1640, #3d3170 45%, #6a4ab8); }
  body[data-screen="steal"]::before { background: #1d1626; }
  body[data-screen="steal"] { overflow: hidden; background: #1d1626; }
  #stealSetup h1 { color: var(--st-gold); text-shadow: 0 3px 0 #5a2a8a, 0 0 18px rgba(255,211,77,.45); }
  #stealSetup .sub, #stealSetup .best { color: #fff4d6; text-shadow: 0 1px 0 rgba(0,0,0,.4); }
  .st-hero { display: block; width: min(100%, 520px); aspect-ratio: 26 / 14; margin: 0 auto 10px; border: 4px solid var(--st-gold); border-radius: 16px;
             box-shadow: 0 6px 0 #5a2a8a; background: #1d1626; object-fit: cover; }
  .st-new { margin: 6px 0 10px; }
  .st-newask p { margin: 0 0 10px; font-size: 18px; color: var(--st-ink); }
  .st-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
  .st-big { flex: 1; min-width: 120px; min-height: 48px; font: 800 18px "Baloo 2", sans-serif; color: #fff; background: var(--st-purple); border: 3px solid var(--st-edge); border-radius: 14px;
            padding: 6px 12px; box-shadow: 0 4px 0 var(--st-edge); cursor: pointer; }
  .st-big:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 var(--st-edge); }
  .st-big:disabled { background: #d6d0e2; border-color: #b4abc8; box-shadow: 0 4px 0 #9a90b0; color: #f8f6fb; cursor: default; }
  .st-soft { background: var(--st-paper-dark); color: var(--st-ink); }
  .st-danger { background: var(--st-red); }

  /* The game: the maze fills the screen, with the bar on top and the controls on the bottom corners. */
  #steal.on { position: fixed; inset: 0; max-width: none; padding: 0; animation: none; overflow: hidden; touch-action: none;
              -webkit-user-select: none; user-select: none; font-family: "Baloo 2", sans-serif; color: var(--st-ink); }
  #steal [hidden], .st-modal[hidden], .st-modal [hidden], .st-caught[hidden] { display: none !important; }
  #stCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
  .st-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .st-top { position: absolute; left: 0; right: 0; top: 0; z-index: 3; display: flex; gap: 6px; align-items: center; pointer-events: none;
            padding: calc(6px + env(safe-area-inset-top)) calc(64px + env(safe-area-inset-right)) 0 calc(8px + env(safe-area-inset-left)); }
  .st-top > * { pointer-events: auto; }
  .st-hud { display: flex; flex-wrap: nowrap; gap: 5px; flex: 1; min-width: 0; overflow: hidden; }
  .st-hud .st-pill { flex: none; } .st-hud .st-pill:last-child { flex: 0 1 auto; min-width: 0; }
  .st-btn, .st-pill { font: 800 16px "Baloo 2", sans-serif; color: var(--st-ink); background: var(--st-paper); border: 3px solid var(--st-edge); border-radius: 12px;
                      padding: 0 9px; box-shadow: 0 3px 0 var(--st-edge); display: inline-flex; align-items: center; gap: 4px; min-height: 36px; white-space: nowrap; }
  .st-btn { cursor: pointer; min-width: 44px; justify-content: center; font-size: 20px; }
  .st-pill { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .st-where { background: var(--st-gold); }
  .st-got { background: #b8f0c8; }
  .st-wear { color: var(--st-purple); }
  .st-air { position: absolute; z-index: 3; left: 50%; top: calc(52px + env(safe-area-inset-top)); transform: translateX(-50%); display: flex; align-items: center; gap: 6px;
            background: rgba(255,249,236,.94); border: 3px solid var(--st-edge); border-radius: 12px; padding: 2px 10px; font-weight: 800; }
  .st-airbar { width: 120px; height: 14px; background: #d8e8f2; border-radius: 8px; overflow: hidden; }
  .st-airbar i { display: block; height: 100%; background: #3aa6d8; transition: width .1s linear; }
  .st-air.low .st-airbar i { background: var(--st-red); }
  /* What you can use here (in the HQ). */
  .st-act { position: absolute; z-index: 4; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100% - 380px);
            font: 800 20px "Baloo 2", sans-serif; color: var(--st-ink); background: var(--st-gold); border: 3px solid var(--st-edge); border-radius: 16px;
            box-shadow: 0 5px 0 var(--st-edge); padding: 8px 18px; cursor: pointer; animation: st-bob 1.4s ease-in-out infinite; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  @keyframes st-bob { 50% { transform: translate(-50%, -4px); } }
  /* The joystick (bottom left) and Jump / Dive (bottom right). */
  .st-stick { position: absolute; z-index: 3; left: calc(24px + env(safe-area-inset-left)); bottom: calc(24px + env(safe-area-inset-bottom)); width: 150px; height: 150px;
              border-radius: 50%; background: rgba(255,249,236,.28); border: 4px solid rgba(255,249,236,.6); touch-action: none; display: grid; place-items: center; }
  .st-stick.on { background: rgba(255,249,236,.4); }
  .st-knob { width: 64px; height: 64px; border-radius: 50%; background: var(--st-paper); border: 4px solid var(--st-edge); box-shadow: 0 4px 0 rgba(0,0,0,.3); pointer-events: none; }
  .st-btns { position: absolute; z-index: 3; right: calc(20px + env(safe-area-inset-right)); bottom: calc(24px + env(safe-area-inset-bottom)); display: flex; gap: 12px; align-items: flex-end; }
  .st-jump, .st-dive { width: 92px; height: 92px; border-radius: 50%; font: 800 20px "Baloo 2", sans-serif; color: #fff; border: 4px solid var(--st-edge); cursor: pointer;
                       box-shadow: 0 5px 0 var(--st-edge); touch-action: none; }
  .st-jump { background: #e0567a; width: 104px; height: 104px; font-size: 22px; }
  .st-dive { background: #3a8ac0; opacity: .7; }
  .st-dive.wet { opacity: 1; background: #2a9ad8; }
  .st-jump.on, .st-dive.on { transform: translateY(3px); box-shadow: 0 2px 0 var(--st-edge); }
  .st-keys { position: absolute; z-index: 2; left: 50%; bottom: calc(4px + env(safe-area-inset-bottom)); transform: translateX(-50%); font-size: 13px; color: rgba(255,249,236,.7);
             white-space: nowrap; pointer-events: none; display: none; }
  @media (hover: hover) and (pointer: fine) { .st-keys { display: block; } }
  .st-toast { position: absolute; z-index: 4; left: 50%; top: calc(90px + env(safe-area-inset-top)); transform: translate(-50%, -16px); opacity: 0; pointer-events: none;
              max-width: min(88%, 560px); text-align: center; font: 700 18px "Baloo 2", sans-serif; background: var(--st-paper); border: 3px solid var(--st-edge);
              border-radius: 14px; padding: 5px 14px; box-shadow: 0 4px 0 var(--st-edge); transition: opacity .25s, transform .25s; }
  .st-toast.on { opacity: 1; transform: translate(-50%, 0); }
  .st-banner { position: absolute; z-index: 4; left: 50%; top: 38%; transform: translate(-50%, -50%); pointer-events: none; opacity: 0; white-space: nowrap;
               font: 800 clamp(32px, 7vw, 64px) "Baloo 2", sans-serif; color: var(--st-gold); text-shadow: 0 4px 0 #5a2a8a, 0 0 20px rgba(0,0,0,.6); }
  .st-banner.go { animation: lm-banner 1.8s ease-out; }
  .st-banner.st-b-red { color: #fff; text-shadow: 0 4px 0 #a01e30, 0 0 24px rgba(255,60,80,.8); }

  /* Windows. */
  .st-modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(20,12,40,.55);
              padding: calc(12px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left)); }
  .st-board { position: relative; display: flex; flex-direction: column; width: 100%; max-width: 640px; max-height: 100%; background: var(--st-paper); color: var(--st-ink);
              border: 6px solid var(--st-edge); border-radius: 22px; box-shadow: 0 10px 0 #1d1626, 0 20px 40px rgba(0,0,0,.4);
              padding: 14px 16px; font-family: "Baloo 2", sans-serif; animation: pop .25s ease-out; }
  .st-board.st-wide { max-width: 1100px; }
  .st-board h2 { margin: 0 46px 6px 0; font-size: 24px; line-height: 1.15; color: var(--st-purple); }
  .st-body { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
  .st-body p { margin: 0 0 6px; line-height: 1.3; }
  .st-x { position: absolute; top: 8px; right: 8px; width: 42px; height: 42px; border-radius: 12px; border: 3px solid var(--st-edge); background: var(--st-paper-dark);
          font: 800 18px "Baloo 2", sans-serif; color: var(--st-ink); cursor: pointer; z-index: 2; }
  .st-sub { color: var(--st-soft); }
  .st-count { font-size: 16px; background: var(--st-gold); border-radius: 10px; padding: 1px 8px; color: var(--st-ink); vertical-align: middle; }
  .st-say { display: flex; gap: 12px; align-items: flex-start; }
  .st-say > img { width: 96px; height: 96px; flex: none; background: #2b2540; border-radius: 50%; border: 3px solid var(--st-edge); }
  .st-city { display: block; width: 100%; aspect-ratio: 900 / 520; max-height: 42vh; object-fit: contain; border-radius: 14px; border: 3px solid var(--st-edge); background: #1d1640; margin-bottom: 8px; }
  .st-places { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
  .st-place { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; text-align: left; align-items: center; font: 600 14px "Baloo 2", sans-serif; color: var(--st-ink);
              background: #fff; border: 3px solid var(--st-edge); border-radius: 14px; padding: 6px 10px; cursor: pointer; line-height: 1.2; min-height: 64px; }
  .st-place .st-pe { grid-row: span 2; font-size: 28px; }
  .st-place b { font-size: 17px; } .st-place small { color: var(--st-soft); }
  .st-place.done { background: #e6f9ec; border-color: var(--st-green); }
  .st-place.off { background: #f1ecf6; opacity: .75; }
  .st-place:not(.off):not(.done) { background: #fff6cf; border-color: #c48a12; }
  .st-trophies { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .st-trophy { display: grid; justify-items: center; text-align: center; gap: 2px; background: #2b2540; color: #d8d2e6; border-radius: 14px; padding: 8px; border: 3px solid #4a4266; line-height: 1.15; }
  .st-trophy img { width: 72px; height: 72px; }
  .st-trophy.got { background: #3d3170; border-color: var(--st-gold); color: #fff; }
  .st-trophy small { color: #a89ec4; font-size: 12px; }
  .st-empty { width: 72px; height: 72px; display: grid; place-items: center; font-size: 34px; font-weight: 800; color: #6a6090; border: 3px dashed #6a6090; border-radius: 12px; }
  .st-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
  .st-item { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; background: #fff; border: 2px solid var(--st-edge); border-radius: 14px; padding: 6px 10px; }
  .st-item > img { width: 64px; height: 64px; background: var(--st-paper-dark); border-radius: 12px; }
  .st-item p { font-size: 14px; margin: 0; line-height: 1.25; }
  .st-item .st-big { min-width: 86px; flex: none; }
  .st-item.off > img { filter: grayscale(.5) opacity(.75); }
  .st-item.have { background: #effbef; border-color: var(--st-green); }
  .st-have { font-weight: 800; color: var(--st-green); white-space: nowrap; }
  .st-cost { font-size: 16px; font-weight: 800; white-space: nowrap; }
  .st-why { font-size: 13px !important; color: #a83a32; }
  .st-h3 { grid-column: 1 / -1; margin: 6px 0 0; font-size: 17px; }
  .st-wardrobe { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
  .st-outfit { position: relative; display: grid; justify-items: center; gap: 2px; text-align: center; font: 600 13px "Baloo 2", sans-serif; color: var(--st-ink); line-height: 1.15;
               background: #fff; border: 3px solid var(--st-edge); border-radius: 14px; padding: 6px; cursor: pointer; }
  .st-outfit img { width: 76px; height: 76px; } .st-outfit b { font-size: 15px; } .st-outfit small { color: var(--st-soft); }
  .st-outfit.on { background: #fff6cf; border-color: #c48a12; box-shadow: 0 0 0 3px var(--st-gold); }
  .st-outfit.off { opacity: .5; }
  .st-on { position: absolute; top: 4px; right: 4px; font-size: 11px; font-weight: 800; background: var(--st-gold); border-radius: 8px; padding: 0 6px; }

  /* The lock: a timer, the sum and the number pad. */
  .st-lockboard { max-width: 760px; display: grid; grid-template-columns: 1fr minmax(220px, 300px); gap: 12px; align-items: center; background: #2b2540; border-color: var(--st-gold); }
  .st-lockcard { position: relative; background: var(--st-paper); border-radius: 16px; padding: 8px 10px; text-align: center; }
  .st-lockcard.good { animation: good .4s; }
  .st-lockhead { display: flex; gap: 10px; align-items: center; text-align: left; }
  .st-lockhead img { width: 64px; height: 64px; flex: none; background: #2b2540; border-radius: 12px; }
  .st-lockhead h2 { margin: 0; font-size: 22px; color: var(--st-purple); line-height: 1.1; }
  .st-lockhead p { margin: 0; font-size: 14px; color: var(--st-soft); line-height: 1.2; }
  .st-tumblers { display: flex; gap: 6px; margin-top: 3px; }
  .st-tumblers i { width: 22px; height: 22px; border-radius: 6px; background: #e6dcf2; border: 3px solid var(--st-edge); }
  .st-tumblers i.on { background: var(--st-gold); border-color: #a87c10; }
  .st-timer { display: flex; align-items: center; gap: 8px; margin: 8px 0 2px; }
  .st-timebar { flex: 1; height: 20px; background: #e6dcf2; border: 3px solid var(--st-edge); border-radius: 12px; overflow: hidden; }
  .st-timebar i { display: block; height: 100%; background: var(--st-green); }
  .st-timer b { min-width: 36px; font-size: 24px; line-height: 1; }
  .st-timer.mid .st-timebar i { background: #f0b32e; }
  .st-timer.low .st-timebar i { background: var(--st-red); }
  .st-timer.low b { color: var(--st-red); animation: st-tick .5s ease-in-out infinite alternate; }
  .st-timer.wait .st-timebar { opacity: .55; }
  @keyframes st-tick { to { transform: scale(1.25); } }
  .st-qrow { min-height: 0; }
  .st-qrow .fm-say { width: 38px; height: 38px; border-color: var(--st-edge); background: var(--st-paper-dark); }
  .st-lockcard .q { font-size: 56px; padding: 4px 0 0; }
  .st-lockcard .q .vadd { font-size: 44px; }
  .st-lockcard .ans { width: 70%; min-height: 58px; line-height: 52px; font-size: 44px; margin: 4px auto 0; border-width: 3px; }
  .st-fix { min-height: 22px; margin: 4px 0 0; font-size: 16px; line-height: 1.2; font-weight: 700; }
  .st-fix.good { color: var(--st-green); } .st-fix.bad { color: #c4303f; }
  .st-leave { font: 700 14px "Baloo 2", sans-serif; color: var(--st-soft); background: none; border: 2px solid #d8cfe6; border-radius: 10px; padding: 2px 12px; cursor: pointer; margin-top: 4px; }
  .st-pad { gap: 8px; }
  .st-pad .key { font-size: 32px; padding: 8px 0; background: var(--st-paper); box-shadow: 0 4px 0 #1d1626; }
  .st-pad .key.del { background: #f7a6b4; } .st-pad .key.ok { background: #8fdca8; }

  /* Caught! A cage drops down. */
  .st-caught { position: fixed; inset: 0; z-index: 45; display: grid; place-content: center; justify-items: center; text-align: center; gap: 6px;
               background: radial-gradient(rgba(120,20,40,.6), rgba(20,10,30,.85)); color: #fff; font-family: "Baloo 2", sans-serif; padding: 20px; }
  .st-caught h2 { margin: 0; font-size: clamp(54px, 12vw, 110px); line-height: 1; color: #fff; text-shadow: 0 6px 0 #a01e30, 0 0 30px rgba(255,60,80,.9); }
  .st-caught p { margin: 0; font-size: 20px; max-width: 520px; }
  .st-caught .st-big { flex: none; min-width: 200px; font-size: 22px; margin-top: 8px; }
  .st-cage { width: 150px; height: 120px; display: flex; justify-content: space-between; border-top: 10px solid #c9c2e0; border-bottom: 10px solid #c9c2e0; border-radius: 8px; }
  .st-cage i { width: 8px; background: #c9c2e0; border-radius: 4px; }
  .st-caught.go .st-cage { animation: st-drop .55s cubic-bezier(.5, 0, .7, 1.4); }
  .st-caught.go h2 { animation: pop .4s ease-out .3s both; }
  @keyframes st-drop { from { transform: translateY(-60vh); } }

  @media (orientation: portrait) {
    .st-stick { width: 132px; height: 132px; }
    .st-jump { width: 92px; height: 92px; } .st-dive { width: 80px; height: 80px; }
    .st-act { max-width: calc(100% - 24px); bottom: calc(170px + env(safe-area-inset-bottom)); font-size: 18px; }
    .st-lockboard { grid-template-columns: 1fr; max-width: 520px; gap: 8px; padding: 10px; }
    .st-lockcard .q { font-size: 46px; }
  }
  @media (max-width: 520px) {
    .st-btn, .st-pill { font-size: 13px; min-height: 30px; padding: 0 6px; border-width: 2px; gap: 2px; }
    .st-item { grid-template-columns: 52px 1fr; } .st-item > img { width: 52px; height: 52px; } .st-item .st-big, .st-item .st-have { grid-column: 1 / -1; }
    .st-say > img { width: 70px; height: 70px; }
    .st-board { padding: 10px 12px; } .st-board h2 { font-size: 20px; }
    .st-lockhead img { width: 48px; height: 48px; } .st-lockhead h2 { font-size: 18px; }
    .st-pad .key { font-size: 26px; padding: 4px 0; }
    .st-toast { font-size: 15px; top: calc(84px + env(safe-area-inset-top)); }
  }
  /* Phones on their side: everything small and close to the edges. */
  @media (orientation: landscape) and (max-height: 500px) {
    .st-btn, .st-pill { font-size: 13px; min-height: 30px; padding: 0 6px; border-width: 2px; }
    .st-stick { width: 118px; height: 118px; left: calc(14px + env(safe-area-inset-left)); bottom: calc(12px + env(safe-area-inset-bottom)); }
    .st-knob { width: 50px; height: 50px; }
    .st-jump { width: 80px; height: 80px; font-size: 18px; } .st-dive { width: 66px; height: 66px; font-size: 16px; }
    .st-btns { bottom: calc(12px + env(safe-area-inset-bottom)); right: calc(14px + env(safe-area-inset-right)); }
    .st-act { font-size: 16px; padding: 4px 12px; max-width: calc(100% - 320px); bottom: calc(10px + env(safe-area-inset-bottom)); }
    .st-toast { font-size: 15px; top: calc(76px + env(safe-area-inset-top)); }
    .st-board { padding: 8px 12px; } .st-board h2 { font-size: 19px; }
    .st-city { max-height: 34vh; }
    .st-say > img { width: 64px; height: 64px; }
    .st-lockboard { grid-template-columns: 1fr minmax(180px, 250px); padding: 8px; gap: 8px; max-width: 700px; }
    .st-lockhead img { width: 40px; height: 40px; } .st-lockhead h2 { font-size: 17px; } .st-lockhead p { font-size: 12px; }
    .st-tumblers i { width: 16px; height: 16px; border-width: 2px; }
    .st-timer { margin: 4px 0 0; } .st-timebar { height: 14px; } .st-timer b { font-size: 18px; }
    .st-lockcard { padding: 4px 8px; } .st-lockcard .q { font-size: 36px; padding: 0; } .st-lockcard .q .vadd { font-size: 30px; }
    .st-lockcard .ans { min-height: 40px; line-height: 36px; font-size: 30px; }
    .st-fix { font-size: 13px; min-height: 16px; } .st-qrow .fm-say { width: 30px; height: 30px; font-size: 14px; }
    .st-pad { gap: 4px; } .st-pad .key { font-size: 22px; padding: 2px 0; }
    .st-caught h2 { font-size: 60px; } .st-cage { width: 100px; height: 70px; }
  }
  @media (prefers-reduced-motion: reduce) { .st-act, .st-board, .st-caught.go .st-cage, .st-caught.go h2, .st-timer.low b { animation: none; } }

  /* ---------- Ellie's Dog Shelter ---------- */
  /* The start screen (zoomed like the others) and the town: full screen like Tiny Planet, never zoomed. */
  .mode.sheltermode .mt { color: #c9503f; }
  body[data-screen="shelterSetup"]::before { background: linear-gradient(#bfe6f2, #fdeee0 55%, #f6dcc8); }
  #shelterSetup h1 { color: #fff; text-shadow: 0 3px 0 #c9503f, 0 0 14px rgba(201,80,63,.45); }
  #shelterSetup .sub, #shelterSetup .best { color: #4b3a2f; text-shadow: none; }
  .sh-hero { display: block; width: min(70%, 260px); aspect-ratio: 3 / 4; margin: 0 auto 10px; border: 4px solid #3a2e28; border-radius: 14px;
             box-shadow: 5px 5px 0 #3a2e28; background: #e9d8c0; object-fit: cover; transform: rotate(-1.5deg); }
  body[data-screen="shelter"] { overflow: hidden; }
  body[data-screen="shelter"]::before { background: #9fd6ec; }
  #shelter.on { position: fixed; inset: 0; max-width: none; padding: 0; animation: none; overflow: hidden; touch-action: none; -webkit-user-select: none; user-select: none; }
  #shelter [hidden] { display: none !important; }
  #shCanvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; touch-action: none; }
  #shelter .dv-stick.rest .dv-knob::after { content: "🐾"; }
  #shGuide.off { opacity: .55; }
  .sh-dogs { background: #fde7d8; transform: rotate(2deg); }
  .sh-food { background: #f2e6c8; transform: rotate(-1deg); }
  .sh-lead { background: #fbd3cf; transform: rotate(1.5deg); }
  .sh-loading { background: linear-gradient(#9fd6ec, #fdeee0); }
  #shelter.mapping .pl-side, #shelter.mapping .pl-place, #shelter.mapping .dv-stick, #shelter.mapping .pl-act, #shelter.mapping .pl-jump,
  #shelter.mapping .pl-toast, #shelter.mapping .pl-coins, #shelter.mapping .sh-goal { display: none !important; }
  /* The map's symbols: a dot on the place, a stalk, and a round badge with a short name. */
  .sh-pin { position: absolute; left: 0; top: 0; z-index: 1; --s: var(--pin, 1); }
  .sh-pin-dot { position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: #fffdf6; border: 2px solid #2b2d3c; box-sizing: border-box; }
  .sh-pin-line { position: absolute; left: 0; top: -1.5px; height: 3px; background: #2b2d3c; transform-origin: 0 50%; border-radius: 2px; }
  .sh-pin-b { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: calc(4px * var(--s)); white-space: nowrap; font-weight: 800;
              font-size: calc(13px * var(--s)); line-height: 1; padding: calc(3px * var(--s)) calc(9px * var(--s)) calc(3px * var(--s)) calc(3px * var(--s));
              border-radius: 999px; background: #fffdf6; color: #2d3436; border: 2px solid #2b2d3c; box-shadow: 0 2px 0 #2b2d3c; }
  .sh-pin-e { display: grid; place-items: center; width: calc(24px * var(--s)); height: calc(24px * var(--s)); border-radius: 50%; background: #ffd27a; font-size: calc(15px * var(--s)); line-height: 1; }
  .sh-pin.talk .sh-pin-e { background: #cfe8ff; }
  .sh-pin.talk .sh-pin-b { font-size: calc(12px * var(--s)); }
  .sh-pin.small .sh-pin-t { display: none; }
  .sh-pin.small .sh-pin-b { padding: calc(2px * var(--s)); }
  /* The key: what each symbol means. */
  .sh-map-key { position: absolute; left: calc(14px + env(safe-area-inset-left)); bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 2; pointer-events: none;
                display: flex; flex-direction: column; gap: 3px; margin: 0; padding: 8px 12px; border-radius: 14px; background: rgba(255, 253, 246, .92); color: #2d3436;
                font-size: 13px; font-weight: 700; line-height: 1.25; max-width: 260px; }
  .sh-map-key b { display: inline-block; width: 1.4em; text-align: center; }
  @media (max-width: 520px) { .sh-map-key { left: 10px; right: 10px; max-width: none; display: grid; grid-template-columns: repeat(3, auto); justify-content: space-between; gap: 2px 6px;
                                            font-size: 11px; padding: 5px 8px; white-space: nowrap; } }
  @media (max-height: 500px) { .sh-map-key { display: none; } }

  /* A window open: it sits at the side (landscape) or the bottom (portrait), and the 3D view shrinks to the rest. */
  :root { --sh-w: min(440px, 50vw); --sh-h: 60vh; --sh-ink: #3a2e28; --sh-soft: #7a6a5e; --sh-paper: #fffaf2; --sh-edge: #e0b48a; --sh-teal: #2fae9a; --sh-red: #d4544b; --sh-green: #2f9a5a; }
  .sh-care { position: absolute; z-index: 6; right: 0; top: 0; bottom: 0; width: var(--sh-w); display: flex; flex-direction: column; background: var(--sh-paper);
             border-left: 5px solid var(--sh-ink); padding: calc(8px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) 12px;
             font-family: "Baloo 2", sans-serif; color: var(--sh-ink); box-shadow: -6px 0 0 rgba(58,46,40,.25); }
  #shelter.sh-side #shCanvas { width: calc(100% - var(--sh-w)); }
  /* (Room on the right of the window's title bar for the page's sound button, which sits in that corner.) */
  @media (orientation: landscape) { .sh-head { padding-right: 58px; } }
  #shelter.sh-side .pl-side, #shelter.sh-side .pl-jump, #shelter.sh-side .dv-stick, #shelter.sh-side .sh-goal, #shelter.sh-side .pl-act { display: none !important; }
  @media (orientation: portrait) {
    .sh-care { left: 0; right: 0; top: auto; width: auto; height: var(--sh-h); border-left: 0; border-top: 5px solid var(--sh-ink); box-shadow: 0 -6px 0 rgba(58,46,40,.25);
               padding-left: calc(10px + env(safe-area-inset-left)); }
    #shelter.sh-side #shCanvas { width: 100%; height: calc(100% - var(--sh-h)); }
  }
  .sh-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; min-width: 0; }
  .sh-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 22px; line-height: 1.2; color: #c9503f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sh-purse span { background: #fdeee0; border: 2px solid var(--sh-edge); border-radius: 10px; padding: 0 8px; font-weight: 800; font-size: 16px; white-space: nowrap; }
  .sh-x { flex: none; width: 44px; height: 44px; border-radius: 12px; border: 3px solid var(--sh-ink); background: #fdeee0; font: 800 18px "Baloo 2", sans-serif; cursor: pointer; color: var(--sh-ink); }
  .sh-body { overflow-y: auto; overscroll-behavior: contain; min-height: 0; flex: 1 1 auto; }
  .sh-body p { margin: 0 0 6px; line-height: 1.3; }
  .sh-sub { color: var(--sh-soft); font-size: 15px; }
  .sh-why { color: var(--sh-red); font-weight: 700; }
  .sh-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
  .sh-big { flex: 1; min-width: 96px; min-height: 48px; font: 800 18px "Baloo 2", sans-serif; color: #fff; background: var(--sh-teal); border: 3px solid var(--sh-ink); border-radius: 14px;
            padding: 6px 12px; box-shadow: 0 4px 0 var(--sh-ink); cursor: pointer; }
  .sh-big:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 var(--sh-ink); }
  .sh-big:disabled { background: #ddd5cb; color: #fbf8f4; cursor: default; }
  .sh-soft { background: #fdeee0; color: var(--sh-ink); }
  .sh-qcard { background: #fff; border: 3px solid var(--sh-edge); border-radius: 16px; padding: 4px 8px; text-align: center; }
  .sh-qcard.good { animation: good .4s; }
  .sh-story { margin: 0 !important; min-height: 22px; font-size: 15px; color: var(--sh-soft); }
  .sh-q { font-size: 44px; padding: 0; }
  .sh-ans { min-height: 48px; line-height: 44px; font-size: 36px; margin: 4px auto 0; border-width: 3px; }
  .sh-fix { min-height: 22px; margin: 4px 0 0 !important; font-size: 15px; font-weight: 800; }
  .sh-fix.good { color: var(--sh-green); } .sh-fix.bad { color: var(--sh-red); }
  .sh-pad { gap: 7px; margin-top: 6px; }
  .sh-pad .key { font-size: 26px; padding: 4px 0; background: #fffaf0; border: 2px solid var(--sh-edge); box-shadow: 0 4px 0 #f0d9bb; min-height: 46px; }
  .sh-pad .key.del { background: #f7a6a0; } .sh-pad .key.ok { background: #8fdcb4; }
  .sh-ask { display: flex; flex-direction: column; gap: 4px; }
  .sh-paws { font-size: 20px; letter-spacing: 1px; white-space: nowrap; } .sh-paws i { font-style: normal; filter: grayscale(1); opacity: .3; }
  .sh-trust { font-size: 17px; margin: 4px 0 8px; display: flex; gap: 8px; align-items: center; }
  .sh-stepname { font-size: 18px; margin: 6px 0 4px !important; }
  .sh-steps { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin: 6px 0; }
  .sh-step { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 4px 0; min-height: 52px; background: #fff; border: 2px solid var(--sh-edge); border-radius: 10px; cursor: pointer;
             font: 700 11px "Baloo 2", sans-serif; color: var(--sh-ink); line-height: 1.1; }
  .sh-step span { font-size: 20px; }
  .sh-step.on { border: 3px solid var(--sh-teal); background: #e9f8f4; }
  .sh-step.done { background: #f0f9f2; }
  .sh-step:disabled { opacity: .45; cursor: default; }
  .sh-meters { display: grid; gap: 4px; margin: 4px 0; }
  .sh-meters > div { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 8px; font-size: 15px; }
  .sh-bar { position: relative; height: 14px; background: #f1e6d6; border-radius: 99px; overflow: hidden; display: block; min-width: 40px; }
  .sh-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; transition: width .4s; background: linear-gradient(90deg, #ff8fa3, #ff5a7a); }
  .sh-bar.happy i { background: linear-gradient(90deg, #ffd23f, #f6a23a); } .sh-bar.food i { background: linear-gradient(90deg, #c9a46a, #a5784f); }
  .sh-mini { display: grid; grid-template-columns: auto 1fr auto 1fr auto 1fr; gap: 3px 5px; align-items: center; font-size: 13px; margin: 2px 0; }
  .sh-list { display: grid; gap: 8px; }
  .sh-item { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 8px; align-items: center; background: #fff; border: 2px solid var(--sh-edge); border-radius: 14px; padding: 6px 8px; }
  .sh-item b { font-size: 16px; } .sh-item small { display: block; color: var(--sh-soft); font-size: 13px; line-height: 1.25; } .sh-item small.sh-inline { display: inline; }
  .sh-item .sh-big { min-width: 0; flex: none; padding: 4px 10px; font-size: 16px; }
  .sh-item.got { background: #f0f9f2; }
  .sh-icon { font-size: 30px; text-align: center; line-height: 1; }
  .sh-dogicon { width: 44px; height: 44px; display: grid; place-items: center; font-size: 26px; border-radius: 50%; background: var(--c, #e9c27a); border: 3px solid rgba(58,46,40,.35); }
  .sh-gotit { font-size: 24px; color: var(--sh-green); font-weight: 800; padding: 0 8px; }
  .sh-stars { color: #f0a417; font-size: 18px; letter-spacing: 1px; white-space: nowrap; } .sh-stars i { font-style: normal; color: #e3d9cc; }
  .sh-say { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 6px; }
  .sh-face { flex: none; width: 60px; height: 60px; display: grid; place-items: center; font-size: 36px; background: #fdeee0; border: 3px solid var(--sh-edge); border-radius: 50%; }
  .sh-quote { font-size: 17px; font-style: italic; }
  .sh-win { text-align: center; }
  .sh-bigface { font-size: 60px; line-height: 1.2; }
  .sh-gain { font-size: 24px; font-weight: 800; color: var(--sh-green); }
  .sh-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
  .sh-tab { flex: 1; min-height: 44px; font: 800 15px "Baloo 2", sans-serif; color: var(--sh-ink); background: #fdeee0; border: 3px solid var(--sh-edge); border-radius: 12px; cursor: pointer; }
  .sh-tab.on { background: #c9503f; border-color: var(--sh-ink); color: #fff; }
  .sh-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; } .sh-stats span { background: #fdeee0; border-radius: 10px; padding: 2px 8px; }
  @media (orientation: landscape) and (max-height: 520px) {
    .sh-care { padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 4px; }
    .sh-head h2 { font-size: 17px; } .sh-x { width: 38px; height: 38px; }
    .sh-q { font-size: 28px; } .sh-ans { min-height: 34px; line-height: 30px; font-size: 26px; } .sh-pad .key { font-size: 20px; padding: 0; min-height: 36px; } .sh-pad { gap: 4px; margin-top: 3px; }
    .sh-story { font-size: 13px; min-height: 0; } .sh-fix { font-size: 13px; min-height: 16px; } .sh-sub { font-size: 13px; }
    .sh-steps { gap: 2px; margin: 2px 0; } .sh-step { min-height: 40px; font-size: 10px; } .sh-step span { font-size: 16px; }
    .sh-meters > div { grid-template-columns: 90px 1fr; font-size: 13px; } .sh-stepname { font-size: 15px; margin: 2px 0 !important; } .sh-body p { margin-bottom: 3px; }
  }
  /* A phone on its side: the sum and the number pad side by side, and only what you need. */
  @media (orientation: landscape) and (max-height: 430px) {
    .sh-head { min-height: 50px; }
    .sh-ask { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 6px; align-items: center; }
    .sh-pad { margin-top: 0; } .sh-pad .key { min-height: 34px; font-size: 19px; }
    .sh-q { font-size: 26px; } .sh-ans { width: 90%; }
    .sh-care[data-kind="care"] .sh-sub, .sh-care[data-kind="care"] .sh-stepname, .sh-care[data-kind="care"] .sh-meters { display: none; }
  }
  /* A phone held upright: a taller, tighter window so the whole number pad fits under the dog. */
  @media (orientation: portrait) and (max-width: 560px) {
    :root { --sh-h: 70vh; }
    .sh-care { padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
    .sh-head { margin-bottom: 2px; } .sh-head h2 { font-size: 18px; } .sh-x { width: 38px; height: 38px; } .sh-purse span { font-size: 14px; }
    .sh-q { font-size: 30px; } .sh-ans { min-height: 34px; line-height: 30px; font-size: 26px; width: 60%; margin-top: 2px; }
    .sh-pad .key { font-size: 21px; padding: 0; min-height: 38px; } .sh-pad { gap: 4px; margin-top: 3px; }
    .sh-story { font-size: 12.5px; min-height: 0; } .sh-fix { font-size: 13px; min-height: 16px; margin-top: 1px !important; } .sh-qcard { padding: 2px 6px; }
    .sh-care[data-kind="care"] .sh-sub, .sh-care[data-kind="care"] .sh-stepname { display: none; }
    .sh-meters { grid-template-columns: 1fr 1fr; gap: 2px 8px; margin: 2px 0; } .sh-meters > div { grid-template-columns: auto 1fr; gap: 4px; font-size: 12.5px; }
    .sh-steps { gap: 2px; margin: 3px 0; } .sh-step { min-height: 38px; font-size: 9.5px; } .sh-step span { font-size: 15px; }
    .sh-body p { margin-bottom: 3px; } .sh-trust { margin: 2px 0 4px; font-size: 15px; }
  }

  /* ---------- PUZZLE MANOR ---------- */
  :root { --mn-ink: #3a2414; --mn-paper: #fbf3e0; --mn-paper-dark: #efe0bf; --mn-edge: #7a4a1a; --mn-blue: #1d4a8a; --mn-deep: #12305e; --mn-gold: #ffd84a; --mn-green: #3a9a5a; --mn-red: #c8443a; }
  .mode.manormode .mt { color: #1d4a8a; }
  body[data-screen="manorSetup"]::before { background: linear-gradient(#1d2a5a, #4a3a7a 50%, #e89a6a); }
  #manorSetup h1 { color: var(--mn-gold); text-shadow: 0 3px 0 #7a4a1a, 0 0 18px rgba(255,216,74,.45); }
  #manorSetup .sub { color: #fff4dc; text-shadow: 0 1px 0 rgba(0,0,0,.45); }
  .mn-hero { width: min(100%, 560px); aspect-ratio: 1040 / 560; margin: 0 auto 10px; border: 4px solid var(--mn-gold); border-radius: 18px; overflow: hidden; box-shadow: 0 6px 0 #7a4a1a; background: #1d2a5a; }
  .mn-hero svg { display: block; width: 100%; height: 100%; }
  .mn-summary { font-size: 18px; text-align: center; line-height: 1.4; }
  .mn-new { margin: 6px 0 10px; }
  .mn-newask p { margin: 0 0 10px; font-size: 18px; }
  .mn-modes .time .w { font-size: 14px; }
  #manorSetup [hidden] { display: none !important; }
  .mn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
  .mn-big { flex: 1; min-width: 120px; min-height: 50px; font: 800 18px "Baloo 2", sans-serif; color: #fff; background: var(--mn-blue); border: 3px solid #0e2448; border-radius: 14px;
            padding: 6px 12px; box-shadow: 0 4px 0 #0e2448; cursor: pointer; }
  .mn-big:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #0e2448; }
  .mn-big:disabled { opacity: .45; cursor: default; }
  .mn-soft { background: var(--mn-paper-dark); color: var(--mn-ink); border-color: var(--mn-edge); box-shadow: 0 4px 0 var(--mn-edge); }
  .mn-danger { background: var(--mn-red); border-color: #7a1f1a; box-shadow: 0 4px 0 #7a1f1a; }
  .mn-key { background: #c8962a; border-color: #6a4a10; box-shadow: 0 4px 0 #6a4a10; }
  .mn-go { background: var(--mn-green); border-color: #1f5a32; box-shadow: 0 4px 0 #1f5a32; }

  /* The game: a bar on top, then the floor plan and the room side by side (or one at a time on a phone). */
  #manor.on { position: fixed; inset: 0; max-width: none; padding: 0; animation: none; display: flex; flex-direction: column; overflow: hidden;
              background: radial-gradient(circle at 30% 20%, #23528f, #0f2a52); font-family: "Baloo 2", sans-serif; color: var(--mn-ink); touch-action: manipulation; }
  body[data-screen="manor"] { overflow: hidden; background: #0f2a52; }
  body[data-screen="manor"]::before { background: #0f2a52; }
  #manor [hidden], .mn-modal[hidden], .mn-modal [hidden] { display: none !important; }
  .mn-top { flex: none; display: flex; gap: 6px; align-items: center; padding: calc(6px + env(safe-area-inset-top)) calc(64px + env(safe-area-inset-right)) 6px calc(8px + env(safe-area-inset-left)); }
  .mn-hud { flex: 1; min-width: 0; display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; padding-bottom: 3px; }
  .mn-hud::-webkit-scrollbar { display: none; }
  .mn-btn, .mn-pill { font: 800 17px "Baloo 2", sans-serif; color: var(--mn-ink); background: var(--mn-paper); border: 3px solid var(--mn-edge); border-radius: 12px;
                      padding: 0 9px; box-shadow: 0 3px 0 var(--mn-edge); display: inline-flex; align-items: center; gap: 4px; min-height: 40px; white-space: nowrap; flex: none; }
  .mn-btn { cursor: pointer; min-width: 46px; justify-content: center; font-size: 20px; }
  .mn-pill b { font-size: 19px; }
  .mn-pill.mn-steps { background: #d8f0ff; } .mn-pill.mn-steps.low { background: #ffd6cc; }
  .mn-codepill { background: var(--mn-gold); letter-spacing: 1px; }
  .mn-endbtn { font-size: 16px; background: #2a2a5a; color: #fff; border-color: #0e1a3a; box-shadow: 0 3px 0 #0e1a3a; }
  .mn-endbtn.pulse { background: #6a3ac0; animation: mn-throb 1.1s ease-in-out infinite; }
  @keyframes mn-throb { 50% { transform: scale(1.07); } }
  .mn-main { flex: 1; min-height: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 0 calc(10px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left)); }
  .mn-planview { min-height: 0; height: 100%; display: flex; justify-content: center; }
  .mn-planbox { height: 100%; aspect-ratio: 532 / 1086; max-width: 100%; border-radius: 14px; overflow: hidden; border: 3px solid #a8c8f0; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
  .mn-planbox svg { display: block; width: 100%; height: 100%; }
  .mn-plan .mn-go, .mn-plan .mn-room { cursor: pointer; }
  .mn-plan .mn-new rect { animation: mn-dash 1.2s linear infinite; }
  @keyframes mn-dash { to { stroke-dashoffset: -30; } }
  .mn-roomview { min-height: 0; display: flex; flex-direction: column; gap: 8px; }
  .mn-scenebox { flex: none; width: 100%; aspect-ratio: 1000 / 620; max-height: 70%; margin: 0 auto; border-radius: 16px; overflow: hidden; border: 4px solid #3a2414; box-shadow: 0 8px 24px rgba(0,0,0,.45); background: #2a170c; }
  .mn-scenebox svg { display: block; width: 100%; height: 100%; }
  .mn-scene .mn-obj, .mn-scene .mn-door { cursor: pointer; }
  .mn-scene .mn-obj:not(.done):hover, .mn-scene .mn-door:hover { filter: brightness(1.12); }
  .mn-spark { animation: mn-twinkle 1.6s ease-in-out infinite; }
  @keyframes mn-twinkle { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }
  .mn-pulse { animation: mn-twinkle 1.4s ease-in-out infinite; }
  .mn-roominfo { flex: 1; min-height: 0; overflow-y: auto; background: var(--mn-paper); border: 4px solid var(--mn-edge); border-radius: 16px; padding: 8px 12px; box-shadow: 0 6px 0 rgba(0,0,0,.25); }
  .mn-roomhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .mn-roomhead h2 { margin: 0; font-size: 24px; line-height: 1.1; color: var(--mn-blue); }
  .mn-tag { font-size: 13px; font-weight: 800; border-radius: 8px; padding: 0 8px; color: var(--mn-ink); white-space: nowrap; }
  .mn-roomtext { margin: 2px 0 6px; font-size: 16px; line-height: 1.25; color: #6a5040; }
  .mn-things { display: flex; flex-wrap: wrap; gap: 6px; }
  .mn-thing, .mn-way { min-height: 46px; font: 800 17px "Baloo 2", sans-serif; color: var(--mn-ink); background: #fff6d0; border: 3px solid #c48a12; border-radius: 12px; padding: 2px 12px; cursor: pointer; box-shadow: 0 3px 0 #c48a12; }
  .mn-thing.done { background: #e6f6e8; border-color: #8ac49a; box-shadow: none; color: #4a7a5a; }
  .mn-ways { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; margin-top: 2px; }
  .mn-way { background: #e2ecfa; border-color: #5a7ab0; box-shadow: 0 3px 0 #5a7ab0; font-size: 15px; min-height: 42px; }
  .mn-way.new { background: #fff; border-style: dashed; } .mn-way.locked { background: #f6e6d0; border-color: #a8743f; box-shadow: 0 3px 0 #a8743f; }
  .mn-tabs { display: none; }
  .mn-toast { position: fixed; z-index: 50; left: 50%; top: calc(58px + env(safe-area-inset-top)); transform: translate(-50%, -14px); opacity: 0; pointer-events: none; max-width: min(90%, 560px); text-align: center;
              font: 700 18px "Baloo 2", sans-serif; background: var(--mn-paper); color: var(--mn-ink); border: 3px solid var(--mn-edge); border-radius: 14px; padding: 5px 14px; box-shadow: 0 4px 0 var(--mn-edge); transition: opacity .25s, transform .25s; }
  .mn-toast.on { opacity: 1; transform: translate(-50%, 0); }
  /* Phones and narrow screens: one view at a time, with tabs at the bottom. */
  @media (max-width: 899px), (max-aspect-ratio: 1/1), (max-height: 520px) {
    .mn-main { grid-template-columns: minmax(0, 1fr); padding-bottom: 6px; }
    .mn-main[data-tab="plan"] .mn-roomview, .mn-main[data-tab="room"] .mn-planview { display: none; }
    .mn-tabs { display: flex; gap: 8px; flex: none; padding: 0 calc(10px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left)); }
    .mn-tab { flex: 1; min-width: 0; min-height: 50px; font: 800 18px "Baloo 2", sans-serif; color: var(--mn-ink); background: var(--mn-paper-dark); border: 3px solid var(--mn-edge); border-radius: 14px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .mn-tab.on { background: var(--mn-gold); box-shadow: 0 3px 0 var(--mn-edge); }
    .mn-endbtn span { display: none; }
    .mn-scenebox { max-height: 58%; }
  }
  @media (max-width: 899px) and (min-aspect-ratio: 1/1) {
    /* A phone on its side: the room picture beside its buttons. */
    .mn-roomview { flex-direction: row; } .mn-scenebox { width: auto; height: 100%; max-height: none; } .mn-roominfo { flex: 1; }
  }
  @media (max-width: 640px) {
    .mn-top { flex-wrap: wrap; row-gap: 4px; }
    .mn-hud { order: 5; flex-basis: 100%; justify-content: space-between; overflow: visible; padding-bottom: 2px; }
    .mn-top #mnBook { margin-left: auto; } .mn-toast { top: calc(104px + env(safe-area-inset-top)); }
  }
  @media (max-width: 420px) { .mn-hud { gap: 3px; } .mn-pill { font-size: 15px; padding: 0 6px; min-height: 36px; } .mn-pill b { font-size: 17px; } .mn-btn { min-height: 38px; min-width: 40px; } .mn-codepill { display: none; } }

  /* Windows. */
  .mn-modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(10,20,45,.6);
              padding: calc(10px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left)); }
  .mn-board { position: relative; display: flex; flex-direction: column; width: 100%; max-width: 620px; max-height: 100%; background: var(--mn-paper); color: var(--mn-ink);
              border: 6px solid var(--mn-edge); border-radius: 22px; box-shadow: 0 10px 0 #2a170c, 0 20px 40px rgba(0,0,0,.4); padding: 14px 16px; font-family: "Baloo 2", sans-serif; animation: pop .25s ease-out; }
  .mn-board.mn-wide { max-width: 900px; }
  .mn-board h2 { margin: 0 48px 4px 0; font-size: 26px; line-height: 1.15; color: var(--mn-blue); }
  .mn-body { overflow-y: auto; overscroll-behavior: contain; min-height: 0; font-size: 18px; }
  .mn-body p { margin: 0 0 8px; line-height: 1.35; }
  .mn-x { position: absolute; top: 8px; right: 8px; width: 46px; height: 46px; border-radius: 12px; border: 3px solid var(--mn-edge); background: var(--mn-paper-dark); font: 800 19px "Baloo 2", sans-serif; color: var(--mn-ink); cursor: pointer; z-index: 2; }
  .mn-sub { color: #7a6050; font-size: 16px; margin: 0 0 6px; }
  .mn-h3 { margin: 10px 0 6px; font-size: 19px; color: var(--mn-edge); }
  .mn-letter { background: #fffaf0 repeating-linear-gradient(transparent 0 31px, #e4d6b8 31px 32px); border: 2px solid #e0cfa8; border-radius: 6px; padding: 10px 16px; font-family: "Patrick Hand", "Baloo 2", cursive; font-size: 22px; color: #3a2a5a; box-shadow: 0 4px 12px rgba(0,0,0,.12); transform: rotate(-.6deg); margin-bottom: 8px; }
  .mn-letter p { line-height: 32px; margin: 0; }
  .mn-sign { text-align: right; }
  .mn-dials { display: flex; justify-content: center; gap: 14px; margin: 6px 0 10px; }
  .mn-dials span { width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center; font: 400 34px Bungee, "Baloo 2", sans-serif; color: #c9ccd2; background: #4a525c; border: 5px solid #c8962a; box-shadow: inset 0 3px 8px rgba(0,0,0,.5); }
  .mn-dials span.on { color: #7aff9a; } .mn-dials span.new { animation: mn-throb .9s ease-in-out 3; border-color: var(--mn-gold); }
  .mn-shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
  .mn-buy { display: grid; justify-items: center; gap: 2px; font: 600 15px "Baloo 2", sans-serif; color: var(--mn-ink); background: #fff; border: 3px solid var(--mn-edge); border-radius: 14px; padding: 8px; cursor: pointer; min-height: 120px; }
  .mn-buy.off { opacity: .5; } .mn-be { font-size: 34px; line-height: 1.1; } .mn-buy b { font-size: 17px; }
  .mn-cost { font-weight: 800; background: var(--mn-gold); border-radius: 8px; padding: 0 8px; }
  .mn-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); }
  .mn-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; background: #fff; border: 2px solid var(--mn-edge); border-radius: 14px; padding: 6px 10px; }
  .mn-item p { font-size: 15px; margin: 0; line-height: 1.25; } .mn-item b { font-size: 17px; } .mn-item small { color: var(--mn-blue); letter-spacing: 1px; }
  .mn-item .mn-be { text-align: center; } .mn-item .mn-big { min-width: 76px; flex: none; }
  .mn-item.have { background: #effbef; border-color: var(--mn-green); }
  .mn-planitem svg { width: 56px; height: 56px; border-radius: 8px; }
  .mn-have { font-weight: 800; color: var(--mn-green); white-space: nowrap; font-size: 15px; }
  .mn-sticky { position: sticky; bottom: 0; background: var(--mn-paper); padding-top: 6px; margin-top: 8px; }
  .mn-night { display: flex; gap: 12px; align-items: center; background: linear-gradient(#1d2a5a, #3a3a7a); color: #fff4dc; border-radius: 14px; padding: 8px 14px; }
  .mn-night span { font-size: 44px; } .mn-night p { margin: 0; }
  .mn-learned { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 4px; } .mn-learned li { background: #fff; border-radius: 10px; padding: 4px 10px; border: 2px solid var(--mn-paper-dark); }
  .mn-stars { font-size: 22px; font-weight: 800; color: #a8740a; margin: 8px 0 4px !important; } .mn-stars small { font-size: 15px; color: #7a6050; }
  .mn-tip { background: #e2ecfa; border-radius: 10px; padding: 6px 10px; }
  .mn-notes { display: flex; flex-wrap: wrap; gap: 6px; }
  .mn-note { font: 700 15px "Baloo 2", sans-serif; background: #fffaf0; border: 2px solid #e0cfa8; border-radius: 10px; padding: 4px 10px; cursor: pointer; color: var(--mn-ink); min-height: 40px; }
  .mn-note.off { opacity: .5; cursor: default; display: inline-flex; align-items: center; }
  .mn-winscene { max-height: none; margin-bottom: 8px; }

  /* Drafting: a blueprint table. */
  .mn-bp { background: #1d4a8a; background-image: linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px); background-size: 20px 20px;
           border-color: #a8c8f0; color: #fff; max-width: 860px; box-shadow: 0 10px 0 #0e2448, 0 20px 40px rgba(0,0,0,.4); }
  .mn-bp h2 { color: #fff; font-family: "Patrick Hand", "Baloo 2", sans-serif; font-size: 32px; font-weight: 400; }
  .mn-bp .mn-sub { color: #cfe2ff; }
  .mn-bp .mn-x { background: #fff; }
  .mn-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; overflow-y: auto; min-height: 0; }
  .mn-card { display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; font: 600 15px "Baloo 2", sans-serif; color: #fff; background: rgba(255,255,255,.07);
             border: 3px solid #fff; border-radius: 14px; padding: 8px; cursor: pointer; line-height: 1.2; transition: transform .15s; }
  .mn-card:hover { transform: translateY(-3px); background: rgba(255,255,255,.14); }
  .mn-card svg { width: min(100%, 150px); aspect-ratio: 1; border-radius: 6px; }
  .mn-card b { font-family: "Patrick Hand", "Baloo 2", sans-serif; font-size: 24px; font-weight: 400; }
  .mn-card .mn-tag { color: var(--mn-ink); } .mn-card small { font-size: 14px; color: #dbe8ff; flex: 1; }
  .mn-card .mn-cost { color: var(--mn-ink); font-size: 16px; }
  .mn-card.off { opacity: .5; border-style: dashed; }

  /* The lock. */
  .mn-lockboard { max-width: 820px; background: var(--mn-paper); }
  .mn-lockboard.good { animation: mn-good .5s ease-out; } .mn-lockboard.shake { animation: shake .4s; }
  @keyframes mn-good { 40% { box-shadow: 0 10px 0 #2a170c, 0 0 0 10px rgba(122,255,154,.6); } }
  .mn-lockhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-right: 48px; }
  .mn-lockhead h2 { margin: 0; }
  .mn-pips { display: flex; gap: 5px; } .mn-pips i { width: 18px; height: 18px; border-radius: 50%; background: #d8ccb8; border: 2px solid var(--mn-edge); }
  .mn-pips i.on { background: var(--mn-green); } .mn-pips i.now { background: var(--mn-gold); }
  .mn-lockbody { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 290px); gap: 14px; align-items: center; min-height: 0; overflow-y: auto; }
  .mn-lockleft { display: flex; flex-direction: column; align-items: center; min-width: 0; }
  .mn-pzart-box { width: 100%; display: flex; justify-content: center; }
  .mn-pzart { display: block; max-width: 100%; max-height: 190px; }
  .mn-clockart { width: 170px; }
  .mn-frames { display: flex; gap: 12px; } .mn-frames .mn-pzart { width: 120px; }
  .mn-qrow { display: flex; gap: 8px; align-items: center; min-height: 6px; }
  .mn-hear { font-size: 20px; border: 2px solid var(--mn-edge); background: #fff; border-radius: 10px; min-width: 44px; min-height: 40px; cursor: pointer; }
  .mn-q { font-size: 40px; text-align: center; line-height: 1.2; margin: 2px 0; }
  .mn-q small { display: block; font-size: 26px; color: var(--mn-blue); }
  .mn-q .mn-seq { white-space: nowrap; } .mn-goal { color: var(--mn-red); font-size: 1.2em; }
  .mn-q .mn-pan { display: inline-block; background: #fff; border: 3px solid #c8962a; border-radius: 12px; padding: 0 10px; }
  .mn-lockboard[data-type="choice"] .mn-q, .mn-lockboard[data-type="num"] .mn-q { font-size: clamp(24px, 3.6vw, 40px); }
  .mn-ans { min-width: 150px; min-height: 64px; }
  .mn-ans .mn-dig { display: inline-block; width: 52px; height: 58px; margin: 0 4px; border-radius: 10px; background: #4a525c; color: #7aff9a; font: 400 36px/58px Bungee, sans-serif; vertical-align: middle; }
  .mn-fix { min-height: 26px; margin: 4px 0 0; text-align: center; font-weight: 800; font-size: 18px; }
  .mn-fix.good { color: var(--mn-green); } .mn-fix.bad { color: var(--mn-red); }
  .mn-pad .key { font-size: 30px; padding: 4px 0; background: #fff8e4; box-shadow: 0 4px 0 var(--mn-paper-dark); border: 2px solid #ead8b0; }
  .mn-pad .key.del { background: #f19a8e; } .mn-pad .key.ok { background: #8fd06b; }
  .mn-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .mn-choice { min-height: 72px; font: 800 30px "Baloo 2", sans-serif; color: var(--mn-ink); background: #fff; border: 4px solid #c8962a; border-radius: 16px; box-shadow: 0 5px 0 #c8962a; cursor: pointer; }
  .mn-choice.right { background: #c8f0d0; border-color: var(--mn-green); } .mn-choice.wrong { background: #ffd6cc; border-color: var(--mn-red); }
  .mn-boxes { grid-template-columns: 1fr; }
  .mn-boxes .mn-choice { display: flex; align-items: center; gap: 12px; font-size: 26px; min-height: 64px; padding: 0 12px; }
  .mn-boxl { width: 44px; height: 44px; border-radius: 8px; display: grid; place-items: center; color: #fff; font: 400 22px Bungee, sans-serif; flex: none; }
  .mn-boxes .mn-choice:nth-child(1) .mn-boxl { background: #c43a4a; } .mn-boxes .mn-choice:nth-child(2) .mn-boxl { background: #3a6ac4; } .mn-boxes .mn-choice:nth-child(3) .mn-boxl { background: #3a9a5a; }
  .mn-lockboard[data-type="spell"] .mn-lockbody { grid-template-columns: 1fr; }
  .mn-lockboard[data-type="spell"] .mn-lockleft { display: none; }
  .mn-lockbtns .mn-big { min-height: 46px; font-size: 16px; }
  @media (max-width: 640px), (max-height: 560px) {
    .mn-lockbody { grid-template-columns: minmax(0, 1fr); gap: 6px; }
    .mn-pzart { max-height: 130px; } .mn-clockart { width: 130px; }
    .mn-q { font-size: 30px; } .mn-pad .key { font-size: 26px; padding: 2px 0; } .mn-pad { gap: 6px; }
    .mn-board { padding: 10px 12px; } .mn-board h2 { font-size: 21px; }
    .mn-cards { grid-template-columns: 1fr; } .mn-card { display: grid; grid-template-columns: 84px 1fr; text-align: left; justify-items: start; column-gap: 10px; }
    .mn-card svg { grid-row: span 4; width: 84px; } .mn-card small { font-size: 13px; }
  }
  @media (max-height: 560px) and (min-aspect-ratio: 1/1) {
    .mn-lockbody { grid-template-columns: minmax(0, 1fr) minmax(200px, 260px); }
    .mn-pzart { max-height: 100px; } .mn-pad .key { font-size: 22px; padding: 0; } .mn-ans { min-height: 48px; } .mn-q { font-size: 24px; }
    .mn-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } .mn-card { display: flex; } .mn-card svg { width: 70px; } .mn-card small { display: none; }
  }

  /* Spelling (spelling.js): a picture, a hint, letter boxes and a big keyboard. Any game can use it. */
  .sp-box { display: flex; flex-direction: column; gap: 8px; align-items: center; font-family: "Baloo 2", sans-serif; color: var(--ink); }
  .sp-top { display: flex; gap: 14px; align-items: center; justify-content: center; width: 100%; }
  .sp-pic { font-size: 84px; line-height: 1; width: 120px; height: 120px; display: grid; place-items: center; background: #fff; border-radius: 22px; border: 4px solid #e0cfa8; box-shadow: 0 4px 0 #e0cfa8; flex: none; }
  .sp-pic { padding: 4px; } .sp-pic svg { display: block; width: 100%; height: 100%; }
  .sp-say { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; max-width: 380px; }
  .sp-hint { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.2; }
  .sp-hear { font: 700 16px "Baloo 2", sans-serif; border: 2px solid #c8962a; background: #fff6d0; border-radius: 10px; padding: 2px 12px; min-height: 40px; cursor: pointer; }
  .sp-letters { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; min-height: 64px; }
  .sp-l { width: 54px; height: 62px; border-radius: 10px; background: #fff; border: 3px solid #b8c4d8; border-bottom-width: 6px; display: grid; place-items: center; font: 800 38px "Baloo 2", sans-serif; color: #2a3a6a; }
  .sp-l.in { border-color: #5a7ab0; }
  .sp-l.shown { background: #fff6c8; border-color: #e0a020; color: #a05a00; animation: sp-show .45s backwards; animation-delay: calc(var(--i) * .3s); }
  .sp-l.sp-extra { width: auto; padding: 0 8px; border-color: var(--red); color: var(--red); }
  @keyframes sp-show { from { transform: scale(.3) translateY(10px); opacity: 0; } }
  .right .sp-l { background: #c8f0d0; border-color: #3a9a5a; }
  .sp-msg { margin: 0; min-height: 26px; font-size: 19px; font-weight: 800; color: #6a7a90; text-align: center; }
  .sp-msg.good { color: #2a8a4a; } .sp-msg.show { color: #a05a00; }
  .sp-ready { font: 800 22px "Baloo 2", sans-serif; background: #3a9a5a; color: #fff; border: 3px solid #1f5a32; border-radius: 14px; box-shadow: 0 4px 0 #1f5a32; padding: 4px 22px; min-height: 52px; cursor: pointer; animation: mn-throb 1.2s ease-in-out infinite; }
  .sp-keys { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 720px; }
  .sp-row { display: flex; gap: 5px; justify-content: center; }
  .sp-key { flex: 1; max-width: 64px; min-width: 0; height: 56px; font: 800 26px "Baloo 2", sans-serif; color: var(--ink); background: #fff; border: 2px solid #d8d0c0; border-radius: 10px; box-shadow: 0 4px 0 #d8d0c0; cursor: pointer; padding: 0; }
  .sp-key:active { transform: translateY(3px); box-shadow: 0 1px 0 #d8d0c0; }
  .sp-del { background: #f19a8e; max-width: 84px; flex: 1.4; } .sp-ok { background: #8fd06b; max-width: 84px; flex: 1.4; }
  @media (max-width: 640px) { .sp-pic { width: 92px; height: 92px; font-size: 64px; } .sp-hint { font-size: 18px; } .sp-l { width: 40px; height: 48px; font-size: 28px; } .sp-key { height: 50px; font-size: 21px; } .sp-row { gap: 4px; } }
  @media (max-height: 560px) { .sp-pic { width: 76px; height: 76px; font-size: 52px; } .sp-l { width: 40px; height: 46px; font-size: 26px; } .sp-letters { min-height: 46px; } .sp-key { height: 40px; font-size: 19px; } .sp-keys { gap: 4px; } .sp-box { gap: 4px; } }
  @media (prefers-reduced-motion: reduce) { .mn-spark, .mn-pulse, .mn-endbtn.pulse, .sp-ready, .mn-plan .mn-new rect { animation: none; } .sp-l.shown { animation: none; } }

  /* ---------- Skill Quest ---------- */
  /* The start screen (zoomed like the others) and the world: full screen like Tiny Planet, never zoomed. */
  .mode.questmode .mt { color: #3d5a9a; }
  body[data-screen="questSetup"]::before { background: linear-gradient(#a9d8f0, #e6f2d8 55%, #d8e8b8); }
  #questSetup h1 { color: #fff; text-shadow: 0 3px 0 #3d5a9a, 0 0 14px rgba(61,90,154,.45); }
  #questSetup .sub, #questSetup .best { color: #2f3a4a; text-shadow: none; }
  .qs-hero { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; max-width: 420px; margin: 0 auto 12px; }
  .qs-hero span { position: relative; display: grid; place-items: center; aspect-ratio: 1; background: #fffdf6; border: 3px solid #2b2d3c; border-radius: 14px; box-shadow: 3px 3px 0 #2b2d3c; }
  .qs-hero span:nth-child(odd) { transform: rotate(-2deg); } .qs-hero span:nth-child(even) { transform: rotate(2deg); }
  .qs-hero .qi { width: 62%; height: 62%; }
  .qs-hero b { position: absolute; right: -6px; bottom: -6px; min-width: 28px; padding: 0 5px; border-radius: 99px; background: var(--c); color: #fff; border: 2px solid #2b2d3c; font: 800 16px/24px "Baloo 2", sans-serif; text-align: center; }
  #qsSummary { grid-template-columns: repeat(4, 1fr); }
  .qs-namecard { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .qs-namecard label { font-weight: 800; font-size: 18px; }
  .qs-namecard input { flex: 1; min-width: 140px; font: 700 20px "Baloo 2", sans-serif; padding: 6px 10px; border: 3px solid #2b2d3c; border-radius: 10px; }
  .qi { width: 1.15em; height: 1.15em; vertical-align: -.22em; flex: none; }
  body[data-screen="quest"] { overflow: hidden; }
  body[data-screen="quest"]::before { background: #9fd6ec; }
  #quest.on { position: fixed; inset: 0; max-width: none; padding: 0; animation: none; overflow: hidden; touch-action: none; -webkit-user-select: none; user-select: none; }
  #quest [hidden] { display: none !important; }
  #qsCanvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; touch-action: none; }
  #quest .dv-stick.rest .dv-knob::after { content: "👟"; }
  #quest .pl-btn .qi { width: 34px; height: 34px; }
  #qsGuide.off { opacity: .55; }
  .qs-top { gap: 8px; }
  .qs-chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; }
  .qs-chip .qi { width: 24px; height: 24px; }
  .qs-hp { background: #fde0e0; transform: rotate(2deg); } .qs-hp.low { animation: qslow 1s ease-in-out infinite alternate; }
  @keyframes qslow { to { background: #ff9a9a; } }
  .qs-tot { background: #fff2c2; transform: rotate(-1deg); }
  .qs-bagbtn.full { background: #ffd0c8; }
  .qs-bagn { position: absolute; z-index: 4; right: calc(8px + env(safe-area-inset-right)); top: calc(130px + env(safe-area-inset-top)); font: 800 13px "Baloo 2", sans-serif; color: #fff; background: #d4544b; border-radius: 99px; padding: 0 6px; pointer-events: none; }
  .qs-bagn:empty { display: none; }
  .qs-decor { position: absolute; z-index: 4; right: calc(108px + env(safe-area-inset-right)); bottom: calc(26px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 6px;
              font: 800 18px "Baloo 2", sans-serif; background: #ffe7a8; color: #2b2d3c; border: 3px solid #2b2d3c; border-radius: 12px; box-shadow: 4px 4px 0 #2b2d3c; padding: 6px 12px; cursor: pointer; }
  .qs-decor .qi { width: 30px; height: 30px; }
  .qs-act { display: inline-flex; align-items: center; gap: 8px; max-width: calc(100vw - 200px); }
  .qs-act span { overflow: hidden; text-overflow: ellipsis; }
  .qs-act .qi { width: 30px; height: 30px; }
  .qs-act.locked { background: #d9d4cc; }
  .qs-goal { max-width: min(40vw, 340px); }
  .qs-loading { background: linear-gradient(#9fd6ec, #e6f2d8); }
  #quest.mapping .pl-side, #quest.mapping .pl-place, #quest.mapping .dv-stick, #quest.mapping .pl-act, #quest.mapping .pl-jump, #quest.mapping .qs-decor,
  #quest.mapping .pl-toast, #quest.mapping .pl-coins, #quest.mapping .qs-goal, #quest.mapping .qs-bagn { display: none !important; }
  .qs-pin .sh-pin-e .qi { width: 82%; height: 82%; }
  .qs-pin .sh-pin-e { background: #fffdf6; }
  .qs-pin.talk .sh-pin-e { background: #ffd84d; }
  .qs-map-key .qi { width: 1.3em; height: 1.3em; }
  .pl-ml .qi { width: 1.2em; height: 1.2em; }
  /* Short screens (a phone on its side): the buttons down the side in two columns, smaller. */
  @media (max-height: 560px) {
    .qs-side-btns { grid-template-columns: repeat(2, 46px); gap: 8px; top: calc(66px + env(safe-area-inset-top)); }
    .qs-side-btns .pl-btn { width: 46px; height: 46px; box-shadow: 3px 3px 0 #2b2d3c; }
    #quest .pl-btn .qi { width: 28px; height: 28px; }
    .qs-bagn { top: calc(60px + env(safe-area-inset-top)); right: calc(66px + env(safe-area-inset-right)); }
    .qs-chip { font-size: 17px; padding: 3px 8px; } .qs-chip .qi { width: 20px; height: 20px; }
    #qsBack { width: 46px; height: 46px; }
    .qs-goal { top: calc(62px + env(safe-area-inset-top)); font-size: 15px; }
  }
  @media (max-width: 520px) {
    .qs-top { gap: 6px; } .qs-chip { font-size: 16px; padding: 3px 7px; } .qs-chip .qi { width: 19px; height: 19px; }
    #qsBack { width: 46px; height: 46px; }
    .qs-side-btns { gap: 8px; } .qs-side-btns .pl-btn { width: 48px; height: 48px; }
    .qs-act { font-size: 15px; padding: 8px 14px; max-width: calc(100vw - 130px); }
    .qs-decor { right: auto; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom)); }
    .qs-goal { max-width: calc(100vw - 100px); }
  }

  /* A window open: at the side (landscape) or the bottom (portrait), the 3D view shrinks to the rest. */
  :root { --qs-w: min(460px, 52vw); --qs-h: 62vh; --qs-ink: #2b2d3c; --qs-soft: #5d6577; --qs-paper: #fbfaf4; --qs-edge: #b9c3d6; --qs-blue: #3d6fd0; --qs-red: #d4544b; --qs-green: #2f9a5a; }
  .qs-win { position: absolute; z-index: 6; right: 0; top: 0; bottom: 0; width: var(--qs-w); display: flex; flex-direction: column; background: var(--qs-paper);
            border-left: 5px solid var(--qs-ink); padding: calc(8px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) 12px;
            font-family: "Baloo 2", sans-serif; color: var(--qs-ink); box-shadow: -6px 0 0 rgba(43,45,60,.25); overflow: hidden; }
  #quest.qs-side #qsCanvas { width: calc(100% - var(--qs-w)); }
  #quest.qs-side .pl-side, #quest.qs-side .pl-jump, #quest.qs-side .dv-stick, #quest.qs-side .qs-goal, #quest.qs-side .pl-act, #quest.qs-side .qs-decor, #quest.qs-side .qs-bagn { display: none !important; }
  @media (orientation: portrait) {
    .qs-win { left: 0; right: 0; top: auto; width: auto; height: var(--qs-h); border-left: 0; border-top: 5px solid var(--qs-ink); box-shadow: 0 -6px 0 rgba(43,45,60,.25);
              padding-left: calc(10px + env(safe-area-inset-left)); }
    #quest.qs-side #qsCanvas { width: 100%; height: calc(100% - var(--qs-h)); }
  }
  .qs-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; min-width: 0; }
  /* (Room on the right of the window's title bar for the page's sound button, which sits in that corner.) */
  @media (orientation: landscape) { .qs-head { padding-right: 58px; } }
  .qs-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 22px; line-height: 1.2; color: var(--qs-blue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
  .qs-head h2 > .qi { width: 34px; height: 34px; }
  .qs-head h2 small { font-size: 15px; color: var(--qs-soft); }
  .qs-head h2 span { overflow: hidden; text-overflow: ellipsis; }
  .qs-face { width: 40px; height: 40px; border-radius: 50%; background: #e6eef8; border: 2px solid var(--qs-ink); flex: none; }
  .qs-purse span { display: inline-flex; align-items: center; gap: 3px; background: #fff2c2; border: 2px solid var(--qs-edge); border-radius: 10px; padding: 0 8px; font-weight: 800; font-size: 16px; white-space: nowrap; }
  .qs-x { flex: none; width: 44px; height: 44px; border-radius: 12px; border: 3px solid var(--qs-ink); background: #eef2f8; font: 800 18px "Baloo 2", sans-serif; cursor: pointer; color: var(--qs-ink); }
  .qs-body { overflow-y: auto; overscroll-behavior: contain; min-height: 0; flex: 1 1 auto; }
  .qs-body p { margin: 0 0 6px; line-height: 1.3; }
  .qs-body h3 { margin: 10px 0 4px; font-size: 17px; display: flex; align-items: center; gap: 6px; }
  .qs-sub { color: var(--qs-soft); font-size: 15px; }
  .qs-why { color: var(--qs-red); font-weight: 700; }
  .qs-done { font-size: 18px; font-weight: 700; }
  .qs-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
  .qs-big { flex: 1; min-width: 96px; min-height: 48px; font: 800 18px "Baloo 2", sans-serif; color: #fff; background: var(--qs-blue); border: 3px solid var(--qs-ink); border-radius: 14px;
            box-shadow: 0 4px 0 var(--qs-ink); cursor: pointer; padding: 4px 12px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
  .qs-big:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 var(--qs-ink); }
  .qs-big:disabled { background: #d6dae2; color: #f6f7fa; cursor: default; }
  .qs-big .qi { width: 22px; height: 22px; }
  .qs-soft { background: #eef2f8; color: var(--qs-ink); }
  .qs-mini { flex: none; min-width: 0; min-height: 40px; font-size: 16px; padding: 2px 10px; }
  .qs-qcard { background: #fff; border: 3px solid var(--qs-edge); border-radius: 16px; padding: 4px 8px; text-align: center; }
  .qs-qcard.good { animation: good .4s; }
  .qs-story { margin: 0 !important; min-height: 22px; font-size: 15px; color: var(--qs-soft); }
  .qs-q { font-size: 44px; padding: 0; }
  .qs-ans { min-height: 48px; line-height: 44px; font-size: 36px; margin: 4px auto 0; border-width: 3px; }
  .qs-fix { min-height: 22px; margin: 4px 0 0 !important; font-size: 15px; font-weight: 800; }
  .qs-fix.good { color: var(--qs-green); } .qs-fix.bad { color: var(--qs-red); }
  .qs-pad { gap: 7px; margin-top: 6px; }
  .qs-pad .key { font-size: 26px; padding: 4px 0; background: #fbfcff; border: 2px solid var(--qs-edge); box-shadow: 0 4px 0 #d3dbe8; min-height: 46px; }
  .qs-pad .key.del { background: #f7a6a0; } .qs-pad .key.ok { background: #8fdcb4; }
  .qs-ask { display: flex; flex-direction: column; gap: 4px; }
  .qs-bar { position: relative; height: 14px; background: #e3e8f0; border-radius: 99px; overflow: hidden; display: block; min-width: 40px; flex: 1; }
  .qs-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; transition: width .4s; background: linear-gradient(90deg, #7fd0ff, #3d6fd0); }
  .qs-bar.hp i { background: linear-gradient(90deg, #ff9aa8, #e9473f); } .qs-bar.mon i { background: linear-gradient(90deg, #b8e86a, #5aa94a); }
  .qs-bar.hp.low i { animation: qslow 1s ease-in-out infinite alternate; }
  .qs-skline { display: grid; grid-template-columns: 32px auto auto 1fr; grid-template-areas: "i n l b" "i s s s"; align-items: center; gap: 0 8px; background: #fff; border: 2px solid var(--qs-edge); border-radius: 12px; padding: 4px 8px; margin-bottom: 6px; }
  .qs-skline .qi { grid-area: i; width: 32px; height: 32px; } .qs-skline > b { grid-area: n; font-size: 17px; } .qs-skline .qs-lv { grid-area: l; font-weight: 800; color: #fff; background: var(--c); border-radius: 99px; padding: 0 8px; font-size: 15px; white-space: nowrap; }
  .qs-skline .qs-bar { grid-area: b; } .qs-skline small { grid-area: s; color: var(--qs-soft); font-size: 13px; line-height: 1.2; }
  .qs-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-weight: 800; font-size: 16px; margin: 0 0 6px; min-height: 26px; }
  .qs-meta span { display: inline-flex; align-items: center; gap: 4px; }
  .qs-meta .qi { width: 24px; height: 24px; }
  .qs-streak { color: #c97a00; }
  .qs-fuel { display: flex; align-items: center; gap: 6px; font-weight: 800; margin: 0 0 6px; flex-wrap: wrap; }
  .qs-fuel .qi { width: 26px; height: 26px; }
  .qs-list { display: grid; gap: 8px; }
  .qs-item { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 8px; align-items: center; background: #fff; border: 2px solid var(--qs-edge); border-radius: 14px; padding: 6px 8px; text-align: left;
             font: inherit; color: inherit; cursor: pointer; width: 100%; }
  button.qs-item:active:not(:disabled) { transform: translateY(1px); }
  .qs-item > .qi { width: 44px; height: 44px; }
  .qs-item > .qi:last-child:not(:first-child) { width: 26px; height: 26px; }
  .qs-item b { font-size: 16px; display: block; } .qs-item small { display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: center; color: var(--qs-soft); font-size: 13px; line-height: 1.25; }
  .qs-item.locked { opacity: .55; cursor: default; } .qs-item.need { background: #f6f7fa; }
  .qs-btn2 { display: flex; gap: 4px; }
  .qs-need { display: inline-flex; align-items: center; gap: 1px; font-weight: 800; color: var(--qs-red); } .qs-need.ok { color: var(--qs-green); }
  .qs-need .qi { width: 20px; height: 20px; }
  .qs-needs { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; }
  .qs-pop { position: absolute; z-index: 9; left: 50%; top: 7%; transform: translateX(-50%); background: #fffdf2; border: 3px solid var(--qs-ink); border-radius: 12px; padding: 2px 12px; font-weight: 800; font-size: 19px;
            display: flex; align-items: center; gap: 4px; white-space: nowrap; pointer-events: none; animation: qspop 1.4s ease-out forwards; max-width: 92%; }
  .qs-pop .qi { width: 26px; height: 26px; }
  .qs-pop.bad { background: #ffe3df; white-space: normal; font-size: 16px; } .qs-pop.big { top: 45%; background: #fff2c2; } .qs-pop.hit { top: 18%; color: #d4544b; left: 70%; } .qs-pop.heal { color: var(--qs-green); }
  @keyframes qspop { 0% { opacity: 0; translate: 0 10px; } 15% { opacity: 1; translate: 0 0; } 75% { opacity: 1; } 100% { opacity: 0; translate: 0 -30px; } }
  .qs-bars { display: grid; gap: 4px; margin: 2px 0 6px; }
  .qs-bars > div { display: grid; grid-template-columns: 26px 70px 1fr 56px; align-items: center; gap: 6px; font-size: 15px; }
  .qs-bars .qi { width: 26px; height: 26px; } .qs-bars b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .qs-bars span:last-child { text-align: right; font-weight: 800; }
  .qs-styles { display: flex; gap: 6px; margin: 0 0 4px; }
  .qs-style { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; background: #fff; border: 3px solid var(--qs-edge); border-radius: 12px; padding: 3px 6px; font: 800 15px "Baloo 2", sans-serif; color: var(--qs-ink); cursor: pointer; text-align: left; line-height: 1.1; min-height: 46px; }
  .qs-style .qi { width: 30px; height: 30px; } .qs-style small { display: flex; align-items: center; font-size: 12px; color: var(--qs-soft); gap: 1px; } .qs-style small .qi { width: 16px; height: 16px; }
  .qs-style span { min-width: 0; overflow: hidden; }
  .qs-style.on { border-color: var(--qs-blue); background: #e6efff; } .qs-style.off { opacity: .5; }
  .qs-style.qs-mini2 { flex: none; justify-content: center; padding: 3px; width: 46px; }
  .qs-flog { min-height: 22px; font-weight: 800; font-size: 16px; text-align: center; margin: 2px 0 4px !important; }
  .qs-wonbox { text-align: center; }
  .qs-wonbox > .qi { width: 96px; height: 96px; }
  .qs-wonbox .qi.big { width: 110px; height: 110px; }
  .qs-drops { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 6px 0; }
  .qs-drop { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 2px solid var(--qs-edge); border-radius: 12px; padding: 2px 8px; font-weight: 700; font-size: 15px; }
  .qs-drop .qi { width: 28px; height: 28px; } .qs-drop em { color: var(--qs-green); font-style: normal; }
  .qs-total { display: flex; align-items: center; gap: 6px; font-size: 18px; margin: 0 0 6px; } .qs-total .qi { width: 28px; height: 28px; } .qs-total b { font-size: 24px; color: var(--qs-blue); } .qs-total small { color: var(--qs-soft); }
  .qs-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .qs-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0; background: #fff; border: 3px solid var(--qs-ink); border-radius: 14px; padding: 6px 4px 6px; cursor: pointer; font: inherit; color: inherit; box-shadow: 0 3px 0 var(--qs-ink); }
  .qs-tile .qi { width: 46px; height: 46px; } .qs-tile b { position: absolute; top: 4px; right: 4px; background: var(--c); color: #fff; border-radius: 99px; min-width: 26px; padding: 0 5px; font-size: 16px; line-height: 22px; border: 2px solid var(--qs-ink); }
  .qs-tile span { font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; } .qs-tile .qs-bar { width: 90%; height: 8px; flex: none; margin-top: 3px; }
  .qs-tile .qs-bar i { background: var(--c); }
  .qs-unlocks { display: grid; gap: 4px; }
  .qs-un { display: grid; grid-template-columns: 34px 28px 1fr 22px; align-items: center; gap: 6px; background: #fff; border: 2px solid var(--qs-edge); border-radius: 10px; padding: 3px 6px; font-size: 15px; opacity: .65; }
  .qs-un.got { opacity: 1; background: #f0f9f2; } .qs-un.next { opacity: 1; border-color: var(--qs-blue); }
  .qs-un .qi { width: 26px; height: 26px; } .qs-un .qi:last-child { width: 20px; height: 20px; }
  .qs-unl { font-weight: 800; background: #e3e8f0; border-radius: 99px; text-align: center; font-size: 14px; }
  .qs-worn { display: grid; grid-template-columns: repeat(3, 64px) 1fr; gap: 8px; align-items: center; margin: 0 0 8px; }
  .qs-wslot { display: flex; flex-direction: column; align-items: center; background: #eef2f8; border: 3px solid var(--qs-ink); border-radius: 12px; padding: 4px 2px; cursor: pointer; font: inherit; color: inherit; }
  .qs-wslot .qi { width: 40px; height: 40px; } .qs-wslot small { font-size: 12px; font-weight: 800; } .qs-wnone { width: 40px; height: 40px; border: 2px dashed var(--qs-edge); border-radius: 8px; }
  .qs-stats { font-size: 14px; font-weight: 700; line-height: 1.5; } .qs-stats .qi { width: 18px; height: 18px; }
  .qs-bag { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
  .qs-slot { position: relative; aspect-ratio: 1; display: grid; place-items: center; background: #fff; border: 2px solid var(--qs-edge); border-radius: 8px; padding: 2px; cursor: pointer; min-height: 36px; }
  .qs-slot .qi { width: 86%; height: 86%; } .qs-slot i { position: absolute; right: 1px; bottom: -1px; font: 800 12px "Baloo 2", sans-serif; font-style: normal; background: #2b2d3c; color: #fff; border-radius: 6px; padding: 0 3px; line-height: 15px; }
  .qs-slot.empty { background: #f0f2f6; border-style: dashed; cursor: default; } .qs-slot.sel { border: 3px solid var(--qs-blue); background: #e6efff; }
  .qs-detail { display: flex; align-items: center; gap: 8px; margin: 6px 0; background: #fff; border: 2px solid var(--qs-blue); border-radius: 12px; padding: 6px 8px; flex-wrap: wrap; }
  .qs-detail:empty { display: none; }
  .qs-detail > .qi { width: 46px; height: 46px; } .qs-detail > div { flex: 1; min-width: 120px; } .qs-detail b { display: block; } .qs-detail small { color: var(--qs-soft); }
  .qs-detail > .qs-dbtns { display: flex; gap: 6px; flex: none; min-width: 0; }
  .qs-tabs { display: flex; gap: 4px; margin: 0 0 8px; flex-wrap: wrap; }
  .qs-tab { flex: 1; min-height: 40px; font: 800 15px "Baloo 2", sans-serif; background: #eef2f8; color: var(--qs-ink); border: 3px solid var(--qs-edge); border-radius: 12px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 3px; white-space: nowrap; padding: 0 6px; }
  .qs-tab .qi { width: 18px; height: 18px; } .qs-tab.on { background: var(--qs-blue); color: #fff; border-color: var(--qs-ink); } .qs-tab.locked { opacity: .65; }
  .qs-say { font-size: 17px; font-style: italic; } .qs-who { font-weight: 800; color: var(--qs-soft); margin: 0 !important; }
  .qs-prog { display: flex; align-items: center; gap: 8px; font-size: 16px; margin: 4px 0; }
  .qs-qrow { display: grid; gap: 2px; background: #fff; border: 2px solid var(--qs-edge); border-radius: 12px; padding: 6px 8px; margin: 0 0 6px; }
  .qs-qrow.ready { border-color: var(--qs-green); background: #f0f9f2; } .qs-qrow em { color: var(--qs-green); font-weight: 800; font-style: normal; } .qs-qrow small { color: var(--qs-soft); }
  .qs-qrow .qs-big { justify-self: start; }
  .qs-room { background: #d9b07a; border: 4px solid #8e5a4c; border-radius: 10px; padding: 6px; display: grid; gap: 6px; }
  .qs-wallrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; background: #f2e6d0; border-radius: 6px; padding: 4px; }
  .qs-floor { display: grid; gap: 6px; }
  .qs-doorrow { text-align: center; font-size: 12px; font-weight: 800; color: #5a4636; }
  .qs-cell { aspect-ratio: 1; display: grid; place-items: center; border: 2px dashed rgba(90,70,54,.45); border-radius: 8px; background: rgba(255,255,255,.18); cursor: pointer; padding: 2px; min-height: 40px; }
  .qs-cell.wall { aspect-ratio: 1.5; background: rgba(255,255,255,.5); }
  .qs-cell.full { border-style: solid; border-color: #5a4636; background: rgba(255,255,255,.55); }
  .qs-cell.fit { border: 3px solid #ffd84d; background: rgba(255,216,77,.35); } .qs-cell.sel { border: 3px solid var(--qs-blue); background: #e6efff; }
  .qs-cell span { display: grid; place-items: center; width: 100%; height: 100%; } .qs-cell .qi { width: 82%; height: 82%; }
  @media (max-height: 560px) and (orientation: landscape) { .qs-cell { min-height: 30px; } .qs-cell.wall { aspect-ratio: 2.2; } .qs-floor .qs-cell { aspect-ratio: 1.6; } }
  /* Level up! */
  .qs-level { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(20,24,40,.55); padding: 16px; }
  .qs-lvcard { width: min(92vw, 420px); max-height: calc(100% - 20px); overflow-y: auto; background: #fffdf4; border: 5px solid var(--qs-ink); border-radius: 22px; box-shadow: 0 8px 0 var(--qs-ink); padding: 14px 16px; text-align: center;
               font-family: "Baloo 2", sans-serif; color: var(--qs-ink); animation: qslv .5s cubic-bezier(.2,1.6,.4,1); }
  @keyframes qslv { from { transform: scale(.4) rotate(-6deg); opacity: 0; } to { transform: none; opacity: 1; } }
  .qs-lvicon { width: 96px; height: 96px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--c); border: 4px solid var(--qs-ink); }
  .qs-lvicon .qi { width: 70%; height: 70%; filter: drop-shadow(0 2px 0 rgba(0,0,0,.3)); }
  .qs-lvcard h2 { font-family: "Bungee", "Arial Black", sans-serif; font-size: 44px; margin: 6px 0 0; color: var(--c); text-shadow: 2px 2px 0 var(--qs-ink); line-height: 1.1; }
  .qs-lvskill { font-size: 24px; font-weight: 800; margin: 0 0 6px; }
  .qs-lvun { display: grid; gap: 4px; margin: 6px 0; } .qs-lvun span { display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 700; font-size: 16px; background: #fff2c2; border-radius: 10px; padding: 2px 8px; }
  .qs-lvun .qi { width: 26px; height: 26px; }
  .qs-lvtot { color: var(--qs-soft); font-weight: 800; } .qs-lvtot .qi { width: 22px; height: 22px; }
  @media (max-height: 500px) { .qs-lvicon { width: 64px; height: 64px; } .qs-lvcard h2 { font-size: 32px; } .qs-lvskill { font-size: 19px; } }
  @media (prefers-reduced-motion: reduce) { .qs-lvcard, .qs-pop { animation: none; } }
  .qs-strip { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 4px; margin-bottom: 6px; scrollbar-width: thin; }
  .qs-strip .qs-slot { flex: 0 0 52px; height: 52px; }
  /* Short windows (a phone): the sum beside the number pad, and everything a little smaller. */
  @media (orientation: portrait) and (max-height: 820px), (orientation: landscape) and (max-height: 620px) {
    .qs-ask { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 8px; align-items: stretch; }
    .qs-qcard { display: flex; flex-direction: column; justify-content: center; padding: 2px 6px; }
    .qs-q { font-size: 32px; } .qs-ans { min-height: 40px; line-height: 38px; font-size: 28px; width: 100%; box-sizing: border-box; }
    .qs-story, .qs-fix { font-size: 13px !important; min-height: 18px; line-height: 1.15; }
    .qs-pad { margin-top: 0; gap: 5px; } .qs-pad .key { min-height: 40px; font-size: 22px; padding: 2px 0; }
    .qs-skline small { display: none; } .qs-skline { grid-template-areas: "i n l b"; padding: 2px 8px; margin-bottom: 4px; } .qs-skline .qi { width: 26px; height: 26px; }
    .qs-meta { margin-bottom: 4px; min-height: 22px; font-size: 15px; } .qs-meta .qi { width: 20px; height: 20px; }
    .qs-row.qs-quizrow { display: none; }
    .qs-head h2 { font-size: 19px; } .qs-head h2 > .qi { width: 28px; height: 28px; } .qs-x { width: 40px; height: 40px; } .qs-head { margin-bottom: 2px; }
    .qs-cell { aspect-ratio: 1.5; min-height: 34px; } .qs-cell.wall { aspect-ratio: 2.4; } .qs-floor, .qs-wallrow, .qs-room { gap: 4px; } .qs-room { padding: 4px; }
    .qs-tab { min-height: 36px; font-size: 14px; }
    .qs-styles { margin-bottom: 2px; } .qs-style { min-height: 40px; } .qs-style .qi { width: 26px; height: 26px; }
    .qs-flog { font-size: 14px; min-height: 18px; margin: 0 0 2px !important; }
    .qs-bars { gap: 2px; margin-bottom: 4px; }
  }
  @media (orientation: portrait) and (max-height: 820px) { :root { --qs-h: 64vh; } }
  @media (orientation: landscape) and (max-height: 620px) {
    .qs-bars { grid-template-columns: 1fr 1fr; } .qs-bars > div { grid-template-columns: 22px 1fr 44px; } .qs-bars > div b { display: none; } .qs-bars .qi { width: 22px; height: 22px; }
    .qs-win { padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
  }
  .qs-cell { position: relative; overflow: hidden; }
  .qs-cell span { position: absolute; inset: 3px; width: auto; height: auto; }
  .qs-cell .qi { width: 100%; height: 100%; }
  #quest.qs-side .pl-place { display: none !important; }
  @media (orientation: portrait) and (max-height: 820px), (orientation: landscape) and (max-height: 620px) { .qs-body h3.qs-thingsh { display: none; } #qsHomeHint { font-size: 14px; margin-bottom: 4px; } }
  @media (orientation: landscape) and (max-height: 620px) { #qsHomeHint { display: none; } .qs-cell { aspect-ratio: 2.1; } .qs-cell.wall { aspect-ratio: 3.2; } }
  .qs-room { max-width: 420px; margin: 0 auto; width: 100%; box-sizing: border-box; }

  /* ---------- Building Houses ---------- */
  /* Cosy and calm: cream paper, warm ink, terracotta and sage. Both screens are full width and never zoomed. */
  :root { --bh-ink: #2f2a25; --bh-soft: #6d6358; --bh-paper: #faf6ef; --bh-edge: #e3d8c8; --bh-warm: #c4683f; --bh-sage: #6f8f78; --bh-pw: min(440px, 46vw); --bh-ph: 50vh; }
  .mode.housemode .mt { color: #b5603a; }
  #bhPick [hidden], #bhPlay [hidden] { display: none !important; }
  body[data-screen="bhPick"]::before { background: linear-gradient(170deg, #f6e7d2, #e9dcc8 45%, #cfdcc6); }
  #bhPick { max-width: 1120px; }
  #bhPick h1 { color: #fff; text-shadow: 0 3px 0 #a9583a, 0 0 18px rgba(169,88,58,.35); }
  #bhPick .sub { color: var(--bh-ink); opacity: .85; font-size: 19px; }
  #bhPick .back { background: rgba(255,255,255,.6); }
  .bh-ic { width: 1.2em; height: 1.2em; flex: none; display: block; }
  .bh-tabsbig { display: flex; justify-content: center; gap: 12px; margin: 12px 0 14px; }
  .bh-tabsbig button { display: inline-flex; align-items: center; gap: 8px; font: 800 20px "Baloo 2", sans-serif; color: var(--bh-ink); background: rgba(255,255,255,.7);
                       border: 3px solid transparent; border-radius: 18px; padding: 8px 18px; cursor: pointer; box-shadow: 0 4px 14px rgba(70,50,30,.12); }
  .bh-tabsbig button .bh-ic { width: 28px; height: 28px; }
  .bh-tabsbig button.pick { background: #fff; border-color: var(--bh-warm); color: #9a4d2c; }
  .bh-n { background: var(--bh-warm); color: #fff; border-radius: 99px; min-width: 26px; padding: 0 7px; font-size: 16px; line-height: 24px; text-align: center; }
  .bh-houses { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 16px; padding-bottom: 20px; }
  .bh-card, .bh-open { display: flex; flex-direction: column; text-align: left; gap: 2px; padding: 10px 10px 12px; background: #fff; border: 0; border-radius: 22px; cursor: pointer;
                       font-family: "Baloo 2", sans-serif; color: var(--bh-ink); box-shadow: 0 8px 22px rgba(70,50,30,.16); transition: transform .12s; width: 100%; }
  .bh-card:active, .bh-open:active { transform: scale(.98); }
  .bh-card b, .bh-open b { font-size: 22px; line-height: 1.15; margin: 6px 4px 0; }
  .bh-card small, .bh-open small { font-size: 15.5px; color: var(--bh-soft); line-height: 1.25; margin: 0 4px; }
  .bh-pic { position: relative; display: block; aspect-ratio: 14 / 9; border-radius: 14px; overflow: hidden; background: linear-gradient(#bcd6ea, #e7eef0 60%, #b9cf9e 61%); }
  .bh-pic canvas, .bh-pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
  .bh-wait { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(60,50,40,.35); }
  .bh-wait .bh-ic { width: 34%; height: 34%; }
  @media (prefers-reduced-motion: no-preference) { .bh-card:not(.ready) .bh-wait { animation: bhwait 1.2s ease-in-out infinite alternate; } }
  @keyframes bhwait { to { opacity: .35; } }
  .bh-card.ready .bh-wait { display: none; }
  .bh-save { position: relative; }
  .bh-saverow { position: absolute; top: 18px; right: 18px; display: flex; gap: 8px; }
  .bh-mini { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 48px; height: 48px; padding: 0 12px; border-radius: 14px; border: 0; cursor: pointer;
             background: rgba(255,255,255,.92); color: var(--bh-ink); font: 800 18px "Baloo 2", sans-serif; box-shadow: 0 3px 10px rgba(0,0,0,.18); }
  .bh-mini .bh-ic { width: 26px; height: 26px; }
  .bh-del { color: #b23b2b; }
  .bh-sure { position: absolute; left: 10px; right: 10px; top: 10px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; padding: 14px; border-radius: 14px;
             background: rgba(255,250,244,.96); font: 800 20px "Baloo 2", sans-serif; color: var(--bh-ink); box-shadow: 0 4px 16px rgba(0,0,0,.2); }
  .bh-sure .bh-yes { background: #d9543f; color: #fff; }
  .bh-none { padding: 30px 0; }

  /* The 3D screen. */
  body[data-screen="bhPlay"] { overflow: hidden; }
  body[data-screen="bhPlay"]::before { background: #d8cfc2; }
  #bhPlay.on { position: fixed; inset: 0; max-width: none; padding: 0; animation: none; overflow: hidden; touch-action: none; -webkit-user-select: none; user-select: none; }
  #bhCanvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; touch-action: none; }
  .bh-btn { display: inline-grid; place-items: center; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 18px; cursor: pointer; color: var(--bh-ink);
            background: rgba(250,246,239,.94); box-shadow: 0 4px 14px rgba(40,30,20,.25), inset 0 -3px 0 rgba(0,0,0,.08); font-family: "Baloo 2", sans-serif; position: relative; }
  .bh-btn .bh-ic { width: 32px; height: 32px; }
  .bh-btn:active { transform: translateY(2px); }
  .bh-btn.pick { background: #fff; color: #9a4d2c; box-shadow: 0 0 0 3px var(--bh-warm), 0 4px 14px rgba(40,30,20,.25); }
  .bh-top { position: absolute; z-index: 4; top: calc(10px + env(safe-area-inset-top)); left: calc(10px + env(safe-area-inset-left)); display: flex; gap: 8px; align-items: center; max-width: calc(50vw - 130px); }
  .bh-chip { display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px; border: 0; border-radius: 14px; background: rgba(250,246,239,.9); color: var(--bh-ink);
             font: 800 18px "Baloo 2", sans-serif; box-shadow: 0 3px 10px rgba(40,30,20,.2); cursor: pointer; min-width: 0; }
  .bh-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bh-chip .bh-ic { width: 20px; height: 20px; opacity: .6; }
  .bh-nav { position: absolute; z-index: 4; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; }
  .bh-arrow { width: 52px; height: 52px; border-radius: 50%; }
  .bh-roomname { min-width: 150px; text-align: center; font: 800 22px "Baloo 2", sans-serif; color: var(--bh-ink); background: rgba(250,246,239,.9); border-radius: 99px; padding: 6px 16px;
                 box-shadow: 0 3px 10px rgba(40,30,20,.2); white-space: nowrap; }
  .bh-side { position: absolute; z-index: 4; right: calc(12px + env(safe-area-inset-right)); top: 50%; transform: translateY(-50%); display: grid; gap: 22px; }
  .bh-big { width: 64px; height: 64px; border-radius: 20px; }
  .bh-big .bh-ic { width: 36px; height: 36px; }
  .bh-big::after { content: attr(data-label); position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 2px; font: 800 13px "Baloo 2", sans-serif;
                   color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.8), 0 0 6px rgba(0,0,0,.5); white-space: nowrap; pointer-events: none; }
  .bh-rooms { position: absolute; z-index: 4; left: 50%; transform: translateX(-50%); bottom: calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 8px; padding: 6px;
              background: rgba(250,246,239,.75); border-radius: 22px; box-shadow: 0 4px 16px rgba(40,30,20,.2); }
  .bh-rooms button { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 74px; height: 64px; border: 0; border-radius: 16px; background: rgba(255,255,255,.7);
                     color: var(--bh-ink); cursor: pointer; font: 800 12.5px/1.05 "Baloo 2", sans-serif; padding: 4px 2px; gap: 2px; }
  .bh-rooms button .bh-ic { width: 30px; height: 30px; }
  .bh-rooms button.pick { background: var(--bh-warm); color: #fff; }
  .bh-goin { position: absolute; z-index: 4; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); display: inline-flex; align-items: center; gap: 10px;
             font: 800 26px "Baloo 2", sans-serif; color: #fff; background: var(--bh-warm); border: 0; border-radius: 999px; padding: 10px 28px; cursor: pointer;
             box-shadow: 0 6px 18px rgba(80,40,20,.35), 0 0 0 4px rgba(255,255,255,.85); white-space: nowrap; }
  .bh-goin .bh-ic { width: 34px; height: 34px; }
  .bh-tools { position: absolute; z-index: 5; left: 50%; transform: translateX(-50%); bottom: calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 4px; }
  .bh-thing { font: 800 17px "Baloo 2", sans-serif; color: #fff; background: rgba(47,42,37,.72); border-radius: 99px; padding: 2px 14px; white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis; }
  .bh-toolrow { display: flex; gap: 8px; padding: 6px; background: rgba(250,246,239,.8); border-radius: 22px; box-shadow: 0 4px 16px rgba(40,30,20,.25); }
  .bh-toolrow .bh-btn { width: 58px; height: 58px; }
  .bh-tint::before { content: ""; position: absolute; right: 6px; bottom: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--sw, #ccc); box-shadow: 0 0 0 2px #fff; }
  .bh-danger { color: #b23b2b; }
  .bh-ok { background: var(--bh-sage); color: #fff; }
  #bhPlay.bh-sel .bh-rooms { display: none; }
  #bhPlay.bh-out #bhFurn, #bhPlay.bh-out #bhPaint { display: none; }
  .bh-labels { position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none; overflow: hidden; }
  .bh-label { position: absolute; left: 0; top: 0; pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px 0 8px; border: 0; border-radius: 99px; cursor: pointer;
              background: rgba(47,42,37,.78); color: #fff; font: 800 16px "Baloo 2", sans-serif; white-space: nowrap; box-shadow: 0 2px 10px rgba(0,0,0,.3); }
  .bh-label .bh-ic { width: 24px; height: 24px; }
  #bhPlay.bh-out .bh-labels { display: none; }
  .bh-toast { position: absolute; z-index: 7; left: 50%; top: calc(76px + env(safe-area-inset-top)); transform: translate(-50%, -10px); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
              font: 800 20px "Baloo 2", sans-serif; background: rgba(47,42,37,.85); color: #fff; padding: 8px 18px; border-radius: 99px; white-space: nowrap; }
  .bh-toast.on { opacity: 1; transform: translate(-50%, 0); }
  .bh-loading { background: linear-gradient(170deg, #f6e7d2, #cfdcc6); color: var(--bh-ink); }

  /* The furniture and wallpaper panel: at the side (landscape) or the bottom (portrait); the room stays in view. */
  .bh-panel { position: absolute; z-index: 6; right: 0; top: 0; bottom: 0; width: var(--bh-pw); display: flex; flex-direction: column; background: var(--bh-paper);
              box-shadow: -8px 0 30px rgba(40,30,20,.25); padding: calc(10px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) 12px; font-family: "Baloo 2", sans-serif; }
  #bhPlay.bh-open #bhCanvas, #bhPlay.bh-open .bh-labels { width: calc(100% - var(--bh-pw)); }
  #bhPlay.bh-open .bh-side { right: calc(var(--bh-pw) + 12px); }
  #bhPlay.bh-open .bh-nav, #bhPlay.bh-open .bh-rooms, #bhPlay.bh-open .bh-tools { left: calc((100% - var(--bh-pw)) / 2); }
  #bhPlay.bh-open .bh-top { max-width: calc((100vw - var(--bh-pw)) / 2 - 130px); }
  .bh-phead { display: flex; align-items: center; gap: 8px; }
  @media (orientation: landscape) { .bh-phead { padding-right: 56px; } }
  .bh-phead h2 { flex: 1; margin: 0; font-size: 24px; color: var(--bh-ink); }
  .bh-x { width: 48px; height: 48px; border-radius: 14px; }
  .bh-x .bh-ic { width: 26px; height: 26px; }
  .bh-ptabs { display: flex; gap: 6px; margin: 6px 0 8px; overflow-x: auto; scrollbar-width: none; flex: none; }
  .bh-tab { flex: 1 0 auto; display: flex; flex-direction: column; align-items: center; gap: 0; min-width: 62px; padding: 4px 6px; border: 0; border-radius: 14px; cursor: pointer;
            background: #efe7da; color: var(--bh-ink); font: 800 12.5px "Baloo 2", sans-serif; }
  .bh-tab .bh-ic { width: 30px; height: 30px; }
  .bh-tab.pick { background: var(--bh-warm); color: #fff; }
  .bh-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: grid; gap: 8px; align-content: start; padding: 2px 2px 10px; touch-action: pan-y; }
  .bh-items { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .bh-swatches { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); }
  .bh-item, .bh-sw { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 4px 6px; border: 0; border-radius: 16px; background: #fff; cursor: pointer;
                     box-shadow: 0 2px 8px rgba(70,50,30,.12); color: var(--bh-ink); font-family: "Baloo 2", sans-serif; }
  .bh-item:active, .bh-sw:active { transform: scale(.96); }
  .bh-thumb { position: relative; width: 100%; aspect-ratio: 1; border-radius: 12px; background: #f1ece4; overflow: hidden; }
  .bh-thumb canvas { width: 100%; height: 100%; display: block; }
  .bh-item:not(.ready) .bh-thumb::after { content: ""; position: absolute; inset: 30%; border-radius: 50%; border: 4px solid #e0d5c4; border-top-color: var(--bh-warm); animation: bhspin 1s linear infinite; }
  @keyframes bhspin { to { transform: rotate(1turn); } }
  .bh-iname { font-size: 13.5px; font-weight: 800; line-height: 1.1; text-align: center; min-height: 2.2em; display: grid; place-items: center; }
  .bh-swp { width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
  .bh-swp canvas { width: 100%; height: 100%; display: block; }
  .bh-sw.pick { box-shadow: 0 0 0 4px var(--bh-warm); }
  .bh-ask[hidden] { display: none !important; }
  .bh-ask { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(30,25,20,.45); padding: 16px; }
  .bh-askbox { background: var(--bh-paper); border-radius: 22px; padding: 18px; width: min(420px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.35); font-family: "Baloo 2", sans-serif; }
  .bh-askbox h2 { margin: 0 0 10px; font-size: 24px; color: var(--bh-ink); }
  .bh-askbox input { width: 100%; font: 700 24px "Baloo 2", sans-serif; padding: 8px 12px; border: 3px solid var(--bh-edge); border-radius: 14px; color: var(--bh-ink); background: #fff; -webkit-user-select: text; user-select: text; }
  .bh-askrow { display: flex; gap: 10px; margin-top: 12px; }
  .bh-askbtn { flex: 1; height: 54px; border: 0; border-radius: 16px; font: 800 20px "Baloo 2", sans-serif; background: #efe7da; color: var(--bh-ink); cursor: pointer; }
  .bh-askok { background: var(--bh-warm); color: #fff; }
  @media (orientation: portrait) {
    .bh-panel { left: 0; right: 0; top: auto; width: auto; height: var(--bh-ph); border-radius: 22px 22px 0 0; box-shadow: 0 -8px 30px rgba(40,30,20,.25); padding-left: calc(12px + env(safe-area-inset-left)); padding-top: 10px; }
    #bhPlay.bh-open #bhCanvas, #bhPlay.bh-open .bh-labels { width: 100%; height: calc(100% - var(--bh-ph)); }
    #bhPlay.bh-open .bh-side { right: calc(12px + env(safe-area-inset-right)); top: auto; bottom: calc(var(--bh-ph) + 12px); transform: none; grid-auto-flow: column; gap: 10px; }
    #bhPlay.bh-open .bh-side .bh-big::after { display: none; }
    #bhPlay.bh-open #bhInOut, #bhPlay.bh-open #bhSave { display: none; }
    #bhPlay.bh-open .bh-nav, #bhPlay.bh-open .bh-tools { left: 50%; }
    #bhPlay.bh-open .bh-top { max-width: calc(100vw - 90px); }
    #bhPlay.bh-open .bh-rooms { display: none; }
  }
  /* Phones upright: the room arrows go under the back button row. */
  @media (max-width: 600px) and (orientation: portrait) {
    .bh-top, #bhPlay.bh-open .bh-top { max-width: calc(100vw - 90px); }
    .bh-nav { top: calc(64px + env(safe-area-inset-top)); }
    .bh-roomname { min-width: 0; font-size: 19px; }
    .bh-side { top: auto; bottom: calc(100px + env(safe-area-inset-bottom)); transform: none; gap: 26px; }
    .bh-rooms { gap: 5px; padding: 5px; } .bh-rooms button { width: 64px; height: 60px; font-size: 11.5px; }
    .bh-toolrow { gap: 5px; } .bh-toolrow .bh-btn { width: 52px; height: 52px; }
    .bh-goin { bottom: calc(90px + env(safe-area-inset-bottom)); font-size: 22px; }
    .bh-toast { top: calc(124px + env(safe-area-inset-top)); }
  }
  /* Short screens (a phone on its side): smaller buttons, two columns down the side. */
  @media (max-height: 520px) {
    :root { --bh-pw: min(400px, 50vw); }
    .bh-btn { width: 48px; height: 48px; border-radius: 14px; } .bh-btn .bh-ic { width: 28px; height: 28px; }
    .bh-big { width: 52px; height: 52px; } .bh-big::after { display: none; } .bh-thing { display: none; }
    .bh-side { grid-template-columns: repeat(2, 52px); gap: 8px; }
    .bh-arrow { width: 44px; height: 44px; } .bh-roomname { font-size: 18px; padding: 4px 12px; min-width: 120px; }
    .bh-chip { height: 40px; font-size: 16px; }
    .bh-rooms { padding: 4px; gap: 5px; } .bh-rooms button { width: 62px; height: 50px; font-size: 11px; } .bh-rooms button .bh-ic { width: 24px; height: 24px; }
    .bh-toolrow { padding: 4px; } .bh-toolrow .bh-btn { width: 48px; height: 48px; }
    .bh-goin { bottom: calc(70px + env(safe-area-inset-bottom)); font-size: 21px; padding: 6px 20px; }
    .bh-tab { min-width: 54px; } .bh-tab .bh-ic { width: 24px; height: 24px; }
    .bh-items { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
  }
  @media (prefers-reduced-motion: no-preference) { .bh-goin { animation: bhpulse .9s ease-in-out infinite alternate; } }
  @keyframes bhpulse { to { transform: translateX(-50%) scale(1.06); } }
  @media (prefers-reduced-motion: reduce) { .bh-item:not(.ready) .bh-thumb::after { animation: none; } }
