/* Thread Loom: cream linen, wood and paper-roll palette */
@font-face {
    font-family: "Lora";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../assets/fonts/lora-latin-400-normal.woff2") format("woff2");
}
@font-face {
    font-family: "Lora";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../assets/fonts/lora-latin-700-normal.woff2") format("woff2");
}
@font-face {
    font-family: "Lora";
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url("../assets/fonts/lora-latin-400-italic.woff2") format("woff2");
}
/* Thread Loom: craft paper, stitched lettering, wood buttons and coloured paper rolls */
:root {
    --rim: #5a2c14;
    --cream: #fff8ee;
    --ink: #3b2a1d;
    --muted: #6f5540;
    --card: #fffaf0;
    --accent: #d9572b;
    --coral: #ef6f5e;
    --sun: #f5b841;
    --mint: #3fc1a0;
    --sky: #5aa9f0;
    --plum: #9a6be0;
    --shadow: rgba(60, 30, 10, 0.22);
    --kraft: #ecd9b6;
}
* {
    box-sizing: border-box;
}
html,
body {
    height: 100%;
    margin: 0;
}
body {
    font-family: "Lora", Georgia, "Times New Roman", serif;
    font-size: 16px;
    color: var(--ink);
    background-color: var(--kraft);
    background-image: radial-gradient(110% 70% at 50% -8%, #fff7e6 0, rgba(255, 247, 230, 0) 60%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='360' viewBox='0 0 360 360'%3E%3Cg fill='none' stroke-linecap='round' stroke-dasharray='2 9' stroke-width='2.4'%3E%3Cpath d='M-10 70 C80 20 150 120 240 70 S350 20 380 60' stroke='%23ef6f5e' opacity='.28'/%3E%3Cpath d='M-10 190 C70 140 160 240 250 190 S340 150 380 180' stroke='%235aa9f0' opacity='.28'/%3E%3Cpath d='M-10 310 C90 260 150 350 250 300 S340 270 380 300' stroke='%233fc1a0' opacity='.28'/%3E%3C/g%3E%3C/svg%3E"),
        repeating-linear-gradient(90deg, rgba(120, 80, 40, 0.045) 0 2px, transparent 2px 13px),
        repeating-linear-gradient(0deg, rgba(120, 80, 40, 0.035) 0 2px, transparent 2px 13px);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}
.app {
    position: relative;
    height: 100%;
    z-index: 1;
}
.screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    gap: 14px;
    padding: calc(env(safe-area-inset-top) + 16px) 18px calc(env(safe-area-inset-bottom) + 18px);
    overflow: auto;
    max-width: 760px;
    margin: 0 auto;
}
.screen.active {
    display: flex;
    animation: fade 0.28s ease-out both;
}
@keyframes fade {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* Wood-block buttons */
.wood {
    --c: #b07a48;
    --c-d: #8a5a30;
    --edge: #4a2a12;
    --grain: rgba(0, 0, 0, 0.07);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex: none;
    min-height: 50px;
    padding: 11px 26px;
    border: 2px solid var(--edge);
    border-radius: 12px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #fff3dc;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
    background: repeating-linear-gradient(95deg, var(--grain) 0 2px, transparent 2px 9px),
        linear-gradient(180deg, var(--c) 0%, var(--c-d) 100%);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.3),
        inset 0 -3px 0 rgba(0, 0, 0, 0.1),
        0 4px 0 var(--edge),
        0 8px 12px rgba(60, 30, 10, 0.2);
    transition:
        transform 0.1s,
        box-shadow 0.1s,
        filter 0.12s;
    -webkit-user-select: none;
    user-select: none;
}
.wood:hover:not(:disabled) {
    filter: brightness(1.08);
    transform: translateY(-1px);
}
.wood:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.22),
        0 1px 0 var(--edge);
}
.wood:focus-visible,
button:focus-visible {
    outline: 3px solid #1f6fd1;
    outline-offset: 3px;
}
.wood:disabled {
    filter: saturate(0.4) brightness(0.92);
    opacity: 0.6;
    cursor: default;
}
.wood.round {
    width: 62px;
    height: 62px;
    min-height: 0;
    padding: 0;
    border-radius: 50%;
}
.wood.round.sm {
    width: 54px;
    height: 54px;
}
.wood.square {
    min-height: 0;
    padding: 0;
}
.wood.plate {
    border-radius: 14px;
}
.wood.sm {
    min-height: 46px;
    padding: 8px 18px;
    font-size: 14px;
}
.wood.big {
    min-width: 240px;
    min-height: 66px;
    font-size: 22px;
    padding: 12px 48px;
    border-radius: 14px;
}
.wood .ico {
    width: 30px;
    height: 30px;
    flex: none;
    filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.3));
}
.wood.round .ico {
    width: 32px;
    height: 32px;
}
.wood.round.sm .ico {
    width: 28px;
    height: 28px;
}
.wood.sm .ico {
    width: 24px;
    height: 24px;
}
.wood.big .ico {
    width: 36px;
    height: 36px;
}
.wood.teal {
    --c: #5c9a7c;
    --c-d: #3d7a5c;
    --edge: #1f4a37;
}
.wood.blue {
    --c: #5b8fb8;
    --c-d: #3b6d96;
    --edge: #1f3f5c;
}
.wood.gold {
    --c: #e8b64a;
    --c-d: #c4922a;
    --edge: #5a3a0a;
    color: #3b2208;
    text-shadow: none;
}
.wood.gold .ico {
    filter: brightness(0) opacity(0.75);
}
.wood.stone {
    --c: #c2b6a2;
    --c-d: #a09480;
    --edge: #5b5143;
    color: #5b5143;
    text-shadow: none;
}

