:root {
    --bg: #1c1c1e;
    --card: #2c2c2e;
    --text: #ffffff;
    --text2: #8e8e93;
    --accent: #26a17b;
    --accent2: #34C759;
    --danger: #FF3B30;
    --border: #3a3a3c;
    --radius: 16px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 420px;
    margin: 0 auto;
    padding: 16px;
}

.screen {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.screen.active {
    display: flex;
}

/* ─── Loading ─── */
#loading {
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ─── Cards ─── */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
}

.badge {
    display: inline-block;
    background: rgba(38, 161, 123, 0.15);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ─── Amount ─── */
.amount-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 16px;
}

.amount-label {
    font-size: 13px;
    color: var(--text2);
}

.amount {
    font-size: 48px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -1px;
}

.currency {
    font-size: 16px;
    color: var(--text2);
    font-weight: 500;
    margin-top: 2px;
}

.fee-breakdown {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.fee-info {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text2);
}

.fee-value {
    color: var(--accent);
    font-weight: 600;
}

.fee-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text2);
    padding: 2px 0;
}

.fee-trx span:last-child {
    color: var(--accent);
    font-weight: 500;
}

/* ─── Checklist ─── */
.checklist-card {
    padding: 14px 20px;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    padding: 6px 0;
    color: var(--text2);
}

.check-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.check-icon.done {
    color: var(--accent2);
}

.check-item.done {
    color: var(--accent2);
}

.description {
    text-align: center;
    color: var(--text2);
    font-size: 14px;
    margin-top: 8px;
}

/* ─── Address ─── */
.section-label {
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 12px;
    text-align: center;
}

.qr-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.qr-wrap canvas {
    width: 180px !important;
    height: 180px !important;
    border-radius: 12px;
    background: #fff;
    padding: 8px;
}

.address-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border-radius: 12px;
    padding: 10px 12px;
}

.address-text {
    flex: 1;
    font-size: 12px;
    word-break: break-all;
    color: var(--text);
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    line-height: 1.4;
}

.copy-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: background 0.2s;
}

.copy-btn:active {
    background: rgba(38, 161, 123, 0.2);
}

.copy-btn.copied {
    color: var(--accent2);
}

.hint {
    font-size: 12px;
    color: var(--text2);
    text-align: center;
    margin-top: 12px;
}

/* ─── Timer ─── */
.timer-card {
    padding: 14px 20px;
}

.timer-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text2);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 10px;
}

.progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 1s linear;
    width: 100%;
}

.progress-fill.danger {
    background: var(--danger);
}

/* ─── Status ─── */
.status-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px;
}

.pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

#status-text {
    font-size: 14px;
    color: var(--text2);
}

/* ─── Success ─── */
#success {
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    gap: 16px;
}

.success-icon {
    animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

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

.success-amount {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent2);
}

.tx-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
}

.btn-primary {
    width: 100%;
    max-width: 300px;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    margin-top: 12px;
}

.btn-primary:active {
    opacity: 0.8;
}

/* ─── Expired ─── */
#expired,
#error {
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    gap: 16px;
}

/* ─── Telegram theme adaptation ─── */
body.tg-theme {
    --bg: var(--tg-theme-bg-color, #1c1c1e);
    --card: var(--tg-theme-secondary-bg-color, #2c2c2e);
    --text: var(--tg-theme-text-color, #ffffff);
    --text2: var(--tg-theme-hint-color, #8e8e93);
    --accent: var(--tg-theme-button-color, #26a17b);
}
