:root {
    --primary-color: #00bcd4;
    --accent-color: #ff5722;
    --bg-overlay: rgba(0, 20, 40, 0.4);
    --grid-rows: 10;
    --grid-cols: 6;

    /* Dynamic Cell Size Calculation */
    /* Reserve space: Header(80) + Valves(120) + Padding(20) + Extra buffer(80) = ~300px */
    --chrome-h: 300px;
    /* Use svh (Small Viewport Height) to guarantee fit with browser bars expanded */
    /* Also subtract bottom safe area from the available calculation space */
    --safe-h: calc(100svh - var(--chrome-h) - env(safe-area-inset-bottom, 20px));
    --safe-w: 95vw;
    --cell-h: calc(var(--safe-h) / var(--grid-rows));
    --cell-w: calc(var(--safe-w) / var(--grid-cols));
    --cell-size: min(var(--cell-h), var(--cell-w), 50px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: #0d1e30;
    color: white;
    height: 100vh;
    height: 100svh;
    /* Force fit within visible area */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    background-image: url('assets/runtime/bg.png');
    background-size: cover;
    background-position: center;
}

.game-container {
    width: 100%;
    max-width: 450px;
    height: 95vh;
    height: 95svh;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
    touch-action: none;
}

.game-header {
    height: auto;
    min-height: 80px;
    flex-shrink: 0;
    background: linear-gradient(180deg, rgba(82, 131, 159, 1) 0%, rgba(35, 60, 80, 1) 100%);
    border-bottom: 3px solid #1a3a4a;
    border-radius: 18px 18px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    z-index: 100;
    position: relative;
    gap: 10px;
    flex-wrap: wrap;
}

.icon-btn {
    background: #ff5252;
    border: 2px solid #b71c1c;
    color: white;
    font-size: 24px;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    cursor: pointer !important;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 0 #b71c1c;
    transition: transform 0.1s, background 0.2s;
    z-index: 110;
    position: relative;
}

.icon-btn:hover {
    background: #ff6e6e;
}

.icon-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #b71c1c;
}

.header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.star-rating {
    font-size: 20px;
    color: #ffd700;
}

.level-indicator {
    font-size: 14px;
    font-weight: bold;
    color: #e0f7fa;
}

.header-right {
    display: flex;
    gap: 8px;
    align-items: center;
    position: static;
    transform: none;
}

.header-controls {
    display: flex;
    gap: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 8px;
    border-radius: 6px;
    min-width: 65px;
}

.stat-label {
    font-size: 9px;
    font-weight: bold;
    color: #00bcd4;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.stat-value {
    font-family: monospace;
    font-size: 16px;
    font-weight: bold;
    color: white;
}

.game-board-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px 0;
    overflow: hidden;
    min-height: 0;
}

.valve-area {
    height: 60px;
    /* constraint width to match grid exactly so percentage-based valve positions align with columns */
    width: calc(var(--grid-cols) * var(--cell-size));
    max-width: 100%;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
    min-height: 40px;
}

.valve-area::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 26px;
    background: linear-gradient(to bottom, #bdc3c7, #95a5a6, #bdc3c7);
    border-top: 2px solid #333;
    border-bottom: 2px solid #333;
    top: 50%;
    transform: translateY(-50%);
}

.valve {
    position: absolute;
    width: 60px;
    height: 85px;
    top: 50%;
    transform: translate(-50%, -50%);
    background-size: 100% 100%;
    background-repeat: no-repeat;
    z-index: 10;
}

.valve::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 65px;
    height: 65px;
    transform: translate(-50%, -50%);
    background-image: url('assets/runtime/valve.png');
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 20;
}

.valve.end {
    left: 58.33%;
    background-image: url('assets/runtime/pipe_t_0.png');
}

.valve.start {
    left: 41.67%;
    background-image: url('assets/runtime/pipe_t_180.png');
}