/* Brand: stitched wordmark */
.brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.logo {
    width: clamp(76px, 15vmin, 112px);
    height: auto;
    margin-bottom: 8px;
    filter: drop-shadow(0 8px 8px var(--shadow));
}
.wordmark {
    margin: 4px 0 0;
    font-size: clamp(40px, 9vw, 64px);
    line-height: 1.05;
    font-weight: 700;
    letter-spacing: 1px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: baseline;
    gap: 0 0.3em;
}
.wordmark span {
    display: inline-flex;
    -webkit-text-stroke: 0.2em var(--cream);
    paint-order: stroke fill;
    text-shadow: 0 4px 0 rgba(90, 44, 20, 0.28);
}
.wordmark .w1 {
    color: #6b3a1c;
}
.wordmark i {
    font-style: normal;
}
.wordmark i:nth-child(1) {
    color: var(--coral);
}
.wordmark i:nth-child(2) {
    color: #e9a62c;
}
.wordmark i:nth-child(3) {
    color: #2fae8c;
}
.wordmark i:nth-child(4) {
    color: #3f8fe0;
}
.tagline {
    position: relative;
    margin: 12px 0 4px;
    padding: 8px 22px;
    max-width: 360px;
    font-style: italic;
    font-size: 15px;
    line-height: 1.4;
    color: #5a3a22;
    background: #fff3d6;
    border-top: 2px dashed #d6b98a;
    border-bottom: 2px dashed #d6b98a;
}

