:root {
  --primary: #007AFF;
  --primary-light: #409CFF;
  --primary-dark: #0062CC;
  --secondary: #5856D6;
  --success: #34C759;
  --warning: #FF9500;
  --danger: #FF3B30;
  --info: #5AC8FA;
  --page-bg: #F2F2F7;
  --card-bg: #FFFFFF;
  --card-radius: 18px;
  --text: #1C1C1E;
  --text-secondary: #8E8E93;
  --text-tertiary: #C7C7CC;
  --border: rgba(60,60,67,0.12);
  --border-strong: rgba(60,60,67,0.25);
  --shadow: 0 8px 20px rgba(0,0,0,0.05);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.08);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --nav-height: 56px;
  --tab-height: 50px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --max-width: 800px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page-bg: #1C1C1E;
    --card-bg: #2C2C2E;
    --text: #F2F3F7;
    --text-secondary: #AEAEB2;
    --border: rgba(84,84,88,0.36);
    --border-strong: rgba(84,84,88,0.65);
    --shadow: 0 8px 20px rgba(0,0,0,0.2);
    --shadow-lg: 0 16px 40px rgba(0,0,0,0.3);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--page-bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: calc(var(--tab-height) + var(--safe-bottom));
}
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
input, textarea, select, button { font-family: var(--font); font-size: 16px; outline: none; }

.top-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-height);
  background: var(--card-bg);
  display: flex; align-items: center; padding: 0 16px;
  gap: 8px; backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.top-nav .logo { font-size: 20px; font-weight: 700; color: var(--text); }