.valve.filled::before {
    filter: drop-shadow(0 0 15px #00e5ff) brightness(1.2);
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(var(--grid-cols), var(--cell-size));
    grid-template-rows: repeat(var(--grid-rows), var(--cell-size));

    width: fit-content;
    height: fit-content;

    background: rgba(0, 0, 0, 0.2);
    border: 4px solid #78909c;
    border-radius: 10px;
    padding: 4px;
    margin: 0 auto;
    touch-action: none;
    /* Aspect ratio is implicit from rows/cols * size */
}

.cell {
    width: 100%;
    height: 100%;
    position: relative;
    cursor: pointer;
}

.pipe {
    width: 100%;
    height: 100%;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;

    /* Use linear transition to avoid 'swinging' feel, faster 0.2s */
    /* Removed filter transition to prevent conflict with flowPulse animation on mobile */
    transition: transform 0.2s linear;
    will-change: transform;
    /* Hint for GPU promotion to avoid jitter */
    pointer-events: none;
    position: relative;
    /* Composite layer fix for mobile safari flickering */
    backface-visibility: hidden;
    transform: translateZ(0);
}

.pipe-straight {
    background-image: url('assets/runtime/pipe_straight_v.png');
}

.pipe-elbow {
    background-image: url('assets/runtime/pipe_elbow_0.png');
}

.pipe-t {
    background-image: url('assets/runtime/pipe_t_0.png');
}

.cell.filled .pipe {
    filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.8)) drop-shadow(0 0 2px #00e5ff);
    animation: flowPulse 2s infinite ease-in-out;
}

/* Force static state during rotation to prevent jitter */
/* Force static state during rotation to prevent jitter */
.pipe.rotating {
    animation: none !important;
    /* CRITICAL: Remove all filters during rotation. Mobile GPUs drift when rotating filters. */
    filter: none !important;
    transition: transform 0.2s linear !important;
    /* Ensure transition stays active */
}

@keyframes flowPulse {
    0% {
        filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.8)) brightness(1);
    }

    50% {
        filter: drop-shadow(0 0 12px rgba(0, 229, 255, 1)) brightness(1.1);
    }

    100% {
        filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.8)) brightness(1);
    }
}

.pipe-debug-dot {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #ff5252;
    border-radius: 50%;
    z-index: 100;
    transition: background 0.2s, box-shadow 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.pipe-debug-dot.active {
    background: #4caf50;
    box-shadow: 0 0 8px #4caf50;
    width: 8px;
    height: 8px;
}

.dot-n {
    top: 0;
    left: 50%;
    transform: translate(-50%, -50%);
}

.dot-e {
    top: 50%;
    right: 0;
    transform: translate(50%, -50%);
}

.dot-s {
    bottom: 0;
    left: 50%;
    transform: translate(-50%, 50%);
}

.dot-w {
    top: 50%;
    left: 0;
    transform: translate(-50%, -50%);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
}

.modal-content {
    background: linear-gradient(145deg, #1a2a3a, #0d1e30);
    padding: 30px;
    border-radius: 25px;
    border: 3px solid #00bcd4;
    text-align: center;
    width: 85%;
    max-width: 320px;
    box-shadow: 0 0 50px rgba(0, 188, 212, 0.3);
    animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

#modal-title {
    color: #ffd700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
    font-size: 28px;
}

.modal-stars {
    font-size: 50px;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.star.dim {
    opacity: 0.3;
    filter: grayscale(1);
}

.modal-score {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.trophy-icon {
    width: 50px;
    height: 50px;
    filter: drop-shadow(0 0 10px #ffd700);
}

#final-score {
    font-size: 36px;
    font-weight: bold;
    color: #ffffff;
}

.modal-stats {
    margin-bottom: 30px;
    color: #b0bec5;
    font-size: 16px;
}

.modal-buttons {
    display: flex;
    justify-content: space-around;
    gap: 10px;
}

.modal-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: none;
    background: #37474f;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 0 #263238;
    transition: all 0.1s;
}

.modal-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #263238;
}

.modal-btn.next {
    background: #4caf50;
    box-shadow: 0 4px 0 #2e7d32;
    transform: scale(1.1);
}

.modal-menu {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.menu-btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
    transition: transform 0.1s, filter 0.2s;
}

.menu-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}

.menu-btn.primary {
    background: #4caf50;
    box-shadow: 0 4px 0 #2e7d32;
}

.menu-btn.primary:hover {
    filter: brightness(1.1);
}

.menu-btn.warning {
    background: #ff5252;
    box-shadow: 0 4px 0 #b71c1c;
}

.menu-btn.warning:hover {
    filter: brightness(1.1);
}

.modal-title {
    color: #ffd700;
    font-size: 32px;
    margin-bottom: 25px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.header-left {
    display: flex;
    flex-direction: row;
    gap: 12px;
    align-items: center;
    position: static;
    transform: none;
    z-index: 200;
}

.audio-btn {
    background: #546e7a;
    border-color: #37474f;
    box-shadow: 0 4px 0 #263238;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.audio-btn:hover {
    background: #78909c;
}

.speaker-icon-svg {
    width: 24px;
    height: 24px;
    fill: #eceff1;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
    transition: fill 0.2s, opacity 0.2s;
}

.audio-btn.muted .speaker-icon-svg {
    fill: #b0bec5;
    opacity: 0.3;
}

.audio-btn.muted {
    background: #455a64;
    filter: grayscale(0.5);
}

#audio-toggle {
    position: static;
    top: auto;
    right: auto;
    border-color: #37474f;
}

#audio-toggle:hover {
    background: #455a64;
}

