:root {
    --bg-color: #030303;
    --text-color: #ffffff;
    --text-muted: #888888;
    --accent-color: #ffffff;
    --border-color: rgba(255, 255, 255, 0.15);
    --border-hover: rgba(255, 255, 255, 0.4);
    --bg-surface: rgba(255, 255, 255, 0.04);
    --bg-surface-hover: rgba(255, 255, 255, 0.08);
    --error-color: #ff5555;
    --transition-curve: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: stretch;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: pan-y;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    width: 100%;
    max-width: 440px;
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    margin: 0 auto;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Top right Telegram link container */
.top-links {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 18px);
    right: 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 100;
}

/* Telegram Link */
.tg-link {
    color: var(--text-color);
    transition: transform 0.3s ease, text-shadow 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
    font-weight: 500;
    text-decoration: none;
    letter-spacing: 0.04em;
}

.tg-link:hover {
    transform: translate(2px, -2px) scale(1.05);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.tg-icon {
    width: 24px;
    height: 24px;
}

/* Top left MAX Support Link */
.support-max-link {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 20px);
    left: 18px;
    color: var(--text-color);
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    line-height: 1.25;
    text-decoration: none;
    transition: transform 0.3s ease, text-shadow 0.3s ease;
    z-index: 100;
}

.support-max-link:hover {
    transform: scale(1.05);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* Views */
.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding:
        calc(env(safe-area-inset-top, 0px) + 32px)
        20px
        calc(env(safe-area-inset-bottom, 0px) + 24px);
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.6s var(--transition-curve), transform 0.5s var(--transition-curve);
    transform: translateY(20px);
}

.view.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.view.fade-up {
    transform: translateY(-20px);
}

/* Intro Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.intro-logo {
    opacity: 0;
    animation: fadeIn 1s ease-out forwards;
}

.intro-form {
    opacity: 0;
    animation: slideUp 0.8s ease-out forwards 1s;
}

.intro-delayed {
    opacity: 0;
    animation: fadeIn 1s ease-out forwards 4s;
}

/* --- Code View --- */
#codeView {
    justify-content: flex-start;
    /* Change from space-between to allow pulling form up */
}

/* Logo */
.logo-container {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: clamp(72px, 11vh, 120px);
    padding-bottom: clamp(20px, 5vh, 48px);
}

.logo-circle {
    width: clamp(164px, 44vw, 220px);
    height: clamp(164px, 44vw, 220px);
    border: 1px solid var(--border-hover);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.05);
    animation: pulseCircle 5s infinite alternate ease-in-out;
}

@keyframes pulseCircle {
    0% {
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.02);
    }

    100% {
        box-shadow: 0 0 50px rgba(255, 255, 255, 0.08);
    }
}

.logo-text {
    font-size: clamp(2rem, 7vw, 2.5rem);
    font-weight: 300;
    letter-spacing: 0.5em;
    margin-right: -0.5em;
    color: var(--text-color);
}

/* Form */
.form-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1 0 auto;
    min-height: 0;
}

.code-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 100%;
}

.trial-btn-container {
    margin-top: auto;
    padding-bottom: 8px;
}

@keyframes trialGlow {
    0% {
        box-shadow:
            0 0 0 1px rgba(255, 255, 255, 0.05),
            0 0 16px rgba(255, 255, 255, 0.14),
            0 0 38px rgba(255, 255, 255, 0.08);
    }

    100% {
        box-shadow:
            0 0 0 1px rgba(255, 255, 255, 0.08),
            0 0 26px rgba(255, 255, 255, 0.24),
            0 0 58px rgba(255, 255, 255, 0.14);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.input-group {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

input[type="text"] {
    width: 100%;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 30px;
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 400;
    outline: none;
    transition: all 0.3s ease;
    font-family: inherit;
    text-align: center;
    letter-spacing: 2px;
}

input[type="text"]::placeholder {
    color: rgba(255, 255, 255, 0.3);
    font-weight: 300;
    letter-spacing: normal;
}

input[type="text"]:focus {
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.02);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.08);
}

.paste-btn {
    height: 48px;
    padding: 0 24px;
    background: rgba(255, 255, 255, 0.08);
    /* slightly darker than input */
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-color);
    border-radius: 24px;
    /* Pill shape */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    margin: 0 auto;
    /* Center it horizontally */
    width: fit-content;
}

.paste-btn:hover {
    color: var(--text-color);
    background: var(--bg-surface);
}

.paste-btn:active {
    transform: scale(0.95);
}

.paste-btn svg {
    width: 20px;
    height: 20px;
}

