@font-face {
    font-family: "Fredoka";
    src: url("../assets/fonts/fredoka-500.woff2") format("woff2");
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: "Fredoka";
    src: url("../assets/fonts/fredoka-600.woff2") format("woff2");
    font-weight: 600;
    font-display: swap;
}
@font-face {
    font-family: "Fredoka";
    src: url("../assets/fonts/fredoka-700.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
}
:root {
    --acc: #ff6b4a;
    --plate: #2f86ff;
    --sky1: #6fc7ff;
    --sky2: #d8f1ff;
    --cream: #fffaf0;
    --cream2: #f3e8d0;
    --line: #e2d3b3;
    --ink: #1b2a5c;
    --muted: #4f5a8c;
    --red: #ff4b4b;
    --red-d: #b92b2b;
    --teal: #10b595;
    --teal-d: #08755d;
    --sun: #ffb61e;
    --sun-d: #b87400;
    --violet: #7d5cff;
    --violet-d: #4b30c6;
    --blue: #2f6bff;
    --blue-d: #1a43b8;
    --ui: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
}
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}
html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    color: var(--ink);
    font: 500 16px/1.3 var(--ui);
    overscroll-behavior: none;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}
body {
    background: linear-gradient(180deg, var(--sky1), var(--sky2));
}
#cv {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 0;
    touch-action: none;
    pointer-events: none;
    cursor: grab;
}
body[data-screen="play"] #cv {
    pointer-events: auto;
}
#cv:active {
    cursor: grabbing;
}
button {
    font: inherit;
    color: inherit;
}
h1,
h2,
h3,
p {
    margin: 0;
}
img {
    -webkit-user-drag: none;
}
#app {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}
.screen,
.play-grid,
.stagewrap,
#stage,
.mhero,
.showcase,
.lv-wrap,
.mtop,
.top,
.camctl,
.pager,
#hud,
.prev,
.title {
    pointer-events: none;
}
.screen button,
.card,
.menu-card,
.tot,
.qsheet,
#ov,
.goals,
.modal,
.camctl .ibtn {
    pointer-events: auto;
}
:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px var(--ink);
}
.ic {
    width: 26px;
    height: 26px;
    flex: none;
    display: block;
}
.ic.sm {
    width: 18px;
    height: 18px;
}
.star {
    width: 18px;
    height: 18px;
    flex: none;
    display: block;
}
.screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    gap: 10px;
    padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom))
        max(14px, env(safe-area-inset-left));
}
.screen.active {
    display: flex;
    animation: screenIn 0.3s ease both;
}
@keyframes screenIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
.card,
.menu-card {
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid #fff;
    border-radius: 22px;
    box-shadow:
        0 8px 0 rgba(20, 50, 130, 0.22),
        0 14px 26px rgba(20, 50, 130, 0.18);
}
.btn {
    --b: var(--acc);
    --bd: color-mix(in srgb, var(--b) 58%, #000);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 52px;
    padding: 0 16px;
    border: 0;
    border-radius: 14px;
    font-weight: 700;
    font-size: 18px;
    line-height: 1.05;
    color: #fff;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
    background: linear-gradient(180deg, color-mix(in srgb, var(--b) 78%, #fff) 0, var(--b) 48%);
    box-shadow: 0 6px 0 var(--bd);
    cursor: pointer;
    user-select: none;
    top: 0;
}
.btn::before,
.btn::after {
    content: "";
    position: absolute;
    top: -6px;
    width: 24px;
    height: 9px;
    border-radius: 5px 5px 1px 1px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--b) 70%, #fff), var(--b));
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}
.btn::before {
    left: 16%;
}
.btn::after {
    right: 16%;
}
.btn:hover {
    background: linear-gradient(180deg, color-mix(in srgb, var(--b) 66%, #fff) 0, color-mix(in srgb, var(--b) 90%, #fff) 48%);
}
.btn:active {
    top: 4px;
    box-shadow: 0 2px 0 var(--bd);
}
.btn.primary {
    --b: var(--red);
}
.btn.primary {
    --bd: var(--red-d);
}
.btn.teal {
    --b: var(--teal);
    --bd: var(--teal-d);
}
.btn.sun {
    --b: var(--sun);
    --bd: var(--sun-d);
    color: #3b2400;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}
.btn.violet {
    --b: var(--violet);
    --bd: var(--violet-d);
}
.btn.blue {
    --b: var(--blue);
    --bd: var(--blue-d);
}
.btn.quiet {
    --b: #dfe6ff;
    --bd: #9aa8dd;
    color: var(--ink);
    text-shadow: none;
}
.btn.xl {
    min-height: 64px;
    font-size: 24px;
}
.btn.sm {
    min-height: 42px;
    font-size: 15px;
    padding: 0 12px;
    box-shadow: 0 4px 0 var(--bd);
}
.btn.sm::before,
.btn.sm::after {
    width: 18px;
    height: 7px;
    top: -5px;
}
.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    top: 0;
    box-shadow: 0 6px 0 var(--bd);
}
.btn[hidden] {
    display: none;
}
.btn .bt {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 2px;
}
.btn .bt em {
    font-style: normal;
}
.btn .bt small {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.9;
    text-shadow: none;
}
.ibtn {
    --b: var(--blue);
    --bd: var(--blue-d);
    position: relative;
    top: 0;
    width: 48px;
    height: 48px;
    flex: none;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--b) 78%, #fff), var(--b) 50%);
    box-shadow: 0 5px 0 var(--bd);
    cursor: pointer;
}
.ibtn:active {
    top: 3px;
    box-shadow: 0 2px 0 var(--bd);
}
.ibtn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.ibtn.sun {
    --b: var(--sun);
    --bd: var(--sun-d);
}
.ibtn.sm {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    box-shadow: 0 4px 0 var(--bd);
}
.ibtn.sm .ic {
    width: 22px;
    height: 22px;
}
.ibtn.xs {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    box-shadow: 0 3px 0 var(--bd);
}
.ibtn.xs .ic {
    width: 20px;
    height: 20px;
}
.ibtn.muted .ic {
    opacity: 0.55;
}
.title {
    --t: clamp(22px, min(9.4vw, 6.2vh), 46px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(var(--t) * 0.3);
}
.tr {
    display: flex;
    gap: 3px;
    padding-top: calc(var(--t) * 0.17);
}
.tl {
    position: relative;
    display: grid;
    place-items: center;
    width: var(--t);
    height: var(--t);
    border-radius: calc(var(--t) * 0.2);
    background: linear-gradient(180deg, color-mix(in srgb, var(--c) 78%, #fff), var(--c) 55%);
    box-shadow: 0 calc(var(--t) * 0.1) 0 color-mix(in srgb, var(--c) 58%, #000);
    font-style: normal;
}
.tl::before {
    content: "";
    position: absolute;
    top: calc(var(--t) * -0.15);
    left: 24%;
    width: 52%;
    height: calc(var(--t) * 0.17);
    border-radius: 4px 4px 1px 1px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--c) 70%, #fff), var(--c));
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}
.tl b {
    font: 700 calc(var(--t) * 0.64)/1 var(--ui);
    color: #fff;
    text-shadow: 0 calc(var(--t) * 0.05) 0 rgba(0, 0, 0, 0.35);
}
.tl.big {
    width: calc(var(--t) * 2 + 3px);
}
.title.sm {
    --t: clamp(22px, min(8.6vw, 6vh), 40px);
}
#menu {
    max-width: 560px;
    margin: 0 auto;
    width: 100%;
    gap: 8px;
}
.mtop {
    display: flex;
    justify-content: space-between;
    flex: none;
    padding-bottom: 6px;
}
.mhero {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.showcase {
    flex: 1;
    min-height: 0;
    width: 100%;
    position: relative;
    pointer-events: none;
}
.menu-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    flex: none;
}
.menu-card .xl {
    justify-content: flex-start;
    padding: 0 20px;
    gap: 14px;
    margin-top: 4px;
}
.menu-card .xl .ic {
    width: 34px;
    height: 34px;
}
.menu-card .xl .bt em {
    font-size: 26px;
}
.duo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 2px;
}
.stats {
    display: flex;
    gap: 14px;
    color: var(--muted);
    font-weight: 600;
    font-size: 16px;
}
.stats span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.stats b {
    color: var(--ink);
}
.stats i {
    font-style: normal;
}
.top {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: none;
}
.ttl {
    flex: 1;
    min-width: 0;
    text-align: center;
    font: 700 22px/1.05 var(--ui);
    color: var(--ink);
    display: flex;
    flex-direction: column;
    align-self: center;
    padding: 6px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 4px 0 rgba(20, 50, 130, 0.22);
    pointer-events: auto;
}
.ttl small {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ttl small:empty {
    display: none;
}
.tot {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 5px;
    height: 40px;
    padding: 0 12px;
    border-radius: 12px;
    background: var(--cream);
    border: 3px solid #fff;
    font-weight: 700;
    box-shadow: 0 4px 0 rgba(0, 20, 90, 0.35);
}
.tot span {
    color: var(--muted);
}
#levels {
    max-width: 620px;
    margin: 0 auto;
    width: 100%;
}
.lv-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
}
.lv-card {
    width: 100%;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.wb {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 2px 10px;
    border-bottom: 3px dashed var(--line);
}
.wb small {
    display: block;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--muted);
}
.wb b {
    font: 700 26px/1.1 var(--ui);
}
.wb p {
    font-size: 14px;
    color: var(--muted);
    margin-top: 2px;
}
.wb span {
    font-weight: 700;
    color: #fff;
    background: var(--acc);
    border-radius: 10px;
    padding: 6px 12px;
    white-space: nowrap;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}
.grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px 10px;
    padding-top: 6px;
}
.lv {
    --b: var(--acc);
    --bd: color-mix(in srgb, var(--b) 58%, #000);
    position: relative;
    top: 0;
    aspect-ratio: 1 / 1.08;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--b) 78%, #fff), var(--b) 55%);
    color: #fff;
    font: 700 24px/1 var(--ui);
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
    cursor: pointer;
    box-shadow: 0 5px 0 var(--bd);
    min-width: 0;
    padding: 0;
}
.lv::before,
.lv::after {
    content: "";
    position: absolute;
    top: -5px;
    width: 30%;
    height: 8px;
    border-radius: 4px 4px 1px 1px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--b) 70%, #fff), var(--b));
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}
.lv::before {
    left: 14%;
}
.lv::after {
    right: 14%;
}
.lv:active {
    top: 3px;
    box-shadow: 0 2px 0 var(--bd);
}
.lv .kind {
    font-size: 9px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    font-weight: 700;
    text-shadow: none;
}
.lv .st {
    display: flex;
    gap: 1px;
}
.lv .st .star {
    width: 12px;
    height: 12px;
}
.lv.next {
    --b: var(--sun);
    --bd: var(--sun-d);
    color: #3b2400;
    text-shadow: none;
}
.lv.locked {
    --b: #c9d0ea;
    --bd: #98a3cf;
    color: var(--muted);
    text-shadow: none;
    cursor: not-allowed;
}
.lv.locked .ic {
    width: 22px;
    height: 22px;
    opacity: 0.9;
}
.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    flex: none;
    padding-bottom: 6px;
}
.dots {
    display: flex;
    gap: 8px;
}
.dots i {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    background: rgba(27, 42, 92, 0.3);
}
.dots i.on {
    width: 30px;
    background: var(--ink);
}
#play {
    gap: 8px;
}
.play-grid {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.stagewrap {
    position: relative;
    flex: 1;
    min-height: 150px;
    display: flex;
    gap: 8px;
}
#stage {
    position: relative;
    flex: 1;
    min-width: 0;
}
.camctl {
    flex: none;
    width: 38px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding-bottom: 6px;
    min-height: 0;
}
.camctl .ibtn {
    flex: 0 1 38px;
    min-height: 26px;
}
.camctl .ibtn .ic {
    width: 60%;
    height: 60%;
}
.ibtn.on {
    --b: #ff8a1e;
    --bd: #b4560a;
}
.prev {
    position: absolute;
    left: 4px;
    top: 4px;
    width: clamp(96px, 30vw, 150px);
    aspect-ratio: 1;
    border-radius: 14px;
    border: 4px solid #fff;
    box-shadow: 0 4px 0 rgba(0, 20, 90, 0.3);
    pointer-events: none;
    background: transparent;
}
.prev.big {
    width: min(58%, 240px);
}
.prev[hidden] {
    display: none;
}
.plabel {
    position: absolute;
    left: 4px;
    bottom: 4px;
    padding: 1px 8px;
    border-radius: 8px;
    background: rgba(20, 30, 90, 0.8);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}
