:root {
    --wpm3_radius: 24px;
    --wpm3_shadow: 0 24px 70px rgba(24, 30, 61, 0.22);
    --wpm3_panel: rgba(255, 255, 255, 0.92);
    --wpm3_text: #18213f;
    --wpm3_muted: #69708a;
    --wpm3_accent: #7657ff;
    --wpm3_accent_2: #24d5ff;
    --wpm3_good: #18b66a;
    --wpm3_bad: #ef476f;
    --wpm3_warning: #ffb703;
}

.wpm3_game_shell,
.wpm3_game_shell * {
    box-sizing: border-box;
}

.wpm3_game_shell {
    width: min(100%, 980px);
    margin: 24px auto;
    padding: clamp(12px, 2.8vw, 26px);
    border-radius: calc(var(--wpm3_radius) + 10px);
    background:
        radial-gradient(circle at 15% 10%, rgba(255, 255, 255, 0.62), transparent 22%),
        radial-gradient(circle at 85% 15%, rgba(255, 235, 145, 0.5), transparent 24%),
        linear-gradient(135deg, #7357ff 0%, #26c6ff 48%, #ff6bc9 100%);
    box-shadow: var(--wpm3_shadow);
    color: var(--wpm3_text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.wpm3_game_shell::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle, rgba(255,255,255,0.35) 0 2px, transparent 3px),
        linear-gradient(135deg, rgba(255,255,255,0.16), transparent);
    background-size: 34px 34px, auto;
    pointer-events: none;
    z-index: -1;
}

.wpm3_game_notice,
.wpm3_game_preloader {
    padding: 28px;
    border-radius: var(--wpm3_radius);
    background: var(--wpm3_panel);
    text-align: center;
}

.wpm3_preloader_gems {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 14px;
}

.wpm3_preloader_gems span {
    width: 18px;
    height: 18px;
    border-radius: 8px;
    background: linear-gradient(135deg, #ff6bc9, #ffdf6b);
    animation: wpm3_bounce 0.8s infinite alternate;
}

.wpm3_preloader_gems span:nth-child(2) {
    animation-delay: 0.12s;
    background: linear-gradient(135deg, #24d5ff, #7357ff);
}

.wpm3_preloader_gems span:nth-child(3) {
    animation-delay: 0.24s;
    background: linear-gradient(135deg, #43e97b, #38f9d7);
}

.wpm3_screen {
    display: none;
}

.wpm3_screen.wpm3_is_active {
    display: block;
}

.wpm3_hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
}

.wpm3_logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wpm3_logo_icon {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: rgba(255,255,255,0.24);
    border: 1px solid rgba(255,255,255,0.46);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.42);
    font-size: 28px;
}

.wpm3_logo h2,
.wpm3_game_title {
    margin: 0;
    font-size: clamp(24px, 4vw, 38px);
    line-height: 1;
    color: #fff;
    text-shadow: 0 4px 18px rgba(38, 38, 82, 0.26);
}

.wpm3_logo p,
.wpm3_hero p {
    margin: 6px 0 0;
    color: rgba(255,255,255,0.88);
    font-weight: 700;
}

.wpm3_progress_wrap {
    background: rgba(255,255,255,0.24);
    border: 1px solid rgba(255,255,255,0.38);
    border-radius: 18px;
    padding: 12px;
    min-width: 190px;
    color: #fff;
}

.wpm3_progress_track {
    height: 10px;
    background: rgba(255,255,255,0.32);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 8px;
}

.wpm3_progress_bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #fff, #ffe36e);
    border-radius: inherit;
    transition: width 0.35s ease;
}

.wpm3_menu_panel,
.wpm3_game_panel {
    background: var(--wpm3_panel);
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: var(--wpm3_radius);
    padding: clamp(14px, 2vw, 22px);
    backdrop-filter: blur(12px);
}

.wpm3_reward_banner,
.wpm3_ad_placeholder,
.wpm3_extra_moves_placeholder,
.wpm3_ad_slot {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    border-radius: 18px;
    border: 1px dashed rgba(118,87,255,0.45);
    background: rgba(255,255,255,0.58);
    color: #4c3fad;
    font-weight: 800;
    text-align: center;
    margin-bottom: 14px;
    padding: 10px;
}


.wpm3_ad_slot {
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
}

.wpm3_ad_label {
    width: 100%;
    font-size: 11px;
    line-height: 1;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #64748b;
}

.wpm3_ad_inner {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpm3_ad_inner iframe,
.wpm3_ad_inner img {
    max-width: 100%;
}

.wpm3_level_grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    gap: 12px;
    max-height: 640px;
    overflow: auto;
    padding: 3px;
}

.wpm3_level_card {
    appearance: none;
    border: 0;
    cursor: pointer;
    min-height: 118px;
    border-radius: 22px;
    padding: 12px;
    text-align: left;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 12px 28px rgba(30, 38, 79, 0.16);
    transform: translateY(0);
    transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
}

.wpm3_level_card:hover,
.wpm3_level_card:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 18px 36px rgba(30, 38, 79, 0.22);
    outline: none;
}