.flow-overlay {
    display: none;
}

@media (max-width: 480px) {
    :root {
        /* Inherit dynamic calculation */
    }

    .game-container {
        height: 100vh;
        height: 100svh;
        width: 100vw;
        max-width: 100%;
        border-radius: 0;
        border: none;
        padding-bottom: env(safe-area-inset-bottom);
        /* Handle iPhone Home Indicator */
    }

    .game-header {
        padding: 5px 10px;
        min-height: 60px;
        flex-shrink: 0;
    }

    /* Mobile specific chrome height optimization */
    :root {
        /* Header(60) + Valves(90) + Padding(30) = 180px */
        --chrome-h: 180px;
    }

    .header-right {
        gap: 4px;
    }

    .stat-item {
        min-width: 40px;
        padding: 2px 4px;
    }

    .stat-label {
        font-size: 8px;
    }

    .stat-value {
        font-size: 14px;
    }

    .valve-area {
        height: 45px;
        min-height: 30px;
        /* Ensure it matches grid on mobile too */
        width: calc(var(--grid-cols) * var(--cell-size));
    }

    .valve {
        width: 40px;
        height: 60px;
        transform: translate(-50%, -50%) scale(0.8);
    }

    .grid-container {
        /* Explicitly use the calculated size */
        grid-template-columns: repeat(var(--grid-cols), var(--cell-size));
        grid-template-rows: repeat(var(--grid-rows), var(--cell-size));
        width: fit-content;
        height: fit-content;
        max-width: none;
        max-height: none;
        border-width: 2px;
        aspect-ratio: auto;
    }

    /* Force static state during rotation ONLY on mobile to prevent jitter */
    .pipe.rotating {
        animation: none !important;
        /* CRITICAL: Remove all filters during rotation to save mobile GPU */
        filter: none !important;
        transition: transform 0.2s linear !important;
    }

    /* FIX: Disable filter animation on mobile to prevent shaking/jittering */
    .cell.filled .pipe {
        animation: none !important;
        /* Use a static generous glow instead of pulsing */
        filter: drop-shadow(0 0 10px rgba(0, 229, 255, 0.9)) brightness(1.1) !important;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    .game-title {
        font-size: 32px;
        margin-bottom: 20px;
        /* Use explicit margin for top spacing, safer than container padding mix */
        margin-top: 80px;
    }

    .level-grid {
        gap: 10px;
        max-width: 90vw;
    }

    /* Override main menu centering for short screens */
    .main-menu {
        justify-content: flex-start;
        /* Only handle safe area here, let margin handle visual distance */
        padding-top: calc(20px + env(safe-area-inset-top));
    }

    .level-btn {
        font-size: 16px;
    }

    .landing-title {
        font-size: 40px;
        margin-bottom: 30px;
    }

    .cta-btn {
        padding: 15px 40px;
        font-size: 20px;
    }

    .modal-content {
        width: 90%;
        padding: 20px;
        max-height: 90dvh;
        overflow-y: auto;
    }
}

@keyframes errorPulse {

    0%,
    100% {
        filter: drop-shadow(0 0 5px red) brightness(1);
    }

    50% {
        filter: drop-shadow(0 0 15px red) brightness(1.2);
    }
}

.pipe.error-pulse {
    animation: errorPulse 1s infinite ease-in-out !important;
}

.main-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100svh;
    /* Ensure full visibility on mobile */
    background: rgba(13, 30, 48, 0.95);
    backdrop-filter: blur(10px);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    /* Add safe area buffer */
    overflow-y: auto;
    /* Allow scrolling if really short screen */
}

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