.pbar {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 8px;
    background: rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: none;
    border-radius: 9px 9px 0 0;
}
.pbar i {
    display: block;
    height: 100%;
    width: 100%;
    background: #ffd92b;
    transform-origin: left;
}
.prev.timed .pbar {
    display: block;
}
.phide {
    position: absolute;
    inset: 0;
    display: none;
    place-items: center;
    border-radius: 10px;
    background: linear-gradient(135deg, #7d5cff, #3b2a8f);
    color: #fff;
    font: 700 54px var(--ui);
}
.prev.hidden .phide {
    display: grid;
}
.goals {
    position: absolute;
    left: 4px;
    top: 4px;
    max-width: min(66%, 300px);
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 250, 238, 0.97);
    color: var(--ink);
    box-shadow: 0 4px 0 rgba(0, 20, 90, 0.3);
    font-size: 14px;
    font-weight: 600;
}
.goals[hidden] {
    display: none;
}
.goals h3 {
    font-size: 13px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 4px;
}
.goals ul {
    margin: 0;
    padding: 0;
}
.goals li {
    list-style: none;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 2px 0;
}
.goals li i {
    flex: none;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 3px solid var(--line);
    display: grid;
    place-items: center;
    margin-top: 1px;
    background: #fff;
}
.goals li.ok i {
    background: #14b86a;
    border-color: #14b86a;
}
.goals li i .ic {
    width: 12px;
    height: 12px;
    display: none;
}
.goals li.ok i .ic {
    display: block;
}
#hud {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    pointer-events: none;
}
.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 30px;
    padding: 0 10px;
    border-radius: 10px;
    background: rgba(20, 30, 90, 0.82);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
}
.pill .star {
    width: 17px;
    height: 17px;
}
.pill:empty {
    display: none;
}
#ov {
    position: fixed;
    inset: 0;
    z-index: 25;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 14px;
    background: rgba(10, 20, 80, 0.55);
}
#ov.on {
    display: flex;
}
.sheet {
    width: min(100%, 360px);
    max-height: 100%;
    padding: 22px 20px 20px;
    border-radius: 24px;
    text-align: center;
    background: var(--cream);
    color: var(--ink);
    border: 4px solid #fff;
    box-shadow: 0 8px 0 rgba(0, 20, 90, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    animation: screenIn 0.3s ease both;
}
.sheet h2 {
    font: 700 30px/1.05 var(--ui);
}
.sheet p {
    color: var(--muted);
    font-size: 16px;
}
.sheet .tip {
    background: #fff;
    color: var(--ink);
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 14px;
    border: 2px dashed var(--line);
}
.sheet .tip:empty {
    display: none;
}
#stars {
    display: flex;
    gap: 6px;
}
#stars .star {
    width: 48px;
    height: 48px;
}
.rows {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    padding-top: 4px;
}
.rows.h {
    flex-direction: row;
}
.rows .btn {
    flex: 1;
}
.qsheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px 12px 14px;
    background: var(--cream);
    border-radius: 18px 18px 0 0;
    border-top: 4px solid #fff;
    text-align: center;
}
.qsheet[hidden] {
    display: none;
}
.qsheet h2 {
    font: 700 20px/1.15 var(--ui);
    margin-bottom: 14px;
}
.qopts {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding-bottom: 4px;
}
.qopts .btn {
    flex: 1;
    max-width: 90px;
    font-size: 28px;
    min-height: 58px;
}
.qopts .btn.wrong {
    --b: #8a94bf;
    --bd: #5d6690;
}
.panel {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: none;
}
#msg {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 2.6em;
    font-weight: 600;
    font-size: 15px;
    line-height: 1.25;
}
#msgText {
    flex: 1;
    text-align: left;
}
.tools {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
}
.tools:has(#tTurn[hidden]) {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}
.tbtn {
    --b: #5b6bff;
    --bd: #3340c4;
    position: relative;
    top: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 6px 1px 4px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--b) 78%, #fff), var(--b) 50%);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
    cursor: pointer;
    box-shadow: 0 4px 0 var(--bd);
}
.tbtn .ic {
    width: 24px;
    height: 24px;
}
.tbtn.on {
    --b: #ff5a3c;
    --bd: #b62f16;
}
.tbtn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.tbtn[hidden] {
    display: none;
}
.tbtn:active {
    top: 3px;
    box-shadow: 0 1px 0 var(--bd);
}
.trays {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.shapes {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.shp {
    flex: 1;
    max-width: 96px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 3px solid var(--line);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    padding: 0;
}
.shpic {
    position: relative;
    width: 36px;
    height: 36px;
    display: block;
}
.shpic::before,
.shpic::after {
    content: "";
    position: absolute;
    inset: 0;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-position: center;
    mask-position: center;
}
.shpic::before {
    background: var(--c, #3a7bff);
}
.shpic::after {
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}
.shp[data-shape="cube"] .shpic::before {
    -webkit-mask-image: url("../assets/shape_cube_mask.png");
    mask-image: url("../assets/shape_cube_mask.png");
}
.shp[data-shape="cube"] .shpic::after {
    background-image: url("../assets/shape_cube_shade.png");
}
.shp[data-shape="ramp"] .shpic::before {
    -webkit-mask-image: url("../assets/shape_ramp_mask.png");
    mask-image: url("../assets/shape_ramp_mask.png");
}
.shp[data-shape="ramp"] .shpic::after {
    background-image: url("../assets/shape_ramp_shade.png");
}
.shp[data-shape="round"] .shpic::before {
    -webkit-mask-image: url("../assets/shape_round_mask.png");
    mask-image: url("../assets/shape_round_mask.png");
}
.shp[data-shape="round"] .shpic::after {
    background-image: url("../assets/shape_round_shade.png");
}
.shp[aria-checked="true"] {
    border-color: var(--acc);
    background: color-mix(in srgb, var(--acc) 18%, #fff);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 45%, transparent);
}
.colors {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
.sw {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    border: 3px solid #fff;
    box-shadow: 0 3px 0 rgba(0, 0, 30, 0.3);
    cursor: pointer;
    padding: 0;
    position: relative;
}
.sw[aria-checked="true"] {
    box-shadow:
        0 0 0 3px var(--ink),
        0 3px 0 rgba(0, 0, 30, 0.3);
}
.sw[aria-checked="true"]::after {
    content: "";
    position: absolute;
    left: 11px;
    top: 5px;
    width: 8px;
    height: 15px;
    border: solid #fff;
    border-width: 0 4px 4px 0;
    transform: rotate(45deg);
    filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.6));
}
.actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
    gap: 12px;
    padding-top: 2px;
}
#actFree {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}
#actFree .btn {
    padding: 0 4px;
    min-height: 52px;
    font-size: 14px;
    gap: 5px;
    flex-direction: column;
}
#actFree .btn .ic {
    width: 22px;
    height: 22px;
}
#actLevel[hidden],
#actFree[hidden] {
    display: none;
}
.actions .btn {
    min-height: 58px;
}
.modal {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(10, 20, 80, 0.62);
}
.modal[hidden] {
    display: none;
}
.dialog {
    width: min(100%, 440px);
    max-height: 100%;
    overflow: auto;
    background: var(--cream);
    border: 4px solid #fff;
    border-radius: 24px;
    padding: 20px 18px 22px;
    box-shadow: 0 8px 0 rgba(0, 20, 90, 0.4);
}
.dialog h2 {
    font: 700 28px/1.05 var(--ui);
    margin-bottom: 12px;
    text-align: center;
}
.dialog ol {
    list-style: none;
    counter-reset: s;
    margin: 0 0 14px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.dialog li {
    counter-increment: s;
    position: relative;
    padding: 8px 10px 8px 50px;
    border-radius: 12px;
    background: #fff;
    border: 2px solid var(--line);
    font-size: 15px;
    line-height: 1.35;
}
.dialog li::before {
    content: counter(s);
    position: absolute;
    left: 10px;
    top: 50%;
    margin-top: -15px;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--acc);
    color: #fff;
    font: 700 16px/30px var(--ui);
    text-align: center;
}
.dialog p {
    color: var(--muted);
    text-align: center;
    margin-bottom: 12px;
}
.dialog .rows {
    padding-top: 10px;
}
.setrow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 2px;
    border-bottom: 2px dashed var(--line);
}
.setrow label {
    font-weight: 700;
}
.ctl {
    display: flex;
    gap: 6px;
}
.switch {
    --b: #c9d0ea;
    --bd: #98a3cf;
    color: var(--ink);
    text-shadow: none;
    min-width: 74px;
}
.switch[aria-checked="true"] {
    --b: var(--teal);
    --bd: var(--teal-d);
    color: #fff;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}
.slots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}
.slot {
    border: 3px solid var(--line);
    border-radius: 14px;
    background: #fff;
    padding: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}