.wpm3_level_card::after {
    content: "";
    position: absolute;
    right: -22px;
    bottom: -30px;
    width: 92px;
    height: 92px;
    border-radius: 28px;
    background: rgba(255,255,255,0.23);
    transform: rotate(28deg);
}

.wpm3_level_card.wpm3_is_locked {
    cursor: not-allowed;
    filter: grayscale(1);
    background: linear-gradient(135deg,#a8adb9,#6b7280) !important;
    opacity: 0.72;
}

.wpm3_level_number {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background: rgba(255,255,255,0.28);
    font-weight: 950;
}

.wpm3_level_name {
    display: block;
    margin-top: 12px;
    font-weight: 950;
    font-size: 14px;
    line-height: 1.18;
    position: relative;
    z-index: 1;
}

.wpm3_level_meta {
    display: flex;
    gap: 7px;
    align-items: center;
    margin-top: 10px;
    font-size: 12px;
    font-weight: 800;
    position: relative;
    z-index: 1;
}

.wpm3_stars {
    letter-spacing: 1px;
    color: #ffe15d;
    text-shadow: 0 2px 6px rgba(0,0,0,0.18);
}

.wpm3_game_topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: start;
    margin-bottom: 12px;
}

.wpm3_game_stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.wpm3_stat {
    background: #fff;
    border: 1px solid rgba(118,87,255,0.14);
    border-radius: 16px;
    padding: 9px 10px;
    min-height: 60px;
    box-shadow: 0 8px 20px rgba(24, 30, 61, 0.06);
}

.wpm3_stat_label {
    display: block;
    color: var(--wpm3_muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.wpm3_stat_value {
    display: block;
    margin-top: 3px;
    font-size: 20px;
    font-weight: 950;
    color: var(--wpm3_text);
    line-height: 1.05;
}

.wpm3_game_actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.wpm3_button {
    appearance: none;
    border: 0;
    cursor: pointer;
    min-height: 44px;
    padding: 10px 15px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--wpm3_accent), var(--wpm3_accent_2));
    color: #fff;
    font-weight: 950;
    letter-spacing: 0.01em;
    box-shadow: 0 12px 24px rgba(72, 88, 255, 0.22);
    transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
    touch-action: manipulation;
}

.wpm3_button:hover,
.wpm3_button:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 16px 30px rgba(72, 88, 255, 0.28);
    outline: none;
}

.wpm3_button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.wpm3_button_secondary {
    background: #fff;
    color: var(--wpm3_accent);
    border: 1px solid rgba(118,87,255,0.28);
    box-shadow: 0 8px 18px rgba(24, 30, 61, 0.08);
}

.wpm3_board_wrap {
    width: min(100%, 560px);
    margin: 0 auto;
    position: relative;
}

