:root {
    --pink: #ff4fa3;
    --hot-pink: #ff2f86;
    --bubble: #ffd2ef;
    --cream: #fff5d8;
    --mint: #79efc6;
    --blue: #49b9ff;
    --orange: #ffad35;
    --choco: #75452e;
    --ink: #56305c;
    --white: #fff;
    --panel: rgba(255, 246, 222, 0.92);
    --shadow: 0 14px 30px rgba(121, 48, 102, 0.22);
    --card-size: clamp(82px, 24vw, 132px);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
}

body {
    color: var(--ink);
    font-family: 'Trebuchet MS', 'Comic Sans MS', cursive, sans-serif;
    background: #ffd6ec url('assets/backgrounds/candy_land.png') center / cover
        fixed no-repeat;
    overflow-x: hidden;
}

button {
    border: 0;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    filter: grayscale(0.35);
    opacity: 0.58;
}

.app-shell {
    position: relative;
    min-height: 100vh;
    padding: 18px;
    overflow: hidden;
}

.app-shell::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(
            circle at 20% 12%,
            rgba(255, 255, 255, 0.92) 0 2px,
            transparent 3px
        ),
        radial-gradient(
            circle at 76% 25%,
            rgba(255, 255, 255, 0.78) 0 3px,
            transparent 4px
        ),
        linear-gradient(
            180deg,
            rgba(255, 211, 236, 0.22),
            rgba(255, 246, 209, 0.34)
        );
}

.game-app {
    position: relative;
    z-index: 1;
    width: min(100%, 980px);
    min-height: calc(100vh - 36px);
    margin: 0 auto;
}

.screen {
    display: none;
    min-height: calc(100vh - 36px);
    align-items: center;
    justify-content: center;
    animation: screenIn 300ms ease both;
}

.screen.is-active {
    display: flex;
}

.loading-screen,
.home-screen,
.difficulty-screen {
    flex-direction: column;
    gap: 20px;
}

.brand-logo,
.brand-badge,
.hero-panel,
.difficulty-card,
.modal-card,
.stat-box,
.level-pill {
    border: 3px solid rgba(255, 255, 255, 0.82);
    background:
        linear-gradient(
            135deg,
            rgba(255, 255, 255, 0.84),
            rgba(255, 255, 255, 0.22)
        ),
        var(--panel);
    box-shadow:
        var(--shadow),
        inset 0 2px 0 rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(8px);
}

.brand-badge {
    padding: 18px 26px;
    border-radius: 28px;
    color: var(--hot-pink);
    font-size: clamp(2.2rem, 10vw, 5rem);
    font-weight: 1000;
    letter-spacing: -0.06em;
    text-align: center;
    text-shadow:
        0 5px 0 var(--white),
        0 10px 18px rgba(110, 34, 88, 0.22);
}

.brand-logo {
    position: relative;
    display: block;
    width: min(76vw, 430px);
    height: auto;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    filter: drop-shadow(0 16px 20px rgba(98, 42, 72, 0.24));
}

.loading-logo {
    width: min(72vw, 360px);
    animation: pop-in 420ms ease both;
}

.home-logo {
    width: min(70vw, 360px);
}

.loader-candy {
    display: flex;
    gap: 12px;
}

.loader-candy span {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: var(--pink);
    box-shadow:
        inset -4px -5px 0 rgba(134, 34, 92, 0.18),
        0 8px 16px rgba(116, 38, 83, 0.2);
    animation: bounce 700ms ease-in-out infinite alternate;
}

.loader-candy span:nth-child(2) {
    background: var(--mint);
    animation-delay: 120ms;
}

.loader-candy span:nth-child(3) {
    background: var(--orange);
    animation-delay: 240ms;
}

.loading-copy {
    margin: 0;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    font-weight: 900;
}

.progress-shell {
    width: min(280px, 76vw);
    height: 18px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.74);
    box-shadow: inset 0 3px 8px rgba(95, 42, 87, 0.16);
}

.progress-fill {
    height: 100%;
    border-radius: inherit;
    background: repeating-linear-gradient(
        45deg,
        var(--pink) 0 12px,
        var(--cream) 12px 24px
    );
    animation: loadFill 1250ms ease forwards;
}

.hero-panel {
    width: min(92vw, 500px);
    min-height: min(84vh, 760px);
    padding: clamp(22px, 5.5vw, 42px);
    border-radius: 42px;
    text-align: center;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: clamp(12px, 2.4vh, 22px);
}

.hero-panel::before,
.modal-card::before {
    content: '';
    position: absolute;
    inset: 12px;
    border-radius: inherit;
    pointer-events: none;
    background: repeating-linear-gradient(
        -35deg,
        transparent 0 20px,
        rgba(255, 79, 163, 0.09) 20px 32px
    );
}

