@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,700;0,800;0,900;1,900&display=swap');

:root {
    --purple-dark: #1f0040;
    --purple-mid: #320066;
    --purple-light: #5a00a3;
    --yellow-light: #fff000;
    --yellow-mid: #ffd700;
    --yellow-dark: #ff8c00;
    --text-shadow-3d: 0px 3px 0px #3b0078, 0px 6px 12px rgba(0, 0, 0, 0.6);
    --card-max-width: 820px;
    --card-desktop-height: 320px;
    --scratch-min-height: 240px;
    --brush-radius: 30px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--purple-dark);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
    padding: 8px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100dvh;
}

/* --- PRELOADER & MODAL --- */
#preloader,
#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: rgba(15, 0, 30, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
    padding: 20px;
}

.hidden {
    opacity: 0;
    pointer-events: none;
}

.pulse-btn {
    background: linear-gradient(180deg, var(--yellow-light), var(--yellow-dark));
    color: var(--purple-dark);
    border: none;
    padding: clamp(12px, 3vw, 15px) clamp(28px, 8vw, 40px);
    font-size: clamp(1.1rem, 3.5vw, 1.5rem);
    font-weight: 900;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 0 #cc7a00, 0 15px 20px rgba(0, 0, 0, 0.4);
    text-transform: uppercase;
    animation: pulse 1.5s infinite;
    transition: transform 0.1s, box-shadow 0.1s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.pulse-btn:active {
    transform: translateY(6px);
    box-shadow: 0 0px 0 #cc7a00, 0 5px 10px rgba(0, 0, 0, 0.4);
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.04);
    }

    100% {
        transform: scale(1);
    }
}

/* --- MODAL BOX --- */
.modal-box {
    position: relative;
    width: 90%;
    max-width: 500px;
    padding: 35px 30px;
    text-align: center;
    overflow: hidden;
    border-radius: 28px;
    background: linear-gradient(180deg,
            #6d22d8 0%,
            #4d1196 55%,
            #30005d 100%);
    border: 4px solid #ffd84c;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, .45),
        inset 0 -5px 0 rgba(80, 20, 0, .25),
        0 0 20px rgba(255, 215, 0, .45),
        0 0 60px rgba(255, 190, 0, .35),
        0 25px 45px rgba(0, 0, 0, .55);
    transform: scale(.75);
    transition: .35s cubic-bezier(.175, .885, .32, 1.35);
}

.modal-box::before {
    content: "";
    position: absolute;
    inset: 8px;
    border-radius: 20px;
    border: 2px solid rgba(255, 239, 170, .9);
    pointer-events: none;
}

.modal-box::after {
    content: "";
    position: absolute;
    top: -60%;
    left: -90%;
    width: 45%;
    height: 220%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, .6),
            transparent);
    transform: rotate(25deg);
    animation: modalShine 5s linear infinite;
}

@keyframes modalShine {
    from {
        left: -90%;
    }

    to {
        left: 180%;
    }
}

#modal-overlay:not(.hidden) .modal-box {
    transform: scale(1);
}

.modal-box h2 {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 900;
    font-style: italic;
    text-transform: uppercase;
    margin-bottom: 12px;
    background: linear-gradient(to bottom,
            #fffdd5,
            #ffe95a,
            #ffb300);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    -webkit-text-stroke: 2px #a05a00;
    text-shadow:
        0 2px 0 #ffe58a,
        0 5px 0 #ffb700,
        0 8px 14px rgba(0, 0, 0, .45);
}

.modal-box p {
    font-size: clamp(1.1rem, 3vw, 1.6rem);
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 30px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, .45);
}

/* --- BACKGROUND ANIMATIONS --- */
.sunburst {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: repeating-conic-gradient(from 0deg,
            var(--purple-mid) 0deg 15deg,
            var(--purple-dark) 15deg 30deg);
    animation: spin 60s linear infinite;
    z-index: -2;
    pointer-events: none;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.particle {
    position: absolute;
    font-size: clamp(1rem, 3vw, 2rem);
    animation: floatup linear infinite;
}

@keyframes floatup {
    0% {
        transform: translateY(105vh) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(-15vh) rotate(360deg);
        opacity: 0;
    }
}

/* --- MAIN GAME UI --- */
.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(4px, 1vw, 8px);
    width: 100%;
    max-width: 900px;
    max-height: 100dvh;

    flex-shrink: 1;
}

