:root {
    /* Light Mode Tokens (Playful, Inspiring) */
    --bg-primary: #f0f4f8; /* Soft light blue/grey */
    --bg-secondary: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-primary: #6366f1; /* Indigo */
    --accent-secondary: #f43f5e; /* Rose */
    --accent-success: #10b981; /* Emerald */
    --accent-warning: #f59e0b; /* Amber */
    --border-color: #e2e8f0;
    
    /* Layout */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
}

.dark-mode {
    /* Dark Mode Tokens */
    --bg-primary: #0f172a; /* Deep slate */
    --bg-secondary: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

/* App Container */
.app-container {
    max-width: 480px; /* Mobile first */
    margin: 0 auto;
    min-height: 100vh;
    background-color: var(--bg-secondary);
    position: relative;
    box-shadow: 0 0 40px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
}

.dark-mode .app-container {
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 2px solid var(--border-color);
    background-color: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent-primary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.points-badge {
    background-color: var(--accent-success);
    color: white;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.9rem;
    font-family: 'Outfit', sans-serif;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-full);
    background-color: var(--bg-primary);
}

/* Content Area */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg) var(--spacing-lg) 80px var(--spacing-lg);
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    max-width: 480px;
    background-color: var(--bg-secondary);
    display: flex;
    justify-content: space-around;
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
    border-top: 2px solid var(--border-color);
    z-index: 10;
}

.nav-btn {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    flex: 1;
}

.nav-btn.active {
    color: var(--accent-primary);
}

.nav-btn .icon {
    font-size: 1.4rem;
    transition: transform 0.2s ease;
}

.nav-btn.active .icon {
    transform: translateY(-2px);
}

.nav-btn .label {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Utility Classes */
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.full-width { width: 100%; }

/* Buttons */
.btn {
    padding: 14px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    font-family: 'Outfit', sans-serif;
    transition: transform 0.1s ease, opacity 0.2s ease;
}

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

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

.btn.secondary {
    background-color: var(--bg-primary);
    color: var(--accent-primary);
    border: 2px solid var(--accent-primary);
}

.btn.outline {
    background-color: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-primary);
}