/* Menu */
#menu {
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    overflow-y: auto;
    max-width: none;
}
.menu-card {
    position: relative;
    z-index: 1;
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    width: min(92vw, 460px);
    padding: 16px 0;
    text-align: center;
}
.deco-rolls {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}
.dr {
    position: absolute;
    width: 150px;
    height: 46px;
    border-radius: 14px;
    opacity: 0.55;
    background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 4px, rgba(0, 0, 0, 0.05) 4px 9px),
        linear-gradient(180deg, var(--c2) 0%, var(--c1) 40%, var(--c3) 100%);
    box-shadow: 0 6px 0 rgba(60, 30, 10, 0.18);
    transform: rotate(var(--r));
}
.dr.a {
    --c1: #ef6f5e;
    --c2: #ff9a8a;
    --c3: #b9473a;
    --r: -14deg;
    left: -40px;
    top: 9%;
}
.dr.b {
    --c1: #5aa9f0;
    --c2: #9dd0ff;
    --c3: #2f6fb4;
    --r: 12deg;
    right: -46px;
    top: 15%;
}
.dr.c {
    --c1: #3fc1a0;
    --c2: #8ce8d2;
    --c3: #23816b;
    --r: 78deg;
    left: 4%;
    bottom: 12%;
}
.dr.d {
    --c1: #f5b841;
    --c2: #ffdc7a;
    --c3: #b9821a;
    --r: -10deg;
    right: -30px;
    bottom: 10%;
}
.dr.e {
    --c1: #9a6be0;
    --c2: #c7a6ff;
    --c3: #6a40b0;
    --r: 70deg;
    right: 6%;
    top: 44%;
    opacity: 0.35;
}
.dr.f {
    --c1: #f08cc1;
    --c2: #ffc2e0;
    --c3: #b5558c;
    --r: -66deg;
    left: 2%;
    top: 46%;
    opacity: 0.35;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 20px 7px 12px;
    border-radius: 999px;
    background: var(--cream);
    color: #4a2a12;
    font-weight: 700;
    font-size: 17px;
    box-shadow:
        0 0 0 3px #5a2c14,
        0 6px 0 3px #5a2c14;
}
.chip img {
    width: 30px;
    height: 30px;
    filter: sepia(1) saturate(5) hue-rotate(5deg) brightness(0.95) drop-shadow(0 2px 0 #5a2c14);
}
.menu-row {
    display: flex;
    gap: 28px;
    justify-content: center;
    align-items: flex-start;
}
.mbtn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}
.mbtn span {
    font-weight: 700;
    font-size: 15px;
    color: #4a2a12;
}
.wood.round.lg {
    width: 78px;
    height: 78px;
}
.wood.round.lg .ico {
    width: 42px;
    height: 42px;
}

/* Top bar and ribbon plates */
.bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: none;
}
.bar-sp {
    width: 54px;
    flex: none;
}
.plate {
    flex: 1;
    min-height: 58px;
    padding: 8px 24px;
    cursor: default;
    justify-content: center;
}
.plate h2 {
    margin: 0;
    font-size: 25px;
    letter-spacing: 0.5px;
    color: #fff8ee;
    text-shadow: 0 2px 0 var(--edge);
}
.hint {
    min-height: 22px;
    margin: 0;
    text-align: center;
    font-size: 15px;
    color: #8a4a2b;
}