.eyebrow {
    position: relative;
    margin: 0;
    color: var(--blue);
    font-weight: 1000;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-size: clamp(0.88rem, 3.6vw, 1.15rem);
}

h1,
h2,
p {
    position: relative;
}

h1 {
    margin: 0;
    color: var(--hot-pink);
    font-size: clamp(4rem, 17vw, 8rem);
    line-height: 0.77;
    letter-spacing: -0.08em;
    text-shadow:
        0 6px 0 var(--white),
        0 14px 22px rgba(111, 36, 91, 0.24);
}

.hero-copy {
    width: min(100%, 340px);
    margin: 0 auto;
    color: #7a4b76;
    font-size: clamp(0.98rem, 4vw, 1.08rem);
    font-weight: 800;
    line-height: 1.35;
}

.image-button,
.icon-image-button {
    position: relative;
    display: inline-grid;
    place-items: center;
    background: transparent;
    transition:
        transform 180ms ease,
        filter 180ms ease;
}

.image-button:hover,
.icon-image-button:hover,
.candy-button:hover,
.power-button:hover,
.difficulty-card:hover {
    transform: translateY(-3px) scale(1.02);
}

.image-button:active,
.icon-image-button:active,
.candy-button:active,
.power-button:active,
.difficulty-card:active {
    transform: translateY(1px) scale(0.98);
}

.play-button {
    width: min(270px, 68vw);
    aspect-ratio: 1.5;
    margin: 2px auto 0;
}

.play-button img,
.icon-image-button img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 12px 16px rgba(111, 33, 91, 0.25));
}

.play-button span {
    display: none;
    position: absolute;
    color: var(--white);
    font-size: clamp(1.55rem, 7vw, 2.45rem);
    font-weight: 1000;
    text-shadow: 0 3px 0 rgba(136, 28, 83, 0.32);
}

.candy-button,
.power-button,
.modal-actions button {
    position: relative;
    min-height: 48px;
    padding: 12px 22px;
    border-radius: 999px;
    color: var(--white);
    font-weight: 1000;
    letter-spacing: 0.01em;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.48), transparent 42%),
        linear-gradient(135deg, var(--pink), var(--orange));
    box-shadow:
        0 12px 20px rgba(131, 40, 92, 0.22),
        inset 0 -5px 0 rgba(109, 31, 75, 0.16),
        inset 0 2px 0 rgba(255, 255, 255, 0.58);
    transition:
        transform 180ms ease,
        filter 180ms ease;
}

.candy-button.secondary,
.modal-actions .secondary {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.42), transparent 42%),
        linear-gradient(135deg, var(--blue), var(--mint));
}

.candy-button.small {
    min-height: 42px;
    padding: 10px 18px;
    font-size: 0.95rem;
}

