/* ═══════════════════════════════════════════════════════════════════
   BASE v3.0 - Variables, Reset, Typography, Utilities, Animations
   ENFORCER MINI APP - Gangsta Theme 🔫
   ═══════════════════════════════════════════════════════════════════ */

/* Prevent pull-to-close in Telegram Mini App */
html, body {
    overscroll-behavior: none;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
}

:root {
    /* === COLORS === */
    --bg: #0a0a0a;
    --bg-card: #111111;
    --bg-card-hover: #161616;
    --bg-elevated: #1a1a1a;
    --bg-input: #0d0d0d;
    
    --text: #ffffff;
    --text-secondary: #cccccc;
    --text-dim: #888888;
    --text-muted: #555555;
    
    /* Accent - Green (main brand) */
    --accent: #22c55e;
    --accent-dim: #16a34a;
    --accent-glow: rgba(34, 197, 94, 0.3);
    --accent-bg: rgba(34, 197, 94, 0.1);
    
    /* Gold - VIP / Premium */
    --gold: #ffd700;
    --gold-dim: #b8860b;
    --gold-glow: rgba(255, 215, 0, 0.3);
    --gold-bg: rgba(255, 215, 0, 0.1);
    
    /* Medals */
    --silver: #C0C0C0;
    --bronze: #CD7F32;
    
    /* Status Colors */
    --positive: #22c55e;
    --negative: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --purple: #8b5cf6;
    
    /* Borders */
    --border: #222222;
    --border-light: #333333;
    --border-accent: var(--accent);
    
    /* === SPACING === */
    --nav-h: 70px;
    --header-h: 60px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    
    /* === SHADOWS === */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);
    --shadow-gold: 0 0 20px var(--gold-glow);
    
    /* === ANIMATION === */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    --bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    /* === GRADIENTS === */
    --gradient-accent: linear-gradient(135deg, var(--accent) 0%, #059669 100%);
    --gradient-gold: linear-gradient(135deg, var(--gold) 0%, #f59e0b 100%);
    --gradient-fire: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    --gradient-purple: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    --gradient-dark: linear-gradient(180deg, var(--bg-card) 0%, var(--bg) 100%);
}

/* === RESET === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* === TYPOGRAPHY === */
h1, h2, h3, h4, h5, h6 {
    font-weight: 800;
    line-height: 1.2;
}

h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }

p { line-height: 1.5; }

a {
    color: var(--accent);
    text-decoration: none;
    transition: opacity 0.2s;
}
a:hover { opacity: 0.8; }

strong, b { font-weight: 700; }

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { 
    background: var(--border-light); 
    border-radius: 2px; 
}
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* === SELECTION === */
::selection {
    background: var(--accent);
    color: var(--bg);
}

/* === FOCUS === */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes fadeInBg {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalPop {
    from { transform: scale(0.9) translateY(20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

@keyframes toastSlide {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

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

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px var(--accent-glow); }
    50% { box-shadow: 0 0 20px var(--accent-glow), 0 0 30px var(--accent-glow); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes countUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* === UTILITY CLASSES === */
.hidden { display: none !important; }
.invisible { visibility: hidden !important; }

.pos, .positive { color: var(--positive) !important; }
.neg, .negative { color: var(--negative) !important; }
.warn, .warning { color: var(--warning) !important; }
.gold { color: var(--gold) !important; }
.accent { color: var(--accent) !important; }
.dim { color: var(--text-dim) !important; }
.muted { color: var(--text-muted) !important; }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* === LOADING & EMPTY STATES === */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-dim);
    font-size: 14px;
}

.loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin-right: 10px;
    animation: spin 0.8s linear infinite;
}

.empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-dim);
}

.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
    opacity: 0.7;
}

.empty-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text);
}

.empty-text {
    font-size: 13px;
    line-height: 1.5;
}

.empty-btn {
    display: inline-block;
    margin-top: 16px;
    padding: 10px 20px;
    background: var(--accent);
    color: var(--bg);
    font-weight: 700;
    font-size: 13px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

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

/* === ERROR STATE === */
.error-state {
    text-align: center;
    padding: 40px 20px;
}

.error-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.error-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.error-msg {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 20px;
}

.retry-btn {
    padding: 12px 24px;
    background: var(--accent);
    color: var(--bg);
    font-weight: 700;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

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

/* === SKELETON LOADING === */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-card) 25%,
        var(--bg-elevated) 50%,
        var(--bg-card) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* === CONFETTI CANVAS === */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* === SECTION TITLE === */
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin: 20px 0 12px;
    padding: 0 2px;
}