.slot img,
.slot .empty {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    object-fit: cover;
    background: #e7ecff;
    display: grid;
    place-items: center;
    color: var(--muted);
}
.slot:hover {
    border-color: var(--acc);
}
#loading {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 24px;
    text-align: center;
    color: #fff;
    background: linear-gradient(180deg, #6fc7ff, #d8f1ff);
    transition: opacity 0.4s;
}
#loading.done {
    opacity: 0;
    pointer-events: none;
}
.lbar {
    width: min(70vw, 320px);
}
.track {
    height: 16px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.35);
    overflow: hidden;
}
.track i {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 6px;
    background: linear-gradient(90deg, #ffb61e, #ff4b4b);
}
.ltip {
    font-weight: 700;
    color: var(--ink);
}
@media (min-width: 700px) {
    .grid {
        gap: 20px 14px;
    }
}
@media (max-height: 520px) and (orientation: landscape) {
    .ibtn {
        width: 40px;
        height: 40px;
    }
    .ibtn.sm {
        width: 34px;
        height: 34px;
    }
    .ttl {
        font-size: 17px;
    }
    .ttl small {
        font-size: 11px;
    }
    .grid {
        gap: 12px 8px;
    }
    .lv {
        aspect-ratio: auto;
        padding: 8px 0;
        font-size: 20px;
    }
    .lv-card {
        padding: 10px;
        gap: 8px;
    }
    .wb b {
        font-size: 18px;
    }
    .wb p {
        display: none;
    }
    #levels {
        max-width: 760px;
    }
    .dialog {
        padding: 12px 14px 14px;
    }
    .dialog h2 {
        font-size: 22px;
        margin-bottom: 8px;
    }
    .dialog li {
        font-size: 13px;
        padding: 5px 8px 5px 44px;
    }
    .sheet {
        padding: 12px;
        gap: 6px;
    }
    .sheet h2 {
        font-size: 22px;
    }
    #stars .star {
        width: 34px;
        height: 34px;
    }
    .rows {
        gap: 12px;
    }
    .rows.h {
        flex-direction: row;
    }
}
@media (max-width: 400px) {
    .btn {
        font-size: 16px;
    }
    .btn.xl {
        font-size: 22px;
    }
    .lv {
        font-size: 21px;
    }
    .ibtn.sm {
        width: 36px;
        height: 36px;
    }
}
@media (max-height: 700px) and (orientation: portrait) {
    .btn {
        min-height: 46px;
    }
}
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
.ibtn[hidden],
.tbtn[hidden],
.goals[hidden] {
    display: none;
}
@media (max-height: 700px) {
    .dialog {
        padding: 14px 14px 16px;
    }
    .dialog h2 {
        font-size: 24px;
        margin-bottom: 8px;
    }
    .dialog li {
        font-size: 13.5px;
        padding: 6px 8px 6px 46px;
        line-height: 1.25;
    }
    .dialog ol {
        gap: 6px;
        margin-bottom: 8px;
    }
    .dialog li::before {
        width: 26px;
        height: 26px;
        margin-top: -13px;
        font-size: 14px;
        line-height: 26px;
    }
}
@media (max-height: 520px) and (orientation: landscape) {
    .dialog {
        width: min(100%, 680px);
    }
    .dialog ol {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    .dialog li {
        font-size: 12.5px;
    }
    .setrow {
        padding: 5px 2px;
    }
    .dialog p {
        margin-bottom: 6px;
    }
    .dialog .rows {
        padding-top: 6px;
    }
    .dialog .btn {
        min-height: 42px;
    }
}
@media (max-height: 520px) and (orientation: landscape) {
    .sheet {
        width: min(100%, 540px);
    }
    #obtns {
        flex-direction: row;
    }
    #obtns .btn {
        padding: 0 8px;
        font-size: 15px;
    }
    .sheet .tip {
        font-size: 12px;
        padding: 5px 8px;
    }
    .sheet p {
        font-size: 14px;
    }
}
#winPic {
    width: 180px;
    height: 135px;
    object-fit: cover;
    border-radius: 14px;
    border: 3px solid #fff;
    box-shadow: 0 4px 0 rgba(20, 50, 130, 0.25);
    background: #d8f1ff;
}
#winPic:not([src]) {
    display: none;
}
@media (max-height: 760px) {
    #winPic {
        display: none;
    }
}
@media (min-width: 1200px) and (min-height: 700px) {
    .btn {
        font-size: 20px;
        min-height: 58px;
    }
    .btn.sm {
        font-size: 17px;
        min-height: 48px;
    }
    .btn .bt small {
        font-size: 13px;
    }
    .ibtn {
        width: 56px;
        height: 56px;
    }
    .ibtn .ic {
        width: 30px;
        height: 30px;
    }
    .ibtn.xs {
        width: 36px;
        height: 36px;
    }
    .ttl {
        font-size: 28px;
    }
    .ttl small {
        font-size: 15px;
    }
    .lv-card {
        padding: 22px;
    }
    .lv {
        font-size: 30px;
    }
    .lv .kind {
        font-size: 11px;
    }
    .wb b {
        font-size: 32px;
    }
    .dialog {
        width: min(100%, 560px);
        padding: 26px;
    }
    .dialog li {
        font-size: 17px;
    }
    .sheet {
        width: min(100%, 440px);
    }
}
@media (min-width: 980px) and (min-height: 560px) {
    #play .ttl,
    #levels .ttl {
        flex: 0 1 420px;
        margin: 0 auto;
    }
    #play .top,
    #levels .top {
        justify-content: space-between;
    }
}