/* Settings */
.panel,
.chapter-block,
.steps {
    background: var(--card);
    border-radius: 22px;
    box-shadow:
        0 0 0 3px var(--rim),
        0 8px 0 3px var(--rim),
        0 16px 24px rgba(60, 30, 10, 0.18);
}
#settings .panel {
    margin: 12px 4px 0;
    overflow: hidden;
}
.set-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 20px;
}
.set-row + .set-row {
    border-top: 2px dashed #e2cfaa;
}
.set-txt {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.set-txt b {
    font-size: 19px;
}
.set-txt small {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.35;
}
.set-row .wood.sm {
    min-width: 128px;
}

/* Loading page */
#loader {
    justify-content: center;
    align-items: center;
}
.loader-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 34px;
}
#loader .logo {
    animation: rise 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.load-row {
    display: flex;
    align-items: center;
    gap: 16px;
}
.spin {
    width: 52px;
    height: 52px;
    animation: spin 1.1s linear infinite;
}
.track {
    position: relative;
    width: min(56vw, 300px);
    height: 24px;
    padding: 4px;
    border-radius: 999px;
    background: var(--cream);
    box-shadow:
        0 0 0 2px var(--rim),
        0 4px 0 2px var(--rim);
}
.track i {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.25) 0 6px, transparent 6px 12px),
        linear-gradient(180deg, #f27d57 0%, #d4502c 100%);
    transition: width 0.25s ease-out;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* Levels */
.chapters {
    display: flex;
    flex-direction: column;
    gap: 26px;
    padding: 6px 4px 12px;
}
.chapter-block {
    --ac: var(--coral);
    position: relative;
    padding: 24px 18px 18px;
    margin-top: 4px;
}
.chapter-block:nth-child(2) {
    --ac: var(--sun);
}
.chapter-block:nth-child(3) {
    --ac: var(--mint);
}
.chapter-block:nth-child(4) {
    --ac: var(--sky);
}
.chapter-block:nth-child(5) {
    --ac: var(--plum);
}
.chapter-block::before {
    content: "";
    position: absolute;
    left: 18px;
    right: 18px;
    top: 0;
    height: 8px;
    border-radius: 0 0 8px 8px;
    background: var(--ac);
}
.chapter-block h3 {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 10px;
    margin: 0 0 14px;
    font-size: 21px;
    color: #4a2a12;
}
.chapter-block h3 small {
    font-weight: 400;
    font-style: italic;
    color: var(--muted);
    font-size: 15px;
}
.lvl-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: clamp(9px, 2vw, 14px);
    padding: 2px 2px 6px;
}
.tile {
    width: 100%;
    aspect-ratio: 1;
    flex-direction: column;
    gap: 2px;
    font-size: 21px;
    border-radius: 12px;
}
.tile .st {
    font-size: 12px;
    color: #ffe9a8;
    letter-spacing: 1px;
    min-height: 14px;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
.tile.stone .st {
    color: #5b5143;
    text-shadow: none;
    font-size: 10px;
    letter-spacing: 0.5px;
}
.tile.stone .ico {
    width: 24px;
    height: 24px;
    filter: none;
}
.reset {
    align-self: center;
    margin-top: 4px;
}

/* How to play: numbered step cards */
.steps {
    list-style: none;
    counter-reset: step;
    margin: 12px 4px 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    line-height: 1.55;
    font-size: 17px;
}
.steps li {
    counter-increment: step;
    position: relative;
    min-height: 56px;
    padding: 12px 14px 12px 66px;
    border-radius: 14px;
    background: #fff3d8;
    display: flex;
    align-items: center;
}
.steps li:nth-child(even) {
    background: #fdecc8;
}
.steps li::before {
    content: counter(step);
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    color: #fff;
    background: var(--ac, var(--coral));
    box-shadow:
        0 0 0 3px #fff8ee,
        0 0 0 5px rgba(90, 44, 20, 0.35);
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}
.steps li:nth-child(1) {
    --ac: var(--coral);
}
.steps li:nth-child(2) {
    --ac: #e9a62c;
}
.steps li:nth-child(3) {
    --ac: #2fae8c;
}
.steps li:nth-child(4) {
    --ac: #3f8fe0;
}
.steps li:nth-child(5) {
    --ac: var(--plum);
}

/* Game */
#game {
    gap: 10px;
}
.hud {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: none;
}
.hud .title {
    flex: 1;
    min-width: 0;
    text-align: center;
}
.chapter {
    font-size: 13px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--muted);
}
.lvl {
    font-size: 24px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pic-card {
    position: relative;
    align-self: center;
    flex: none;
    width: min(236px, 30vh, 80vw);
    padding: 16px 14px 10px;
    border-radius: 6px 6px 14px 14px;
    background: #fffdf6;
    background-image: repeating-linear-gradient(180deg, transparent 0 21px, #e6dcc6 21px 22px);
    box-shadow:
        0 6px 0 #dcc6a2,
        0 14px 22px var(--shadow);
    transform: rotate(-1.2deg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.pic-card canvas {
    width: 100%;
    aspect-ratio: 1;
    display: block;
    border-radius: 6px;
    background: var(--card);
    box-shadow: inset 0 0 0 2px #e6d4b4;
}
.pin {
    position: absolute;
    top: -9px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ff8a7a, #c8382a 70%);
    box-shadow: 0 3px 4px rgba(0, 0, 0, 0.3);
}
.pic-label {
    font-size: 12px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--muted);
}
.board-wrap {
    flex: 1;
    min-height: 180px;
    position: relative;
}
.board-wrap canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}
.rolls {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.msg {
    flex: none;
    margin: 0;
    min-height: 24px;
    text-align: center;
    font-size: 16px;
    color: var(--muted);
}
.msg.bad {
    color: #c4262e;
    font-weight: 700;
}
.dock {
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}
.actions {
    display: flex;
    gap: 10px;
}

/* Paper rolls */
.roll {
    position: absolute;
    margin: 0;
    border: 0;
    padding: 0;
    cursor: pointer;
    pointer-events: auto;
    background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0 4px, rgba(0, 0, 0, 0.05) 4px 9px),
        linear-gradient(180deg, var(--c2) 0%, var(--c) 38%, var(--d) 100%);
    box-shadow:
        0 6px 0 rgba(60, 30, 10, 0.24),
        0 10px 14px rgba(60, 30, 10, 0.22);
    transform: rotate(var(--rot, 0deg));
    transition:
        transform 0.15s,
        visibility 0s;
}
.roll.row {
    width: 118px;
    height: 42px;
    border-radius: 12px;
}
.roll.col {
    width: 42px;
    height: 118px;
    border-radius: 12px;
    background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.16) 0 4px, rgba(0, 0, 0, 0.05) 4px 9px),
        linear-gradient(90deg, var(--c2) 0%, var(--c) 38%, var(--d) 100%);
}
.roll::before,
.roll::after {
    content: "";
    position: absolute;
    border-radius: 50%;
}
.roll::before {
    background: radial-gradient(circle at 40% 35%, #fff 0 10%, var(--c2) 30%, var(--d) 100%);
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.35);
}
.roll::after {
    background: repeating-radial-gradient(circle, var(--d) 0 3px, var(--c) 3px 6px);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.4);
}
.roll.row::before {
    left: -7px;
    top: 0;
    bottom: 0;
    width: 16px;
}
.roll.row::after {
    right: -7px;
    top: 4px;
    bottom: 4px;
    width: 14px;
}
.roll.col::before {
    top: -7px;
    left: 0;
    right: 0;
    height: 16px;
}
.roll.col::after {
    bottom: -7px;
    left: 4px;
    right: 4px;
    height: 14px;
}
.roll:hover:not(:disabled) {
    transform: rotate(var(--rot, 0deg)) translateY(-3px);
}
.roll:active:not(:disabled) {
    transform: rotate(var(--rot, 0deg)) translateY(3px);
}
.roll:disabled {
    cursor: default;
}
.roll.used {
    visibility: hidden;
}
.roll.pulse {
    outline: 3px solid #ffd54a;
    outline-offset: 5px;
    border-radius: 14px;
    animation: glow 0.9s ease-in-out infinite alternate;
}
@keyframes glow {
    from {
        outline-color: rgba(255, 213, 74, 0.35);
    }
    to {
        outline-color: #ffd54a;
    }
}