.wpm3_board {
    display: grid;
    gap: clamp(4px, 1vw, 8px);
    aspect-ratio: 1 / 1;
    width: 100%;
    padding: clamp(8px, 2vw, 14px);
    border-radius: 28px;
    background:
        linear-gradient(135deg, rgba(255,255,255,0.76), rgba(255,255,255,0.36)),
        rgba(30, 38, 79, 0.1);
    border: 1px solid rgba(255,255,255,0.7);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.45), 0 20px 45px rgba(24, 30, 61, 0.13);
    touch-action: none;
    user-select: none;
}

.wpm3_cell {
    position: relative;
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 0;
    border-radius: 18px;
    background: rgba(255,255,255,0.4);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.65), inset 0 -6px 12px rgba(36,46,95,0.08);
    overflow: hidden;
}

.wpm3_cell.wpm3_is_selected {
    outline: 3px solid rgba(255, 235, 89, 0.96);
    outline-offset: -3px;
}

.wpm3_cell.wpm3_is_hint {
    outline: 3px solid rgba(255, 183, 3, 0.96);
    outline-offset: -3px;
    animation: wpm3_hint_pulse 0.82s ease-in-out infinite alternate;
}

.wpm3_cell.wpm3_is_hint .wpm3_gem {
    transform: scale(1.1);
}

.wpm3_cell.wpm3_is_locked::before,
.wpm3_cell.wpm3_has_ice::after {
    content: "";
    position: absolute;
    inset: 5px;
    border-radius: 14px;
    pointer-events: none;
    z-index: 5;
}

.wpm3_cell.wpm3_has_ice::after {
    background: linear-gradient(135deg, rgba(202, 241, 255, 0.58), rgba(255,255,255,0.28));
    border: 1px solid rgba(209, 244, 255, 0.88);
    box-shadow: inset 0 0 16px rgba(255,255,255,0.64);
}

.wpm3_cell.wpm3_is_locked::before {
    background:
        linear-gradient(135deg, rgba(64,72,101,0.2), rgba(17,24,39,0.34));
    border: 2px solid rgba(45,55,72,0.35);
}

.wpm3_cell.wpm3_is_locked .wpm3_gem::after {
    content: "LOCK";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: clamp(13px, 3vw, 22px);
    text-shadow: 0 2px 8px rgba(0,0,0,0.4);
    z-index: 8;
}

.wpm3_gem {
    width: 78%;
    height: 78%;
    position: relative;
    filter: drop-shadow(0 8px 8px rgba(25, 32, 68, 0.22));
    transform: scale(1);
    transition: transform 0.16s ease;
}

.wpm3_cell:hover .wpm3_gem {
    transform: scale(1.06);
}