/* ==========================================================================
   Layout v2 - buttons sit directly on the sky (no white boxes behind them),
   one spacing unit (--gap) everywhere, and a side panel on wide screens.
   Everything below overrides the older rules above on purpose.
   ========================================================================== */
:root {
    --gap: 12px;
    --chip-bg: rgba(255, 255, 255, 0.95);
    --chip-shadow: 0 4px 0 rgba(20, 50, 130, 0.22);
}

/* ---------------------------------------------------------------- menu */
#menu {
    gap: 0;
}
.mhero {
    gap: var(--gap);
    padding-top: 4px;
}
.menu-card {
    background: none;
    border: 0;
    box-shadow: none;
    padding: 0;
    gap: var(--gap);
    margin-top: var(--gap);
    padding-bottom: 6px;
}
.menu-card .xl {
    margin-top: 0;
    min-height: 72px;
}
.duo {
    gap: var(--gap);
}
.menu-card .duo .btn,
.menu-card .foot .btn {
    min-height: 56px;
}
.foot {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap);
    margin-top: 0;
    align-items: center;
}
.foot .btn.sm {
    width: 100%;
    font-size: 17px;
}
.stats {
    height: 50px;
    justify-content: center;
    align-items: center;
    gap: 14px;
    padding: 0 10px;
    border-radius: 14px;
    background: var(--chip-bg);
    box-shadow: var(--chip-shadow);
    white-space: nowrap;
}

