:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --accent: #e94560;
    --accent-light: #ff6b6b;
    --gold: #ffd700;
    --success: #00d26a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --border-radius: 16px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

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

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

.app-container {
    max-width: 100%;
    padding-bottom: 40px; /* Increased bottom padding */
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
    padding: 40px 20px 20px 20px; /* Increased top padding for Telegram header */
    border-radius: 0 0 24px 24px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    border: 3px solid var(--gold);
}

.user-details h2 {
    font-size: 1.3rem;
    margin-bottom: 4px;
}

.rep-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 215, 0, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    color: var(--gold);
}

/* Navigation Tabs */
.tabs {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 16px;
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--bg-primary);
}

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

.tab {
    flex: 1;
    text-align: center;
    padding: 12px 10px;
    border: none;
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.3);
}

/* Content */
.content {
    padding: 0 16px;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
    padding: 16px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-icon {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--gold);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Sections */
.section {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 16px;
}

.section h3 {
    margin-bottom: 12px;
    font-size: 1.1rem;
}

/* NFT Grid */
.nft-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.nft-item {
    background: linear-gradient(135deg, var(--accent), var(--gold));
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.nft-empty, .inventory-empty {
    color: var(--text-secondary);
    font-style: italic;
}

/* Inventory Grid */
.inventory-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.inventory-item {
    background: var(--bg-card);
    padding: 8px 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
}

.item-count {
    background: var(--accent);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: bold;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    width: 100%;
}

.btn-large {
    padding: 16px;
    font-size: 1.1rem;
}

.btn-casino {
    background: linear-gradient(135deg, var(--gold), #ff9500);
    color: #1a1a2e;
    width: 100%;
    margin-top: 16px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 8px;
}

/* Shop */
.shop-categories {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.category-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--bg-card);
    border-radius: 12px;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.category-btn.active {
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.2);
    color: var(--accent);
}

.shop-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.shop-item {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shop-item-info h4 {
    margin-bottom: 4px;
}

.shop-item-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.shop-item-price {
    background: var(--gold);
    color: #1a1a2e;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
}

.shop-item-price.sold {
    background: var(--text-secondary);
    cursor: not-allowed;
}

/* Leaderboard */
.leaderboard-filter {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.filter-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 10px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
}

.filter-btn.active {
    background: var(--accent);
    color: white;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.leaderboard-item {
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.leaderboard-item.top-1 {
    background: linear-gradient(135deg, #ffd700, #ff9500);
    color: #1a1a2e;
}

.leaderboard-item.top-2 {
    background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
    color: #1a1a2e;
}

.leaderboard-item.top-3 {
    background: linear-gradient(135deg, #cd7f32, #b87333);
    color: #1a1a2e;
}

.lb-rank {
    font-size: 1.2rem;
    font-weight: bold;
    width: 30px;
}

.lb-name {
    flex: 1;
    font-weight: 600;
}

.lb-rep {
    font-weight: bold;
}

/* Casino */
.casino-header {
    text-align: center;
    margin-bottom: 20px;
}

.exclusive-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--gold), #ff9500);
    color: #1a1a2e;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-top: 8px;
}

.game-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 16px;
    text-align: center;
}

.game-card h3 {
    margin-bottom: 8px;
}

.game-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

/* Wheel */
.wheel-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 20px auto;
}

.wheel {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(
        var(--accent) 0deg 45deg,
        var(--bg-card) 45deg 90deg,
        var(--gold) 90deg 135deg,
        var(--bg-card) 135deg 180deg,
        var(--success) 180deg 225deg,
        var(--bg-card) 225deg 270deg,
        var(--accent-light) 270deg 315deg,
        var(--bg-card) 315deg 360deg
    );
    border: 4px solid var(--gold);
    transition: transform 4s cubic-bezier(0.17, 0.67, 0.12, 0.99);
}

.wheel.spinning {
    transform: rotate(var(--rotation));
}

.wheel-segment {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 25px;
    font-size: 11px;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    transform: rotate(calc(var(--i) * 45deg + 22.5deg));
    pointer-events: none;
}

.wheel-pointer {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
    color: var(--gold);
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Coin Game */
.coin-game {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.coin-game input {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--bg-card);
    border-radius: 12px;
    background: var(--bg-primary);
    color: white;
    font-size: 1.2rem;
    text-align: center;
    font-weight: bold;
}

.coin-game input:focus {
    border-color: var(--gold);
    outline: none;
}

.coin-buttons {
    display: flex;
    gap: 12px;
}

.btn-heads, .btn-tails {
    flex: 1;
    padding: 16px;
}

.btn-heads {
    background: linear-gradient(135deg, var(--gold), #ff9500);
    color: #1a1a2e;
}

.btn-tails {
    background: linear-gradient(135deg, #c0c0c0, #808080);
    color: #1a1a2e;
}

/* Scratch Card */
.scratch-container {
    position: relative;
    width: 280px;
    max-width: 100%;
    height: 150px;
    margin: 16px auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

#scratch-canvas {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    cursor: crosshair;
}

.scratch-prize {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-card), var(--bg-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: var(--gold);
    z-index: 1;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-secondary);
    padding: 12px 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    animation: slideUp 0.3s ease;
    border-left: 4px solid var(--accent);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: #ff4444;
}

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