.main-title {
    position: relative;
    text-align: center;
    line-height: .82;
    font-style: italic;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 2px;
    user-select: none;
    animation: titleFloat 3s ease-in-out infinite;
    flex-shrink: 0;
}

.main-title .white-text {
    display: block;
    font-size: clamp(1.8rem, 5.5vw, 5.8rem);
    color: #ffffff;
    -webkit-text-stroke: clamp(1.5px, 0.4vw, 3px) #7b2cbf;
    text-shadow:
        0 2px 0 #f8f8f8,
        0 5px 0 #d5d5d5,
        0 8px 0 #b8b8b8,
        0 12px 18px rgba(0, 0, 0, .45);
}

.main-title .yellow-text {
    display: block;
    font-size: clamp(2rem, 6.5vw, 6.5rem);
    background: linear-gradient(to bottom,
            #fffed2 0%,
            #fff26c 18%,
            #ffd93a 38%,
            #ffb300 65%,
            #ff8a00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    -webkit-text-stroke: clamp(1.5px, 0.4vw, 3px) #b96a00;
    text-shadow:
        0 2px 0 #ffe889,
        0 5px 0 #ffc107,
        0 8px 0 #ff9800,
        0 12px 20px rgba(0, 0, 0, .45);
}

.main-title::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: clamp(200px, 40vw, 320px);
    height: clamp(70px, 14vw, 120px);
    transform: translate(-50%, -50%);
    background: radial-gradient(circle,
            rgba(255, 230, 0, .45),
            transparent 70%);
    filter: blur(18px);
    z-index: -1;
}

@keyframes titleFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

/* --- THE CARD --- */
.card {
    background: var(--purple-light);
    border: clamp(3px, 1vw, 8px) solid var(--yellow-mid);
    border-radius: clamp(14px, 2.5vw, 25px);
    padding: clamp(4px, 1vw, 10px);
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: var(--card-max-width);
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, 0.15) inset,
        0 0 10px rgba(255, 215, 0, .6),
        0 0 25px rgba(255, 196, 0, .5),
        0 10px 25px rgba(0, 0, 0, .4),
        0 15px 40px rgba(0, 0, 0, 0.6),
        inset 0 0 30px rgba(0, 0, 0, 0.5);
    background: linear-gradient(180deg, #4a0c88, #25004f);
    position: relative;
    gap: clamp(4px, 1vw, 0px);
    flex-shrink: 1;
    min-height: 0;
}

.card::before {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 12px;
    border: 2px solid rgba(255, 236, 140, .9);
    pointer-events: none;
    z-index: 1;
}

.card::after {
    content: "";
    position: absolute;
    top: -60%;
    left: -80%;
    width: 50%;
    height: 220%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, .45),
            transparent);
    transform: rotate(25deg);
    animation: shine 4s linear infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes shine {
    from {
        left: -80%;
    }

    to {
        left: 150%;
    }
}

/* Left Panel */
.left-panel {
    width: 100%;
    padding: clamp(8px, 2vw, 20px);
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: clamp(6px, 1.5vw, 16px);
    border-right: none;
    border-bottom: 2px dashed rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    z-index: 2;
    position: relative;
}

.left-panel h2 {
    font-size: clamp(1rem, 3vw, 2.2rem);
    font-weight: 900;
    font-style: italic;
    line-height: 1.1;
    text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

.left-panel h2 span {
    color: var(--yellow-mid);
}

.left-panel p {
    font-size: clamp(0.65rem, 1.6vw, 0.95rem);
    color: #ddd;
    display: none;
}

.small-btn {
    background: linear-gradient(180deg, var(--yellow-light), var(--yellow-dark));
    color: var(--purple-dark);
    border: none;
    padding: clamp(6px, 1.5vw, 8px) clamp(14px, 3.5vw, 25px);
    font-size: clamp(0.75rem, 2vw, 1.1rem);
    font-weight: 800;
    border-radius: 20px;
    box-shadow: 0 4px 0 #cc7a00;
    cursor: pointer;
    transition: transform 0.1s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    min-height: 36px;
    min-width: 40px;
}

.small-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #cc7a00;
}