.screen-header,
.game-topbar {
    width: min(100%, 720px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.screen-header {
    margin-bottom: 4px;
}

.screen-header h2 {
    margin: 0;
    padding: 12px 20px;
    border-radius: 999px;
    color: var(--hot-pink);
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 10px 22px rgba(110, 36, 88, 0.16);
    font-size: clamp(1.45rem, 7vw, 2.7rem);
    letter-spacing: -0.04em;
    text-align: center;
}

.header-spacer {
    width: 58px;
}

.icon-image-button {
    width: 58px;
    height: 58px;
    flex: 0 0 auto;
}

.difficulty-grid {
    width: min(100%, 760px);
    display: grid;
    gap: 16px;
}

.difficulty-card {
    min-height: 158px;
    padding: 18px;
    border-radius: 32px;
    text-align: left;
    overflow: hidden;
    transition: transform 180ms ease;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(128px, 42%);
    align-items: center;
    gap: 10px;
}

.difficulty-card::after {
    content: '';
    position: absolute;
}

.difficulty-card {
    position: relative;
}

.difficulty-card::before {
    content: '';
    position: absolute;
    width: 120px;
    height: 120px;
    right: -28px;
    bottom: -32px;
    border-radius: 50%;
    background: repeating-linear-gradient(
        45deg,
        var(--pink) 0 12px,
        var(--white) 12px 24px
    );
    box-shadow: inset -10px -12px 0 rgba(125, 42, 92, 0.12);
    opacity: 0.32;
}

.difficulty-card.featured {
    background:
        linear-gradient(
            135deg,
            rgba(255, 255, 255, 0.9),
            rgba(255, 255, 255, 0.26)
        ),
        linear-gradient(135deg, #fff8da, #ffd2ef);
}

.difficulty-copy,
.difficulty-name,
.difficulty-count,
.difficulty-detail {
    position: relative;
    display: block;
}

.difficulty-copy {
    z-index: 2;
}

.level-art {
    position: relative;
    z-index: 1;
    width: min(100%, 190px);
    justify-self: end;
    object-fit: contain;
    filter: drop-shadow(0 12px 12px rgba(105, 41, 86, 0.18));
    transform: rotate(2deg) scale(1.04);
    transition: transform 180ms ease;
}

.difficulty-card:hover .level-art {
    transform: rotate(-1deg) scale(1.1);
}

.difficulty-name {
    color: var(--hot-pink);
    font-size: 2rem;
    font-weight: 1000;
    letter-spacing: -0.04em;
}

.difficulty-count {
    margin-top: 8px;
    font-size: 1.1rem;
    font-weight: 1000;
}

.difficulty-detail {
    margin-top: 3px;
    color: #845983;
    font-weight: 800;
}

.game-screen {
    min-height: calc(100vh - 36px);
    flex-direction: column;
    justify-content: flex-start;
    gap: 8px;
    padding: 2px 0 12px;
}

.game-topbar {
    position: sticky;
    top: 8px;
    z-index: 4;
    width: min(100%, 840px);
}

.level-pill {
    min-width: 118px;
    padding: 7px 14px;
    border-radius: 999px;
    color: var(--hot-pink);
    font-size: 1.08rem;
    font-weight: 1000;
    text-align: center;
}

.stats-bar {
    width: min(100%, 760px);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
}

.stat-box {
    min-height: 42px;
    padding: 5px 6px;
    border-radius: 15px;
    text-align: center;
}

.stat-box span {
    display: block;
    color: #8e5b87;
    font-size: 0.58rem;
    font-weight: 1000;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat-box strong {
    display: block;
    color: var(--hot-pink);
    font-size: 1.05rem;
    line-height: 1.05;
}

.power-row {
    width: min(100%, 560px);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.power-button {
    min-height: 36px;
    padding: 5px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.82rem;
}

.power-button b {
    min-width: 20px;
    min-height: 20px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--hot-pink);
    background: var(--white);
    box-shadow: inset 0 -3px 0 rgba(126, 43, 95, 0.12);
}

.card-grid {
    width: min(100%, 760px);
    display: grid;
    grid-template-columns: repeat(var(--columns, 4), minmax(0, 1fr));
    gap: clamp(5px, 1.8vw, 12px);
    justify-items: center;
    padding: 4px 0 0;
    perspective: 900px;
}

.memory-card {
    width: min(100%, var(--card-size));
    aspect-ratio: 0.72;
    padding: 0;
    border-radius: 18%;
    background: transparent;
    position: relative;
    transform-style: preserve-3d;
}

.card-inner {
    position: absolute;
    inset: 0;
}

.card-face {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    border-radius: 18%;
    overflow: hidden;
    transition:
        opacity 220ms ease,
        transform 260ms cubic-bezier(0.2, 0.75, 0.2, 1.12);
}

.card-face img.card-art {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
}

.card-front {
    z-index: 2;
    opacity: 0;
    transform: scale(0.82) rotate(-4deg);
    pointer-events: none;
}

.card-back {
    z-index: 1;
}

.memory-card.is-flipped .card-back,
.memory-card.is-matched .card-back,
.memory-card.is-hinted .card-back {
    opacity: 0;
    transform: scale(0.84) rotate(4deg);
}

.memory-card.is-flipped .card-front,
.memory-card.is-matched .card-front,
.memory-card.is-hinted .card-front {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.candy-icon {
    position: relative;
    z-index: 5;
    width: 68%;
    height: 68%;
    object-fit: contain;
    filter: drop-shadow(0 8px 8px rgba(86, 48, 92, 0.2));
    transform: scale(0.92);
    transition: transform 180ms ease;
}

.memory-card.is-flipped .candy-icon,
.memory-card.is-matched .candy-icon,
.memory-card.is-hinted .candy-icon {
    transform: scale(1.16) rotate(-3deg);
}

.memory-card.is-matched {
    animation: matchPop 440ms ease both;
}

.memory-card.is-hinted::after {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 24%;
    background: url('assets/cards/card_highlight.png') center / contain
        no-repeat;
    pointer-events: none;
    filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.88));
    animation: glimmer 900ms ease-in-out infinite alternate;
}

.memory-card.is-matched .card-front::after {
    content: '';
    position: absolute;
    inset: 10%;
    z-index: 3;
    border-radius: 18%;
    pointer-events: none;
    box-shadow:
        inset 0 0 0 4px rgba(255, 255, 255, 0.9),
        0 0 18px rgba(255, 242, 104, 0.78);
}

.modal-layer {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(94, 43, 91, 0.34);
    backdrop-filter: blur(7px);
}

.modal-layer.is-active {
    display: flex;
}

.modal-card {
    position: relative;
    width: min(100%, 430px);
    padding: 28px 22px 24px;
    border-radius: 36px;
    text-align: center;
    overflow: hidden;
    animation: modalIn 260ms ease both;
}

.modal-card h2 {
    margin: 4px 0 8px;
    color: var(--hot-pink);
    font-size: clamp(2rem, 10vw, 3.3rem);
    letter-spacing: -0.06em;
    text-shadow: 0 4px 0 var(--white);
}

.modal-card p {
    margin: 0 auto 14px;
    max-width: 320px;
    color: #7a4b76;
    font-weight: 900;
    line-height: 1.35;
}

.star-row {
    position: relative;
    display: flex;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
}

.star {
    width: 38px;
    height: 38px;
    clip-path: polygon(
        50% 0%,
        61% 35%,
        98% 35%,
        68% 56%,
        79% 91%,
        50% 70%,
        21% 91%,
        32% 56%,
        2% 35%,
        39% 35%
    );
    background: linear-gradient(180deg, #fff6a5, #ffc739 68%, #ff9e1b);
    filter: drop-shadow(0 5px 0 rgba(133, 78, 17, 0.18));
}

.star.empty {
    background: linear-gradient(180deg, #efd8e8, #caaac8);
}

.modal-stats {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 16px 0;
}

.modal-stat {
    padding: 9px 10px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: inset 0 -4px 0 rgba(121, 43, 92, 0.08);
}

.modal-stat span {
    display: block;
    color: #8e5b87;
    font-size: 0.74rem;
    font-weight: 1000;
    text-transform: uppercase;
}

.modal-stat strong {
    display: block;
    color: var(--hot-pink);
    font-size: 1.2rem;
}

.modal-actions {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.floating-candy {
    position: fixed;
    z-index: 0;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0.55;
    filter: blur(0.2px);
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.92) 0 12px,
        rgba(255, 79, 163, 0.78) 12px 24px
    );
    animation: floaty 8s ease-in-out infinite;
}

.candy-a {
    left: -26px;
    top: 12%;
}
.candy-b {
    right: -32px;
    top: 42%;
    width: 110px;
    height: 110px;
    animation-delay: -2s;
    background: repeating-linear-gradient(
        -45deg,
        rgba(255, 255, 255, 0.92) 0 14px,
        rgba(73, 185, 255, 0.75) 14px 28px
    );
}
.candy-c {
    left: 8%;
    bottom: -42px;
    width: 120px;
    height: 120px;
    animation-delay: -4s;
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.92) 0 14px,
        rgba(121, 239, 198, 0.72) 14px 28px
    );
}

@keyframes screenIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    from {
        transform: translateY(0) scale(1);
    }
    to {
        transform: translateY(-14px) scale(1.08);
    }
}

@keyframes loadFill {
    from {
        width: 12%;
    }
    to {
        width: 100%;
    }
}

@keyframes pop-in {
    from {
        opacity: 0;
        transform: scale(0.94);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes matchPop {
    50% {
        transform: scale(1.08) rotate(2deg);
    }
}

@keyframes glimmer {
    from {
        opacity: 0.46;
        transform: scale(0.98);
    }
    to {
        opacity: 0.95;
        transform: scale(1.03);
    }
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes floaty {
    0%,
    100% {
        transform: translate3d(0, 0, 0) rotate(0deg);
    }
    50% {
        transform: translate3d(0, -28px, 0) rotate(12deg);
    }
}

.pop-in {
    animation: pop-in 360ms ease both;
}

@media (min-width: 640px) {
    .app-shell {
        padding: 28px;
    }

    .game-app,
    .screen,
    .game-screen {
        min-height: calc(100vh - 56px);
    }

    .difficulty-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .stats-bar {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }

    .stat-box {
        min-height: 58px;
        padding: 8px 10px;
        border-radius: 19px;
    }

    .stat-box span {
        font-size: 0.72rem;
    }

    .stat-box strong {
        font-size: 1.3rem;
    }

    .power-row {
        width: min(100%, 600px);
        gap: 12px;
    }

    .power-button {
        min-height: 46px;
        padding: 8px 12px;
        font-size: 0.95rem;
    }

    .power-button b {
        min-width: 25px;
        min-height: 25px;
    }

    .card-grid {
        gap: 16px;
    }
}

@media (max-width: 390px) {
    .app-shell {
        padding: 6px;
    }

    .game-app,
    .screen,
    .game-screen {
        min-height: calc(100vh - 12px);
    }

    .hero-panel {
        min-height: min(82vh, 700px);
        border-radius: 34px;
        gap: 10px;
    }

    .home-logo {
        width: min(68vw, 320px);
    }

    .play-button {
        width: min(250px, 66vw);
    }

    .difficulty-grid {
        gap: 10px;
    }

    .difficulty-card {
        min-height: 128px;
        padding: 14px;
        grid-template-columns: minmax(0, 1fr) minmax(110px, 40%);
        border-radius: 26px;
    }

    .difficulty-name {
        font-size: 1.65rem;
    }

    .difficulty-count {
        margin-top: 4px;
        font-size: 0.98rem;
    }

    .difficulty-detail {
        font-size: 0.92rem;
    }

    .level-art {
        width: min(100%, 145px);
    }

    .game-topbar {
        top: 4px;
    }

    .level-pill {
        min-width: 96px;
        padding: 5px 12px;
        font-size: 0.98rem;
    }

    .stat-box strong {
        font-size: 0.96rem;
    }

    .card-grid {
        width: calc(100vw - 12px);
        gap: 4px;
    }
}

/* Reference-style candy UI refresh */
.game-app {
    width: min(100%, 520px);
}

.screen {
    width: 100%;
}

.home-screen,
.difficulty-screen,
.game-screen {
    position: relative;
    border: 5px solid rgba(255, 255, 255, 0.88);
    border-radius: 36px;
    box-shadow:
        0 22px 44px rgba(120, 48, 91, 0.26),
        inset 0 0 0 2px rgba(255, 210, 239, 0.48);
    overflow: hidden;
}

.home-screen::before,
.difficulty-screen::before,
.game-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.06),
        rgba(255, 174, 211, 0.1)
    );
}

.hero-panel {
    width: 100%;
    min-height: calc(100vh - 46px);
    padding: clamp(24px, 7vw, 46px) clamp(18px, 5vw, 32px)
        clamp(20px, 5vw, 32px);
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    justify-content: space-around;
}

.hero-panel::before {
    display: none;
}

.eyebrow {
    color: #ffffff;
    text-shadow:
        0 3px 0 rgba(57, 128, 199, 0.26),
        0 5px 12px rgba(58, 86, 158, 0.2);
}

.home-logo {
    margin: clamp(6px, 2vh, 20px) auto clamp(0px, 1vh, 8px);
    filter: drop-shadow(0 20px 18px rgba(87, 38, 55, 0.26));
}

.hero-copy {
    width: min(100%, 360px);
    padding: 12px 16px;
    border-radius: 22px;
    color: #74456f;
    background: rgba(255, 249, 232, 0.7);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.75),
        0 10px 18px rgba(107, 45, 86, 0.1);
}