.error-msg {
    color: var(--error-color);
    font-size: 0.85rem;
    text-align: center;
    min-height: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    margin-top: -8px;
}

.error-msg.visible {
    opacity: 1;
}

.referral-state {
    min-height: 20px;
    margin-top: -6px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.82rem;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.referral-state.visible {
    opacity: 1;
}

/* Buttons */
.primary-btn,
.secondary-btn {
    width: 100%;
    padding: 16px 18px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
    border: none;
    outline: none;
}

.primary-btn {
    background: var(--accent-color);
    color: var(--bg-color);
    border: 1px solid var(--accent-color);
}

.primary-btn:hover:not(:disabled) {
    background: transparent;
    color: var(--accent-color);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

.primary-btn:disabled {
    cursor: not-allowed;
}

/* Initially hidden state for continue button */
.submit-btn {
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
    position: absolute;
    /* Take out of flow to not take up space */
    bottom: -60px;
    /* Position it below the form */
}

/* State when code is valid and it should be visible */
.submit-btn.is-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    position: relative;
    /* Put back into flow */
    bottom: 0;
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-color);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-weight: 500;
}

.secondary-btn:hover {
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.12);
}

.trial-btn {
    position: relative;
    z-index: 0;
    overflow: visible;
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 0 16px rgba(255, 255, 255, 0.14),
        0 0 38px rgba(255, 255, 255, 0.08);
    animation: trialGlow 2.8s ease-in-out infinite alternate;
}

.trial-btn::before {
    content: "";
    position: absolute;
    inset: -10px;
    border-radius: 999px;
    background: radial-gradient(circle at center,
            rgba(255, 255, 255, 0.22) 0%,
            rgba(255, 255, 255, 0.09) 44%,
            rgba(255, 255, 255, 0) 74%);
    filter: blur(14px);
    opacity: 0.95;
    z-index: -1;
    pointer-events: none;
}

.trial-btn:hover {
    border-color: rgba(255, 255, 255, 0.46);
    background: rgba(255, 255, 255, 0.12);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.1),
        0 0 30px rgba(255, 255, 255, 0.28),
        0 0 72px rgba(255, 255, 255, 0.16);
}

/* --- Payment View --- */
#paymentView {
    justify-content: center;
    padding-top: 80px;
}

.payment-header {
    text-align: center;
    margin-bottom: 40px;
}

.payment-header h2 {
    font-size: 1.8rem;
    font-weight: 300;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.payment-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 300;
}

.payment-code {
    margin-top: 12px;
    color: rgba(255, 255, 255, 0.8);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.payment-referral {
    min-height: 20px;
    margin-top: 8px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.82rem;
}

.payment-status {
    min-height: 22px;
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.payment-status.visible {
    opacity: 1;
}

.payment-status.is-error {
    color: var(--error-color);
}

.payment-status.is-success {
    color: rgba(255, 255, 255, 0.88);
}

.plans-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.plan-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    color: var(--text-color);
    outline: none;
    font-family: inherit;
    text-decoration: none;
}

.plan-card:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.plan-card:active {
    transform: translateY(0);
}

.plan-card:disabled {
    opacity: 0.55;
    cursor: wait;
    transform: none;
    box-shadow: none;
}

.plan-duration {
    font-size: 1.1rem;
    font-weight: 400;
    z-index: 1;
}

.plan-price {
    font-size: 1.4rem;
    font-weight: 500;
    z-index: 1;
}

.currency {
    font-weight: 300;
    font-size: 1rem;
    color: var(--text-muted);
}

.plan-badge {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-color);
    color: var(--bg-color);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 14px;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Back button */
.back-btn {
    margin-top: 40px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.3s ease;
    padding: 16px;
}

@media (max-width: 420px) {
    .view {
        padding-left: 16px;
        padding-right: 16px;
    }

    .top-links {
        right: 14px;
    }

    .support-max-link {
        left: 14px;
        font-size: 0.76rem;
    }

    .tg-link {
        font-size: 0.84rem;
        gap: 6px;
    }

    .tg-icon {
        width: 20px;
        height: 20px;
    }
}

@media (max-height: 820px) {
    .view {
        padding-top: calc(env(safe-area-inset-top, 0px) + 24px);
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
    }

    .top-links {
        top: calc(env(safe-area-inset-top, 0px) + 14px);
    }

    .support-max-link {
        top: calc(env(safe-area-inset-top, 0px) + 16px);
    }

    .logo-container {
        margin-top: clamp(60px, 9vh, 92px);
        padding-bottom: clamp(16px, 3vh, 32px);
    }
}

@media (max-height: 720px) {
    .logo-container {
        margin-top: clamp(48px, 7vh, 72px);
        padding-bottom: 16px;
    }

    .logo-circle {
        width: clamp(136px, 34vw, 172px);
        height: clamp(136px, 34vw, 172px);
    }

    .logo-text {
        font-size: clamp(1.7rem, 6vw, 2rem);
    }

    .code-form,
    .form-container,
    .plans-container,
    .download-links,
    .result-actions {
        gap: 12px;
    }

    .payment-header,
    .download-header {
        margin-bottom: 24px;
    }

    .back-btn {
        margin-top: 24px;
        padding: 12px;
    }

    .support-max-link {
        font-size: 0.72rem;
    }
}

@media (max-height: 640px) {
    .view {
        padding-top: calc(env(safe-area-inset-top, 0px) + 18px);
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
    }

    .logo-container {
        margin-top: clamp(40px, 6vh, 56px);
        padding-bottom: 12px;
    }

    .paste-btn,
    .primary-btn,
    .secondary-btn,
    .download-btn {
        font-size: 0.92rem;
    }

    input[type="text"] {
        font-size: 0.95rem;
        padding: 14px 18px;
    }

    .trial-btn-container {
        padding-bottom: 0;
    }
}

.back-btn:hover {
    color: var(--text-color);
}

.back-btn svg {
    width: 18px;
    height: 18px;
}

/* --- Download View --- */
#downloadView {
    justify-content: center;
    padding-top: 60px;
}

