/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    max-width: 100vw;
    background-color: #111827;
    color: #f1f5f9;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* 移动端优化 */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
    -webkit-overflow-scrolling: touch;
}

/* 安全区域适配 - 刘海屏/打孔屏 */
body {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

/* Container */
.container {
    width: 100%;
    padding-right: 1rem;
    padding-left: 1rem;
    margin-right: auto;
    margin-left: auto;
}
@media (min-width: 640px) {
    .container {
        max-width: 640px;
    }
}
@media (min-width: 768px) {
    .container {
        max-width: 768px;
    }
}
@media (min-width: 1024px) {
    .container {
        max-width: 1024px;
    }
}

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-5 { gap: 1.25rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }
.space-x-1 > * + * { margin-left: 0.25rem; }
.space-x-2 > * + * { margin-left: 0.5rem; }
.space-x-3 > * + * { margin-left: 0.75rem; }
.space-x-4 > * + * { margin-left: 1rem; }
.space-y-1 > * + * { margin-top: 0.25rem; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }

/* Grid utilities */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

/* Spacing utilities */
.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.px-0 { padding-left: 0; padding-right: 0; }
.px-1 { padding-left: 0.25rem; padding-right: 0.25rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-5 { padding-left: 1.25rem; padding-right: 1.25rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-0 { padding-top: 0; padding-bottom: 0; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-5 { padding-top: 1.25rem; padding-bottom: 1.25rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.m-0 { margin: 0; }
.m-1 { margin: 0.25rem; }
.m-2 { margin: 0.5rem; }
.m-3 { margin: 0.75rem; }
.m-4 { margin: 1rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.my-1 { margin-top: 0.25rem; margin-bottom: 0.25rem; }
.my-2 { margin-top: 0.5rem; margin-bottom: 0.5rem; }
.my-3 { margin-top: 0.75rem; margin-bottom: 0.75rem; }
.my-4 { margin-top: 1rem; margin-bottom: 1rem; }
.my-6 { margin-top: 1.5rem; margin-bottom: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }
.mt-6 { margin-top: 1.5rem; }
.mr-1 { margin-right: 0.25rem; }
.mr-2 { margin-right: 0.5rem; }
.mr-3 { margin-right: 0.75rem; }
.mr-4 { margin-right: 1rem; }
.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }
.ml-3 { margin-left: 0.75rem; }
.ml-4 { margin-left: 1rem; }

/* Typography */
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.text-4xl { font-size: 2.25rem; line-height: 2.5rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.font-normal { font-weight: 400; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-gray-400 { color: #9ca3af; }
.text-gray-500 { color: #6b7280; }
.text-gray-600 { color: #4b5563; }
.text-gray-700 { color: #374151; }
.text-white { color: #ffffff; }
.text-red-500 { color: #ef4444; }
.text-red-600 { color: #dc2626; }
.text-green-500 { color: #22c55e; }
.text-green-600 { color: #16a34a; }
.text-blue-500 { color: #3b82f6; }
.text-purple-500 { color: #a855f7; }
.text-orange-500 { color: #f97316; }
.text-gray-200 { color: #e5e7eb; }
.text-gray-300 { color: #d1d5db; }
.text-primary { color: #ef4444; }
.line-through { text-decoration: line-through; }
.leading-tight { line-height: 1.25; }
.leading-normal { line-height: 1.5; }

/* Backgrounds */
.bg-gray-50 { background-color: #f9fafb; }
.bg-gray-100 { background-color: #f3f4f6; }
.bg-gray-200 { background-color: #e5e7eb; }
.bg-gray-300 { background-color: #d1d5db; }
.bg-gray-400 { background-color: #9ca3af; }
.bg-gray-500 { background-color: #6b7280; }
.bg-gray-600 { background-color: #4b5563; }
.bg-gray-700 { background-color: #374151; }
.bg-gray-800 { background-color: #1f2937; }
.bg-gray-850 { background-color: #111827; }
.bg-gray-900 { background-color: #111827; }
.bg-red-500 { background-color: #ef4444; }
.bg-red-600 { background-color: #dc2626; }
.bg-green-500 { background-color: #22c55e; }
.bg-blue-500 { background-color: #3b82f6; }
.bg-purple-500 { background-color: #a855f7; }
.bg-orange-500 { background-color: #f97316; }
.bg-white { background-color: #ffffff; }
.bg-gradient-to-br { background-image: linear-gradient(to bottom right, var(--tw-gradient-stops)); }
.bg-gradient-to-r { background-image: linear-gradient(to right, var(--tw-gradient-stops)); }
.bg-gradient-to-l { background-image: linear-gradient(to left, var(--tw-gradient-stops)); }
.bg-gradient-to-t { background-image: linear-gradient(to top, var(--tw-gradient-stops)); }
.from-red-500 { --tw-gradient-from: #ef4444; --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }
.to-red-600 { --tw-gradient-to: #dc2626; }
.from-gray-400 { --tw-gradient-from: #9ca3af; }
.to-gray-600 { --tw-gradient-to: #4b5563; }

/* Borders */
.rounded-none { border-radius: 0; }
.rounded { border-radius: 0.25rem; }
.rounded-sm { border-radius: 0.125rem; }
.rounded-md { border-radius: 0.375rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-2xl { border-radius: 1rem; }
.rounded-full { border-radius: 9999px; }
.border { border-width: 1px; }
.border-0 { border-width: 0; }
.border-gray-200 { border-color: #e5e7eb; }
.border-gray-300 { border-color: #d1d5db; }
.border-gray-400 { border-color: #9ca3af; }
.border-gray-500 { border-color: #6b7280; }
.border-gray-600 { border-color: #4b5563; }
.border-gray-700 { border-color: #374151; }
.border-red-500 { border-color: #ef4444; }

/* Shadows */
.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.shadow { box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1); }
.shadow-md { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1); }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1); }
.shadow-xl { box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1); }

/* Width/Height */
.w-0 { width: 0; }
.w-full { width: 100%; }
.w-auto { width: auto; }
.w-4 { width: 1rem; }
.w-5 { width: 1.25rem; }
.w-6 { width: 1.5rem; }
.w-7 { width: 1.75rem; }
.w-8 { width: 2rem; }
.w-10 { width: 2.5rem; }
.w-12 { width: 3rem; }
.w-14 { width: 3.5rem; }
.w-16 { width: 4rem; }
.w-20 { width: 5rem; }
.w-24 { width: 6rem; }
.w-32 { width: 8rem; }
.w-40 { width: 10rem; }
.w-48 { width: 12rem; }
.w-64 { width: 16rem; }
.w-96 { width: 24rem; }
.max-w-xs { max-width: 20rem; }
.max-w-sm { max-width: 24rem; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }
.max-w-2xl { max-width: 42rem; }
.max-w-full { max-width: 100%; }
.h-0 { height: 0; }
.h-4 { height: 1rem; }
.h-5 { height: 1.25rem; }
.h-6 { height: 1.5rem; }
.h-7 { height: 1.75rem; }
.h-8 { height: 2rem; }
.h-10 { height: 2.5rem; }
.h-12 { height: 3rem; }
.h-14 { height: 3.5rem; }
.h-16 { height: 4rem; }
.h-20 { height: 5rem; }
.h-24 { height: 6rem; }
.h-32 { height: 8rem; }
.h-full { height: 100%; }
.h-screen { height: 100vh; }
.min-h-screen { min-height: 100vh; }

/* Display */
.block { display: block; }
.inline-block { display: inline-block; }
.inline { display: inline; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.table { display: table; }
.table-row { display: table-row; }
.table-cell { display: table-cell; }
.none { display: none; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* Positioning */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }
.top-0 { top: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }
.right-0 { right: 0; }
.inset-0 { inset: 0; }
.inset-x-0 { left: 0; right: 0; }
.inset-y-0 { top: 0; bottom: 0; }
.-translate-x-1\/2 { transform: translateX(-50%); }
.-translate-y-1\/2 { transform: translateY(-50%); }
.translate-x-full { transform: translateX(100%); }
.translate-y-full { transform: translateY(100%); }

/* Z-index */
.z-0 { z-index: 0; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }

/* Glassmorphism */
.glass-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Transition */
.transition-all { transition-property: all; }
.transition-transform { transition-property: transform; }
.transition-colors { transition-property: color, background-color, border-color; }
.transition-opacity { transition-property: opacity; }
.duration-150 { transition-duration: 150ms; }
.duration-200 { transition-duration: 200ms; }
.duration-300 { transition-duration: 300ms; }
.duration-500 { transition-duration: 500ms; }
.ease-in { transition-timing-function: cubic-bezier(0.4, 0, 1, 1); }
.ease-out { transition-timing-function: cubic-bezier(0, 0, 0.2, 1); }
.ease-in-out { transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); }

/* Opacity */
.opacity-0 { opacity: 0; }
.opacity-25 { opacity: 0.25; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* Cursor */
.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }
.cursor-not-allowed { cursor: not-allowed; }

/* Hover */
.hover\:opacity-90:hover { opacity: 0.9; }
.hover\:opacity-80:hover { opacity: 0.8; }
.hover\:scale-105:hover { transform: scale(1.05); }
.hover\:scale-110:hover { transform: scale(1.1); }
.hover\:bg-gray-700:hover { background-color: #374151; }
.hover\:text-primary:hover { color: #ef4444; }
.hover\:text-white:hover { color: #ffffff; }

/* Misc */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.break-words { overflow-wrap: break-word; }
.whitespace-nowrap { white-space: nowrap; }
.object-cover { object-fit: cover; }
.object-contain { object-fit: contain; }

/* Gradient */
.gradient-bg {
    background: linear-gradient(135deg, #C0C0C0 0%, #808080 30%, #A9A9A9 60%, #D3D3D3 100%);
}

/* Button styles */
.btn-primary {
    background-color: #EF4444;
    color: white;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}
.btn-primary:hover {
    background-color: #DC2626;
}

button.recharge-withdraw-btn,
button.recharge-withdraw-btn.btn-primary,
button.recharge-withdraw-btn.btn-outline,
#rechargeBtn,
#withdrawBtn {
    background-color: #EF4444 !important;
    color: #ffffff !important;
    border: 1px solid #EF4444 !important;
}
button.recharge-withdraw-btn:hover,
button.recharge-withdraw-btn.btn-primary:hover,
button.recharge-withdraw-btn.btn-outline:hover,
#rechargeBtn:hover,
#withdrawBtn:hover {
    background-color: #DC2626 !important;
    color: #ffffff !important;
}

/* Responsive utilities */
@media (min-width: 640px) {
    .sm\:w-10 { width: 2.5rem; }
    .sm\:h-10 { height: 2.5rem; }
    .sm\:mr-3 { margin-right: 0.75rem; }
    .sm\:text-base { font-size: 1rem; }
    .sm\:px-4 { padding-left: 1rem; padding-right: 1rem; }
    .sm\:text-xl { font-size: 1.25rem; }
    .sm\:space-x-4 > * + * { margin-left: 1rem; }
    .sm\:text-lg { font-size: 1.125rem; }
    .sm\:text-xl { font-size: 1.25rem; }
    .sm\:text-2xl { font-size: 1.5rem; }
    .sm\:text-3xl { font-size: 1.875rem; }
}

@media (min-width: 768px) {
    .md\:w-64 { width: 16rem; }
    .md\:h-64 { height: 16rem; }
    .md\:text-2xl { font-size: 1.5rem; }
    .md\:text-3xl { font-size: 1.875rem; }
}

@media (min-width: 1024px) {
    .lg\:w-80 { width: 20rem; }
    .lg\:h-80 { height: 20rem; }
}

/* Theme header */
.theme-header {
    background-color: #1f2937;
}

/* Font family */
.font-sans {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Min height */
.min-h-screen {
    min-height: 100vh;
}

/* ========================================
   移动端适配增强 (Mobile-First)
   ======================================== */

/* 修复底部导航字体过小问题 - 原为3.5px~7px */
.bottom-nav .fa,
nav.fixed.bottom-0 .fa {
    font-size: 20px !important;
}
.bottom-nav span,
nav.fixed.bottom-0 span {
    font-size: 11px !important;
}

/* 触控目标最小尺寸 44x44px */
button, .btn, .clickable {
    min-width: 44px;
    min-height: 44px;
}

/* 图片自适应 */
img {
    max-width: 100%;
    height: auto;
}

/* 小屏手机适配 (320-374px) */
@media screen and (max-width: 374px) {
    .container, .container-mobile {
        padding-left: 12px;
        padding-right: 12px;
    }
    .grid {
        gap: 0.5rem;
    }
    .card, .glass-card, .stat-card {
        padding: 0.75rem !important;
    }
}

/* 横屏小高度适配 */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .bottom-nav,
    nav.fixed.bottom-0 {
        display: none;
    }
    main.pb-24, main.pb-safe {
        padding-bottom: 1rem !important;
    }
}

/* 固定头部的安全区域适配 */
header.sticky {
    padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
}

/* 底部导航安全区域 */
.bottom-nav,
nav.fixed.bottom-0 {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 4px);
}

/* 有底部导航的页面增加额外底部间距 */
.pb-safe {
    padding-bottom: calc(8rem + env(safe-area-inset-bottom, 0px)) !important;
}

/* 模态框安全区域 */
.modal-overlay,
.fixed.inset-0.z-50 {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Toast安全区域 */
.toast {
    top: calc(20px + env(safe-area-inset-top, 0px)) !important;
}

/* 动画GPU加速 */
.animate-slide-up,
.animate-fade-in,
.card-hover,
.feature-btn,
.icon-btn-circle {
    will-change: transform, opacity;
    -webkit-transform: translateZ(0);
}

/* 防止iOS输入框自动缩放 */
@media screen and (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* 平板/大屏居中 */
@media screen and (min-width: 768px) {
    .container-mobile {
        max-width: 480px;
        margin-left: auto;
        margin-right: auto;
    }
}