/* Home View */
.hero-card {
    background: linear-gradient(135deg, var(--accent-primary), #818cf8);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    color: white;
    margin-bottom: var(--spacing-lg);
}

.hero-card h2 {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.hero-stats {
    margin-top: 20px;
    background: rgba(255,255,255,0.2);
    border-radius: var(--radius-md);
    padding: 12px;
    display: inline-block;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    display: block;
}

.stat-label {
    font-size: 0.8rem;
    opacity: 0.9;
}

.section-title {
    margin-bottom: 16px;
    font-size: 1.2rem;
}

.grid-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.action-card {
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.action-card:hover {
    border-color: var(--accent-primary);
}

.action-card .action-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.action-card h4 {
    color: var(--text-primary);
    margin-bottom: 4px;
}

.action-card p {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Earn View */
.offerwall-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.offer-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background-color: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
}

.offer-card h3 {
    margin-bottom: 4px;
}

.offer-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Redeem View */
.rewards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.reward-card {
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.reward-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

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

.reward-card p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.reward-card .btn {
    width: 100%;
}

/* Profile View */
.profile-card {
    text-align: center;
    padding: 30px 20px;
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}

.profile-card .avatar {
    font-size: 4rem;
    margin-bottom: 12px;
}

.profile-card h3 {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.profile-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-family: monospace;
}

.menu-list {
    background-color: var(--bg-primary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.menu-item {
    display: flex;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    font-weight: 500;
}

.menu-item:last-child {
    border-bottom: none;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background-color: var(--bg-secondary);
    padding: 30px;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 400px;
    position: relative;
    border: 2px solid var(--border-color);
}

.close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.modal-content h2 {
    margin-bottom: 20px;
    text-align: center;
}

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9rem;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: var(--accent-primary);
}

/* Page Titles */
.page-title {
    margin-bottom: 8px;
    font-size: 1.6rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.loading {
    color: var(--text-secondary);
    text-align: center;
    padding: 40px 0;
}

/* Games View */
.games-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.game-card {
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
}

.game-card .game-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

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

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

.game-card .btn {
    width: 100%;
    margin-top: 12px;
}

/* Leaderboard View */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}

.leaderboard-item .rank {
    font-size: 1.4rem;
    font-weight: 800;
    width: 40px;
    text-align: center;
    font-family: 'Outfit', sans-serif;
}

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

.leaderboard-item .level {
    color: var(--accent-warning);
    font-size: 0.8rem;
    font-weight: 600;
    background-color: rgba(245, 158, 11, 0.15);
    padding: 4px 8px;
    border-radius: var(--radius-full);
}

.leaderboard-item .pts {
    font-weight: 700;
    color: var(--accent-success);
    font-family: 'Outfit', sans-serif;
}

/* Referrals View */
.referral-card {
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
}

.referral-card p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.referral-code {
    font-size: 2rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    letter-spacing: 4px;
    color: var(--accent-primary);
    background-color: var(--bg-secondary);
    border: 2px dashed var(--accent-primary);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
}

.referral-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Level Badge */
.level-badge {
    display: inline-block;
    margin-top: 8px;
    background-color: rgba(245, 158, 11, 0.15);
    color: var(--accent-warning);
    font-weight: 700;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
}

/* Disabled Button */
.btn-disabled {
    background-color: var(--border-color) !important;
    color: var(--text-secondary) !important;
    cursor: not-allowed;
}

/* Toast */
#toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background-color: var(--text-primary);
    color: var(--bg-primary);
    padding: 14px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 200;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Hero stats: two columns */
.hero-stats {
    display: flex;
    gap: 24px;
}

/* Earn subtitle spacing */
.view-container > .subtitle {
    margin-bottom: 24px;
}

/* Lucky Draws */
.draws-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.draw-card {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border-radius: var(--radius-lg);
    padding: 20px;
}

.draw-card h3 {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.draw-card > p {
    opacity: 0.9;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.draw-prizes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.draw-prize-chip {
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.draw-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    opacity: 0.95;
    margin-bottom: 14px;
}

.draw-card .btn {
    background-color: white;
    color: var(--accent-primary);
}

/* Pool Draws */
.draw-card.pool {
    background: linear-gradient(135deg, #f59e0b, #f43f5e);
}

.pool-badge {
    display: inline-block;
    background: rgba(255,255,255,0.25);
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.pool-amount {
    font-size: 2.5rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
    margin: 8px 0;
}

.pool-amount small {
    font-size: 1rem;
}

.pool-progress {
    height: 10px;
    background: rgba(255,255,255,0.25);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 12px;
}

.pool-progress-bar {
    height: 100%;
    background: white;
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

.pool-buy-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.pool-buy-row .btn {
    flex: 1;
    background-color: white;
    color: var(--accent-primary);
    padding: 10px;
    font-size: 0.9rem;
}

.pool-buy-row .btn:active {
    background-color: #f0f0f0;
}

.my-tickets {
    margin-top: 8px;
    font-weight: 600;
    font-size: 0.85rem;
}

/* Wallet */
.wallet-balance-card {
    background: linear-gradient(135deg, var(--accent-success), #34d399);
    color: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    margin-bottom: 24px;
}

.wallet-label {
    font-size: 0.85rem;
    opacity: 0.95;
}

.wallet-points {
    display: block;
    font-size: 2.5rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    margin: 8px 0;
}

.wallet-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.wallet-item {
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
}

.wallet-item-icon {
    font-size: 1.8rem;
    display: block;
    margin-bottom: 6px;
}

.wallet-item-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.wallet-item-value {
    font-weight: 800;
    font-size: 1.1rem;
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
}

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

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}

.history-title {
    font-weight: 600;
    font-size: 0.9rem;
    display: block;
}

.history-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.history-amount {
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    white-space: nowrap;
}

.history-amount.credit {
    color: var(--accent-success);
}

.history-amount.debit {
    color: var(--accent-secondary);
}