/* Right Panel (Scratch Area) */
.right-panel {
    width: 100%;
    position: relative;
    padding: clamp(4px, 1vw, 10px);
    border-radius: clamp(8px, 1.5vw, 15px);
    overflow: hidden;
    min-height: var(--scratch-min-height);
    aspect-ratio: 16/10;
    max-height: 340px;
    flex-shrink: 1;
    z-index: 2;
}

.prize-bg {
    background: radial-gradient(circle, #ffffff 0%, #e6e6e6 100%);
    width: 100%;
    height: 100%;
    border-radius: clamp(8px, 1.5vw, 15px);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.2);
    position: absolute;
    top: 0;
    left: 0;
    padding: clamp(4px, 1vw, 10px);
}

.prize-content {
    display: flex;
    align-items: center;
    gap: clamp(8px, 2.5vw, 20px);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    flex-wrap: wrap;
    justify-content: center;
}

@keyframes popIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.gift-icon {
    font-size: clamp(2.2rem, 8vw, 5.5rem);
    filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.3));
    line-height: 1;
}

.prize-text {
    color: var(--purple-dark);
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    text-align: center;
}

.prize-text .you-won {
    font-size: clamp(0.8rem, 2.5vw, 1.5rem);
    font-weight: 800;
    color: var(--purple-light);
}

.prize-text .amount {
    font-size: clamp(1.5rem, 5.5vw, 4rem);
    font-weight: 900;
    white-space: nowrap;
}

.prize-text .cash {
    font-size: clamp(0.6rem, 1.6vw, 1.2rem);
    font-weight: 700;
    color: #555;
}

#scratch-canvas {
    position: absolute;
    top: clamp(4px, 1vw, 10px);
    left: clamp(4px, 1vw, 10px);
    width: calc(100% - clamp(8px, 2vw, 20px));
    height: calc(100% - clamp(8px, 2vw, 20px));
    border-radius: clamp(8px, 1.5vw, 15px);
    cursor: crosshair;
    z-index: 10;
    touch-action: none;
    -webkit-touch-callout: none;
}

/* --- RIBBON --- */
.ribbon {
    position: relative;
    display: inline-block;
    padding: clamp(6px, 1.5vw, 14px) clamp(30px, 8vw, 60px);
    font-size: clamp(0.65rem, 1.6vw, 1.3rem);
    font-weight: 900;
    font-style: italic;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #4d1d00;
    background: linear-gradient(to bottom,
            #fff9b2 0%,
            #ffe85b 18%,
            #ffd53d 40%,
            #ffb400 70%,
            #ff8f00 100%);
    border: 3px solid #ffd84a;
    border-radius: 12px;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, .8),
        inset 0 -4px 0 rgba(170, 90, 0, .4),
        0 6px 0 #d97d00,
        0 14px 25px rgba(0, 0, 0, .35);
    overflow: hidden;
    flex-shrink: 0;
}

.ribbon::before {
    content: "";
    position: absolute;
    top: -40%;
    left: -80%;
    width: 40%;
    height: 180%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, .7),
            transparent);
    transform: rotate(25deg);
    animation: ribbonShine 4s linear infinite;
}

.ribbon::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 10px;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35);
    pointer-events: none;
}

.ribbon-left,
.ribbon-right {
    position: absolute;
    top: 50%;
    width: 22px;
    height: 26px;
    background: #ff9800;
    transform: translateY(-50%);
    z-index: -1;
}

.ribbon-left {
    left: -16px;
    clip-path: polygon(100% 0, 0 50%, 100% 100%);
}

.ribbon-right {
    right: -16px;
    clip-path: polygon(0 0, 100% 50%, 0 100%);
}

@keyframes ribbonShine {
    from {
        left: -80%;
    }

    to {
        left: 180%;
    }
}