.controls-group.left {
    flex-grow: 1;
    justify-content: flex-start;
}

.controls-group.center {
    flex-grow: 1;
    justify-content: center;
}

.game-title {
    font-size: 48px;
    color: #00e5ff;
    text-shadow: 0 0 20px rgba(0, 229, 255, 0.5);
    margin-bottom: 40px;
    font-weight: 800;
    letter-spacing: 2px;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    max-width: 400px;
    width: 100%;
}

.level-btn {
    aspect-ratio: 1;
    background: linear-gradient(145deg, #1a3a4a, #102027);
    border: 2px solid #37474f;
    border-radius: 12px;
    color: #b0bec5;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 0 #000000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Outfit', sans-serif;
}

.level-btn:hover {
    background: #00bcd4;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #00838f;
    border-color: #00bcd4;
}

.level-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #00838f;
}

.menu-btn.secondary {
    background: #78909c;
    box-shadow: 0 4px 0 #455a64;
}

.menu-btn.secondary:hover {
    filter: brightness(1.1);
}

.hidden {
    display: none !important;
}

.landing-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #1a3a4a 0%, #0d1e30 100%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.landing-title {
    font-size: 64px;
    font-weight: 900;
    color: #ffd700;
    text-transform: uppercase;
    text-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    margin-bottom: 60px;
    line-height: 1.2;
    animation: floating 3s ease-in-out infinite;
}

@keyframes floating {

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

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

.cta-btn {
    background: linear-gradient(135deg, #00bcd4, #0097a7);
    color: white;
    border: none;
    padding: 20px 60px;
    font-size: 28px;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(0, 188, 212, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: 'Outfit', sans-serif;
}

.cta-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 30px rgba(0, 188, 212, 0.6);
    filter: brightness(1.1);
}

.cta-btn:active {
    transform: scale(0.95);
}

.back-btn {
    position: static;
}

.level-stars {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
}

.level-star {
    font-size: 10px;
    color: #455a64;
}

.level-star.active {
    color: #ffd700;
    filter: drop-shadow(0 0 2px rgba(255, 215, 0, 0.5));
}

.level-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding-bottom: 15px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 400px;
    margin-top: 30px;
    padding: 0 10px;
    font-family: 'Outfit', sans-serif;
    color: #e0f7fa;
}

.page-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #455a64;
    color: white;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 0 #263238;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.page-btn:hover:not(:disabled) {
    background: #00bcd4;
    box-shadow: 0 4px 0 #00838f;
    transform: translateY(-2px);
}

.page-btn:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #00838f;
}

.page-btn:disabled {
    background: #263238;
    color: #546e7a;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

#menu-audio-toggle.page-btn {
    background: #455a64;
    border: none;
    box-shadow: 0 4px 0 #263238;
}

