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

html, body {
    width: 100%;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #000;
}

:root {
    --primary: #007AFF;
    --secondary: #5AC8FA;
    --success: #34C759;
    --warning: #FF9500;
    --danger: #FF3B30;
    --bg: #000;
    --bg-secondary: #1C1C1E;
    --text: #fff;
    --text-secondary: #A1A1A6;
    --border: #3C3C43;
}

/* App Container - Mobile Frame */
.app-container {
    width: 100%;
    height: 100vh;
    max-width: 100%;
    margin: 0 auto;
    background: var(--bg);
    color:white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Status Bar */
.status-bar {
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.status-left, .status-right {
    display: flex;
    gap: 4px;
    align-items: center;
}

.time {
    font-weight: 600;
}

/* Main App Content */
.app-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding-bottom: 120px;
}

.app-content::-webkit-scrollbar {
    width: 0;
}

.app-content::-webkit-scrollbar-track {
    background: transparent;
}

.app-content::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 2px;
}

/* Screen Navigation */
.screen {
    display: block;
    padding: 16px;
    animation: slideIn 0.3s ease;
}

.screen.active {
    display: block;
}

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

/* Home Screen */
#home-screen {
    padding-bottom: 80px;
}

.header-title {
    text-align: center;
    margin-bottom: 24px;
    padding-top: 12px;
}

.header-title h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.header-title .subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.stats-card {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    padding: 12px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

/* Sections */
.section {
    margin-bottom: 20px;
}

.section h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
}

.section h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

/* Grid Buttons */
.grid-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.grid-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.grid-btn:active {
    background: var(--border);
    transform: scale(0.95);
}

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

