/* Robůtek – UI (menu, level picker, pause, win panel, play dock + top bar, hint hand).
   Same visual language as the portal and Díra: white chunky panels with a purple rim,
   big round buttons (≥ 64 px), MDI icons, Nunito. Menu-type screens blur the 3D scene
   and centre ONE panel; in play only the top bar and the dock sit at the screen edges. */

/* Safe areas (notch / Dynamic Island, home indicator): never env() directly – only the shared --sat/--sar/--sab/--sal
   (base.css = env(safe-area-inset-*); shared/device.js applySafeAreaDebug() simulates them with ?safe=iphone | t,r,b,l). */

/* ================================================================ shared bits (as in Díra's ui.css) */
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  padding: max(16px, var(--sat)) max(16px, var(--sar)) max(16px, var(--sab)) max(16px, var(--sal));
  background: radial-gradient(ellipse at 50% 45%, rgba(110, 84, 230, 0.22), rgba(40, 26, 104, 0.55));
  -webkit-backdrop-filter: blur(4px) saturate(0.9);
  backdrop-filter: blur(4px) saturate(0.9);
  animation: ui-fade 0.25s ease both; pointer-events: auto; overflow: hidden;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .screen { background: radial-gradient(ellipse at 50% 45%, rgba(104, 78, 214, 0.5), rgba(32, 22, 84, 0.8)); }
}
@keyframes ui-fade { from { opacity: 0; } to { opacity: 1; } }
/* the menu keeps the island with the waving robot recognisable behind the panel */
.screen-menu { -webkit-backdrop-filter: blur(1.5px) saturate(0.95); backdrop-filter: blur(1.5px) saturate(0.95); background: radial-gradient(ellipse at 50% 45%, rgba(110, 84, 230, 0.12), rgba(40, 26, 104, 0.42)); }

