* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    color: #000;
    overflow-x: hidden;
}

/* Container */
.screen {
    display: none;
    max-width: 600px;
    margin: 0 auto;
    background: #fff;
    min-height: 100vh;
    position: relative;
}

.screen.active {
    display: block;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
}

.btn-back,
.btn-menu {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Content */
.content {
    padding: 20px;
    padding-bottom: 100px;
}

.content.centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 70px);
    text-align: center;
    padding: 40px 20px;
}

/* Balance Section */
.balance-section {
    margin-bottom: 24px;
}

.balance-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 600;
}

.balance-header svg {
    width: 20px;
    height: 20px;
}

.balance-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.balance-amount {
    display: flex;
    align-items: center;
    gap: 8px;
}

.coin-icon {
    flex-shrink: 0;
}

.amount {
    font-size: 24px;
    font-weight: 700;
}

.transaction-link {
    color: #999;
    font-size: 14px;
    text-decoration: none;
}

/* Username Section */
.username-section {
    margin-bottom: 24px;
}

.username-section label {
    display: block;
    color: #999;
    font-size: 14px;
    margin-bottom: 8px;
}

.input-wrapper {
    display: flex;
    align-items: center;
    border: 2px solid #00B8FF;
    border-radius: 12px;
    padding: 16px;
    background: #fff;
}

.input-prefix {
    color: #000;
    font-size: 16px;
    margin-right: 4px;
}

.input-wrapper input {
    border: none;
    outline: none;
    flex: 1;
    font-size: 16px;
}

/* Error shake animation */
.error-shake {
    animation: shake 0.5s;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

/* User Info Card */
.user-info-card {
    margin-top: 12px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 12px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-info-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-nickname {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
    color: #000;
}

.user-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #666;
}

.coin-icon-small {
    flex-shrink: 0;
}

.unique-id {
    color: #999;
    margin-left: 4px;
}

.btn-copy {
    background: none;
    border: 1px solid #e0e0e0;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-copy:hover {
    background: #f8f8f8;
    border-color: #00B8FF;
}

.btn-copy svg {
    color: #666;
}

.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    color: #666;
    font-size: 14px;
}

.loading-spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid #f0f0f0;
    border-top-color: #FF2D55;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.promo-text {
    color: #FF2D55;
    font-size: 14px;
    margin-top: 12px;
}

/* Packages Grid */
.packages-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.package-item {
    background: #f8f8f8;
    border: 2px solid #f0f0f0;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.package-item:hover {
    background: #fff;
    border-color: #e0e0e0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.package-item.custom {
    border: 2px solid #FF2D55;
    background: #fff;
}

/* Compact Wrapper */
.package-content {
    display: flex;
    align-items: center;
    flex-direction: column;
    gap: 5px;
    text-align: left;
}

.package-text {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 5px;
    justify-content: left;
}

.package-amount {
    font-size: 16px;
    font-weight: 700;
    color: #000;
    line-height: 1.2;
    margin: 0;
}

.package-price {
    color: #999;
    font-size: 13px;
    line-height: 1.2;
}