.section-title .see-all {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.section-title .see-all:active {
    background: var(--accent-bg);
}

/* === DIVIDER === */
.divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}

/* === BADGE === */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
}

.badge.accent {
    background: var(--accent-bg);
    color: var(--accent);
}

.badge.gold {
    background: var(--gold-bg);
    color: var(--gold);
}

.badge.negative {
    background: rgba(239, 68, 68, 0.1);
    color: var(--negative);
}

/* === CHIP === */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

.chip:active {
    transform: scale(0.95);
}

.chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
}

/* === PROGRESS BAR === */
.progress-bar {
    height: 6px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-accent);
    border-radius: var(--radius-full);
    transition: width 0.5s var(--ease);
}

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

/* === AVATAR === */
.avatar {
    width: 40px;
    height: 40px;
    background: var(--bg-elevated);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.avatar.sm { width: 32px; height: 32px; font-size: 16px; }
.avatar.lg { width: 56px; height: 56px; font-size: 28px; }
.avatar.xl { width: 72px; height: 72px; font-size: 36px; }

.avatar-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: var(--accent);
    color: var(--bg);
    font-size: 10px;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: var(--radius-sm);
    min-width: 18px;
    text-align: center;
}

/* === UNIFIED USER AVATAR (photo or rank emoji) === */
.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 2px solid var(--border);
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.user-avatar .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.user-avatar .avatar-emoji,
.user-avatar .avatar-fallback {
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Size variants */
.user-avatar.avatar-sm { width: 32px; height: 32px; }
.user-avatar.avatar-sm .avatar-emoji,
.user-avatar.avatar-sm .avatar-fallback { font-size: 16px; }

.user-avatar.avatar-md { width: 44px; height: 44px; }
.user-avatar.avatar-md .avatar-emoji,
.user-avatar.avatar-md .avatar-fallback { font-size: 22px; }

.user-avatar.avatar-lg { width: 56px; height: 56px; }
.user-avatar.avatar-lg .avatar-emoji,
.user-avatar.avatar-lg .avatar-fallback { font-size: 28px; }

.user-avatar.avatar-xl { width: 72px; height: 72px; border-width: 3px; }
.user-avatar.avatar-xl .avatar-emoji,
.user-avatar.avatar-xl .avatar-fallback { font-size: 36px; }

/* === HISTORY STYLES (moved from inline) === */
.history-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    font-weight: 700;
    font-size: 16px;
}

.back-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 0;
    transition: opacity 0.2s;
}

.back-btn:active {
    opacity: 0.7;
}

.history-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}

.history-tabs::-webkit-scrollbar {
    display: none;
}

.ht-btn {
    flex-shrink: 0;
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

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

.ht-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
}

.history-date {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    padding: 12px 4px 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 6px;
    transition: background 0.2s;
}

.hi-icon {
    font-size: 22px;
    width: 36px;
    text-align: center;
}

.hi-info {
    flex: 1;
    min-width: 0;
}

.hi-title {
    font-size: 13px;
    font-weight: 600;
}

.hi-desc {
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hi-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

.hi-amount {
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.hi-amount.pos { color: var(--positive); }
.hi-amount.neg { color: var(--negative); }

/* === SLOTS REELS === */
.slots-reels {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.slots-reels span {
    font-size: 36px;
    background: var(--bg-elevated);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    min-width: 56px;
    text-align: center;
}

.slots-reels.spinning span {
    animation: spin 0.1s linear infinite;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PIXEL ART ASSETS STYLES
   ═══════════════════════════════════════════════════════════════════════════ */

/* SVG icons rendering */
.item-icon-svg {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    -webkit-image-rendering: pixelated;
}

.skill-icon-svg {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    width: 32px;
    height: 32px;
}

.portrait-svg {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border: 3px solid var(--border);
}

/* Pixel art общие стили */
.pixel-art {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    -webkit-image-rendering: pixelated;
}

/* Pixel font для заголовков (опционально) */
@font-face {
    font-family: 'PixelFont';
    src: local('Courier New');
}

.pixel-text {
    font-family: 'PixelFont', 'Courier New', monospace;
    letter-spacing: 1px;
}

/* Player Card Loading (for lazy-load support) */
.pc-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
}
.pc-loading-icon { font-size: 48px; animation: pulse 1.5s ease-in-out infinite; }
.pc-loading-spinner {
    width: 32px; height: 32px;
    border: 3px solid #222;
    border-top-color: #22c55e;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.pc-loading-text { color: #666; font-size: 13px; }
@keyframes pulse { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; } }