.panel {
  margin: auto; max-width: 100%; max-height: 100%;
  background: linear-gradient(180deg, #ffffff 0%, #f7f3ff 100%);
  border-radius: 44px; padding: 26px 34px 28px;
  box-shadow: 0 0 0 6px var(--purple), 0 12px 0 6px #5d3fd6, 0 26px 60px 6px rgba(12, 6, 40, 0.5);
  display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center;
  animation: hr-bounce-in 0.45s ease both;
}
.panel[data-scroll] { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.row { display: flex; gap: 22px; align-items: center; justify-content: center; flex-wrap: wrap; }

.btn.round.sm { width: 70px; height: 70px; min-width: 70px; min-height: 70px; font-size: 32px; }
.btn.round.big-round { width: 100px; height: 100px; font-size: 48px; }
.btn.round.big-round > .ic { width: 60%; height: 60%; }
.panel .btn:not(.primary), .dock .btn:not(.primary), .topbar .btn {
  box-shadow: 0 0 0 4px #e3dafd, 0 6px 0 4px #cfc2fb, 0 10px 18px rgba(43, 35, 80, 0.18);
}
.panel .btn:not(.primary):active, .dock .btn:not(.primary):active, .topbar .btn:active { box-shadow: 0 0 0 4px #e3dafd, 0 2px 0 4px #cfc2fb; }
.tool-row { gap: 18px; }

[data-action="home"], [data-action="menu"] { color: var(--orange); }
[data-action="music"] { color: var(--pink); }
[data-action="mute"] { color: var(--blue); }
[data-action="fullscreen"], [data-action="back"], [data-action="levels"] { color: var(--purple); }
[data-action="pause"] { color: #5d3fd6; }
[data-action="again"], [data-action="restart"] { color: #ff8a1f; }
[data-action="undo"] { color: #e0457b; }
[data-action="clear"] { color: #7b70ad; }
.btn.off { color: #8a84a8; }
.btn.primary > .ic { color: #fff; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.13)); }
.btn:disabled { cursor: default; }

.stars-pill {
  background: #fff6cc; border-radius: 999px; padding: 10px 22px 10px 16px; min-height: 66px;
  font-size: 32px; font-weight: 900; color: var(--ink);
  box-shadow: 0 0 0 4px var(--sun), 0 6px 0 4px #e0a800, 0 10px 18px rgba(43, 35, 80, 0.18);
  display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums;
}
.stars-pill .sp-star { font-size: 44px; display: grid; animation: star-twinkle 3s ease-in-out infinite; }
@keyframes star-twinkle { 0%, 80%, 100% { transform: rotate(0) scale(1); } 88% { transform: rotate(-15deg) scale(1.15); } 94% { transform: rotate(10deg) scale(1.1); } }
.bump { animation: pill-bump 0.35s ease; }
@keyframes pill-bump { 50% { transform: scale(1.18); } }

.play-btn {
  width: 160px; height: 160px; min-width: 160px; border-radius: 50%; padding: 0; font-size: 64px;
  box-shadow: 0 8px 0 #2f9c58, 0 14px 30px rgba(43, 35, 80, 0.3);
  animation: play-pulse 2.2s ease-in-out infinite;
}
.play-btn:active { box-shadow: 0 3px 0 #2f9c58; }
.play-btn > .ic, .foot-play > .ic { width: 66%; height: 66%; margin-left: 5%; }
.next-btn > .ic { margin-left: 0; width: 62%; height: 62%; }
@keyframes play-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 8px 0 #2f9c58, 0 14px 30px rgba(43, 35, 80, 0.3), 0 0 0 0 rgba(76, 211, 123, 0.5); }
  50% { transform: scale(1.05); box-shadow: 0 8px 0 #2f9c58, 0 14px 30px rgba(43, 35, 80, 0.3), 0 0 0 18px rgba(76, 211, 123, 0); }
}
.btn.foot-play {
  width: 112px; height: 112px; min-width: 112px; font-size: 48px; border-radius: 50%; padding: 0;
  box-shadow: 0 7px 0 #2f9c58, 0 12px 26px rgba(43, 35, 80, 0.3);
  animation: play-pulse 2.2s ease-in-out infinite;
}
.pulse { animation: play-pulse 1.2s ease-in-out infinite; }
.wiggle { animation: ui-wiggle 0.4s ease; }
@keyframes ui-wiggle { 20% { transform: rotate(-4deg) translateX(-4px); } 40% { transform: rotate(4deg) translateX(4px); } 60% { transform: rotate(-3deg); } 80% { transform: rotate(2deg); } }
.new-badge {
  position: absolute; top: -12px; right: -12px; width: 40px; height: 40px; border-radius: 50%;
  background: var(--sun); color: #fff; display: grid; place-items: center; font-size: 28px;
  box-shadow: 0 3px 0 #e0a800; animation: badge-pop 1.4s ease-in-out infinite; pointer-events: none;
}
@keyframes badge-pop { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.15) rotate(12deg); } }

.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 5; }
.confetti i { position: absolute; top: -30px; display: block; animation: confetti-fall linear both; }
@keyframes confetti-fall {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate(var(--drift), 110vh) rotate(var(--spin)); opacity: 0; }
}
.star-row { display: inline-flex; gap: 1px; font-size: 24px; }
.star-row .ic.off { color: #d9d3ee; }
.star-row .ic.off path { stroke: #c4bde0; }

/* ================================================================ main menu */
.menu-panel { gap: clamp(16px, 2.6vh, 26px); padding: 22px clamp(22px, 4vw, 44px) 28px; }
.menu-title {
  margin: 0; display: flex; align-items: center; gap: 14px;
  font-size: clamp(60px, 9vw, 96px); font-weight: 900; letter-spacing: 1px; line-height: 1;
  color: var(--purple); text-shadow: 0 5px 0 #d8ccff;
}
.title-robot { display: grid; color: #2f9cf6; font-size: 1.05em; filter: drop-shadow(0 4px 0 rgba(43, 35, 80, 0.18)); animation: hr-float 2.6s ease-in-out infinite; }
.menu-grid { display: grid; grid-template-columns: auto auto auto; align-items: center; gap: clamp(22px, 4vw, 48px); }
.menu-card {
  appearance: none; border: 0; font: inherit; color: var(--ink); position: relative;
  width: 170px; height: 170px; border-radius: 40px; background: #fff;
  display: grid; place-items: center; align-content: center; gap: 2px;
  box-shadow: 0 0 0 5px #e3dafd, 0 8px 0 5px #cfc2fb, 0 14px 24px rgba(43, 35, 80, 0.2);
  animation: hr-bounce-in 0.5s ease both; animation-delay: 0.08s; touch-action: manipulation;
}
button.menu-card { cursor: pointer; transition: transform 0.15s ease; }
button.menu-card:hover { transform: translateY(-4px) rotate(-2deg); }
button.menu-card:active { transform: scale(0.95); }
button.menu-card:focus-visible { outline: 6px solid var(--sun); outline-offset: 6px; }
.lc-grid { display: grid; font-size: 84px; color: var(--purple); }
.lc-count { font-size: 28px; font-weight: 900; color: var(--ink-soft); }
.play-btn { position: relative; }
.play-num {
  position: absolute; right: -8px; bottom: -6px; min-width: 56px; height: 56px; padding: 0 10px; border-radius: 999px;
  background: #fff; color: var(--ink); font-size: 32px; font-weight: 900; line-height: 56px; text-align: center;
  box-shadow: 0 0 0 4px #9fe3b5, 0 4px 0 4px #6fcf8e; font-variant-numeric: tabular-nums;
}
/* robot look card (3D preview of the chosen look) */
.look-card-menu { background: radial-gradient(circle at 50% 40%, #e6f7ff 0%, #b9e6ff 70%, #a6dcff 100%); animation-delay: 0.16s; overflow: visible; }
.menu-look { width: 168px; height: 168px; margin-top: -8px; animation: hr-float 2.6s ease-in-out infinite; filter: drop-shadow(0 6px 4px rgba(43, 35, 80, 0.18)); pointer-events: none; }
.menu-card .new-badge { top: -14px; right: -14px; }
.look-img { display: block; object-fit: contain; pointer-events: none; -webkit-user-drag: none; user-select: none; }
.look-img:not([src]) { visibility: hidden; }
.next-look {
  display: inline-flex; align-items: center; gap: 10px; min-height: 66px; padding: 4px 22px 4px 8px; border-radius: 999px;
  background: #fff6cc; font-size: 30px; font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 4px var(--sun), 0 6px 0 4px #e0a800, 0 10px 18px rgba(43, 35, 80, 0.18);
}
.next-look .nl-img { position: relative; width: 64px; height: 64px; border-radius: 50%; background: #e7e3f2; display: grid; place-items: center; }
.next-look .nl-img .look-img { width: 64px; height: 64px; filter: grayscale(0.85) brightness(1.05) opacity(0.75); }
.next-look .nl-lock { position: absolute; right: -6px; bottom: -4px; font-size: 26px; color: #8f87b3; background: #fff; border-radius: 50%; width: 32px; height: 32px; display: grid; place-items: center; box-shadow: 0 2px 0 rgba(43, 35, 80, 0.15); }
.next-look .nl-text { display: inline-flex; align-items: center; gap: 6px; }
.next-look .nl-text .ic { font-size: 40px; }

/* ================================================================ level picker */
.picker-panel { width: min(100%, 900px); padding: 18px 18px 20px; gap: 14px; }
.picker-head { display: flex; align-items: center; justify-content: center; gap: 20px; flex: 0 0 auto; flex-wrap: wrap; align-self: stretch; }
.picker-head .head-mid { display: flex; align-items: center; gap: 16px; flex: 1; justify-content: center; flex-wrap: wrap; }
.picker-title {
  width: 86px; height: 86px; border-radius: 50%; display: grid; place-items: center; font-size: 52px; color: var(--purple);
  background: #fff; box-shadow: 0 0 0 4px #e3dafd, 0 6px 0 4px #cfc2fb;
}
.done-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 30px; font-weight: 900; min-height: 66px;
  background: #e6fbe9; color: #1f8a49; border-radius: 999px; padding: 8px 22px 8px 16px;
  box-shadow: 0 0 0 4px #9fe3b5, 0 6px 0 4px #6fcf8e;
}
.done-pill .ic { font-size: 36px; }
.picker-body {
  flex: 1 1 auto; min-height: 0; align-self: stretch; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 18px 10px 24px; border-radius: 32px; touch-action: pan-y;
  background: #efe9ff; box-shadow: inset 0 3px 0 rgba(43, 35, 80, 0.08);
}
.picker-foot { flex: 0 0 auto; gap: 28px; }
.world-head { display: inline-flex; align-items: center; gap: 10px; font-size: 32px; font-weight: 900; color: var(--ink); background: #fff; border-radius: 999px; padding: 6px 24px 6px 16px; box-shadow: 0 0 0 4px #e3dafd; }
.wh-emoji { font-size: 38px; line-height: 1; }
.level-grid { display: grid; grid-template-columns: repeat(5, 106px); gap: 16px 18px; justify-content: center; }
.level-tile {
  appearance: none; border: 0; font: inherit; cursor: pointer; position: relative;
  width: 106px; height: 106px; border-radius: 30px; background: #fff; color: var(--purple);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  box-shadow: 0 0 0 4px #e3dafd, 0 7px 0 4px #cfc2fb, 0 10px 16px rgba(43, 35, 80, 0.14);
  transition: transform 0.12s ease; touch-action: manipulation;
}
.level-tile:hover { transform: translateY(-3px); }
.level-tile:active { transform: scale(0.94); }
.level-tile:focus-visible { outline: 6px solid var(--sun); outline-offset: 4px; }
.lt-num { font-size: 50px; font-weight: 900; line-height: 1; }
.level-tile .star-row { font-size: 26px; }
.level-tile.done { background: linear-gradient(180deg, #fff, #fff8dc); }
.level-tile.next { background: linear-gradient(180deg, #eafff0, #c9f5d6); color: #1f8a49; box-shadow: 0 0 0 5px var(--green), 0 7px 0 5px #2f9c58, 0 10px 16px rgba(43, 35, 80, 0.14); animation: tile-pulse 1.6s ease-in-out infinite; }
@keyframes tile-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.level-tile.locked { background: #e7e3f2; color: #a8a1c4; box-shadow: 0 0 0 4px #d8d2ea, 0 7px 0 4px #c4bddb; cursor: default; }
.level-tile.locked .lt-num { font-size: 34px; opacity: 0.7; }
.lt-lock { display: grid; font-size: 30px; color: #8f87b3; }

/* world tabs (one world's levels at a time – scales to ~10 worlds) */
.levels-panel { gap: 12px; }
.world-tabs { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; flex: 0 0 auto; padding: 2px 4px 6px; }
/* 7d: 10 worlds → one even row of compact tabs (landscape), two rows of five (portrait / narrow) */
.world-tabs.many { display: grid; grid-template-columns: repeat(var(--tabs, 10), minmax(0, 1fr)); gap: 9px; width: 100%; padding: 4px 6px 8px; }
.world-tabs.many .world-tab { min-width: 0; height: 76px; padding: 2px 2px; border-radius: 24px; }
.world-tabs.many .wt-emoji { font-size: 34px; }
.world-tabs.many .wt-stars { font-size: 17px; }
.world-tabs.many .wt-stars .ic { font-size: 18px; }
@media (orientation: portrait), (max-width: 900px) {
  .world-tabs.many { grid-template-columns: repeat(var(--tabs-half, 5), minmax(0, 1fr)); gap: 12px; }
  .world-tabs.many .world-tab { height: 72px; }
}
.world-tab {
  appearance: none; border: 0; font: inherit; cursor: pointer; position: relative; touch-action: manipulation;
  min-width: 96px; height: 84px; padding: 4px 12px; border-radius: 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  background: linear-gradient(180deg, var(--wb) -40%, #fff 55%, var(--wa) 160%); color: var(--ink);
  box-shadow: 0 0 0 4px #e3dafd, 0 6px 0 4px #cfc2fb; transition: transform 0.12s ease;
}
.world-tab:hover { transform: translateY(-2px); }
.world-tab:focus-visible { outline: 6px solid var(--sun); outline-offset: 4px; }
.world-tab.on { box-shadow: 0 0 0 6px var(--purple), 0 7px 0 6px #5d3fd6; transform: translateY(-3px) scale(1.06); }
.world-tab.locked { background: #e7e3f2; cursor: default; }
.world-tab.locked .wt-emoji { filter: grayscale(1) opacity(0.5); }
.wt-emoji { font-size: 40px; line-height: 1.05; }
.wt-stars, .wt-lock { display: inline-flex; align-items: center; gap: 2px; font-size: 20px; font-weight: 900; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.wt-stars .ic { font-size: 22px; }
.wt-lock { font-size: 24px; color: #8f87b3; }
.levels-panel .picker-body { background: linear-gradient(180deg, var(--world-a, #efe9ff) 0%, #f4f0ff 40%, #efe9ff 100%); transition: background 0.3s ease; }
.world-head .wh-count { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; font-size: 26px; color: var(--ink-soft); }
.world-head .wh-count .ic { font-size: 30px; }
.grid-in { animation: grid-in 0.3s ease both; }
@keyframes grid-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* look picker */
.looks-panel { width: min(100%, 860px); }
.look-hero { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 0; min-height: 150px; }
.look-hero .hero-front { width: 170px; height: 170px; filter: drop-shadow(0 6px 4px rgba(43, 35, 80, 0.18)); }
.look-hero .hero-back { width: 140px; height: 140px; margin-left: -24px; opacity: 0.95; filter: drop-shadow(0 4px 3px rgba(43, 35, 80, 0.15)); }
.bounce { animation: ui-bounce 0.45s ease; }
@keyframes ui-bounce { 30% { transform: scale(1.12) rotate(-3deg); } 60% { transform: scale(0.96) rotate(2deg); } 100% { transform: scale(1); } }
.look-grid { display: grid; grid-template-columns: repeat(4, 150px); gap: 18px; justify-content: center; }
.look-card {
  appearance: none; border: 0; font: inherit; cursor: pointer; position: relative; touch-action: manipulation;
  width: 150px; height: 150px; border-radius: 34px; display: grid; place-items: center; padding: 0;
  background: radial-gradient(circle at 50% 40%, #ffffff 0%, #e6f4ff 75%); color: var(--ink);
  box-shadow: 0 0 0 4px #e3dafd, 0 7px 0 4px #cfc2fb, 0 10px 16px rgba(43, 35, 80, 0.14); transition: transform 0.12s ease;
}
.look-card .look-img { width: 132px; height: 132px; }
.look-card:hover { transform: translateY(-3px); }
.look-card:focus-visible { outline: 6px solid var(--sun); outline-offset: 4px; }
.look-card.selected { box-shadow: 0 0 0 6px var(--green), 0 8px 0 6px #2f9c58, 0 10px 16px rgba(43, 35, 80, 0.14); background: radial-gradient(circle at 50% 40%, #ffffff 0%, #d9f7e3 80%); }
.look-check { position: absolute; right: -10px; top: -10px; width: 42px; height: 42px; border-radius: 50%; display: none; place-items: center; background: var(--green); color: #fff; font-size: 30px; box-shadow: 0 3px 0 #2f9c58; }
.look-card.selected .look-check { display: grid; }
.look-card.locked { background: #e7e3f2; cursor: default; box-shadow: 0 0 0 4px #d8d2ea, 0 7px 0 4px #c4bddb; }
.look-card.locked .look-img { filter: grayscale(0.9) brightness(1.08) opacity(0.55); }
.look-lock { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 4px; padding: 2px 12px 2px 6px; border-radius: 999px; background: #fff; font-size: 22px; font-weight: 900; color: var(--ink); box-shadow: 0 2px 0 rgba(43, 35, 80, 0.15); white-space: nowrap; }
.look-lock .ll-icon { display: grid; color: #8f87b3; font-size: 24px; }
.look-lock .ll-need { display: inline-flex; align-items: center; gap: 2px; font-variant-numeric: tabular-nums; }
.look-lock .ll-need .ic { font-size: 24px; }

/* ================================================================ pause */
.pause-panel { gap: 22px; padding: 26px 40px 30px; }
.pause-icon { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-size: 52px; color: #5d3fd6; background: #efe9ff; }
.pause-row { gap: 30px; }

/* ================================================================ play: top bar + dock */
.play-ui { position: absolute; inset: 0; pointer-events: none; }
.play-ui[hidden] { display: none; }
.topbar {
  position: absolute; left: max(14px, var(--sal)); top: max(14px, var(--sat));
  display: flex; align-items: center; gap: 14px; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.tb-gap { width: 6px; }
.level-pill, .bat-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 64px; padding: 6px 22px 6px 12px;
  background: #fff; border-radius: 999px; font-size: 38px; font-weight: 900; color: var(--ink);
  box-shadow: 0 0 0 4px #e3dafd, 0 6px 0 4px #cfc2fb, 0 10px 18px rgba(43, 35, 80, 0.18);
  font-variant-numeric: tabular-nums;
}
.lp-icon { display: grid; font-size: 44px; color: #2f9cf6; }
.bat-pill { padding: 6px 14px; gap: 2px; }
.bat-pill[hidden] { display: none; }
.bat { display: grid; font-size: 44px; color: #cfd6e4; transition: color 0.2s ease, transform 0.2s ease; }
.bat.got { color: #2fc764; transform: scale(1.12); filter: drop-shadow(0 0 6px rgba(80, 255, 140, 0.7)); }

.dock {
  position: absolute; pointer-events: auto; display: grid; gap: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f6f2ff 100%);
  border-radius: 40px; padding: 16px;
  box-shadow: 0 0 0 6px var(--purple), 0 10px 0 6px #5d3fd6, 0 22px 50px 6px rgba(12, 6, 40, 0.35);
  animation: hr-bounce-in 0.4s ease both;
}
/* phase 8 (playtest): one panel at the bottom centre (landscape and portrait), the map uses the whole width above it.
   Landscape:  [ palette ........ | undo clear (fast) ]  ( START )
               [ queue – 2 rows visible, wraps, scrolls ]  ( START )
   Portrait:   [ palette ........ ]  ( START )
               [ queue – 4 rows ]   [ undo / clear stacked ]
   The camera fits the island into the free rect above the panel (play.js updateInsets). */
.dock {
  --qi: 54px;            /* queue item */
  --qgap: 8px;
  --qrows: 2;            /* visible queue rows (the rest scrolls) */
  left: 0; right: 0; margin: 0 auto; top: auto;
  bottom: max(12px, var(--sab));
  width: min(calc(100vw - 28px - var(--sal) - var(--sar)), 1180px);
  padding: 12px 16px; gap: 8px 14px;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-rows: auto auto;
  grid-template-areas: "pal tools start" "queue queue start";
  border-radius: 36px;
}
.palette { grid-area: pal; display: flex; gap: 14px; justify-content: flex-start; flex-wrap: nowrap; align-items: center; padding: 2px 2px 7px; }
.queue-wrap {
  grid-area: queue; min-height: 0; display: flex; border-radius: 26px; background: #efe9ff; box-shadow: inset 0 3px 0 rgba(43, 35, 80, 0.08);
  height: calc(var(--qrows) * (var(--qi) + var(--qgap)) + 12px);
}
.dock-foot { display: contents; }
.play-ui.done .dock { visibility: hidden; } /* the win panel sits there now */
.tools { grid-area: tools; display: flex; gap: 14px; align-items: center; justify-content: flex-end; padding: 0 2px 8px; }
.dock .start-btn { grid-area: start; align-self: center; width: 112px; height: 112px; min-width: 112px; }

@media (orientation: portrait) {
  .dock {
    --qrows: 4;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    grid-template-areas: "pal start" "queue tools";
  }
  .tools { flex-direction: column; justify-content: center; padding: 0; }
}

.cmd-btn {
  appearance: none; border: 0; font: inherit; cursor: pointer; position: relative;
  width: 82px; height: 82px; border-radius: 25px; padding: 0; flex: 0 0 auto;
  background: var(--c); color: #fff; font-size: 58px; display: grid; place-items: center;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 7px 0 4px var(--cd), 0 12px 18px rgba(43, 35, 80, 0.25);
  transition: transform 0.1s ease; touch-action: manipulation;
}
.cmd-btn .ic { filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.15)); }
.cmd-btn:hover { transform: translateY(-2px); }
.cmd-btn:active { transform: translateY(4px) scale(0.96); box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 2px 0 4px var(--cd); }
.cmd-btn:focus-visible { outline: 5px solid var(--sun); outline-offset: 4px; }
.cmd-btn:disabled { filter: saturate(0.35) brightness(1.1); opacity: 0.7; transform: none; cursor: default; }
.cmd-btn.tap, .q-item.tap, .btn.tap { animation: btn-tap 0.25s ease; }
@keyframes btn-tap { 40% { transform: scale(0.88); } 100% { transform: scale(1); } }
.cmd-btn.new { animation: cmd-intro 0.9s ease 0.2s 2 both; }
@keyframes cmd-intro { 0%, 100% { transform: scale(1) rotate(0); } 30% { transform: scale(1.18) rotate(-6deg); } 60% { transform: scale(1.1) rotate(5deg); } }

.queue {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y;
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: var(--qgap) 8px; padding: 9px 10px 4px;
}
.q-item {
  appearance: none; border: 0; font: inherit; cursor: pointer; position: relative; padding: 0;
  width: var(--qi); height: var(--qi); border-radius: 18px; background: var(--c); color: #fff; font-size: 38px;
  display: grid; place-items: center; flex: 0 0 auto;
  box-shadow: 0 5px 0 var(--cd), 0 7px 10px rgba(43, 35, 80, 0.2);
  transition: transform 0.15s ease, opacity 0.2s ease, filter 0.2s ease; touch-action: manipulation;
}
.q-item .ic { filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.15)); }
.q-num {
  position: absolute; left: -6px; top: -7px; min-width: 25px; height: 25px; padding: 0 5px; border-radius: 999px;
  background: #fff; color: var(--ink-soft); font-size: 15px; font-weight: 900; line-height: 25px; text-align: center;
  box-shadow: 0 2px 0 rgba(43, 35, 80, 0.2); pointer-events: none;
}
.q-item.pop-in { animation: q-pop 0.28s ease both; }
@keyframes q-pop { 0% { transform: scale(0.3); opacity: 0; } 70% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
.q-item.pop-out { transform: scale(0.2) rotate(-20deg); opacity: 0; }
.q-ghost {
  width: var(--qi); height: var(--qi); border-radius: 18px; flex: 0 0 auto; border: 4px dashed #c8bdf0;
  display: grid; place-items: center; color: #fff; font-size: 38px;
}
.play-ui.running .q-ghost { opacity: 0.35; }
.q-item.now { transform: scale(1.18); z-index: 1; box-shadow: 0 0 0 5px #fff, 0 0 0 10px var(--sun), 0 6px 18px rgba(255, 190, 0, 0.7); }
.q-item.done { opacity: 0.55; filter: saturate(0.6); transform: scale(0.92); }
.q-item.fail { box-shadow: 0 0 0 5px #fff, 0 0 0 10px #ff9f43, 0 5px 0 10px #e07b18; animation: q-fail 0.6s ease 2; z-index: 1; }
@keyframes q-fail { 25% { transform: rotate(-10deg) scale(1.08); } 75% { transform: rotate(10deg) scale(1.08); } }
.q-ask, .q-ghost.ask {
  color: #fff;
}
.q-ask {
  position: absolute; right: -12px; top: -14px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: #ff9f43; font-size: 24px; box-shadow: 0 0 0 3px #fff; pointer-events: none;
}
.q-ghost.ask { background: #ff9f43; border: 4px solid #fff; box-shadow: 0 0 0 5px #ff9f43; animation: ghost-ask 1s ease-in-out infinite; }
@keyframes ghost-ask { 50% { transform: scale(1.12); } }

.start-btn {
  width: 120px; height: 120px; min-width: 120px; border-radius: 50%; padding: 0; font-size: 56px; flex: 0 0 auto;
  box-shadow: 0 8px 0 #2f9c58, 0 12px 26px rgba(43, 35, 80, 0.3);
}
.start-btn > .ic { width: 64%; height: 64%; margin-left: 6%; }
.start-btn.ready { animation: play-pulse 1.6s ease-in-out infinite; }
.start-btn:disabled { filter: saturate(0.5); opacity: 0.85; animation: none; transform: none; }
.play-ui.running .start-btn > .ic { animation: start-run 0.8s ease-in-out infinite; }
@keyframes start-run { 50% { transform: translateX(6px); } }
.fast-btn { display: none; color: #2f9cf6; }
.play-ui.running .fast-btn { display: inline-flex; }
.play-ui.running [data-action="undo"], .play-ui.running [data-action="clear"] { display: none; }
.fast-btn.on { background: #2f9cf6; color: #fff; }
.tool:disabled { opacity: 0.45; transform: none; }

@media (orientation: portrait) {
  .start-btn { width: 112px; height: 112px; min-width: 112px; }
}
/* low landscape screens (phones, small laptops): a bit smaller, the queue still shows two rows */
@media (max-height: 700px) and (orientation: landscape) {
  .cmd-btn { width: 76px; height: 76px; font-size: 52px; border-radius: 23px; }
  .dock .start-btn { width: 100px; height: 100px; min-width: 100px; }
  .dock { --qi: 50px; --qgap: 8px; gap: 8px 12px; padding: 10px 14px; }
}

/* "?" bubble above the robot */
.bubble {
  position: absolute; left: 0; top: 0; width: 70px; height: 70px; margin: -86px 0 0 -35px; border-radius: 50%;
  background: #fff; color: #ff8a1f; font-size: 50px; display: grid; place-items: center; pointer-events: none;
  box-shadow: 0 0 0 5px #ffcf8a, 0 8px 18px rgba(43, 35, 80, 0.25); opacity: 0; will-change: transform;
}
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -12px; margin-left: -10px; border: 10px solid transparent; border-top-color: #fff; border-bottom: 0; }
.bubble.show { animation: bubble-in 0.35s ease both; }
@keyframes bubble-in { from { opacity: 0; scale: 0.4; } to { opacity: 1; scale: 1; } }

/* animated hint hand */
.hint-hand { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; opacity: 0; z-index: 3; }
.hint-hand.show { opacity: 1; transition: opacity 0.25s ease; }
.hh-hand {
  position: absolute; left: -24px; top: 0; font-size: 84px; color: #fff; display: grid;
  filter: drop-shadow(0 0 0 #5d3fd6) drop-shadow(3px 0 0 #5d3fd6) drop-shadow(-3px 0 0 #5d3fd6) drop-shadow(0 3px 0 #5d3fd6) drop-shadow(0 -3px 0 #5d3fd6) drop-shadow(0 8px 10px rgba(43, 35, 80, 0.35));
  transform-origin: 30% 0;
}
.hh-hand.down { display: none; top: auto; bottom: 0; left: -60px; transform-origin: 70% 100%; }
.hint-hand.above .hh-hand.up { display: none; }
.hint-hand.above .hh-hand.down { display: grid; }
.hint-hand.show .hh-hand.up { animation: hand-tap 1.1s ease-in-out infinite; }
.hint-hand.show .hh-hand.down { animation: hand-tap-down 1.1s ease-in-out infinite; }
@keyframes hand-tap { 0%, 100% { transform: translate(14px, 26px) scale(1); } 45% { transform: translate(0, 0) scale(0.92); } 55% { transform: translate(0, 0) scale(0.92); } }
@keyframes hand-tap-down { 0%, 100% { transform: translate(-14px, -26px) scale(1); } 45% { transform: translate(0, 0) scale(0.92); } 55% { transform: translate(0, 0) scale(0.92); } }
.hh-ring { position: absolute; left: -30px; top: -30px; width: 60px; height: 60px; border-radius: 50%; border: 6px solid rgba(255, 255, 255, 0.95); box-shadow: 0 0 0 3px #5d3fd6; opacity: 0; }
.hint-hand.show .hh-ring { animation: hand-ring 1.1s ease-out infinite; }
@keyframes hand-ring { 0%, 40% { transform: scale(0.3); opacity: 0; } 50% { opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }

/* ================================================================ win panel (sits where the dock is, the robot dances) */
/* phase 8: like the dock – a panel at the bottom centre; the dancing robot stays visible above it.
   Landscape:  [ 12  Hurá! ] [ ★ ★ ★ ] [ levels  again  ( NEXT ) ]
               [ ⭐ 37  🎁  ] [ why   ]
   Portrait:   head / stars + total / buttons in rows */
.screen-win { background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.win-panel {
  position: absolute; margin: 0 auto; left: 0; right: 0; top: auto; bottom: max(12px, var(--sab));
  width: min(calc(100vw - 28px - var(--sal) - var(--sar)), 1180px);
  display: grid; gap: 8px 26px; padding: 16px 22px; align-items: center; justify-items: center; justify-content: center;
  grid-template-columns: auto auto auto;
  grid-template-areas: "head stars buttons" "mid stars buttons";
  background: linear-gradient(180deg, #fffdf0 0%, #fff4c8 100%);
  box-shadow: 0 0 0 6px var(--sun), 0 10px 0 6px #e0a800, 0 22px 50px 6px rgba(12, 6, 40, 0.35);
}
.win-panel .win-head { grid-area: head; }
.win-panel .win-starbox { grid-area: stars; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.win-panel .win-mid { grid-area: mid; }
.win-panel .win-buttons { grid-area: buttons; }
@media (orientation: portrait) {
  .win-panel { grid-template-columns: auto auto; grid-template-areas: "head head" "stars mid" "buttons buttons"; gap: 10px 20px; }
}
.win-head { display: flex; align-items: center; justify-content: center; gap: 14px; }
.win-num { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font-size: 40px; font-weight: 900; color: #fff; background: #2f9cf6; box-shadow: 0 5px 0 #1c6fc0; }
.win-praise { font-size: clamp(40px, 4.4vw, 56px); font-weight: 900; color: #ff8a1f; text-shadow: 0 4px 0 #ffd79a; }
.win-stars { display: flex; justify-content: center; gap: 6px; }
.win-star { position: relative; display: grid; width: 96px; height: 96px; font-size: 96px; }
.win-star.s1 { transform: translateY(-14px); }
.win-star > .ic { position: absolute; inset: 0; width: 100%; height: 100%; }
.win-star .star-empty { color: #ece4c4; }
.win-star .star-empty path { stroke: #d8cfa6; }
.win-star .star-full { transform: scale(0); opacity: 0; }
.win-star.on .star-full { animation: star-land 0.5s cubic-bezier(.2, 1.6, .5, 1) both; }
@keyframes star-land { 0% { transform: scale(2.2) rotate(-40deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.win-star.dim { opacity: 0.55; }
.win-why { display: flex; justify-content: center; gap: 6px; margin-top: -10px; }
.win-why > span { width: 96px; display: grid; place-items: center; font-size: 40px; color: #c9c2dc; transition: color 0.3s ease, transform 0.3s ease; }
.win-why > span.got { color: #2fc764; transform: scale(1.1); }
.win-why > span.goal.got { color: #ff5d8f; }
.win-buttons { gap: 18px; }
.win-mid { gap: 18px; }
.win-unlock {
  appearance: none; border: 0; font: inherit; cursor: pointer; position: relative; padding: 0; touch-action: manipulation;
  width: 112px; height: 112px; border-radius: 32px; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, #ffffff 0%, #ffe9a8 85%);
  box-shadow: 0 0 0 5px var(--sun), 0 7px 0 5px #e0a800, 0 12px 20px rgba(43, 35, 80, 0.2);
}
.win-unlock[hidden] { display: none; }
.win-unlock .look-img { width: 100px; height: 100px; }
.win-unlock .wu-gift { position: absolute; left: -12px; top: -12px; width: 40px; height: 40px; border-radius: 50%; background: #ff5d8f; color: #fff; display: grid; place-items: center; font-size: 26px; box-shadow: 0 3px 0 #d02a66; }
.unlock-in { animation: unlock-in 0.7s cubic-bezier(.2, 1.6, .5, 1) both; }
@keyframes unlock-in { 0% { transform: scale(0.2) rotate(-25deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.win-panel .next-btn { width: 128px; height: 128px; min-width: 128px; }
.screen-win .confetti { z-index: 0; }

/* ================================================================ final screen (7d: all 150 levels done) */
.screen-finale { background: radial-gradient(ellipse at 50% 40%, rgba(255, 214, 90, 0.35), rgba(40, 26, 104, 0.6)); }
.finale-panel {
  gap: clamp(12px, 2.2vh, 22px); padding: 24px clamp(22px, 4vw, 48px) 28px;
  background: linear-gradient(180deg, #fffdf0 0%, #fff1bf 100%);
  box-shadow: 0 0 0 6px var(--sun), 0 12px 0 6px #e0a800, 0 26px 60px 6px rgba(12, 6, 40, 0.5);
}
.finale-top { display: flex; align-items: flex-end; justify-content: center; gap: 6px; }
.finale-trophy { display: grid; font-size: clamp(120px, 20vh, 170px); color: #ffc61a; filter: drop-shadow(0 6px 0 #e0a800) drop-shadow(0 12px 18px rgba(43, 35, 80, 0.25)); animation: trophy-in 0.9s cubic-bezier(.2, 1.5, .5, 1) both, hr-float 2.8s ease-in-out 0.9s infinite; }
@keyframes trophy-in { 0% { transform: scale(0.2) rotate(-30deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.finale-look { width: clamp(110px, 17vh, 150px); height: clamp(110px, 17vh, 150px); animation: hr-float 2.2s ease-in-out infinite; }
.finale-praise { font-size: clamp(38px, 5.5vw, 60px); font-weight: 900; color: #ff8a1f; text-shadow: 0 4px 0 #ffd79a; line-height: 1.05; }
.finale-worlds { display: grid; grid-template-columns: repeat(10, 54px); justify-content: center; gap: 7px; }
@media (max-width: 760px) { .finale-worlds { grid-template-columns: repeat(5, 54px); } }
.fw-world { width: 54px; height: 54px; border-radius: 17px; display: grid; place-items: center; font-size: 33px; background: #fff; box-shadow: 0 0 0 3px #ffe08a, 0 4px 0 3px #f0c040; animation: hr-bounce-in 0.5s ease both; }
.finale-stars .sp-max { font-size: 24px; color: var(--ink-soft); margin-left: 2px; }
.menu-title { position: relative; }
.menu-trophy {
  appearance: none; border: 0; background: none; cursor: pointer; padding: 0; display: grid; font-size: 0.8em; color: #ffc61a;
  filter: drop-shadow(0 4px 0 #e0a800); animation: hr-float 2.4s ease-in-out infinite; touch-action: manipulation;
}
.menu-trophy:focus-visible { outline: 6px solid var(--sun); outline-offset: 4px; border-radius: 20px; }
.trophy-btn { background: linear-gradient(180deg, #ffd84d, #ffb800) !important; box-shadow: 0 0 0 5px #fff3b0, 0 8px 0 5px #d99a00 !important; }

/* ================================================================ smaller screens */
@media (max-height: 700px) {
  .play-btn { width: 128px; height: 128px; min-width: 128px; font-size: 52px; }
  .menu-card { width: 140px; height: 140px; }
  .lc-grid { font-size: 66px; }
  .menu-look { width: 140px; height: 140px; }
  .world-tab { height: 72px; min-width: 84px; }
  .wt-emoji { font-size: 34px; }
  .menu-title { font-size: 64px; }
  .level-grid { grid-template-columns: repeat(5, 96px); gap: 14px; }
  .level-tile { width: 96px; height: 96px; }
  .lt-num { font-size: 42px; }
  .win-star { width: 80px; height: 80px; font-size: 80px; }
}
@media (max-width: 860px) {
  .look-grid { grid-template-columns: repeat(3, 150px); }
}
@media (max-width: 640px) {
  .level-grid { grid-template-columns: repeat(4, 96px); }
  .look-grid { grid-template-columns: repeat(2, 140px); }
  .menu-grid { gap: 16px; }
}
/* ================================================================ 10c: iPhone (both orientations)
   Media queries = ui/layout.js PHONE_LAND / PHONE_PORT (keep in sync). Targets for a 5-year-old's finger:
   commands 56–60 px, queue items 44–48, START 76–88, round tools 48–52. Safe areas via --sat/--sar/--sab/--sal (base.css). */
@media (orientation: landscape) and (max-height: 500px), (orientation: portrait) and (max-width: 520px) {
  .screen { padding: max(8px, var(--sat)) max(10px, var(--sar)) max(8px, var(--sab)) max(10px, var(--sal)); }
  .panel { border-radius: 32px; box-shadow: 0 0 0 5px var(--purple), 0 9px 0 5px #5d3fd6, 0 18px 40px 5px rgba(12, 6, 40, 0.45); }
  .btn.round.sm { width: 52px; height: 52px; min-width: 52px; min-height: 52px; font-size: 26px; }
  .btn.round.big-round { width: 72px; height: 72px; min-width: 72px; min-height: 72px; font-size: 36px; }
  .play-btn { width: 112px; height: 112px; min-width: 112px; }
  .btn.foot-play { width: 68px; height: 68px; min-width: 68px; }
  .stars-pill { min-height: 50px; font-size: 26px; padding: 4px 16px 4px 10px; gap: 6px; }
  .stars-pill .sp-star { font-size: 34px; }
  .new-badge { width: 32px; height: 32px; font-size: 22px; top: -10px; right: -10px; }
  .tool-row { gap: 12px; }

  /* play */
  .cmd-btn { width: var(--cmd, 60px); height: var(--cmd, 60px); font-size: calc(var(--cmd, 60px) * 0.7); border-radius: 19px;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9), 0 5px 0 3px var(--cd), 0 8px 12px rgba(43, 35, 80, 0.22); }
  .cmd-btn:active { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9), 0 2px 0 3px var(--cd); }
  .level-pill, .bat-pill { min-height: 46px; font-size: 28px; padding: 2px 14px 2px 8px; box-shadow: 0 0 0 3px #e3dafd, 0 5px 0 3px #cfc2fb, 0 8px 14px rgba(43, 35, 80, 0.16); }
  .bat-pill { padding: 2px 8px; }
  .lp-icon, .bat { font-size: 32px; }
  .q-item { border-radius: 15px; font-size: calc(var(--qi) * 0.68); }
  .q-ghost { border-radius: 15px; border-width: 3px; font-size: calc(var(--qi) * 0.68); }
  .q-num { left: -4px; top: -5px; min-width: 20px; height: 20px; line-height: 20px; font-size: 12px; padding: 0 4px; }
  .q-item.now { transform: scale(1.1); box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--sun), 0 4px 12px rgba(255, 190, 0, 0.7); }
  .q-item.fail { box-shadow: 0 0 0 3px #fff, 0 0 0 6px #ff9f43, 0 3px 0 6px #e07b18; }
  .q-ask { right: -7px; top: -7px; width: 26px; height: 26px; font-size: 19px; box-shadow: 0 0 0 2px #fff; }
  .q-ghost.ask { border-width: 3px; box-shadow: 0 0 0 3px #ff9f43; }
  .hh-hand { font-size: 64px; left: -18px; }
  .hh-hand.down { left: -46px; }
  .hh-ring { left: -24px; top: -24px; width: 48px; height: 48px; border-width: 5px; }
  .bubble { width: 56px; height: 56px; margin: -70px 0 0 -28px; font-size: 40px; }

  /* menu */
  .menu-title { font-size: 48px; gap: 10px; text-shadow: 0 4px 0 #d8ccff; }
  .menu-card { width: 112px; height: 112px; border-radius: 30px; }
  .menu-look { width: 112px; height: 112px; margin-top: -4px; }
  .lc-grid { font-size: 56px; }
  .lc-count { font-size: 21px; }
  .play-num { min-width: 44px; height: 44px; line-height: 44px; font-size: 24px; padding: 0 8px; }
  .next-look { min-height: 52px; font-size: 24px; padding: 2px 16px 2px 4px; gap: 8px; }
  .next-look .nl-img, .next-look .nl-img .look-img { width: 48px; height: 48px; }
  .next-look .nl-lock { width: 26px; height: 26px; font-size: 20px; }
  .next-look .nl-text .ic { font-size: 32px; }

  /* pickers */
  .picker-panel { width: 100%; padding: 10px 12px 12px; gap: 8px; }
  .picker-head { gap: 10px; flex-wrap: nowrap; }
  .picker-head .head-mid { gap: 8px; }
  .done-pill { min-height: 50px; font-size: 24px; padding: 4px 14px 4px 10px; box-shadow: 0 0 0 3px #9fe3b5, 0 5px 0 3px #6fcf8e; }
  .done-pill .ic { font-size: 28px; }
  .picker-head .btn.round.big-round { width: 60px; height: 60px; min-width: 60px; min-height: 60px; font-size: 30px; }
  .picker-body { padding: 12px 8px 14px; border-radius: 24px; gap: 10px; }
  .world-head { font-size: 22px; padding: 4px 16px 4px 10px; gap: 6px; }
  .wh-emoji { font-size: 28px; }
  .world-head .wh-count { font-size: 19px; }
  .world-head .wh-count .ic { font-size: 22px; }
  .world-tabs.many { gap: 7px; padding: 2px 4px 6px; }
  .world-tabs.many .world-tab { height: 56px; border-radius: 18px; box-shadow: 0 0 0 3px #e3dafd, 0 5px 0 3px #cfc2fb; }
  .world-tabs.many .world-tab.on { box-shadow: 0 0 0 4px var(--purple), 0 5px 0 4px #5d3fd6; }
  .world-tabs.many .wt-emoji { font-size: 27px; }
  .world-tabs.many .wt-stars { font-size: 14px; }
  .world-tabs.many .wt-stars .ic { font-size: 15px; }
  .world-tabs.many .wt-lock { font-size: 17px; }
  .level-grid { width: 100%; grid-template-columns: repeat(auto-fill, 66px); gap: 12px 10px; }
  .level-tile { width: 66px; height: 66px; border-radius: 20px; box-shadow: 0 0 0 3px #e3dafd, 0 5px 0 3px #cfc2fb, 0 7px 10px rgba(43, 35, 80, 0.12); }
  .level-tile.next { box-shadow: 0 0 0 4px var(--green), 0 5px 0 4px #2f9c58; }
  .level-tile.locked { box-shadow: 0 0 0 3px #d8d2ea, 0 5px 0 3px #c4bddb; }
  .lt-num { font-size: 31px; }
  .level-tile .star-row { font-size: 16px; }
  .level-tile.locked .lt-num { font-size: 22px; }
  .lt-lock { font-size: 19px; }
  .look-grid { width: 100%; grid-template-columns: repeat(auto-fill, 92px); gap: 12px; }
  .look-card { width: 92px; height: 92px; border-radius: 24px; box-shadow: 0 0 0 3px #e3dafd, 0 5px 0 3px #cfc2fb, 0 7px 10px rgba(43, 35, 80, 0.12); }
  .look-card.selected { box-shadow: 0 0 0 5px var(--green), 0 6px 0 5px #2f9c58; }
  .look-card.locked { box-shadow: 0 0 0 3px #d8d2ea, 0 5px 0 3px #c4bddb; }
  .look-card .look-img { width: 80px; height: 80px; }
  .look-check { width: 30px; height: 30px; font-size: 21px; right: -8px; top: -8px; }
  .look-lock { bottom: 4px; font-size: 15px; padding: 1px 8px 1px 4px; }
  .look-lock .ll-icon, .look-lock .ll-need .ic { font-size: 16px; }
  .look-hero { min-height: 0; }
  .look-hero .hero-front { width: 104px; height: 104px; }
  .look-hero .hero-back { width: 84px; height: 84px; margin-left: -16px; }

  /* pause */
  .pause-panel { gap: 12px; padding: 14px 24px 18px; }
  .pause-icon { width: 52px; height: 52px; font-size: 32px; }
  .pause-row { gap: 20px; }

  /* win panel (both phone orientations): "head head" / "stars mid" / "buttons buttons", mid stacked */
  .win-panel { grid-template-columns: auto auto; grid-template-areas: "head head" "stars mid" "buttons buttons"; gap: 8px 14px; padding: 10px 16px 12px; border-radius: 30px;
    box-shadow: 0 0 0 5px var(--sun), 0 8px 0 5px #e0a800, 0 18px 40px 5px rgba(12, 6, 40, 0.35); }
  .win-head { gap: 10px; }
  .win-num { width: 48px; height: 48px; font-size: 27px; box-shadow: 0 4px 0 #1c6fc0; }
  .win-praise { font-size: 32px; text-shadow: 0 3px 0 #ffd79a; }
  .win-star { width: 56px; height: 56px; font-size: 56px; }
  .win-star.s1 { transform: translateY(-8px); }
  .win-stars { gap: 4px; }
  .win-why { gap: 4px; margin-top: -4px; }
  .win-why > span { width: 56px; font-size: 26px; }
  .win-mid { flex-direction: column; gap: 8px; }
  .win-unlock { width: 72px; height: 72px; border-radius: 22px; }
  .win-unlock .look-img { width: 64px; height: 64px; }
  .win-unlock .wu-gift { width: 30px; height: 30px; font-size: 20px; left: -9px; top: -9px; }
  .win-buttons { gap: 14px; flex-wrap: nowrap; }
  .win-panel .btn.round.big-round { width: 60px; height: 60px; min-width: 60px; min-height: 60px; font-size: 30px; }
  .win-panel .next-btn { width: 84px; height: 84px; min-width: 84px; }

  /* final screen */
  .finale-trophy { font-size: 104px; }
  .finale-look { width: 92px; height: 92px; }
  .finale-praise { font-size: 32px; }
  .finale-worlds { grid-template-columns: repeat(5, 44px); gap: 6px; }
  .fw-world { width: 44px; height: 44px; font-size: 26px; border-radius: 14px; }
}

/* ---------------------------------------------------------------- 10c: landscape phone (height ≤ 500)
   ┌──────────────────────────────────────────────────────────┐
   │ (II)                                          [🤖 12]   │   pause top-left, level / batteries top-right
   │                                               [🔋🔋]    │
   │ [Jdi]                MAP                     [⌫][🗑]   │   the camera fits the island between the columns
   │ [ ↰ ]                                        ( START )  │
   │ [ ↱ ]  [1][2][3][4][5][6] … queue strip (one row, scrolls sideways)
   └──────────────────────────────────────────────────────────┘
   Palette of 4–5 commands = two columns. Win panel: a column on the side away from the robot (.win-left/right). */
@media (orientation: landscape) and (max-height: 500px) {
  .play-ui {
    --edge-l: calc(var(--sal) + 8px);
    --edge-r: calc(var(--sar) + 8px);
    --edge-t: max(8px, calc(var(--sat) + 6px));
    --edge-b: max(8px, calc(var(--sab) + 4px));
  }
  .topbar { display: contents; }
  .topbar .tb-gap, .topbar [data-action="mute"] { display: none; } /* sound: in the pause screen */
  .topbar [data-action="pause"] { position: absolute; left: var(--edge-l); top: var(--edge-t); }
  .play-ui.done .topbar [data-action="pause"] { visibility: hidden; } /* the win column may cover that corner */
  .tb-info { position: absolute; right: var(--edge-r); top: var(--edge-t); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
  .level-pill, .bat-pill { min-height: 42px; font-size: 25px; }
  .lp-icon, .bat { font-size: 29px; }

  .dock {
    display: contents;
    --cmd: 60px; --pal-gap: 10px; --pal-pad: 9px;
    --pal-w: calc(var(--cmd) + 2 * var(--pal-pad));
    --qi: 48px; --qgap: 8px; --strip: 72px;
  }
  .dock[data-pal="4"], .dock[data-pal="5"] { --pal-w: calc(2 * var(--cmd) + var(--pal-gap) + 2 * var(--pal-pad)); }
  .palette, .queue-wrap, .dock-foot {
    position: absolute; pointer-events: auto;
    background: linear-gradient(180deg, #ffffff 0%, #f6f2ff 100%);
    box-shadow: 0 0 0 5px var(--purple), 0 7px 0 5px #5d3fd6, 0 14px 30px 4px rgba(12, 6, 40, 0.3);
    animation: hr-bounce-in 0.4s ease both;
  }
  /* left column: palette at the bottom (next to the start of the queue strip) */
  .palette {
    left: var(--edge-l); bottom: var(--edge-b); top: auto; width: var(--pal-w);
    max-height: calc(100% - var(--edge-t) - var(--edge-b) - 64px);
    display: flex; flex-direction: column; align-items: center; gap: var(--pal-gap); padding: var(--pal-pad) var(--pal-pad) calc(var(--pal-pad) + 3px);
    border-radius: 26px;
  }
  .palette[data-count="4"], .palette[data-count="5"] { display: grid; grid-template-columns: repeat(2, var(--cmd)); justify-content: center; }
  /* the queue: one row along the bottom, scrolls sideways */
  .queue-wrap {
    left: calc(var(--edge-l) + var(--pal-w) + 14px); right: var(--edge-r); bottom: var(--edge-b);
    height: var(--strip); padding: 5px; border-radius: 24px; background: #fff;
  }
  .queue {
    flex-wrap: nowrap; align-items: flex-start; align-content: normal; overflow-x: auto; overflow-y: hidden; touch-action: pan-x;
    padding: 9px 10px 0; border-radius: 19px; background: #efe9ff; box-shadow: inset 0 3px 0 rgba(43, 35, 80, 0.08); scrollbar-width: none;
  }
  .queue::-webkit-scrollbar { display: none; }
  /* right column: undo / clear (fast while running) above START */
  .dock-foot {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    right: var(--edge-r); bottom: calc(var(--edge-b) + var(--strip) + 12px); padding: 9px 10px 12px; border-radius: 28px;
  }
  .tools { padding: 0; gap: 8px; justify-content: center; }
  .dock .start-btn { width: 84px; height: 84px; min-width: 84px; }

  /* win: a column at the side away from the robot */
  .win-panel { top: var(--sat); bottom: var(--sab); left: auto; right: auto; margin: auto 0; height: max-content; width: max-content; max-width: 50vw; }
  .win-panel.win-right { right: calc(var(--sar) + 8px); }
  .win-panel.win-left { left: calc(var(--sal) + 8px); }

  /* menu: title / cards + PLAY / next look + tool buttons in one row */
  .menu-panel { display: grid; grid-template-columns: auto auto; grid-template-areas: "title title" "grid grid" "next tools"; gap: 10px 22px; padding: 12px 24px 16px; justify-items: center; align-items: center; }
  .menu-title { grid-area: title; font-size: 42px; }
  .menu-grid { grid-area: grid; gap: 26px; }
  .menu-panel > .row:not(.tool-row) { grid-area: next; }
  .menu-panel > .tool-row { grid-area: tools; }
  .menu-card, .menu-look { width: 104px; height: 104px; }
  .lc-grid { font-size: 52px; }

  /* level picker: all 10 world tabs in one row, no world title (the tab shows it), tiles fill the width */
  .world-tabs.many { grid-template-columns: repeat(var(--tabs, 10), minmax(0, 1fr)); }
  .world-tabs.many .world-tab { height: 54px; }
  .levels-panel .world-head { display: none; }
  .levels-panel .picker-body { padding-top: 10px; }

  /* look picker: back / hero / play + stars in a column on the left, the cards scroll on the right */
  .looks-panel { display: grid; height: 100%; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "head body" "stars body"; gap: 8px 14px; align-items: center; }
  /* hero on top, back + play side by side under it */
  .looks-panel .picker-head { grid-area: head; flex-wrap: wrap; align-self: center; gap: 8px 14px; width: 190px; }
  .looks-panel .look-hero { order: -1; flex: 0 0 100%; }
  .looks-panel .picker-body { grid-area: body; align-self: stretch; }
  .looks-panel > .row { grid-area: stars; }
  .look-hero { flex: none; }

  /* pause */
  .play-btn { width: 104px; height: 104px; min-width: 104px; }

  /* final screen: trophy + robot on the left */
  .finale-panel { display: grid; grid-template-columns: auto auto auto; grid-template-areas: "top praise praise" "top worlds worlds" "top stars buttons"; gap: 8px 18px; padding: 12px 22px 16px; align-items: center; justify-items: center; }
  .finale-top { grid-area: top; flex-direction: column; align-items: center; gap: 0; }
  .finale-trophy { font-size: 92px; }
  .finale-look { width: 84px; height: 84px; }
  .finale-praise { grid-area: praise; }
  .finale-worlds { grid-area: worlds; }
  .finale-panel > .row:nth-child(4) { grid-area: stars; }
  .finale-panel > .row:nth-child(5) { grid-area: buttons; flex-wrap: nowrap; }
}
/* very low (iPhone SE in Safari with its toolbar, ~ 320–360 px) */
@media (orientation: landscape) and (max-height: 360px) {
  .dock { --cmd: 56px; --pal-gap: 8px; --pal-pad: 8px; --qi: 44px; --strip: 66px; }
  .queue { padding-top: 8px; }
  .dock-foot { padding: 7px 8px 10px; gap: 6px; bottom: calc(var(--edge-b) + var(--strip) + 10px); }
  .dock .btn.round.sm { width: 48px; height: 48px; min-width: 48px; min-height: 48px; }
  .dock .start-btn { width: 76px; height: 76px; min-width: 76px; }
  .level-pill, .bat-pill { min-height: 38px; font-size: 22px; }
  .lp-icon, .bat { font-size: 25px; }
  .menu-title { font-size: 36px; }
  .menu-card, .menu-look { width: 96px; height: 96px; }
  .play-btn { width: 96px; height: 96px; min-width: 96px; }
  .menu-panel { gap: 8px 22px; padding: 10px 22px 12px; }
  .finale-trophy { font-size: 80px; }
  .win-panel { padding: 8px 14px 10px; gap: 6px 12px; }
  .win-num { width: 42px; height: 42px; font-size: 24px; }
  .win-praise { font-size: 28px; }
  .win-star { width: 48px; height: 48px; font-size: 48px; }
  .win-why > span { width: 48px; font-size: 22px; }
  .win-unlock { width: 62px; height: 62px; border-radius: 18px; }
  .win-unlock .look-img { width: 56px; height: 56px; }
  .win-panel .stars-pill { min-height: 44px; font-size: 23px; }
  .win-panel .btn.round.big-round { width: 54px; height: 54px; min-width: 54px; min-height: 54px; font-size: 27px; }
  .win-panel .next-btn { width: 74px; height: 74px; min-width: 74px; }
  .picker-head .btn.round.big-round { width: 54px; height: 54px; min-width: 54px; min-height: 54px; }
  .btn.foot-play { width: 60px; height: 60px; min-width: 60px; }
  .stars-pill, .done-pill { min-height: 44px; font-size: 22px; }
  .world-tabs.many .world-tab { height: 48px; }
  .world-tabs.many .wt-emoji { font-size: 23px; }
  .look-hero .hero-front { width: 88px; height: 88px; }
  .look-hero .hero-back { width: 70px; height: 70px; }
}

/* ---------------------------------------------------------------- 10c: portrait phone (width ≤ 520)
   top bar (pause · level · batteries … sound) under the notch, the map, then the dock in three rows:
   [ palette (centred) ] / [ queue – 3 rows, scrolls ] / [ undo clear …… ( START ) ] above the home indicator. */
@media (orientation: portrait) and (max-width: 520px) {
  .topbar { left: max(10px, var(--sal)); right: max(10px, var(--sar)); top: max(10px, calc(var(--sat) + 4px)); gap: 8px; }
  .tb-info { display: flex; gap: 8px; align-items: center; }
  .tb-gap { flex: 1; }
  .dock {
    --cmd: 58px; --qi: 46px; --qgap: 8px; --qrows: 3;
    width: calc(100vw - 16px - var(--sal) - var(--sar)); bottom: max(10px, var(--sab));
    padding: 10px 10px 12px; gap: 8px; border-radius: 30px;
    grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto auto;
    grid-template-areas: "pal pal" "queue queue" "tools start";
    box-shadow: 0 0 0 5px var(--purple), 0 8px 0 5px #5d3fd6, 0 18px 40px 5px rgba(12, 6, 40, 0.35);
  }
  .palette { justify-content: center; gap: 10px; padding: 3px 2px 8px; }
  .queue-wrap { border-radius: 20px; }
  .queue { padding: 9px 8px 4px; gap: var(--qgap) 7px; }
  .tools { flex-direction: row; justify-content: flex-start; padding: 0 0 0 6px; gap: 14px; }
  .dock .start-btn { width: 88px; height: 88px; min-width: 88px; justify-self: end; margin-right: 4px; }
  .win-panel { width: calc(100vw - 16px - var(--sal) - var(--sar)); bottom: max(10px, var(--sab)); }
  .menu-panel { padding: 18px 20px 22px; gap: 16px; }
  .menu-grid { grid-template-columns: auto auto; grid-template-areas: "play play" "levels look"; gap: 16px 30px; }
  .menu-grid > .play-btn { grid-area: play; justify-self: center; width: 128px; height: 128px; min-width: 128px; }
  .menu-grid > .levels-card { grid-area: levels; }
  .menu-grid > .look-card-menu { grid-area: look; }
  .level-grid { grid-template-columns: repeat(4, 66px); justify-content: center; }
  .look-grid { grid-template-columns: repeat(3, 92px); justify-content: center; }
  .look-hero .hero-front { width: 120px; height: 120px; }
  .look-hero .hero-back { width: 96px; height: 96px; }
  .finale-trophy { font-size: 120px; }
  .finale-look { width: 110px; height: 110px; }
  .finale-praise { font-size: 34px; }
}
@media (orientation: portrait) and (max-width: 520px) and (max-height: 760px) {
  .dock { --qrows: 2; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