.package-subtitle {
    color: #999;
    font-size: 12px;
    margin-top: 0;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: flex-end;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: 12px 12px 0 0;
    padding: 20px;
    width: 100%;
    max-width: 600px;
    animation: slideUp 0.3s ease-out;
    padding-bottom: 30px;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

/* Centered Modal (for Processing) */
.modal.centered {
    align-items: center;
    /* Center vertically */
    justify-content: center;
    /* Center horizontally */
}

.modal.centered .modal-content {
    border-radius: 12px;
    /* Full rounded corners */
    max-width: 320px;
    width: 90%;
    animation: fadeInScale 0.3s ease-out;
    padding-bottom: 24px;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content h2 {
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 24px;
    color: #000;
}

.custom-amount-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 40px;
}

.custom-amount-display .coin-icon {
    width: 32px;
    height: 32px;
}

.custom-amount {
    font-size: 36px;
    font-weight: 700;
    color: #000;
}

/* Numpad */
.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    margin-bottom: 24px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.numpad-btn {
    background: none;
    border: none;
    font-size: 24px;
    font-weight: 400;
    color: #167af6;
    padding: 24px 0;
    cursor: pointer;
    transition: background 0.1s;
    border-radius: 8px;
}

.numpad-btn:active {
    background: #f0f0f0;
}

.numpad-btn.empty {
    cursor: default;
}

.numpad-btn.backspace {
    display: flex;
    align-items: center;
    justify-content: center;
}

.numpad-btn.backspace svg {
    width: 28px;
    height: 28px;
    color: #167af6;
    fill: #167af6;
    /* TikTok styled backspace usually filled */
}

/* Using a more accurate backspace icon color or style if needed, blue is standard for iOS-like numpads */

.total-price {
    text-align: center;
    color: #000;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 600;
}

/* Primary Button */
.btn-primary {
    width: 100%;
    background: #FF2D55;
    /* TikTok Red */
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-primary:active {
    opacity: 0.8;
}

.btn-fixed {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    max-width: 560px;
    margin: 0 auto;
}

/* Order Summary */
.order-info {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.order-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.order-row .label {
    font-size: 16px;
    color: #000;
    font-weight: 500;
}

.order-row .value {
    font-size: 16px;
    font-weight: 600;
}

.order-detail {
    display: flex;
    justify-content: space-between;
    color: #999;
    font-size: 14px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

/* Payment Section */
.payment-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #000;
}

.payment-option {
    display: flex;
    align-items: center;
    padding: 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 12px;
    cursor: pointer;
    background: #fff;
    transition: all 0.2s;
}

.payment-option.selected {
    border: 2px solid #FF2D55;
    background: #FF2D550D;
    /* Slight red tint */
    padding: 15px;
    /* Adjust for border width change to keep size */
}

.payment-option input[type="radio"] {
    margin-right: 12px;
    width: 20px;
    height: 20px;
    accent-color: #FF2D55;
    flex-shrink: 0;
}

.payment-info {
    display: flex;
    justify-content: space-between;
    flex: 1;
    align-items: center;
    width: 100%;
}

.payment-add-text {
    font-size: 14px;
    font-weight: 500;
    color: #000;
}

.payment-icons {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Saved Card Specifics */
.saved-card-option {
    background: #f8f8f8;
    border: none !important;
    padding: 12px 16px;
}

.saved-card-option.selected {
    border: 2px solid #FF2D55 !important;
    background: #FF2D550D;
}

.saved-card-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
}

.saved-card-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 600;
}

.card-brand {
    font-weight: 800;
    font-style: italic;
    color: #1a1f71;
    /* Visa Blue */
}

.card-number {
    color: #333;
    font-family: monospace;
    font-size: 14px;
}

.card-alert-dot {
    width: 8px;
    height: 8px;
    background: #FF2D55;
    border-radius: 50%;
}

.payment-disclaimer {
    color: #999;
    font-size: 11px;
    line-height: 1.4;
    margin-top: 20px;
}

.paypal-logo {
    color: #003087;
    font-weight: 700;
    font-style: italic;
}

/* Loading Spinner */
/* TikTok Loader */

/* Loading Spinner */
/* TikTok Processing Loader - Two Dots */
.tiktok-loader {
    position: relative;
    width: 40px;
    height: 20px;
    margin: 0 auto 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.tiktok-loader .circle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: tiktok_pulse 0.8s ease-in-out infinite alternate;
}

.tiktok-loader .circle.red {
    background: #FE2C55;
    animation-delay: 0s;
}

.tiktok-loader .circle.blue {
    background: #25F4EE;
    animation-delay: 0.4s;
}

@keyframes tiktok_pulse {
    0% {
        transform: scale(0.8);
        opacity: 0.6;
    }

    100% {
        transform: scale(1.2);
        opacity: 1;
    }
}


.countdown {
    background: #f0f0f0;
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 18px;
    font-weight: 600;
    margin-top: 16px;
}

/* Success */
.success-icon {
    margin-bottom: 24px;
}

.content.centered h2 {
    font-size: 24px;
    margin-bottom: 16px;
}

.content.centered p {
    color: #666;
    font-size: 16px;
    margin-bottom: 12px;
    line-height: 1.6;
}

.success-note {
    font-size: 14px !important;
    color: #999 !important;
    margin-bottom: 32px !important;
}

/* Mobile Optimization */
@media (max-width: 600px) {
    .screen {
        max-width: 100%;
    }

    .btn-fixed {
        max-width: calc(100% - 40px);
    }
}