/* wide screens and landscape phones: title and model on the left, buttons on the right */
@media (min-aspect-ratio: 5/4) {
    #menu {
        max-width: min(1060px, 100%);
    }
    #menu.active {
        display: grid;
        grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
        grid-template-rows: minmax(0, 1fr);
        column-gap: clamp(20px, 4vw, 56px);
        align-items: center;
    }
    .mtop {
        position: absolute;
        left: max(14px, env(safe-area-inset-left));
        right: max(14px, env(safe-area-inset-right));
        top: max(12px, env(safe-area-inset-top));
        padding: 0;
    }
    .mhero {
        grid-column: 1;
        height: 100%;
        padding-top: 52px;
    }
    .menu-card {
        grid-column: 2;
        margin-top: 0;
        padding-top: 52px;
        max-width: 480px;
        width: 100%;
        justify-self: center;
    }
    .title {
        --t: clamp(22px, min(5.2vw, 8.4vh), 56px);
    }
}
@media (min-aspect-ratio: 5/4) and (max-height: 520px) {
    .mhero {
        padding-top: 48px;
    }
    .menu-card {
        gap: 10px;
        padding-top: 48px;
    }
    .menu-card .xl {
        min-height: 60px;
    }
    .menu-card .duo .btn,
    .menu-card .foot .btn {
        min-height: 48px;
    }
    .stats {
        height: 44px;
        font-size: 14px;
    }
}