/* ==================== */
/*  TABLET & DESKTOP    */
/* ==================== */
@media (min-width: 640px) {
    .card {
        flex-direction: row;
        height: var(--card-desktop-height);
        gap: 0;
    }

    .left-panel {
        width: 35%;
        flex-direction: column;
        justify-content: center;
        border-right: 3px dashed rgba(255, 255, 255, 0.2);
        border-bottom: none;
        padding: clamp(14px, 3vw, 20px);
        gap: 6px;
    }

    .left-panel h2 {
        font-size: clamp(1.4rem, 3vw, 2.2rem);
        white-space: normal;
    }

    .left-panel p {
        display: block;
        font-size: clamp(0.7rem, 1.5vw, 0.95rem);
        margin-bottom: clamp(10px, 2vw, 20px);
    }

    .right-panel {
        width: 65%;
        min-height: auto;
        aspect-ratio: auto;
        max-height: none;
        padding: 10px;
    }

    #scratch-canvas {
        top: 10px;
        left: 10px;
        width: calc(100% - 20px);
        height: calc(100% - 20px);
        border-radius: 15px;
    }

    .prize-bg {
        position: relative;
        padding: 10px;
    }

    .prize-text .amount {
        font-size: clamp(2.5rem, 5vw, 4rem);
    }

    .gift-icon {
        font-size: clamp(3.5rem, 7vw, 5.5rem);
    }
}

/* ==================== */
/*  LARGE DESKTOP       */
/* ==================== */
@media (min-width: 900px) {
    .card {
        width: 800px;
        height: 320px;
    }

    .left-panel {
        width: 35%;
        padding: 20px;
    }

    .left-panel h2 {
        font-size: 2.2rem;
    }

    .left-panel p {
        font-size: 0.95rem;
        margin-bottom: 20px;
    }

    .right-panel {
        width: 65%;
        padding: 10px;
    }

    .prize-text .amount {
        font-size: 4rem;
    }

    .gift-icon {
        font-size: 5.5rem;
    }

    .ribbon {
        padding: 10px 50px;
        font-size: 1.2rem;
    }
}

/* ==================== */
/*  VERY SMALL SCREENS  */
/* ==================== */
@media (max-width: 360px) {
    :root {
        --scratch-min-height: 180px;
        --brush-radius: 24px;
    }

    .left-panel h2 {
        font-size: 0.9rem;
    }

    .left-panel {
        padding: 6px 8px;
        gap: 4px;
    }

    .small-btn {
        padding: 5px 12px;
        font-size: 0.7rem;
        min-height: 30px;
        min-width: 36px;
    }

    .prize-text .amount {
        font-size: 1.3rem;
    }

    .prize-text .you-won {
        font-size: 0.7rem;
    }

    .gift-icon {
        font-size: 1.8rem;
    }

    .ribbon {
        padding: 5px 18px;
        font-size: 0.6rem;
        border-radius: 8px;
    }

    .right-panel {
        min-height: 160px;
        max-height: 200px;
    }

    body {
        padding: 4px;
    }

    .game-wrapper {
        gap: 3px;
    }

    .main-title .white-text {
        font-size: 1.4rem;
        -webkit-text-stroke: 1px #7b2cbf;
    }

    .main-title .yellow-text {
        font-size: 1.6rem;
        -webkit-text-stroke: 1px #b96a00;
    }
}

/* ==================== */
/*  LANDSCAPE MOBILE    */
/* ==================== */
@media (max-width: 850px) and (orientation: landscape) {
    body {
        padding: 4px;
    }

    .game-wrapper {
        gap: 2px;
    }

    .main-title .white-text {
        font-size: clamp(1rem, 3vw, 2rem);
        -webkit-text-stroke: 1px #7b2cbf;
    }

    .main-title .yellow-text {
        font-size: clamp(1.1rem, 3.5vw, 2.4rem);
        -webkit-text-stroke: 1px #b96a00;
    }

    .card {
        flex-direction: row;
        height: auto;
        min-height: 150px;
        max-height: 55vh;
    }

    .left-panel {
        width: 28%;
        flex-direction: column;
        border-right: 2px dashed rgba(255, 255, 255, 0.2);
        border-bottom: none;
        padding: 6px;
        gap: 2px;
    }

    .left-panel h2 {
        font-size: 0.8rem;
        white-space: normal;
    }

    .left-panel p {
        display: none;
    }

    .small-btn {
        padding: 4px 10px;
        font-size: 0.65rem;
        min-height: 26px;
        min-width: 32px;
    }

    .right-panel {
        width: 72%;
        min-height: auto;
        aspect-ratio: auto;
        max-height: none;
        padding: 4px;
    }

    #scratch-canvas {
        top: 4px;
        left: 4px;
        width: calc(100% - 8px);
        height: calc(100% - 8px);
    }

    .prize-text .amount {
        font-size: clamp(1.2rem, 3.5vw, 2.4rem);
    }

    .gift-icon {
        font-size: clamp(1.5rem, 4vw, 3rem);
    }

    .ribbon {
        font-size: 0.55rem;
        padding: 4px 16px;
        border-radius: 6px;
    }
}

