:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark-bg: #0f172a;
    --dark-surface: #1e293b;
    --dark-surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --border-color: #475569;
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-warm: linear-gradient(135deg, #ec4899 0%, #f59e0b 100%);
}

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

html, body {
    width: 100%;
    height: 100%;
    background: var(--dark-bg);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
}

/* Telegram WebApp overrides */
body {
    background-color: var(--dark-bg) !important;
    color: var(--text-primary) !important;
}

.app-container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--dark-bg);
    padding-bottom: 20px;
}

/* Header */
.header {
    padding: 20px;
    background: linear-gradient(180deg, var(--dark-surface) 0%, rgba(30, 41, 59, 0.7) 100%);
    border-bottom: 1px solid var(--border-color);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.streak-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(236, 72, 153, 0.15);
    border: 1px solid rgba(236, 72, 153, 0.3);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #ec4899;
}

.streak-flame {
    font-size: 14px;
    animation: flicker 0.5s ease-in-out infinite alternate;
}

@keyframes flicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
        opacity: 1;
    }
    20%, 24%, 55% {
        opacity: 0.7;
    }
}

.header-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Usage Counter */
.usage-counter {
    background: var(--dark-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
}

.usage-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.usage-bar {
    width: 100%;
    height: 8px;
    background: var(--dark-surface-light);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.usage-fill {
    height: 100%;
    background: var(--gradient-primary);
    transition: width 0.3s ease;
}

.usage-text {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Screens */
.screen {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.screen.active {
    display: block;
    opacity: 1;
}

/* Scan Screen */
.scan-area {
    text-align: center;
    padding: 40px 20px;
    background: var(--dark-surface);
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    margin-bottom: 24px;
}

.scan-icon {
    font-size: 48px;
    margin-bottom: 16px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.scan-area h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

.scan-area p {
    color: var(--text-secondary);
    margin-bottom: 28px;
    font-size: 13px;
}

.info-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.info-card {
    background: var(--dark-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    transition: all 0.3s ease;
}

.info-card:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.info-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.info-title {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
}

.info-text {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* Results Screen */
.results-header {
    text-align: center;
    margin-bottom: 28px;
}

.results-header h2 {
    margin-bottom: 20px;
    font-size: 18px;
}

.risk-score-circle {
    width: 140px;
    height: 140px;
    margin: 0 auto;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.3);
}

.risk-score-inner {
    width: 130px;
    height: 130px;
    background: var(--dark-bg);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.risk-number {
    font-size: 48px;
    font-weight: 700;
    line-height: 1;
}

.risk-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.risk-label-below {
    margin-top: 12px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}

.results-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.result-item {
    background: var(--dark-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
}

.result-label {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.result-value {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 6px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-description {
    font-size: 12px;
    color: var(--text-secondary);
}

.results-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Premium Section */
.premium-section {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border: 1px solid rgba(236, 72, 153, 0.2);
    border-radius: 16px;
    padding: 20px;
    margin-top: 20px;
}

.premium-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.premium-icon {
    font-size: 24px;
}

.premium-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.premium-benefits {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.benefit {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.benefit-icon {
    font-size: 16px;
}

/* History Section */
.history-section {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.history-header h3 {
    font-size: 16px;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary-light);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
}

.btn-text:hover {
    text-decoration: underline;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-empty {
    text-align: center;
    color: var(--text-tertiary);
    padding: 20px;
    font-size: 13px;
}

.history-item {
    background: var(--dark-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.history-item-date {
    font-size: 12px;
    color: var(--text-tertiary);
}

.history-item-score {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-light);
}

/* Buttons */
.btn {
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
}

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

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--dark-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.btn-premium {
    background: linear-gradient(135deg, #ec4899 0%, #f59e0b 100%);
    color: white;
}

.btn-premium:hover {
    box-shadow: 0 8px 24px rgba(236, 72, 153, 0.4);
    transform: translateY(-2px);
}

.btn-large {
    padding: 18px 32px;
    font-size: 16px;
    width: 100%;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Spinner */
.spinner-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.spinner-text {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 360px) {
    .header h1 {
        font-size: 24px;
    }

    .info-cards {
        grid-template-columns: 1fr;
    }

    .btn {
        padding: 12px 16px;
        font-size: 13px;
    }

    .btn-large {
        padding: 16px 24px;
    }
}

/* Dark mode override for Telegram */
@media (prefers-color-scheme: dark) {
    body {
        background: var(--dark-bg);
        color: var(--text-primary);
    }
}