/* ---------------------------------------------------------------- level select */
.lv-card {
    background: none;
    border: 0;
    box-shadow: none;
    padding: 0;
    gap: var(--gap);
}
.lv-card .wb {
    padding: 10px 14px;
    border: 3px solid #fff;
    border-radius: 18px;
    background: var(--chip-bg);
    box-shadow: var(--chip-shadow);
}
.lv-card .grid {
    padding-top: 10px;
    gap: 18px 12px;
}
.pager {
    gap: var(--gap);
}

/* ---------------------------------------------------------------- game page */
#play {
    gap: var(--gap);
}
.play-grid {
    gap: var(--gap);
}
.stagewrap {
    gap: 10px;
}
.camctl {
    gap: 8px;
    padding-bottom: 0;
    justify-content: center;
}
.panel.card {
    background: none;
    border: 0;
    box-shadow: none;
    padding: 0 0 4px;
    gap: var(--gap);
}
#msg {
    min-height: 52px;
    padding: 6px 12px 6px 8px;
    border: 3px solid #fff;
    border-radius: 16px;
    background: var(--chip-bg);
    box-shadow: var(--chip-shadow);
}
.tools {
    gap: 8px;
}
.tbtn {
    min-height: 58px;
}
.trays {
    gap: var(--gap);
}
.shapes {
    gap: 8px;
}
.shp {
    max-width: none;
    height: 48px;
    box-shadow: 0 3px 0 rgba(20, 50, 130, 0.2);
}
.colors {
    gap: 8px;
}
.actions {
    display: flex;
    gap: var(--gap);
    padding-top: 0;
}
.actions[hidden] {
    display: none;
}
.actions .btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 58px;
    padding: 0 10px;
    font-size: 18px;
}
#bCheck {
    flex-grow: 1.4;
}
#actFree {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}
#actFree[hidden] {
    display: none;
}
#actFree .btn {
    flex-direction: column;
    gap: 4px;
    padding: 0 4px;
}