/* ==================== */
/*  SHORT DEVICES       */
/* ==================== */
@media (max-height: 700px) and (max-width: 639px) {
    :root {
        --scratch-min-height: 170px;
    }

    .right-panel {
        max-height: 220px;
        min-height: 150px;
    }

    .main-title .white-text {
        font-size: 1.6rem;
    }

    .main-title .yellow-text {
        font-size: 1.8rem;
    }

    .ribbon {
        padding: 5px 22px;
        font-size: 0.65rem;
    }

    .left-panel {
        padding: 6px 10px;
        gap: 4px;
    }

    .left-panel h2 {
        font-size: 0.95rem;
    }

    .game-wrapper {
        gap: 3px;
    }

    body {
        padding: 3px;
    }
}

@media (max-height: 600px) and (max-width: 639px) {
    :root {
        --scratch-min-height: 130px;
    }

    .right-panel {
        max-height: 170px;
        min-height: 120px;
    }

    .main-title .white-text {
        font-size: 1.3rem;
    }

    .main-title .yellow-text {
        font-size: 1.5rem;
    }

    .ribbon {
        padding: 3px 16px;
        font-size: 0.55rem;
        border-width: 2px;
        border-radius: 6px;
    }

    .left-panel h2 {
        font-size: 0.8rem;
    }

    .small-btn {
        padding: 4px 10px;
        font-size: 0.65rem;
        min-height: 26px;
        min-width: 30px;
    }

    .game-wrapper {
        gap: 2px;
    }

    body {
        padding: 2px;
    }

    .card {
        border-width: 2px;
        border-radius: 10px;
        padding: 3px;
    }
}

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;700;800;900&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    font-family: 'Poppins', sans-serif;
    background: #1a0033;
    background-image: radial-gradient(circle at 20% 30%, #3d0066, #0f001a);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    margin: 0;
    width: 100%;
    height: 100dvh;
    position: fixed;
    top: 0;
    left: 0;
}

/* ===== PRELOADER ===== */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: #0f001a;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease, transform 0.5s ease;
    gap: 16px;
    padding: 20px;
}

#preloader.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.05);
}

.pre-drop {
    width: 50px;
    height: 50px;
    background: radial-gradient(circle at 30% 30%, #60e0ff, #0088cc);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 0 40px rgba(0, 180, 255, 0.5);
    animation: dropPulse 1.2s ease-in-out infinite;
}

@keyframes dropPulse {
    0%, 100% { transform: rotate(-45deg) scale(1); opacity: 1; }
    50% { transform: rotate(-45deg) scale(1.15); opacity: 0.7; }
}

.pre-title {
    font-size: clamp(2rem, 8vw, 4.5rem);
    font-weight: 900;
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: 3px;
    background: linear-gradient(to bottom, #fff9c4, #ffd740, #ffab00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 20px rgba(255, 200, 0, 0.3);
}

.pre-bar-track {
    width: min(280px, 70vw);
    height: 8px;
    background: #2a1a3a;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
}

.pre-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #ffd740, #ff6f00);
    border-radius: 12px;
    transition: width 0.15s ease;
}

.pre-pct {
    font-size: clamp(0.8rem, 2.5vw, 1.1rem);
    font-weight: 700;
    color: #bb9fd4;
    letter-spacing: 1px;
}

/* ===== GAME ROOT ===== */
#gameRoot {
    width: 100%;
    max-width: 540px;
    height: 100%;
    max-height: 820px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#stage {
    width: 100%;
    height: 100%;
    max-height: 820px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: linear-gradient(170deg, #2d004d, #16002b);
    border: 3px solid #ffd740;
    border-radius: 28px;
    padding: 12px 14px 16px;
    box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.2) inset,
                0 0 40px rgba(255, 200, 0, 0.15),
                0 20px 40px rgba(0,0,0,0.7);
    position: relative;
}