.download-header {
    text-align: center;
    margin-bottom: 30px;
}

.download-header h2 {
    font-size: 1.8rem;
    font-weight: 300;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.download-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 300;
}

.download-links {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 32px;
}

.partner-install-assist {
    margin-bottom: 24px;
    padding: 20px 22px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.1), transparent 48%),
        rgba(255, 255, 255, 0.04);
}

.partner-install-title {
    margin: 0 0 8px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-color);
}

.partner-install-copy {
    margin: 0 0 16px;
    font-size: 0.93rem;
    line-height: 1.45;
    color: var(--text-muted);
}

.partner-install-code {
    margin: 14px 0 0;
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.84);
}

.download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-decoration: none;
    padding: 18px 20px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.download-btn.active-btn {
    background: var(--text-color);
    color: var(--bg-color);
    border: 1px solid var(--text-color);
}

.download-btn.active-btn:hover {
    background: transparent;
    color: var(--text-color);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

.download-btn svg {
    width: 20px;
    height: 20px;
}

.payment-result-card {
    margin-bottom: 24px;
}

.result-line {
    min-height: 22px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
}

.result-line + .result-line {
    margin-top: 10px;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.hidden {
    display: none;
}

.instructions-block {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    color: var(--text-color);
}

.instructions-block h3 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 16px;
    color: var(--text-muted);
}

.instructions-block ol {
    margin: 0;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.instructions-block li {
    font-size: 0.95rem;
    font-weight: 300;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.9);
}

.instructions-block li b {
    font-weight: 500;
    color: var(--text-color);
}

/* ============================================================
   Legal pages (privacy.html, terms.html) + consent-notice on SPA
   ============================================================ */

.legal-page {
    max-width: 720px;
    margin: 40px auto 80px;
    padding: 0 24px;
    line-height: 1.6;
    color: #ccc;
    font-family: 'Inter', system-ui, sans-serif;
}

.legal-header {
    margin-bottom: 32px;
}

.legal-header h1 {
    font-size: 28px;
    margin: 16px 0 0;
    color: #fff;
    font-weight: 600;
}

.legal-back-btn {
    color: #888;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.legal-back-btn:hover {
    color: #fff;
}

.legal-content h2 {
    font-size: 20px;
    margin-top: 32px;
    color: #fff;
    font-weight: 500;
}

.legal-content h3 {
    font-size: 16px;
    margin-top: 24px;
    color: #ddd;
    font-weight: 500;
}

.legal-content p,
.legal-content li {
    color: #ccc;
    font-size: 15px;
}

.legal-content a {
    color: #aaa;
    text-decoration: underline;
}

.legal-content ul,
.legal-content ol {
    padding-left: 24px;
}

.legal-footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid #333;
    font-size: 13px;
    color: #888;
}

.legal-footer p {
    margin: 4px 0;
}

.legal-footer a {
    color: #aaa;
    text-decoration: underline;
}

/* consent-notice on paymentView */
.consent-notice {
    margin-top: 16px;
    font-size: 12px;
    color: #888;
    text-align: center;
    line-height: 1.5;
}

.consent-notice a {
    color: #aaa;
    text-decoration: underline;
}

.consent-notice a:hover {
    color: #fff;
}