/* Popups */
.scrim {
    position: fixed;
    inset: 0;
    background: rgba(40, 25, 12, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 10;
}
.scrim.show {
    display: flex;
    animation: fadein 0.2s ease-out both;
}
@keyframes fadein {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
.card {
    position: relative;
    color: var(--ink);
    background: var(--card);
    box-shadow:
        0 0 0 3px var(--rim),
        0 9px 0 3px var(--rim),
        0 20px 30px rgba(0, 0, 0, 0.25);
    border-radius: 26px;
    padding: 40px 24px 28px;
    max-width: 380px;
    width: 100%;
    text-align: center;
    animation: pop 0.35s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}
@keyframes pop {
    from {
        opacity: 0;
        transform: scale(0.85) translateY(10px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
.card h3 {
    position: absolute;
    left: 50%;
    top: -26px;
    transform: translateX(-50%);
    margin: 0;
    padding: 10px 34px;
    white-space: nowrap;
    font-size: 24px;
    color: #fff8ee;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
    background: linear-gradient(180deg, #ef6f5e, #c9503f);
    border-radius: 12px;
    box-shadow:
        0 0 0 3px var(--rim),
        0 5px 0 3px var(--rim);
}
.card .stars {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
}
.card .stars img {
    width: 50px;
    height: 50px;
    filter: sepia(1) saturate(5) hue-rotate(5deg) brightness(0.95) drop-shadow(0 2px 0 var(--rim));
    animation: starpop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
.card .stars img:nth-child(2) {
    animation-delay: 0.15s;
}
.card .stars img:nth-child(3) {
    animation-delay: 0.3s;
}
.card .stars img.off {
    opacity: 0.3;
    filter: grayscale(1);
}
@keyframes starpop {
    from {
        transform: scale(0) rotate(-40deg);
    }
    to {
        transform: none;
    }
}
.card p {
    margin: 8px 0 20px;
    font-size: 16px;
    line-height: 1.45;
}
.card .row {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: center;
}
.card .row .wood {
    min-width: 240px;
}

@media (min-width: 700px) {
    .lvl {
        font-size: 28px;
    }
    .roll.row {
        width: 140px;
        height: 48px;
    }
    .roll.col {
        width: 48px;
        height: 140px;
    }
}

/* Small phones */
@media (max-width: 420px) {
    .screen {
        padding-left: 14px;
        padding-right: 14px;
    }
    .wood.sm {
        padding: 8px 12px;
        font-size: 13px;
        gap: 5px;
    }
    .wood.sm .ico {
        width: 22px;
        height: 22px;
    }
    .wood.big {
        min-width: 210px;
        padding: 11px 36px;
    }
    .actions {
        gap: 8px;
    }
    .wood.round.lg {
        width: 70px;
        height: 70px;
    }
    .menu-row {
        gap: 20px;
    }
    .set-row {
        padding: 16px 14px;
    }
    .set-row .wood.sm {
        min-width: 112px;
    }
    .steps li {
        font-size: 16px;
    }
}
@media (max-width: 480px) {
    .tile.stone .st {
        display: none;
    }
    .tile {
        font-size: 19px;
    }
    .plate {
        padding: 8px 14px;
    }
    .plate h2 {
        font-size: 21px;
        white-space: nowrap;
    }
    .dr {
        width: 110px;
        height: 36px;
    }
}

/* Short screens: tighter menu */
@media (max-height: 520px) {
    .menu-card {
        gap: 12px;
        padding: 6px 0;
    }
    .logo {
        width: 56px;
        margin-bottom: 2px;
    }
    .wordmark {
        font-size: 34px;
    }
    .tagline {
        display: none;
    }
    .chip {
        padding: 4px 14px 4px 8px;
        font-size: 15px;
    }
    .wood.big {
        min-height: 52px;
        font-size: 20px;
        padding: 10px 36px;
        min-width: 190px;
    }
    .wood.big .ico {
        width: 30px;
        height: 30px;
    }
    .wood.round.lg {
        width: 58px;
        height: 58px;
    }
    .wood.round.lg .ico {
        width: 30px;
        height: 30px;
    }
    .mbtn {
        gap: 8px;
    }
    .mbtn span {
        font-size: 13px;
    }
    .loader-box {
        gap: 16px;
    }
}

/* Landscape phones: picture left, board right */
@media (max-height: 520px) and (min-width: 560px) {
    #game.active {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
        grid-template-rows: auto minmax(0, 1fr) auto;
        column-gap: 18px;
        row-gap: 6px;
        align-items: center;
        overflow: hidden;
    }
    #game .hud {
        grid-column: 1 / -1;
    }
    #game .pic-card {
        grid-column: 1;
        grid-row: 2;
        width: min(190px, 46vh);
        justify-self: center;
    }
    #game .board-wrap {
        grid-column: 2;
        grid-row: 2;
        min-height: 0;
        height: 100%;
    }
    #game .msg {
        grid-column: 1;
        grid-row: 3;
        font-size: 14px;
    }
    #game .dock {
        grid-column: 2;
        grid-row: 3;
    }
}

/* Wide screens: picture left, big board right, buttons underneath */
@media (min-width: 900px) and (min-height: 560px) {
    #game.active {
        max-width: 1180px;
        display: grid;
        grid-template-columns: clamp(260px, 30vw, 380px) minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr) auto auto;
        grid-template-areas: "hud hud" "pic board" "msg board" "dock dock";
        column-gap: 32px;
        row-gap: 8px;
        align-items: start;
        overflow: hidden;
    }
    #game .hud {
        grid-area: hud;
    }
    #game .pic-card {
        grid-area: pic;
        width: min(100%, 330px);
        justify-self: center;
        align-self: center;
        margin-top: 12px;
    }
    #game .board-wrap {
        grid-area: board;
        min-height: 0;
        height: 100%;
    }
    #game .msg {
        grid-area: msg;
        align-self: start;
        padding: 0 10px;
    }
    #game .dock {
        grid-area: dock;
    }
    #levels,
    #howto,
    #settings {
        max-width: 960px;
    }
    #levels .chapters {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 28px 24px;
        align-items: start;
    }
    #levels .chapter-block:last-child {
        grid-column: 1 / -1;
    }
    #levels .chapter-block:last-child .lvl-grid {
        grid-template-columns: repeat(10, minmax(0, 1fr));
    }
    #howto .steps {
        max-width: 720px;
        align-self: center;
        width: 100%;
    }
    #settings .panel {
        max-width: 640px;
        align-self: center;
        width: 100%;
    }
    .dr {
        width: 190px;
        height: 58px;
    }
}
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
