@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;
    }
}