/* wide screens and landscape phones: 3D area on the left, tools in a side panel */
@media (min-aspect-ratio: 5/4) {
    .play-grid {
        flex-direction: row;
        align-items: stretch;
    }
    .stagewrap {
        flex: 1 1 0;
        min-width: 0;
        min-height: 0;
    }
    .panel.card {
        flex: 0 0 clamp(300px, 34vw, 400px);
        min-height: 0;
        justify-content: center;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: none;
    }
    .panel.card::-webkit-scrollbar {
        display: none;
    }
}
@media (min-aspect-ratio: 5/4) and (max-height: 520px) {
    .panel.card {
        gap: 8px;
    }
    #msg {
        min-height: 42px;
        font-size: 13px;
        padding: 4px 10px 4px 6px;
    }
    .tbtn {
        min-height: 46px;
        padding: 4px 1px 3px;
    }
    .tbtn .ic {
        width: 20px;
        height: 20px;
    }
    .trays {
        gap: 8px;
    }
    .shp {
        height: 38px;
    }
    .sw {
        width: 30px;
        height: 30px;
        border-radius: 9px;
    }
    .sw[aria-checked="true"]::after {
        left: 8px;
        top: 3px;
        width: 7px;
        height: 13px;
    }
    .colors {
        gap: 6px;
    }
    .actions .btn {
        min-height: 46px;
        font-size: 16px;
    }
    #actFree .btn {
        font-size: 12px;
    }
    .camctl {
        gap: 6px;
    }
}