#menu-audio-toggle.page-btn:hover {
    background: #546e7a;
}

.page-indicator {
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 2px;
}

.level-btn.locked {
    background: #263238;
    border-color: #37474f;
    color: #546e7a;
    box-shadow: none;
    cursor: not-allowed;
    transform: none !important;
}

.level-btn.locked span {
    display: none;
}

.level-btn.locked::after {
    content: '🔒';
    font-size: 24px;
    opacity: 0.5;
}

.home-btn {
    background: #0097a7;
    margin-right: 15px;
}

.home-btn:hover:not(:disabled) {
    background: #00acc1;
    box-shadow: 0 4px 0 #006064;
}

.pagination-divider {
    width: 1px;
    height: 30px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 10px;
}

.coin-display-lg,
.coin-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    color: #ffd700;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

.coin-icon-svg {
    width: 32px;
    height: 32px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.coin-icon-svg.small {
    width: 20px;
    height: 20px;
}

.coin-display-lg {
    font-size: 1.5rem;
    background: rgba(0, 0, 0, 0.5);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid #ffd700;
}

.coin-item {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    margin-right: 0.5rem;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.menu-footer {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.hint-btn {
    background: linear-gradient(135deg, #ffc107, #ff9800);
    color: #fff;
    border: none;
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
}

.hint-btn:active {
    transform: scale(0.95);
}

.hint-glow {
    filter: drop-shadow(0 0 15px #ffd700) brightness(1.5);
    transition: all 0.5s ease;
    z-index: 10;
}

.ad-content {
    background: #1a1a1a;
    border: 2px solid #333;
}

.ad-loader {
    width: 100%;
    height: 10px;
    background: #333;
    border-radius: 5px;
    margin: 1.5rem 0;
    overflow: hidden;
}

.ad-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #00e5ff, #00ff9d);
    width: 0%;
    transition: width 0.1s linear;
}

.vertical-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    align-items: center;
    margin-top: 20px;
}

.modal-row {
    display: flex;
    gap: 1rem;
    justify-content: center;
    width: 100%;
}

.modal-btn.primary,
.modal-btn.ad-btn {
    width: 90%;
    height: auto;
    padding: 12px 20px;
    border-radius: 50px;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.modal-btn.primary:active,
.modal-btn.ad-btn:active {
    transform: translateY(3px);
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}

.modal-btn.ad-btn {
    background: linear-gradient(135deg, #7C4DFF, #651FFF);
    margin-bottom: 5px;
    padding: 12px 16px;
    font-size: 18px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    animation: adBtnPulse 2s infinite ease-in-out;
    width: 95%;
}

@keyframes adBtnPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3);
    }

    50% {
        transform: scale(1.02);
        box-shadow: 0 8px 10px rgba(124, 77, 255, 0.4);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3);
    }
}

.modal-btn.primary {
    background: linear-gradient(135deg, #43A047, #2E7D32);
    opacity: 0.9;
    transform: scale(0.95);
    font-size: 16px;
}

.reward-badge {
    background: rgba(0, 0, 0, 0.25);
    padding: 2px 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #FFD700;
    font-weight: 800;
    font-size: 0.9em;
}

.reward-badge.highlight {
    background: rgba(255, 215, 0, 0.2);
    color: #FFF;
    text-shadow: 0 0 5px #ffd700;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.coin-icon-svg.small-inline {
    width: 16px;
    height: 16px;
    display: inline-block;
}

.modal-btn.small {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    padding: 0;
    font-size: 24px;
    background: #546e7a;
}

.modal-btn.ad-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shine 2s infinite;
}

@keyframes shine {
    0% {
        left: -100%;
    }

    20% {
        left: 200%;
    }

    100% {
        left: 200%;
    }
}

.cta-btn.small {
    padding: 0.5rem 1.5rem;
    font-size: 1rem;
    background: linear-gradient(135deg, #2979FF, #00B0FF);
}