.top-nav .nav-links { display: flex; gap: 4px; margin-left: auto; }
.top-nav .nav-links a {
  padding: 6px 12px; border-radius: 8px; font-size: 14px; font-weight: 500;
  color: var(--text-secondary); transition: all 0.2s;
}
.top-nav .nav-links a:hover, .top-nav .nav-links a.active { background: var(--primary); color: #fff; }
.top-nav .nav-links a.admin-link { color: var(--warning); }

.main-content { max-width: var(--max-width); margin: 0 auto; padding: 76px 16px 20px; }

.banner {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-lg); padding: 32px 24px; margin-bottom: 20px;
  color: #fff; position: relative; overflow: hidden;
}
.banner h1 { font-size: 26px; font-weight: 700; margin-bottom: 8px; }
.banner p { font-size: 15px; opacity: 0.9; margin-bottom: 16px; }
.banner .btn-white { display: inline-block; padding: 10px 24px; border-radius: 999px; background: #fff; color: var(--primary); font-weight: 600; font-size: 15px; border: none; cursor: pointer; }
.banner .btn-white:active { transform: scale(0.96); }

.announcement {
  background: var(--card-bg); border-radius: var(--radius-md); padding: 12px 16px;
  margin-bottom: 16px; font-size: 14px; display: flex; align-items: center; gap: 8px;
  border-left: 4px solid var(--warning); box-shadow: var(--shadow);
}
.announcement .label { color: var(--warning); font-weight: 600; white-space: nowrap; }
.announcement .text { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; margin-top: 24px;
}
.section-header h2 { font-size: 20px; font-weight: 700; }
.section-header .more { font-size: 14px; color: var(--text-secondary); }

.game-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.game-card {
  background: var(--card-bg); border-radius: var(--radius-md); overflow: hidden;
  box-shadow: var(--shadow); transition: transform 0.2s; cursor: pointer;
}
.game-card:active { transform: scale(0.97); }
.game-card .card-img { width: 100%; aspect-ratio: 2/1; object-fit: cover; background: linear-gradient(135deg, #e0e0e0, #f5f5f5); display: flex; align-items: center; justify-content: center; font-size: 40px; }
.game-card .card-body { padding: 10px 12px 12px; }
.game-card .card-body h3 { font-size: 15px; font-weight: 600; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-card .card-body .meta { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.game-card .badge { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 4px; font-weight: 600; }
.badge-new { background: var(--success); color: #fff; }
.badge-hot { background: var(--danger); color: #fff; }
.badge-free { background: var(--primary); color: #fff; }

.category-bar { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; margin-bottom: 16px; -webkit-overflow-scrolling: touch; }
.category-bar::-webkit-scrollbar { display: none; }
.category-bar a {
  white-space: nowrap; padding: 6px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 500; background: var(--card-bg); color: var(--text-secondary);
  box-shadow: var(--shadow); transition: all 0.2s; border: 1px solid var(--border);
}
.category-bar a:hover, .category-bar a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.game-detail-header {
  background: var(--card-bg); border-radius: var(--radius-lg); padding: 20px;
  margin-bottom: 16px; box-shadow: var(--shadow); text-align: center;
}
.game-detail-header .game-icon { width: 80px; height: 80px; border-radius: 20px; margin: 0 auto 12px; background: linear-gradient(135deg, #e0e0e0, #f5f5f5); display: flex; align-items: center; justify-content: center; font-size: 36px; }
.game-detail-header h1 { font-size: 22px; font-weight: 700; }
.game-detail-header .english-name { font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; }
.game-detail-header .tags { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.game-detail-header .tags span { background: var(--page-bg); padding: 2px 10px; border-radius: 999px; font-size: 12px; color: var(--text-secondary); }
.game-detail-body { background: var(--card-bg); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.game-detail-body h3 { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.game-detail-body .info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.game-detail-body .info-row:last-child { border: none; }
.game-detail-body .info-row .label { color: var(--text-secondary); }
.download-btn { display: block; width: 100%; padding: 14px; border: none; border-radius: var(--radius-md); font-size: 17px; font-weight: 600; cursor: pointer; text-align: center; transition: all 0.2s; margin-bottom: 8px; }
.download-btn:active { transform: scale(0.97); }
.download-btn.primary { background: var(--primary); color: #fff; }
.download-btn.success { background: var(--success); color: #fff; }

.card-list { display: flex; flex-direction: column; gap: 8px; }
.card-list-item { background: var(--card-bg); border-radius: var(--radius-md); padding: 14px 16px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow); cursor: pointer; transition: transform 0.2s; }
.card-list-item:active { transform: scale(0.98); }
.card-list-item .item-content { flex: 1; }
.card-list-item .item-content h4 { font-size: 15px; font-weight: 600; }
.card-list-item .item-content p { font-size: 13px; color: var(--text-secondary); }
.card-list-item .item-arrow { color: var(--text-tertiary); font-size: 14px; }

.auth-container { max-width: 400px; margin: 40px auto; padding: 0 16px; }
.auth-card { background: var(--card-bg); border-radius: var(--radius-lg); padding: 32px 24px; box-shadow: var(--shadow); }
.auth-card h2 { font-size: 24px; font-weight: 700; text-align: center; margin-bottom: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; color: var(--text-secondary); }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--card-bg); color: var(--text); font-size: 16px; transition: border-color 0.2s; }
.form-group input:focus, .form-group textarea:focus { border-color: var(--primary); }
.form-group textarea { min-height: 100px; resize: vertical; }
.form-group .help-text { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 24px; border: none; border-radius: var(--radius-sm); font-size: 16px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: none; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 6px; }
.btn-ghost { background: none; color: var(--text-secondary); padding: 4px 8px; }
.btn-ghost:hover { background: var(--border); }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

.status-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.status-published { background: #D1FAE5; color: #065F46; }
.status-draft { background: #FEE2E2; color: #991B1B; }
@media (prefers-color-scheme: dark) {
  .status-published { background: rgba(52,199,89,0.2); color: #34C759; }
  .status-draft { background: rgba(255,59,48,0.2); color: #FF3B30; }
}

.toast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--card-bg); padding: 10px 20px; border-radius: 999px; font-size: 14px; font-weight: 500; z-index: 9999; opacity: 0; transition: all 0.3s; pointer-events: none; box-shadow: var(--shadow-lg); }
.toast.show { opacity: 1; }

.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar { width: 240px; background: var(--card-bg); border-right: 1px solid var(--border); padding: 20px 0; position: fixed; top: 0; left: 0; bottom: 0; overflow-y: auto; z-index: 50; }
.admin-sidebar .sidebar-header { padding: 0 20px 20px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.admin-sidebar .sidebar-header h2 { font-size: 18px; font-weight: 700; }
.admin-sidebar .sidebar-header p { font-size: 12px; color: var(--text-secondary); }
.admin-sidebar .nav-group { margin-bottom: 8px; }
.admin-sidebar .nav-group .group-title { padding: 8px 20px 4px; font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.admin-sidebar .nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px; font-size: 14px; font-weight: 500; color: var(--text); transition: all 0.15s; border-left: 3px solid transparent; cursor: pointer; }
.admin-sidebar .nav-item:hover { background: var(--border); }
.admin-sidebar .nav-item.active { background: var(--primary); color: #fff; border-left-color: var(--primary-dark); }
.admin-main { margin-left: 240px; flex: 1; min-height: 100vh; }
.admin-header { position: sticky; top: 0; z-index: 40; background: var(--card-bg); border-bottom: 1px solid var(--border); padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; backdrop-filter: blur(20px); }
.admin-header h1 { font-size: 20px; font-weight: 600; }
.admin-content { padding: 24px; }

.admin-table-wrap { background: var(--card-bg); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th { background: var(--page-bg); padding: 12px 16px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border-strong); }
.admin-table td { padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(0,122,255,0.03); }
.admin-table .actions { display: flex; gap: 4px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card-bg); border-radius: var(--radius-md); padding: 20px; box-shadow: var(--shadow); }
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; }

.admin-form-card { background: var(--card-bg); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.admin-form-card h3 { font-size: 17px; font-weight: 600; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

.toggle { position: relative; width: 44px; height: 28px; cursor: pointer; display: inline-block; }
.toggle input { display: none; }
.toggle .slider { position: absolute; inset: 0; background: #e0e0e0; border-radius: 999px; transition: 0.3s; }
.toggle .slider:before { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; background: #fff; border-radius: 50%; transition: 0.3s; box-shadow: 0 1px 4px rgba(0,0,0,0.15); }
.toggle input:checked + .slider { background: var(--primary); }
.toggle input:checked + .slider:before { transform: translateX(16px); }

.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar input { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-bg); color: var(--text); font-size: 14px; }
.search-bar input:focus { border-color: var(--primary); }
.search-select { padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-bg); color: var(--text); font-size: 14px; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 16px; }
.pagination a, .pagination span { padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; }
.pagination a { color: var(--text); background: var(--card-bg); border: 1px solid var(--border); }
.pagination a:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .current { background: var(--primary); color: #fff; border: 1px solid var(--primary); }

.tab-bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; height: calc(var(--tab-height) + var(--safe-bottom)); background: var(--card-bg); backdrop-filter: blur(20px); border-top: 1px solid var(--border); display: flex; align-items: flex-start; padding-bottom: var(--safe-bottom); }
.tab-bar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 0; font-size: 10px; color: var(--text-secondary); transition: color 0.2s; }
.tab-bar a .tab-icon { font-size: 22px; line-height: 1; }
.tab-bar a.active { color: var(--primary); }
.tab-bar a:active { transform: scale(0.9); }

@media (max-width: 640px) {
  .game-grid { grid-template-columns: repeat(1, 1fr); }
  .admin-sidebar { display: none; }
  .admin-main { margin-left: 0; }
  .admin-header h1 { font-size: 17px; }
  .admin-content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-table-wrap { overflow-x: auto; }
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-secondary); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-state p { font-size: 14px; }
.editor-toolbar { display: flex; gap: 4px; padding: 8px; border: 1px solid var(--border); border-bottom: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: var(--page-bg); flex-wrap: wrap; }
.editor-toolbar button { padding: 4px 10px; background: none; border: 1px solid transparent; border-radius: 6px; font-size: 13px; cursor: pointer; color: var(--text); }
.editor-toolbar button:hover { background: var(--border); }
.upload-area { border: 2px dashed var(--border); border-radius: var(--radius-sm); padding: 24px; text-align: center; cursor: pointer; transition: all 0.2s; margin-bottom: 8px; }
.upload-area:hover { border-color: var(--primary); background: rgba(0,122,255,0.05); }
.upload-area .upload-icon { font-size: 32px; margin-bottom: 8px; }
.upload-area p { font-size: 14px; color: var(--text-secondary); }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-content { background: var(--card-bg); border-radius: var(--radius-lg); padding: 24px; max-width: 500px; width: 100%; max-height: 80vh; overflow-y: auto; }

/* ===== Purchase/App Store Modal ===== */
.appstore-modal {
  background: var(--card-bg); border-radius: var(--radius-lg); padding: 0; max-width: 360px; width: 100%;
  overflow: hidden; animation: slideUp 0.3s;
}
.appstore-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 8px;
}
.appstore-title { font-size: 17px; font-weight: 600; }
.appstore-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-secondary); padding: 4px; }
.appstore-card { padding: 12px 20px 20px; }
.appstore-app { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.appstore-app-icon { width: 60px; height: 60px; border-radius: 14px; }
.appstore-app-info { flex: 1; }
.appstore-app-title { font-size: 16px; font-weight: 600; }
.appstore-app-subtitle { font-size: 13px; color: var(--text-secondary); }
.appstore-app-note { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.appstore-divider { height: 1px; background: var(--border); margin: 12px 0; }
.appstore-price-row { display: flex; align-items: center; justify-content: space-between; }
.appstore-price { font-size: 20px; font-weight: 700; color: var(--primary); }
.appstore-price-note { font-size: 12px; color: var(--text-secondary); }
.appstore-buy-btn {
  display: block; width: 100%; padding: 14px; margin-top: 16px;
  background: var(--primary); color: #fff; border: none; border-radius: var(--radius-md);
  font-size: 17px; font-weight: 600; cursor: pointer; text-align: center;
}
.appstore-buy-btn:disabled { opacity: 0.5; }
.appstore-buy-btn:active { transform: scale(0.97); }

/* ===== Security Modal (Apple-style) ===== */
.security-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 300;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(4px);
}
.security-modal-container {
  background: var(--card-bg); border-radius: var(--radius-lg); padding: 24px;
  max-width: 380px; width: 100%; max-height: 85vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.security-step-1 { text-align: center; }
.security-step-1 h3 { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.security-step-1 p { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; }
.apple-security-header { text-align: center; margin-bottom: 16px; }
.apple-security-header .lock-icon { margin-bottom: 8px; }
.apple-security-header h2 { font-size: 20px; font-weight: 700; }
.apple-security-header p { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.apple-message-area { margin-bottom: 16px; }
.apple-error-box { background: #FEE2E2; color: #991B1B; padding: 12px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 8px; display: none; }
.apple-error-box.visible { display: block; }
.apple-question-box { background: var(--page-bg); padding: 12px 14px; border-radius: 10px; font-size: 13px; color: var(--text-secondary); }
.apple-options { display: flex; gap: 8px; }
.apple-btn-primary, .apple-btn-secondary {
  flex: 1; padding: 12px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600;
  cursor: pointer; text-align: center; border: none;
}
.apple-btn-primary { background: var(--primary); color: #fff; }
.apple-btn-primary:disabled { opacity: 0.4; }
.apple-btn-secondary { background: var(--page-bg); color: var(--text); }
.apple-btn-secondary:disabled { opacity: 0.4; }

.double-auth-overlay { text-align: center; }
.double-auth-header { margin-bottom: 16px; }
.double-auth-header h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.double-auth-header p { font-size: 14px; color: var(--text-secondary); }
.double-auth-message-area { margin-bottom: 16px; }
.double-auth-btn-group { display: flex; gap: 8px; }

.options-group { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.custom-radio-label {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
  transition: all 0.2s; font-size: 14px;
}
.custom-radio-label.selected { border-color: var(--primary); background: rgba(0,122,255,0.06); }
.custom-radio-label input[type=radio] { accent-color: var(--primary); width: 18px; height: 18px; }
.question-text { font-size: 14px; font-weight: 500; color: var(--text-secondary); margin-bottom: 12px; }
.icon-item-box { display: flex; align-items: center; gap: 6px; }
.choice-badge { padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.choice-badge.danger { background: var(--danger); color: #fff; }

/* ===== Account Display ===== */
.account-section { margin-top: 16px; }
.account-card {
  background: var(--card-bg); border-radius: var(--radius-md); padding: 16px;
  margin-bottom: 10px; border: 1px solid var(--border);
}
.account-card .account-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.account-card .account-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; }
.account-card .account-row .label { font-size: 13px; color: var(--text-secondary); }
.account-card .account-row .value { font-size: 14px; font-weight: 500; }
.copy-btn {
  padding: 4px 12px; border: 1px solid var(--primary); border-radius: 6px;
  background: none; color: var(--primary); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
}
.copy-btn:hover { background: rgba(0,122,255,0.08); }
.copy-btn:active { transform: scale(0.95); }

/* ===== Tutorial Entry ===== */
.tutorial-entry-card {
  background: var(--card-bg); border-radius: var(--radius-md); padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px;
  box-shadow: var(--shadow); cursor: pointer; transition: transform 0.2s;
}
.tutorial-entry-card:active { transform: scale(0.98); }
.tutorial-entry-content { display: flex; align-items: center; gap: 12px; width: 100%; }
.tutorial-entry-left { display: flex; align-items: center; gap: 12px; flex: 1; }
.tutorial-play-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.tutorial-play-icon.faq-icon { background: rgba(0,122,255,0.1); color: var(--primary); }
.tutorial-play-icon.video-icon { background: rgba(255,59,48,0.1); color: var(--danger); }
.tutorial-entry-text h4 { font-size: 15px; font-weight: 600; }
.tutorial-entry-text p { font-size: 13px; color: var(--text-secondary); }

/* ===== User Menu / Dropdown ===== */
.user-menu { position: relative; }
.user-btn { background: var(--card-bg); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: var(--text); }
.user-points { background: var(--primary); color: #fff; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.user-dropdown { position: absolute; top: 100%; right: 0; margin-top: 4px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); min-width: 180px; z-index: 200; display: none; overflow: hidden; }
.user-dropdown.show { display: block; }
.user-dropdown a { display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: 14px; color: var(--text); transition: background 0.15s; }
.user-dropdown a:hover { background: var(--border); }
.user-dropdown .dropdown-divider { height: 1px; background: var(--border); }

/* ===== Support Float ===== */
.support-float {
  position: fixed; right: 16px; bottom: calc(var(--tab-height) + var(--safe-bottom) + 16px);
  z-index: 150;
}
.support-float-btn {
  width: 50px; height: 50px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; font-size: 24px;
  box-shadow: 0 4px 16px rgba(0,122,255,0.4); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.support-float-btn:active { transform: scale(0.9); }
.support-float-badge {
  position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.support-panel {
  position: fixed; right: 16px; bottom: calc(var(--tab-height) + var(--safe-bottom) + 76px);
  width: 340px; max-height: 480px; background: var(--card-bg); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); z-index: 151; overflow: hidden; display: none;
  flex-direction: column;
}
.support-panel.show { display: flex; }
.support-panel-header { padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: space-between; }
.support-panel-header button { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-secondary); }
.support-messages { flex: 1; overflow-y: auto; padding: 12px 16px; max-height: 300px; }
.support-msg { margin-bottom: 10px; }
.support-msg .msg-bubble { display: inline-block; padding: 8px 14px; border-radius: 14px; font-size: 14px; max-width: 80%; }
.support-msg.user .msg-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.support-msg.admin .msg-bubble { background: var(--page-bg); color: var(--text); border-bottom-left-radius: 4px; }
.support-msg .msg-time { font-size: 10px; color: var(--text-tertiary); margin-top: 2px; display: block; }
.support-input-area { display: flex; padding: 8px; border-top: 1px solid var(--border); gap: 6px; }
.support-input-area input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 20px; font-size: 14px; background: var(--page-bg); }
.support-input-area button { background: var(--primary); color: #fff; border: none; border-radius: 50%; width: 34px; height: 34px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; }

/* ===== Checkin ===== */
.checkin-card {
  background: var(--card-bg); border-radius: var(--radius-lg); padding: 20px;
  text-align: center; box-shadow: var(--shadow); margin-bottom: 16px;
}
.checkin-card .checkin-icon { font-size: 48px; margin-bottom: 8px; }
.checkin-card h3 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.checkin-card p { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; }
.checkin-btn { padding: 10px 32px; border-radius: 999px; border: none; font-size: 16px; font-weight: 600; cursor: pointer; }
.checkin-btn:active { transform: scale(0.96); }
.checkin-btn.done { background: var(--page-bg); color: var(--text-secondary); cursor: default; }
.checkin-btn.today { background: var(--primary); color: #fff; }

/* ===== Favorites ===== */
.fav-btn {
  background: none; border: none; cursor: pointer; padding: 8px;
  font-size: 22px; transition: transform 0.2s;
}
.fav-btn:active { transform: scale(1.2); }

/* ===== Responsive for support ===== */
@media (max-width: 480px) {
  .support-panel { right: 8px; left: 8px; width: auto; bottom: calc(var(--tab-height) + var(--safe-bottom) + 70px); }
  .security-modal-container { margin: 0 12px; }
}

/* ===== Mobile Responsive - Extra Small Screens ===== */
@media (max-width: 480px) {
  .main-content { padding: 66px 10px 16px; }
  
  .banner { padding: 20px 16px; border-radius: var(--radius-md); }
  .banner h1 { font-size: 20px; }
  .banner p { font-size: 13px; }
  .banner .btn-white { font-size: 13px; padding: 8px 18px; }

  .game-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  
  .game-card .card-body h3 { font-size: 13px; }

  .section-header { margin-top: 16px; }
  .section-header h2 { font-size: 17px; }

  .category-bar a { font-size: 12px; padding: 5px 10px; }

  .game-detail-header { padding: 16px 0 12px; }
  .game-detail-header h1 { font-size: 18px; }
  .game-detail-body { padding: 14px; }
  .game-detail-body h3 { font-size: 15px; }

  .auth-container { padding: 0 4px; }
  .auth-card { padding: 20px 16px; }
  .auth-card h2 { font-size: 18px; }

  .game-grid.list-view .game-card { flex-direction: row; }
  .game-grid.list-view .game-card .card-img { width: 80px; height: 60px; }
  .game-grid.list-view .game-card .card-body { flex: 1; }

  .support-panel { right: 8px; left: 8px; width: auto; max-height: 400px; }

  /* Hide nav links on small screens, show tab bar */
  .top-nav .nav-links a:not(.logo):not(.user-btn) { display: none; }
  .top-nav .nav-links .user-menu { display: flex; }
}

/* ===== Medium Screens ===== */
@media (min-width: 481px) and (max-width: 768px) {
  .game-grid { grid-template-columns: repeat(3, 1fr); }
  .banner { padding: 28px 24px; }
}

/* ===== Large Screens ===== */
@media (min-width: 769px) {
  .game-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  body { padding-bottom: 20px; }
  .tab-bar { display: none; }
}

/* ===== Hide tab-bar on desktop, show on mobile ===== */
@media (min-width: 769px) {
  .tab-bar { display: none !important; }
}
@media (max-width: 768px) {
  .tab-bar { display: flex !important; }
}

/* ===== Better desktop nav ===== */
@media (min-width: 769px) {
  .top-nav .nav-links { gap: 8px; }
  .top-nav .nav-links a { font-size: 14px; padding: 8px 16px; }
}

/* ===== Game detail purchase section ===== */
.purchase-section { margin-top: 16px; }
.purchase-btn {
  display: block; width: 100%; padding: 14px; border: none; border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff; font-size: 17px; font-weight: 600; cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}
.purchase-btn:active { transform: scale(0.97); opacity: 0.9; }
.purchase-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ===== Account display in game detail ===== */
.account-card {
  background: var(--card-bg); border-radius: var(--radius-md); padding: 16px;
  margin-bottom: 12px; box-shadow: var(--shadow); border-left: 4px solid var(--success);
}
.account-card .account-field {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.account-card .account-field:last-child { border-bottom: none; }
.account-field .field-label { color: var(--text-secondary); font-weight: 500; }
.account-field .field-value { font-weight: 600; color: var(--text); word-break: break-all; }
.copy-btn {
  background: var(--page-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 4px 10px; font-size: 12px; color: var(--primary); cursor: pointer;
  white-space: nowrap; margin-left: 8px;
}
.copy-btn:active { background: var(--primary); color: #fff; }

/* ===== Empty state ===== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-secondary); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ===== Flash messages ===== */
.flash-msg {
  padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px;
  font-size: 14px; font-weight: 500; animation: flashIn 0.3s ease;
}
.flash-msg.success { background: #D1FAE5; color: #065F46; }
.flash-msg.error { background: #FEE2E2; color: #991B1B; }
@keyframes flashIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Toast notification ===== */
.toast {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--card-bg); padding: 10px 24px;
  border-radius: 999px; font-size: 14px; font-weight: 500; z-index: 999;
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.toast.show { opacity: 1; }

/* ===== Profile page ===== */
.profile-header {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-lg); padding: 24px; color: #fff; margin-bottom: 16px;
  text-align: center;
}
.profile-header .avatar { width: 64px; height: 64px; border-radius: 50%; background: rgba(255,255,255,0.2); margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; font-size: 28px; }
.profile-header h2 { font-size: 20px; font-weight: 700; }
.profile-header .points-badge { display: inline-block; margin-top: 8px; background: rgba(255,255,255,0.2); padding: 4px 16px; border-radius: 999px; font-size: 14px; }

.profile-menu { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.profile-menu a {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--card-bg); border-radius: var(--radius-md); box-shadow: var(--shadow);
  font-size: 15px; color: var(--text); transition: transform 0.15s;
}
.profile-menu a:active { transform: scale(0.98); }
.profile-menu a .menu-icon { font-size: 20px; width: 28px; text-align: center; }
.profile-menu a .menu-arrow { margin-left: auto; color: var(--text-tertiary); font-size: 14px; }

/* ===== Orders page ===== */
.order-card {
  background: var(--card-bg); border-radius: var(--radius-md); padding: 14px;
  margin-bottom: 10px; box-shadow: var(--shadow);
}
.order-card .order-header { display: flex; justify-content: space-between; margin-bottom: 6px; }
.order-card .order-game { font-size: 15px; font-weight: 600; }
.order-card .order-status { font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.order-card .order-status.completed { background: #D1FAE5; color: #065F46; }
.order-card .order-status.pending { background: #FEF3C7; color: #92400E; }
.order-card .order-meta { font-size: 12px; color: var(--text-secondary); }

/* ===== Support list ===== */
.support-card {
  background: var(--card-bg); border-radius: var(--radius-md); padding: 14px;
  margin-bottom: 10px; box-shadow: var(--shadow); cursor: pointer;
}
.support-card:active { transform: scale(0.98); }
.support-card .support-subject { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.support-card .support-meta { font-size: 12px; color: var(--text-secondary); }

/* ===== Page view ===== */
.page-content { background: var(--card-bg); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }
.page-content h1 { font-size: 22px; font-weight: 700; margin-bottom: 12px; }
.page-content p { font-size: 15px; line-height: 1.7; color: var(--text-secondary); margin-bottom: 12px; }

/* ===== Order detail ===== */
.account-list { margin-top: 12px; }
.account-item {
  background: linear-gradient(135deg, #F0FDF4, #ECFDF5);
  border-radius: var(--radius-md); padding: 12px; margin-bottom: 8px;
  border: 1px solid #BBF7D0;
}
@media (prefers-color-scheme: dark) {
  .account-item { background: linear-gradient(135deg, #052E16, #064E3B); border-color: #166534; }
}

/* ===== Registration bonus notice ===== */
.bonus-notice {
  background: linear-gradient(135deg, #FEF3C7, #FDE68A); color: #92400E;
  padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px;
  text-align: center; margin-bottom: 12px;
}
@media (prefers-color-scheme: dark) {
  .bonus-notice { background: linear-gradient(135deg, #451A03, #78350F); color: #FDE68A; }
}

/* ===== New Tab Bar ===== */
.tab-bar { 
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; 
  height: calc(var(--tab-height) + var(--safe-bottom)); 
  background: var(--card-bg); 
  backdrop-filter: blur(20px); 
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border); 
  display: flex; 
  align-items: flex-start; 
  padding-bottom: var(--safe-bottom); 
}
.tab-bar .tab-item { 
  flex: 1; display: flex; flex-direction: column; align-items: center; 
  justify-content: center; gap: 1px; padding: 6px 0; 
  font-size: 10px; color: var(--text-secondary); 
  transition: color 0.2s; text-decoration: none;
}
.tab-bar .tab-item .tab-icon { font-size: 22px; line-height: 1; }
.tab-bar .tab-item .tab-label { font-size: 10px; font-weight: 500; }
.tab-bar .tab-item.active { color: var(--primary); }
.tab-bar .tab-item:active { transform: scale(0.9); }

/* ===== Points Page ===== */
.points-page { padding-bottom: 20px; }
.points-balance-card {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-lg); padding: 28px 24px; 
  text-align: center; color: #fff; margin-bottom: 16px;
}
.points-balance-card .points-icon { font-size: 40px; margin-bottom: 4px; }
.points-balance-card .points-amount { font-size: 36px; font-weight: 700; margin-bottom: 2px; }
.points-balance-card .points-label { font-size: 14px; opacity: 0.85; margin-bottom: 16px; }
.points-balance-card .checkin-btn { padding: 10px 32px; border-radius: 999px; border: none; font-size: 16px; font-weight: 600; cursor: pointer; }
.points-balance-card .checkin-btn.today { background: rgba(255,255,255,0.25); color: #fff; }
.points-balance-card .checkin-btn.done { background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.6); cursor: default; }

.points-section { margin-bottom: 16px; }
.points-methods { display: flex; flex-direction: column; gap: 8px; }
.method-card {
  display: flex; align-items: center; gap: 12px; 
  background: var(--card-bg); border-radius: var(--radius-md); 
  padding: 14px 16px; box-shadow: var(--shadow);
}
.method-card .method-icon { font-size: 24px; width: 36px; text-align: center; }
.method-card .method-info { flex: 1; }
.method-card .method-title { font-size: 15px; font-weight: 600; }
.method-card .method-desc { font-size: 12px; color: var(--text-secondary); }
.method-card .method-reward { font-size: 18px; font-weight: 700; color: var(--success); }

.points-list { display: flex; flex-direction: column; gap: 1px; background: var(--border); border-radius: var(--radius-md); overflow: hidden; }
.points-item { display: flex; align-items: center; padding: 12px 16px; background: var(--card-bg); }
.points-item-left { flex: 1; }
.points-item-type { font-size: 14px; font-weight: 500; }
.points-item-date { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.points-item-amount { font-size: 16px; font-weight: 700; }
.points-item-amount.positive { color: var(--success); }
.points-item-amount.negative { color: var(--text); }

/* ===== Top Nav New ===== */
.top-nav .nav-links .nav-link-register {
  background: var(--primary); color: #fff !important; 
  padding: 6px 14px !important; border-radius: 999px !important;
}
.top-nav .nav-icon-btn { 
  padding: 6px; border-radius: 50%; font-size: 18px; 
  display: flex; align-items: center; justify-content: center;
}
.top-nav .nav-icon-btn:hover { background: var(--border); }
.top-nav .user-points { background: var(--primary); color: #fff; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }

/* ===== Discover/Category Page ===== */
.category-page-header { padding: 16px 0 12px; }
.category-page-header h1 { font-size: 22px; font-weight: 700; }
.category-section { margin-bottom: 20px; }
.category-section .section-header { margin-bottom: 10px; }
.category-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.category-grid a {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 4px; background: var(--card-bg); border-radius: var(--radius-md);
  box-shadow: var(--shadow); text-decoration: none; color: var(--text);
  font-size: 12px; font-weight: 500;
}
.category-grid a .cat-icon { font-size: 28px; }
.category-grid a:active { transform: scale(0.95); }

/* ===== Guest points page ===== */
.points-page-guest .points-balance-card a { 
  color: #fff; text-decoration: none; 
}
.points-page-guest .points-balance-card p a { color: rgba(255,255,255,0.8); text-decoration: underline; }