.btn-label {
    text-align: center;
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.activity-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.activity-text {
    flex: 1;
}

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

.activity-time {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.activity-amount {
    font-size: 13px;
    font-weight: 600;
    color: var(--success);
}

/* Screen Header */
.screen-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.back-btn {
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 16px;
    cursor: pointer;
    padding: 8px;
    font-weight: 500;
}

.screen-header h2 {
    flex: 1;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

/* Mining Screen */
.mining-container {
    padding-bottom: 80px;
}

.mining-visual {
    font-size: 48px;
    animation: pulse 2s infinite;
}

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

.mining-hash {
    font-size: 20px;
    font-weight: 700;
}

.mining-status-text {
    font-size: 14px;
    opacity: 0.9;
}

.mining-progress {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

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

.progress-fill {
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    height: 100%;
    transition: width 0.3s;
}

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

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

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat .label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat .value {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.btn {
    padding: 14px 20px;
    border-radius: 12px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:active {
    background: #0061D5;
    transform: scale(0.98);
}

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

.btn-secondary:active {
    background: var(--border);
}

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

.btn-danger:active {
    background: #E21B0B;
}

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

/* Shop Screen */
.shop-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    padding-bottom: 80px;
}

.shop-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.item-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.item-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

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

.item-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 12px;
}

/* Wallet Screen */
.wallet-container {
    padding-bottom: 80px;
}

.balance-card {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 16px;
    padding: 24px;
    color: white;
    text-align: center;
    margin-bottom: 24px;
}

.balance-label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.balance-amount {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 16px;
}

.balance-action {
    display: flex;
    gap: 12px;
    justify-content: center;
}

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

.transaction {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
}

.positive {
    color: var(--success);
    font-weight: 600;
}

.negative {
    color: var(--danger);
    font-weight: 600;
}

/* Profile Screen */
.profile-container {
    padding-bottom: 80px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.avatar {
    font-size: 48px;
    flex-shrink: 0;
}

.profile-info {
    flex: 1;
}

.username {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.user-level {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.profile-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.stat-row span:first-child {
    color: var(--text-secondary);
}

.stat-row span:last-child {
    color: var(--text);
    font-weight: 600;
}

/* Bottom Navigation */
.bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 8px 0;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 1;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    transition: color 0.2s;
}

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

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

.nav-label {
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 480px) {
    .app-container {
        max-width: 100%;
        border-radius: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Ranking Screen */
.ranking-container {
    padding-bottom: 80px;
}

.ranking-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-btn:active {
    background: var(--border);
}

/* Your Rank Card */
.your-rank-card {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    color: white;
    margin-bottom: 24px;
}

.your-rank-badge {
    font-size: 12px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.your-rank-position {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

.your-rank-info {
    font-size: 14px;
    opacity: 0.9;
}

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

.rank-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    transition: all 0.2s;
}

.rank-item:active {
    background: var(--border);
}

.rank-item.top-1,
.rank-item.top-2,
.rank-item.top-3 {
    border-color: var(--primary);
    background: rgba(0, 122, 255, 0.1);
}

.rank-medal {
    font-size: 24px;
    flex-shrink: 0;
}

.rank-number {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border);
    border-radius: 50%;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.rank-info {
    flex: 1;
}

.rank-player {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.rank-level {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.rank-points {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

/* App Page Container */
.app-page {
    animation: slideIn 0.3s ease;
}

/* Loading State */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.loading::after {
    content: '';
    display: inline-block;
    margin-left: 8px;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Error Message */
.error-message {
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid var(--danger);
    border-radius: 12px;
    padding: 16px;
    margin: 20px;
    color: var(--danger);
    font-size: 14px;
    text-align: center;
}

/* ============================================= */
/* Material Design Dark Theme - Confirm Dialog  */
/* ============================================= */

:root {
    --md-primary: #0f4c75;
    --md-accent: #3b82f6;
    --md-success: #22c55e;
    --md-warning: #f59e0b;
    --md-danger: #ef4444;
    --md-bg-surface: #121212;
    --md-bg-elevated: #1e1e1e;
    --md-text-primary: #ffffff;
    --md-text-secondary: #b0bec5;
    --md-border: #2c2c2c;
    --md-shadow: rgba(0, 0, 0, 0.5);
}

/* Modal Overlay */
.md-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(2px);
}

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

/* Modal Dialog Container */
.md-dialog {
    background: var(--md-bg-elevated);
    border-radius: 12px;
    box-shadow: 0 20px 60px var(--md-shadow);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--md-border);
}

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

/* Dialog Header */
.md-dialog-header {
    padding: 24px;
    border-bottom: 1px solid var(--md-border);
    background: var(--md-bg-surface);
    border-radius: 12px 12px 0 0;
}

.md-dialog-title {
    font-size: 20px;
    font-weight: 600;
    color: #f8fafc;
    margin: 0;
    letter-spacing: -0.5px;
}

.md-dialog-subtitle {
    font-size: 13px;
    color: var(--md-text-secondary);
    margin-top: 4px;
}

/* Dialog Content */
.md-dialog-content {
    padding: 24px;
    color: #e0e7ff;
    line-height: 1.6;
}

.md-dialog-message {
    font-size: 15px;
    color: #e0e7ff;
    margin-bottom: 16px;
}

.md-info-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.md-info-card {
    background: var(--md-bg-surface);
    border: 1px solid var(--md-border);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    transition: all 0.2s ease;
}

.md-info-card:hover {
    border-color: var(--md-accent);
    background: rgba(59, 130, 246, 0.05);
}

.md-info-label {
    font-size: 12px;
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.md-info-value {
    font-size: 18px;
    font-weight: 700;
    color: #60a5fa;
}

/* Status Indicator */
.md-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--md-bg-surface);
    margin: 12px 0;
    color: #e0e7ff;
}

.md-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.md-status-dot.success {
    background: var(--md-success);
}

.md-status-dot.warning {
    background: var(--md-warning);
}

.md-status-dot.danger {
    background: var(--md-danger);
}

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

/* Dialog Actions/Buttons */
.md-dialog-actions {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--md-border);
    background: var(--md-bg-surface);
    border-radius: 0 0 12px 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.md-btn {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    min-width: 100px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Primary Button - Green */
.md-btn-primary {
    background: var(--md-success);
    color: #ffffff;
    font-weight: 700;
}

.md-btn-primary:hover {
    background: #16a34a;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
    transform: translateY(-1px);
}

.md-btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(34, 197, 94, 0.2);
}

/* Secondary Button - Gray */
.md-btn-secondary {
    background: var(--md-bg-elevated);
    color: #f1f5f9;
    border: 1px solid var(--md-border);
}

.md-btn-secondary:hover {
    background: var(--md-border);
    border-color: var(--md-text-secondary);
}

.md-btn-secondary:active {
    background: rgba(255, 255, 255, 0.05);
}

/* Danger Button - Red */
.md-btn-danger {
    background: var(--md-danger);
    color: white;
}

.md-btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

.md-btn-danger:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

/* Accent Button - Blue */
.md-btn-accent {
    background: var(--md-accent);
    color: white;
}

.md-btn-accent:hover {
    background: #2563eb;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

.md-btn-accent:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

/* Disabled State */
.md-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.md-btn:disabled:hover {
    box-shadow: none;
    transform: none;
}

/* Button with Icon Support */
.md-btn-icon {
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 600px) {
    .md-dialog {
        width: 95%;
        border-radius: 16px;
    }

    .md-dialog-header {
        padding: 20px;
    }

    .md-dialog-content {
        padding: 20px;
    }

    .md-dialog-actions {
        padding: 16px 20px;
        gap: 8px;
    }

    .md-info-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .md-btn {
        flex: 1;
        min-width: auto;
        padding: 12px 16px;
    }

    .md-dialog-actions {
        flex-direction: column-reverse;
    }

    .md-btn {
        width: 100%;
    }
}

/* Loading State */
.md-btn.loading {
    position: relative;
    pointer-events: none;
    color: transparent;
}

.md-btn.loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Popup Modal Styles */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.popup-overlay.active {
    background: rgba(0, 0, 0, 0.7);
    opacity: 1;
}

.popup-container {
    background: #1C1C1E;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease forwards;
}

.popup-container.closing {
    animation: slideDown 0.2s ease forwards;
}

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

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

.popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    gap: 12px;
}

.popup-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #f8fafc;
    flex: 1;
}

.popup-close {
    background: none;
    border: none;
    color: #a1a1a6;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.popup-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
}

.popup-close:active {
    background: rgba(255, 255, 255, 0.15);
}

.popup-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    color: #e0e7ff;
    font-size: 16px;
    line-height: 1.5;
}

/* Hide scrollbar in popup content */
.popup-content::-webkit-scrollbar {
    width: 0;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .popup-container {
        width: 100%;
        max-height: 90vh;
        border-radius: 16px 16px 0 0;
    }

    .popup-overlay {
        align-items: flex-end;
    }

    .popup-content {
        padding: 12px;
        font-size: 15px;
    }
}