/* ===== TOP BAR ===== */
#topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2px;
    flex-shrink: 0;
}

.icon-btn {
    background: rgba(255,255,255,0.08);
    border: 2px solid rgba(255, 215, 0, 0.35);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    color: #fff;
    cursor: pointer;
    transition: 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    touch-action: manipulation;
}

.icon-btn:active {
    transform: scale(0.92);
    background: rgba(255, 215, 0, 0.2);
}

#levelLabel {
    font-weight: 800;
    font-size: clamp(1rem, 3vw, 1.4rem);
    color: #ffd740;
    text-shadow: 0 2px 8px rgba(255, 200, 0, 0.25);
    letter-spacing: 1px;
}

/* ===== CANVAS WRAP ===== */
#canvasWrap {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    background: #0a0510;
    border-radius: 16px;
    border: 2px solid rgba(255, 215, 0, 0.2);
    overflow: hidden;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

#canvasWrap canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

/* ===== FILL METER ===== */
#fillMeterWrap {
    position: absolute;
    bottom: 8px;
    left: 12px;
    right: 12px;
    height: 10px;
    background: rgba(0,0,0,0.65);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(255, 215, 0, 0.2);
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    z-index: 5;
}

#fillMeter {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #00c8ff, #3fd0e8, #80f0ff);
    border-radius: 20px;
    transition: width 0.1s ease;
    box-shadow: 0 0 20px rgba(0, 200, 255, 0.3);
}

/* ===== D-PAD CONTROLS ===== */
#controls {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    padding: 4px 0 2px;
}

.dpad {
    display: grid;
    grid-template-columns: 56px 56px 56px;
    grid-template-rows: 56px 56px 56px;
    gap: 6px;
    background: rgba(0,0,0,0.25);
    border-radius: 24px;
    padding: 8px;
    backdrop-filter: blur(4px);
}

.dbtn {
    background: radial-gradient(circle at 40% 35%, #5a2d8a, #2d0050);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 14px;
    color: #fff;
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.08s;
    touch-action: manipulation;
    box-shadow: 0 4px 0 #15002b, 0 6px 12px rgba(0,0,0,0.4);
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.dbtn:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 #15002b, 0 6px 12px rgba(0,0,0,0.4);
}

.dbtn.up { grid-column: 2; grid-row: 1; }
.dbtn.left { grid-column: 1; grid-row: 2; }
.dbtn.right { grid-column: 3; grid-row: 2; }
.dbtn.down { grid-column: 2; grid-row: 3; }

/* ===== FLOATING HOW-TO BUTTON ===== */
#howtoBtn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd740, #ff8f00);
    border: 2px solid #fff;
    color: #1a0033;
    font-size: 1.5rem;
    font-weight: 900;
    box-shadow: 0 4px 20px rgba(255, 200, 0, 0.4);
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
    touch-action: manipulation;
}

#howtoBtn:active {
    transform: scale(0.9);
}

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: rgba(10, 0, 20, 0.85);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: linear-gradient(160deg, #4a0c88, #1f0040);
    border: 3px solid #ffd740;
    border-radius: 32px;
    padding: clamp(24px, 5vw, 40px) clamp(20px, 4vw, 40px);
    max-width: 480px;
    width: 100%;
    box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.15) inset,
                0 0 50px rgba(255, 200, 0, 0.15),
                0 30px 60px rgba(0,0,0,0.7);
    transform: scale(0.92) translateY(12px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    opacity: 0;
    text-align: center;
}