.play-button {
    margin: 0 auto;
}

.home-nav {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    width: min(100%, 330px);
    margin: 0 auto;
}

.home-nav-button {
    display: grid;
    place-items: center;
    gap: 4px;
    background: transparent;
    color: #7b3f54;
    font-weight: 1000;
}

.home-nav-button span {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    font-size: 1.25rem;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.65), transparent 42%),
        linear-gradient(135deg, #ffd85d, #ff8b35 58%, #ff4f9a);
    border: 4px solid rgba(255, 244, 207, 0.95);
    box-shadow:
        0 10px 14px rgba(120, 58, 52, 0.22),
        inset 0 -5px 0 rgba(119, 58, 32, 0.18);
}

.home-nav-button b {
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(255, 244, 221, 0.86);
    box-shadow: inset 0 -2px 0 rgba(135, 80, 47, 0.12);
    font-size: 0.78rem;
}

.difficulty-screen {
    justify-content: flex-start;
    padding: clamp(18px, 5vw, 28px) 14px 22px;
}

.screen-header {
    position: relative;
    z-index: 2;
    width: 100%;
    margin: 0 0 clamp(18px, 5vh, 38px);
}

.screen-header h2 {
    position: relative;
    padding: 16px 18px 22px;
    color: #fff;
    background:
        radial-gradient(
            circle at 20% 18%,
            rgba(255, 255, 255, 0.44),
            transparent 22%
        ),
        linear-gradient(180deg, #c575ff, #ff4f93 55%, #e23d75);
    border: 4px solid rgba(255, 199, 222, 0.95);
    border-radius: 26px 26px 46px 46px;
    box-shadow:
        0 14px 16px rgba(114, 47, 113, 0.22),
        inset 0 -6px 0 rgba(127, 38, 92, 0.18);
    font-size: clamp(1.45rem, 7vw, 2.2rem);
    text-shadow: 0 3px 0 rgba(117, 41, 96, 0.24);
}

.difficulty-grid {
    position: relative;
    z-index: 1;
    width: 100%;
    gap: 16px;
}

.difficulty-card {
    min-height: 128px;
    padding: 12px 16px;
    grid-template-columns: minmax(86px, 30%) minmax(0, 1fr) 42px;
    border: 4px solid rgba(255, 248, 220, 0.95);
    border-radius: 28px;
    box-shadow:
        0 12px 0 rgba(118, 77, 57, 0.18),
        0 18px 22px rgba(114, 47, 113, 0.16),
        inset 0 -5px 0 rgba(103, 76, 52, 0.12);
}

.difficulty-card:nth-child(1) {
    background: linear-gradient(180deg, #defcc7, #a8ed75);
    color: #3f8a31;
}

.difficulty-card:nth-child(2) {
    background: linear-gradient(180deg, #fff0a8, #ffc95d);
    color: #c66d25;
}

.difficulty-card:nth-child(3) {
    background: linear-gradient(180deg, #eccdff, #bd82f3);
    color: #793ac0;
}

.difficulty-card::before {
    display: none;
}

.difficulty-card::after {
    content: '';
    position: relative;
    z-index: 2;
    width: 34px;
    height: 34px;
    justify-self: center;
    border-radius: 50%;
    background: radial-gradient(
        circle at 35% 30%,
        #fffbe2,
        #ffd245 56%,
        #ff9d2d 57%
    );
    clip-path: polygon(
        50% 0%,
        61% 35%,
        98% 35%,
        68% 56%,
        79% 91%,
        50% 70%,
        21% 91%,
        32% 56%,
        2% 35%,
        39% 35%
    );
    filter: drop-shadow(0 4px 0 rgba(134, 70, 28, 0.2));
}

.level-art {
    grid-column: 1;
    grid-row: 1;
    width: min(100%, 112px);
    justify-self: center;
    transform: rotate(-3deg) scale(1.15);
}

.difficulty-copy {
    grid-column: 2;
    grid-row: 1;
    text-align: center;
}

.difficulty-name {
    color: currentColor;
    font-size: clamp(1.8rem, 8vw, 2.35rem);
    text-shadow: 0 2px 0 rgba(255, 255, 255, 0.72);
}

.difficulty-count,
.difficulty-detail {
    display: inline-block;
    min-width: 96px;
    margin: 8px auto 0;
    padding: 4px 9px;
    border-radius: 10px;
    color: rgba(89, 50, 84, 0.78);
    background: rgba(255, 255, 255, 0.42);
    font-size: 0.85rem;
}

.difficulty-detail {
    margin-top: 3px;
}

.game-screen {
    gap: 7px;
    padding: 12px 14px 16px;
    background: linear-gradient(
        180deg,
        rgba(142, 103, 224, 0.74),
        rgba(104, 74, 179, 0.38)
    );
}

.game-topbar {
    width: 100%;
    position: relative;
    top: auto;
}

.level-pill {
    min-width: 118px;
    padding: 8px 16px;
    color: #fff;
    background: linear-gradient(180deg, #c885ff, #8f4bc4);
    border: 4px solid rgba(255, 226, 181, 0.95);
    text-shadow: 0 2px 0 rgba(82, 42, 106, 0.24);
}

.stats-bar {
    width: min(100%, 390px);
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    padding: 6px;
    border: 4px solid rgba(255, 223, 182, 0.96);
    border-radius: 18px;
    background: linear-gradient(180deg, #fff5dc, #ffdba5);
    box-shadow:
        0 8px 0 rgba(103, 62, 88, 0.16),
        inset 0 2px 0 rgba(255, 255, 255, 0.82);
}

.stat-box {
    min-height: 40px;
    padding: 3px 4px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}

.stat-box + .stat-box {
    border-left: 2px solid rgba(137, 73, 104, 0.13);
}

.stat-box span {
    color: #9a4e61;
    font-size: 0.58rem;
    letter-spacing: 0;
}

.stat-box strong {
    color: #6a2f7e;
    font-size: 0.98rem;
}

.game-progress {
    position: relative;
    z-index: 1;
    width: min(100%, 330px);
    height: 32px;
    display: grid;
    grid-template-columns: 34px 1fr 34px 1fr 34px;
    align-items: center;
    margin: 2px auto 0;
}

.progress-track {
    height: 12px;
    margin: 0 -5px;
    border-radius: 999px;
    background: linear-gradient(90deg, #ffd55d, #ff4f86 54%, #66209d);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.5),
        inset 0 -3px 0 rgba(89, 37, 109, 0.28);
}

.progress-star {
    position: relative;
    z-index: 2;
    width: 34px;
    height: 34px;
    clip-path: polygon(
        50% 0%,
        61% 35%,
        98% 35%,
        68% 56%,
        79% 91%,
        50% 70%,
        21% 91%,
        32% 56%,
        2% 35%,
        39% 35%
    );
    background: linear-gradient(180deg, #4d227e, #2f1558);
    filter: drop-shadow(0 4px 0 rgba(54, 20, 85, 0.25));
}

.progress-star.is-filled {
    background: linear-gradient(180deg, #fff6a5, #ffc739 68%, #ff9e1b);
}

.card-grid {
    width: min(100%, 404px);
    padding: 10px 10px 12px;
    gap: clamp(6px, 1.8vw, 10px);
    border-radius: 24px;
    background: rgba(88, 61, 169, 0.24);
    box-shadow:
        inset 0 0 0 3px rgba(255, 255, 255, 0.18),
        0 14px 22px rgba(72, 41, 110, 0.12);
}

.power-row {
    width: min(100%, 350px);
    gap: 12px;
    margin-top: 2px;
}

.power-button {
    min-height: 66px;
    flex-direction: column;
    gap: 2px;
    padding: 5px 5px 7px;
    border-radius: 20px;
    color: #6f3d58;
    background: transparent;
    box-shadow: none;
}

.power-button::before {
    content: '';
    width: 48px;
    height: 48px;
    border-radius: 16px;
    border: 4px solid rgba(255, 238, 199, 0.96);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.6), transparent 45%),
        linear-gradient(135deg, #79efc6, #35c7a7);
    box-shadow:
        0 8px 0 rgba(87, 76, 82, 0.18),
        inset 0 -5px 0 rgba(39, 114, 98, 0.18);
}

.hint-power::before {
    background:
        radial-gradient(circle at 42% 38%, #d6fbff 0 16%, transparent 17%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.6), transparent 45%),
        linear-gradient(135deg, #8ee7ff, #43c7e8);
}

.shuffle-power::before {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.6), transparent 45%),
        linear-gradient(135deg, #8effca, #48c97f);
}

.undo-power::before {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.6), transparent 45%),
        linear-gradient(135deg, #b8ffcf, #53c98d);
}

.power-button span {
    order: 2;
    margin-top: -2px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 242, 218, 0.9);
    font-size: 0.75rem;
    font-weight: 1000;
    box-shadow: inset 0 -2px 0 rgba(123, 76, 54, 0.13);
}

.power-button b {
    position: absolute;
    top: 2px;
    right: 11px;
    min-width: 22px;
    min-height: 22px;
    color: #fff;
    background: linear-gradient(180deg, #ff789f, #ef376b);
    border: 2px solid #ffe8f0;
    box-shadow: 0 3px 0 rgba(122, 40, 70, 0.16);
}

@media (min-width: 640px) {
    .game-app {
        width: min(100%, 560px);
    }

    .hero-panel {
        min-height: calc(100vh - 66px);
    }

    .home-logo {
        width: min(74vw, 420px);
    }

    .card-grid {
        width: min(100%, 440px);
    }
}

@media (max-width: 390px) {
    .home-screen,
    .difficulty-screen,
    .game-screen {
        border-width: 4px;
        border-radius: 28px;
    }

    .hero-panel {
        min-height: calc(100vh - 20px);
        padding: 18px 14px;
    }

    .home-logo {
        width: min(82vw, 340px);
    }

    .home-nav {
        gap: 8px;
    }

    .home-nav-button span {
        width: 48px;
        height: 48px;
    }

    .difficulty-screen {
        padding: 14px 10px 16px;
    }

    .difficulty-card {
        grid-template-columns: minmax(72px, 28%) minmax(0, 1fr) 30px;
        min-height: 110px;
        padding: 10px 12px;
    }

    .level-art {
        width: min(100%, 92px);
    }

    .difficulty-name {
        font-size: 1.55rem;
    }

    .game-screen {
        padding: 8px 8px 12px;
    }

    .card-grid {
        width: 100%;
        padding: 8px;
        gap: 5px;
    }

    .power-row {
        gap: 6px;
    }

    .power-button::before {
        width: 42px;
        height: 42px;
    }
}

.hint-power::before,
.shuffle-power::before,
.undo-power::before {
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1.15rem;
    font-weight: 1000;
    text-shadow: 0 2px 0 rgba(48, 92, 93, 0.22);
}

.hint-power::before {
    content: '?';
}

.shuffle-power::before {
    content: 'S';
}

.undo-power::before {
    content: 'U';
}

/* Use level artwork as the difficulty cards */
.difficulty-grid {
    width: min(100%, 430px);
    gap: clamp(10px, 2vh, 16px);
}

.difficulty-card,
.difficulty-card:nth-child(1),
.difficulty-card:nth-child(2),
.difficulty-card:nth-child(3) {
    min-height: 0;
    padding: 0;
    display: block;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
}

.difficulty-card::after,
.difficulty-card::before {
    display: none;
}

.difficulty-copy {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.level-art,
.difficulty-card:nth-child(1) .level-art,
.difficulty-card:nth-child(2) .level-art,
.difficulty-card:nth-child(3) .level-art {
    display: block;
    width: 100%;
    max-width: none;
    justify-self: auto;
    transform: none;
    filter: drop-shadow(0 15px 0 rgba(106, 72, 81, 0.16))
        drop-shadow(0 20px 20px rgba(104, 54, 93, 0.18));
    transition:
        transform 180ms ease,
        filter 180ms ease;
}

.difficulty-card:hover .level-art,
.difficulty-card:focus-visible .level-art {
    transform: translateY(-4px) scale(1.025);
    filter: drop-shadow(0 18px 0 rgba(106, 72, 81, 0.14))
        drop-shadow(0 22px 24px rgba(104, 54, 93, 0.2));
}

.difficulty-card:active .level-art {
    transform: translateY(1px) scale(0.99);
}

@media (max-width: 390px) {
    .difficulty-grid {
        width: 100%;
        gap: 8px;
    }

    .difficulty-card,
    .difficulty-card:nth-child(1),
    .difficulty-card:nth-child(2),
    .difficulty-card:nth-child(3) {
        min-height: 0;
        padding: 0;
        display: block;
    }

    .level-art {
        width: 100%;
    }
}

/* Tighten cropped level artwork layout */
.difficulty-screen {
    gap: 8px;
}

.difficulty-grid {
    width: min(100%, 450px);
    gap: clamp(6px, 1.1vh, 10px);
}

.level-art,
.difficulty-card:nth-child(1) .level-art,
.difficulty-card:nth-child(2) .level-art,
.difficulty-card:nth-child(3) .level-art {
    filter: drop-shadow(0 10px 0 rgba(106, 72, 81, 0.14))
        drop-shadow(0 13px 14px rgba(104, 54, 93, 0.16));
}

.screen-header {
    margin-bottom: clamp(8px, 2.2vh, 18px);
}

@media (max-width: 390px) {
    .difficulty-screen {
        padding: 12px 8px 12px;
    }

    .difficulty-grid {
        gap: 5px;
    }
}

/* Use real power-up button artwork */
.power-button::before,
.hint-power::before,
.shuffle-power::before,
.undo-power::before {
    content: none;
    display: none;
}

.power-button {
    min-height: auto;
    padding: 0;
    background: transparent;
    border-radius: 0;
    display: grid;
    place-items: center;
}

.power-button img {
    display: block;
    width: min(100%, 62px);
    height: auto;
    filter: drop-shadow(0 9px 0 rgba(100, 66, 72, 0.14))
        drop-shadow(0 12px 12px rgba(91, 45, 76, 0.18));
    transition:
        transform 180ms ease,
        filter 180ms ease;
}

.power-button:hover img,
.power-button:focus-visible img {
    transform: translateY(-3px) scale(1.05);
}

.power-button:active img {
    transform: translateY(1px) scale(0.98);
}

.power-button span {
    position: static;
    order: 2;
    margin-top: -5px;
    padding: 2px 8px;
    color: #6f3d58;
}

.power-button b {
    top: 0;
    right: calc(50% - 34px);
}

@media (max-width: 390px) {
    .power-button img {
        width: min(100%, 56px);
    }

    .power-button b {
        right: calc(50% - 30px);
    }
}

/* Softer difficulty title to match level artwork */
.difficulty-screen .screen-header {
    width: min(100%, 430px);
    margin: 0 auto clamp(8px, 1.4vh, 12px);
    align-items: center;
}

.difficulty-screen .screen-header h2 {
    min-width: 0;
    padding: 9px 22px 10px;
    border: 4px solid rgba(255, 247, 223, 0.96);
    border-radius: 999px;
    color: #7f4a74;
    background:
        linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.86),
            rgba(255, 245, 213, 0.86)
        ),
        repeating-linear-gradient(
            45deg,
            rgba(255, 94, 155, 0.16) 0 12px,
            rgba(255, 255, 255, 0.16) 12px 24px
        );
    box-shadow:
        0 8px 0 rgba(125, 77, 73, 0.12),
        0 12px 16px rgba(107, 55, 91, 0.1),
        inset 0 2px 0 rgba(255, 255, 255, 0.9);
    font-size: clamp(1rem, 5.2vw, 1.5rem);
    line-height: 1;
    letter-spacing: 0.01em;
    text-shadow: 0 2px 0 rgba(255, 255, 255, 0.78);
}

.difficulty-screen .header-spacer {
    width: 48px;
}

@media (max-width: 390px) {
    .difficulty-screen .screen-header h2 {
        padding: 8px 18px 9px;
        font-size: 1.08rem;
    }
}

/* Home has only the How shortcut now */
.home-nav {
    width: min(100%, 120px);
    grid-template-columns: 1fr;
    justify-items: center;
}

/* Live progress binding: track fill = matched pairs, stars = projected result */
.progress-track {
    --fill: 0%;
    background: linear-gradient(
        90deg,
        #ffd55d 0 var(--fill),
        rgba(74, 27, 112, 0.82) var(--fill) 100%
    );
}

.progress-star {
    opacity: 0.72;
    transition:
        transform 180ms ease,
        opacity 180ms ease,
        filter 180ms ease;
}

.progress-star.is-filled {
    opacity: 1;
    transform: scale(1.08);
}