.wpm3_gem_0 {
    background: linear-gradient(135deg, #42e4ff, #2f6bff);
    clip-path: polygon(50% 0, 92% 50%, 50% 100%, 8% 50%);
}

.wpm3_gem_1 {
    background: linear-gradient(135deg, #ffe36e, #ff8f00);
    clip-path: polygon(50% 0%, 61% 34%, 98% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 2% 35%, 39% 34%);
}

.wpm3_gem_2 {
    background: linear-gradient(135deg, #ff75bd, #e40062);
    clip-path: path("M 50 88 C 20 62 5 47 5 27 C 5 10 25 4 50 24 C 75 4 95 10 95 27 C 95 47 80 62 50 88 Z");
}

.wpm3_gem_3 {
    background: linear-gradient(135deg, #78ff9f, #00a66a);
    border-radius: 50%;
}

.wpm3_gem_4 {
    background: linear-gradient(135deg, #c08bff, #6b37ff);
    clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%);
}

.wpm3_gem_5 {
    background: linear-gradient(135deg, #ff8f70, #ff2e63);
    clip-path: polygon(50% 0, 82% 16%, 100% 50%, 82% 84%, 50% 100%, 18% 84%, 0 50%, 18% 16%);
}

.wpm3_special_line_h::before,
.wpm3_special_line_v::before,
.wpm3_special_bomb::before,
.wpm3_special_color::before,
.wpm3_special_area::before {
    content: "";
    position: absolute;
    inset: 17%;
    border-radius: 999px;
    border: 3px solid rgba(255,255,255,0.94);
    box-shadow: 0 0 12px rgba(255,255,255,0.8);
}

.wpm3_special_line_h::after {
    content: "";
    position: absolute;
    left: 8%;
    right: 8%;
    top: 47%;
    height: 10%;
    border-radius: 999px;
    background: rgba(255,255,255,0.95);
}

.wpm3_special_line_v::after {
    content: "";
    position: absolute;
    top: 8%;
    bottom: 8%;
    left: 47%;
    width: 10%;
    border-radius: 999px;
    background: rgba(255,255,255,0.95);
}

.wpm3_special_bomb::after,
.wpm3_special_area::after,
.wpm3_special_color::after {
    content: "*";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: clamp(14px, 4vw, 26px);
    text-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.wpm3_special_color {
    background: conic-gradient(from 0deg, #42e4ff, #ffe36e, #ff75bd, #78ff9f, #c08bff, #ff8f70, #42e4ff);
    border-radius: 50%;
}

.wpm3_pop {
    animation: wpm3_pop 0.32s ease both;
}

.wpm3_fall {
    animation: wpm3_fall 0.24s ease both;
}

.wpm3_invalid {
    animation: wpm3_shake 0.32s ease both;
}

.wpm3_score_float {
    position: absolute;
    z-index: 20;
    color: #fff;
    font-weight: 950;
    font-size: 18px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.35);
    pointer-events: none;
    animation: wpm3_score_float 0.72s ease-out forwards;
}

.wpm3_target_panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    margin-top: 14px;
    padding: 12px;
    border-radius: 18px;
    background: #fff;
    border: 1px solid rgba(118,87,255,0.14);
}

.wpm3_target_text {
    font-weight: 900;
}

.wpm3_target_subtext {
    color: var(--wpm3_muted);
    font-size: 13px;
    margin-top: 2px;
}

.wpm3_leaderboard {
    margin-top: 14px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.wpm3_leaderboard_header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-weight: 950;
}

.wpm3_period_buttons {
    display: inline-flex;
    width: fit-content;
    border-radius: 999px;
    background: rgba(118,87,255,0.1);
    padding: 4px;
    gap: 4px;
}

.wpm3_period_button {
    appearance: none;
    border: 0;
    min-height: 34px;
    padding: 7px 13px;
    border-radius: 999px;
    cursor: pointer;
    background: transparent;
    color: var(--wpm3_accent);
    font-weight: 950;
}

.wpm3_period_button.wpm3_is_active {
    background: #fff;
    box-shadow: 0 5px 14px rgba(24, 30, 61, 0.1);
}

.wpm3_player_name_row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.wpm3_input {
    width: 100%;
    min-height: 44px;
    padding: 9px 12px;
    border-radius: 14px;
    border: 1px solid rgba(118,87,255,0.24);
    font: inherit;
}

.wpm3_leaderboard_rows {
    display: grid;
    gap: 6px;
}

.wpm3_leaderboard_row {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    gap: 8px;
    align-items: center;
    background: rgba(255,255,255,0.72);
    border-radius: 14px;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 800;
}

.wpm3_modal_backdrop {
    position: absolute;
    inset: 0;
    display: none;
    place-items: center;
    background: rgba(20, 24, 51, 0.42);
    z-index: 50;
    padding: 16px;
}

.wpm3_modal_backdrop.wpm3_is_active {
    display: grid;
}

.wpm3_modal {
    width: min(100%, 440px);
    border-radius: 28px;
    background: #fff;
    padding: 24px;
    text-align: center;
    box-shadow: 0 24px 80px rgba(18, 24, 48, 0.36);
    animation: wpm3_modal_in 0.22s ease both;
}

.wpm3_modal_icon {
    font-size: 46px;
    line-height: 1;
    margin-bottom: 8px;
}

.wpm3_modal h3 {
    margin: 0 0 8px;
    font-size: 28px;
}

.wpm3_modal p {
    color: var(--wpm3_muted);
    margin: 0 0 14px;
    font-weight: 700;
}

.wpm3_modal_actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.wpm3_confetti {
    position: absolute;
    top: -20px;
    width: 10px;
    height: 16px;
    border-radius: 3px;
    animation: wpm3_confetti 1.45s ease-in forwards;
    z-index: 60;
}

.wpm3_toast {
    position: absolute;
    left: 50%;
    bottom: 18px;
    z-index: 70;
    transform: translate(-50%, 18px);
    max-width: calc(100% - 32px);
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(24, 33, 63, 0.92);
    color: #fff;
    font-weight: 900;
    box-shadow: 0 14px 32px rgba(18, 24, 48, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s ease, opacity 0.22s ease;
}

.wpm3_toast.wpm3_is_active {
    transform: translate(-50%, 0);
    opacity: 1;
}

.wpm3_no_motion *,
.wpm3_no_motion *::before,
.wpm3_no_motion *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
}

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

@keyframes wpm3_pop {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.32) rotate(8deg); opacity: 0.72; }
    100% { transform: scale(0); opacity: 0; }
}

@keyframes wpm3_fall {
    from { transform: translateY(-22%); opacity: 0.2; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes wpm3_hint_pulse {
    from { box-shadow: inset 0 1px 0 rgba(255,255,255,0.65), inset 0 -6px 12px rgba(36,46,95,0.08), 0 0 0 rgba(255, 183, 3, 0); }
    to { box-shadow: inset 0 1px 0 rgba(255,255,255,0.65), inset 0 -6px 12px rgba(36,46,95,0.08), 0 0 22px rgba(255, 183, 3, 0.78); }
}

@keyframes wpm3_shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-7px); }
    50% { transform: translateX(7px); }
    75% { transform: translateX(-4px); }
}

@keyframes wpm3_score_float {
    0% { transform: translateY(0) scale(0.9); opacity: 0; }
    18% { opacity: 1; }
    100% { transform: translateY(-44px) scale(1.08); opacity: 0; }
}

@keyframes wpm3_modal_in {
    from { transform: translateY(14px) scale(0.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes wpm3_confetti {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(760px) rotate(720deg); opacity: 0; }
}

@media (max-width: 760px) {
    .wpm3_game_shell {
        margin: 12px auto;
        border-radius: 24px;
    }

    .wpm3_hero,
    .wpm3_game_topbar,
    .wpm3_target_panel {
        grid-template-columns: 1fr;
    }

    .wpm3_progress_wrap {
        min-width: 0;
    }

    .wpm3_game_actions {
        justify-content: stretch;
    }

    .wpm3_game_actions .wpm3_button {
        flex: 1 1 auto;
    }

    .wpm3_game_stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    
.wpm3_ad_slot {
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
}

.wpm3_ad_label {
    width: 100%;
    font-size: 11px;
    line-height: 1;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #64748b;
}

.wpm3_ad_inner {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpm3_ad_inner iframe,
.wpm3_ad_inner img {
    max-width: 100%;
}

.wpm3_level_grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-height: 560px;
    }
}

@media (max-width: 390px) {
    .wpm3_game_shell {
        padding: 9px;
        width: 100%;
    }

    .wpm3_menu_panel,
    .wpm3_game_panel {
        padding: 12px;
        border-radius: 20px;
    }

    .wpm3_board {
        gap: 4px;
        padding: 7px;
        border-radius: 22px;
    }

    .wpm3_cell {
        border-radius: 12px;
    }

    .wpm3_stat_value {
        font-size: 18px;
    }

    .wpm3_button {
        min-height: 46px;
        padding: 10px 12px;
    }
}