.modal-overlay.show .modal-card {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal-card h2 {
    font-size: clamp(1.6rem, 5vw, 2.6rem);
    font-weight: 900;
    font-style: italic;
    text-transform: uppercase;
    background: linear-gradient(to bottom, #fff9c4, #ffd740, #ff8f00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 20px rgba(255, 200, 0, 0.2);
    margin-bottom: 8px;
    line-height: 1.2;
}

.modal-card p {
    color: #e0d0f0;
    font-size: clamp(0.95rem, 2.5vw, 1.2rem);
    font-weight: 500;
    margin: 8px 0 16px;
}

.modal-card ul {
    text-align: left;
    color: #d4c0e8;
    font-size: clamp(0.85rem, 2vw, 1rem);
    list-style: none;
    padding: 0;
    margin: 12px 0 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-card ul li {
    padding-left: 6px;
    line-height: 1.4;
    margin-bottom: 10px;
}

.stars {
    font-size: clamp(2.4rem, 7vw, 3.8rem);
    letter-spacing: 6px;
    margin: 6px 0 2px;
    filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.3));
}

.row {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 12px;
}

.btn {
    font-family: 'Poppins', sans-serif;
    font-weight: 800;
    font-size: clamp(0.9rem, 2.2vw, 1.15rem);
    padding: 10px 28px;
    border: none;
    border-radius: 40px;
    cursor: pointer;
    transition: 0.12s;
    touch-action: manipulation;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:active {
    transform: scale(0.94);
}

.btn-primary {
    background: linear-gradient(180deg, #ffd740, #ff8f00);
    color: #1a0033;
    box-shadow: 0 4px 0 #b36b00, 0 8px 20px rgba(255, 200, 0, 0.25);
}

.btn-primary:active {
    transform: translateY(4px) scale(0.94);
    box-shadow: 0 1px 0 #b36b00, 0 8px 20px rgba(255, 200, 0, 0.2);
}

.btn-ghost {
    background: rgba(255,255,255,0.08);
    color: #ffd740;
    border: 2px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 4px 0 rgba(0,0,0,0.2);
}

.btn-ghost:active {
    transform: translateY(4px) scale(0.94);
    box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}

/* ===== RESPONSIVE TWEAKS ===== */
@media (max-width: 480px) {
    #stage {
        padding: 8px 10px 12px;
        border-radius: 20px;
        gap: 6px;
    }
    .icon-btn {
        width: 34px;
        height: 34px;
        font-size: 1rem;
    }
    .dpad {
        grid-template-columns: 48px 48px 48px;
        grid-template-rows: 48px 48px 48px;
        gap: 5px;
        padding: 6px;
    }
    .dbtn {
        font-size: 1.1rem;
        border-radius: 12px;
    }
    #fillMeterWrap {
        height: 8px;
        bottom: 6px;
        left: 8px;
        right: 8px;
    }
    #howtoBtn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        bottom: 14px;
        right: 14px;
    }
}

@media (max-height: 640px) {
    #stage {
        padding: 6px 8px 8px;
        gap: 4px;
        border-radius: 16px;
    }
    .dpad {
        grid-template-columns: 40px 40px 40px;
        grid-template-rows: 40px 40px 40px;
        gap: 4px;
        padding: 4px;
    }
    .dbtn {
        font-size: 0.9rem;
        border-radius: 10px;
    }
    #topbar .icon-btn {
        width: 30px;
        height: 30px;
        font-size: 0.85rem;
    }
    #levelLabel {
        font-size: 0.85rem;
    }
    #fillMeterWrap {
        height: 6px;
        bottom: 4px;
    }
}

@media (max-height: 540px) {
    .dpad {
        grid-template-columns: 34px 34px 34px;
        grid-template-rows: 34px 34px 34px;
        gap: 3px;
        padding: 3px;
    }
    .dbtn {
        font-size: 0.7rem;
        border-radius: 8px;
    }
    #stage {
        padding: 4px 6px 6px;
        gap: 3px;
    }
    #topbar .icon-btn {
        width: 26px;
        height: 26px;
        font-size: 0.7rem;
    }
    #levelLabel {
        font-size: 0.7rem;
    }
    #fillMeterWrap {
        height: 4px;
        bottom: 2px;
    }
}