/* narrow phones: three action buttons in one row need a little less text */
@media (max-width: 420px) {
    .actions .btn {
        font-size: 16px;
        gap: 6px;
        padding: 0 8px;
    }
    .actions .btn .ic {
        width: 22px;
        height: 22px;
    }
    .actions .btn .bt small {
        font-size: 10.5px;
    }
}

/* the 12-colour tray of Free Build: two even rows instead of 8 + 4 */
.colors:has(.sw:nth-child(9)) {
    display: grid;
    grid-template-columns: repeat(6, max-content);
    justify-content: center;
    gap: 8px 10px;
}

/* three buttons in a row (Hint, Peek, Check): icon above the text so nothing wraps */
.actions .btn .bt small {
    white-space: nowrap;
}
#actLevel:has(#bPeek:not([hidden])) .btn {
    flex-direction: column;
    justify-content: center;
    gap: 0;
    padding: 4px;
}
#actLevel:has(#bPeek:not([hidden])) .btn .bt {
    align-items: center;
    text-align: center;
    gap: 0;
}
#actLevel:has(#bPeek:not([hidden])) .btn .ic {
    width: 22px;
    height: 22px;
}
@media (min-aspect-ratio: 5/4) and (max-height: 520px) {
    #actLevel:has(#bPeek:not([hidden])) .btn .ic {
        width: 18px;
        height: 18px;
    }
    #actLevel:has(#bPeek:not([hidden])) .btn .bt small {
        font-size: 10px;
    }
    .qsheet {
        padding: 8px 10px 10px;
    }
    .qsheet h2 {
        font-size: 16px;
        margin-bottom: 8px;
    }
    .qopts .btn {
        min-height: 44px;
        font-size: 20px;
    }
}

/* ---------------------------------------------------------------- bigger menu buttons */
.menu-card {
    gap: 16px;
}
.menu-card .xl {
    min-height: 92px;
    gap: 16px;
    padding: 0 24px;
    border-radius: 20px;
}
.menu-card .xl .ic {
    width: 46px;
    height: 46px;
}
.menu-card .xl .bt em {
    font-size: 32px;
}
.menu-card .xl .bt small {
    font-size: 15px;
}
.menu-card .duo {
    gap: 16px;
}
.menu-card .duo .btn {
    flex-direction: column;
    min-height: 112px;
    gap: 8px;
    border-radius: 20px;
    padding: 0 8px;
}
.menu-card .duo .btn .ic {
    width: 44px;
    height: 44px;
}
.menu-card .duo .btn .bt {
    align-items: center;
    text-align: center;
}
.menu-card .duo .btn .bt em {
    font-size: 24px;
}
.menu-card .foot {
    gap: 16px;
}
.menu-card .foot .btn.sm {
    min-height: 62px;
    font-size: 20px;
    gap: 10px;
    border-radius: 16px;
}
.menu-card .foot .btn.sm .ic {
    width: 30px;
    height: 30px;
}
.menu-card .stats {
    height: 56px;
    font-size: 17px;
    border-radius: 16px;
}
@media (max-width: 400px) {
    .menu-card .xl {
        min-height: 84px;
    }
    .menu-card .xl .bt em {
        font-size: 28px;
    }
    .menu-card .duo .btn {
        min-height: 104px;
    }
    .menu-card .stats {
        font-size: 15px;
        gap: 10px;
    }
}
@media (max-height: 700px) and (max-aspect-ratio: 5/4) {
    .menu-card {
        gap: 12px;
    }
    .menu-card .xl {
        min-height: 76px;
    }
    .menu-card .duo .btn {
        min-height: 92px;
    }
    .menu-card .foot .btn.sm {
        min-height: 54px;
    }
    .menu-card .stats {
        height: 50px;
    }
}
@media (min-aspect-ratio: 5/4) and (max-height: 520px) {
    .menu-card {
        gap: 10px;
    }
    .menu-card .xl {
        min-height: 68px;
    }
    .menu-card .xl .ic {
        width: 36px;
        height: 36px;
    }
    .menu-card .xl .bt em {
        font-size: 26px;
    }
    .menu-card .duo .btn {
        min-height: 82px;
        gap: 4px;
    }
    .menu-card .duo .btn .ic {
        width: 32px;
        height: 32px;
    }
    .menu-card .duo .btn .bt em {
        font-size: 20px;
    }
    .menu-card .foot .btn.sm {
        min-height: 50px;
        font-size: 17px;
    }
    .menu-card .stats {
        height: 46px;
        font-size: 14px;
    }
}
