/* ========================================
   KING Shop - CSS Variables & Reset
   ======================================== */

:root {
  /* Colors - Primary */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #eef2ff;
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  /* Colors - Semantic */
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --error: #ef4444;
  --error-light: #fef2f2;
  --info: #3b82f6;
  --info-light: #eff6ff;

  /* Colors - Neutral */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-tertiary: #f1f5f9;

  --text-title: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-placeholder: #94a3b8;
  --text-inverse: #ffffff;

  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-focus: #6366f1;

  /* Shadows */
  --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-large: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15), 0 10px 10px rgba(0, 0, 0, 0.04);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;

  /* Z-index */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-backdrop: 400;
  --z-modal: 500;
  --z-toast: 600;
  --z-tooltip: 700;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-surface: #1e293b;
    --bg-tertiary: #334155;

    --text-title: #f8fafc;
    --text-body: #e2e8f0;
    --text-muted: #94a3b8;
    --text-placeholder: #64748b;

    --border-light: #334155;
    --border-medium: #475569;

    --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-large: 0 10px 15px rgba(0, 0, 0, 0.4), 0 4px 6px rgba(0, 0, 0, 0.3);
  }
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-body);
  background: var(--bg-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; background: var(--bg-surface); border: 1px solid var(--border-light); border-radius: var(--radius-md); padding: 12px 14px; width: 100%; outline: none; transition: border-color var(--transition-fast), box-shadow var(--transition-fast); }
input:focus, select:focus, textarea:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15); }
input::placeholder { color: var(--text-placeholder); }
input[disabled], select[disabled] { background: var(--bg-tertiary); color: var(--text-muted); cursor: not-allowed; }
img { max-width: 100%; height: auto; display: block; }
ul, ol { list-style: none; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Selection */
::selection { background: var(--primary); color: white; }

/* ========================================
   Layout & Container
   ======================================== */

.container {
  max-width: 100%;
  padding: 0 var(--space-md);
  padding-bottom: calc(var(--space-xl) + 80px); /* footer space */
}

.step-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  padding: var(--space-md) 0;
}

.step-content {
  display: none;
  animation: fadeIn 0.3s ease;
}
.step-content.active { display: block; }

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

/* ========================================
   Top Navigation
   ======================================== */

.top-nav {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 0 var(--space-md);
  max-width: 640px;
  margin: 0 auto;
}

.top-user-box { flex: 1; min-width: 0; }
.user-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary-gradient);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 16px;
  flex-shrink: 0;
}
.top-user-sub { font-size: 12px; color: var(--text-muted); }
.top-user-title { font-size: 15px; font-weight: 700; color: var(--text-title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.top-search-wrap { flex: 1; display: flex; gap: 6px; max-width: 280px; }
.top-search-input { flex: 1; padding: 10px 14px; font-size: 13px; border-radius: var(--radius-full); background: var(--bg-secondary); border: 1px solid var(--border-light); }
.top-search-btn { padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--primary); background: var(--primary-light); border-radius: var(--radius-full); white-space: nowrap; }
.top-search-btn:active { background: var(--primary); color: white; }

.top-right-links { display: flex; gap: 8px; }
.top-link { padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--text-muted); border-radius: var(--radius-full); background: var(--bg-secondary); transition: all var(--transition-fast); }
.top-link.active, .top-link:hover { color: var(--primary); background: var(--primary-light); }

/* Step Progress Bar */
.order-step-progress { margin-top: var(--space-md); padding: 0 var(--space-md); max-width: 640px; margin-left: auto; margin-right: auto; }
.order-step-progress-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
#order-step-progress-label { font-size: 13px; font-weight: 600; color: var(--text-title); }
#order-step-progress-percent { font-size: 13px; color: var(--primary); font-weight: 700; }
.order-step-progress-track { height: 4px; background: var(--bg-tertiary); border-radius: var(--radius-full); overflow: hidden; }
.order-step-progress-fill { height: 100%; background: var(--primary-gradient); border-radius: var(--radius-full); transition: width 0.4s ease; }

/* ========================================
   Footer Navigation
   ======================================== */

.footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: var(--z-fixed);
  background: var(--bg-primary);
  border-top: 1px solid var(--border-light);
  padding: var(--space-md) var(--space-md) calc(var(--space-md) + env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}

.footer-content { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); }
.price-container { flex: 1; text-align: center; }
.price-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.total-price { font-size: 22px; font-weight: 800; color: var(--text-title); }
.currency-symbol { font-size: 14px; font-weight: 600; }
.price-discount { font-size: 12px; color: var(--success); margin-top: 2px; }

.nav-capsule { display: flex; gap: 8px; }
.btn-prev, .btn-next {
  padding: 14px 28px; font-size: 15px; font-weight: 700;
  border-radius: var(--radius-full); transition: all var(--transition-fast);
}
.btn-prev { color: var(--text-title); background: var(--bg-secondary); border: 1px solid var(--border-light); }
.btn-prev:not(.hidden):active { background: var(--bg-tertiary); }
.btn-prev.hidden { display: none; }
.btn-next { background: var(--primary-gradient); color: white; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35); }
.btn-next:active { transform: scale(0.98); }

/* ========================================
   Home Banner & Categories
   ======================================== */

.home-banner { border-radius: var(--radius-lg); overflow: hidden; margin-bottom: var(--space-md); max-width: 640px; margin-left: auto; margin-right: auto; }
.home-banner-main { width: 100%; aspect-ratio: 16/9; object-fit: cover; }

.search-box-container { padding: 0 var(--space-md); max-width: 640px; margin: 0 auto; }

.category-tabs { display: flex; gap: 8px; overflow-x: auto; padding: var(--space-xs) var(--space-xs) var(--space-sm); scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.category-tabs::-webkit-scrollbar { display: none; }
.category-tab {
  flex-shrink: 0; padding: 10px 20px; border-radius: var(--radius-full);
  background: var(--bg-surface); color: var(--text-muted);
  border: 2px solid transparent; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-soft); scroll-snap-align: start;
  transition: all var(--transition-base);
}
.category-tab:hover:not(.active) { background: var(--bg-secondary); color: var(--text-title); }
.category-tab.active {
  background: var(--primary-gradient); color: white;
  border-color: rgba(255,255,255,0.2);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
  transform: translateY(-1px);
}

/* ========================================
   Game Cards (Step 1)
   ======================================== */

#all-games-render-list { padding: 0 var(--space-md) var(--space-xl); max-width: 640px; margin: 0 auto; }
.game-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.game-card {
  background: var(--bg-surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); overflow: hidden;
  transition: all var(--transition-base);
  display: flex; flex-direction: column;
}
.game-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-medium); border-color: var(--border-medium); }
.game-card:active { transform: scale(0.98); }
.game-card-img-wrap { position: relative; aspect-ratio: 1/1; overflow: hidden; background: var(--bg-tertiary); }
.game-card-img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--transition-slow); }
.game-card:hover .game-card-img { transform: scale(1.05); }
.game-card-tag {
  position: absolute; top: 8px; left: 8px;
  padding: 2px 8px; font-size: 10px; font-weight: 700;
  border-radius: var(--radius-full); background: rgba(0,0,0,0.6); color: white;
}
.game-card-info { padding: var(--space-md); display: flex; flex-direction: column; gap: 6px; flex: 1; }
.game-card-name { font-size: 14px; font-weight: 700; color: var(--text-title); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.game-card-slogan { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.game-card-price-row { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: var(--space-xs); }
.game-card-price { font-size: 16px; font-weight: 800; color: var(--primary); }
.game-card-arrow { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 14px; transition: all var(--transition-fast); }
.game-card:hover .game-card-arrow { background: var(--primary); color: white; }

/* Empty state */
.empty-state { text-align: center; padding: var(--space-2xl) var(--space-md); color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: var(--space-md); opacity: 0.5; }
.empty-state p { font-size: 14px; }

/* ========================================
   Step 2 - Product Selection
   ======================================== */

.flow-game-hero { padding: var(--space-lg) var(--space-md); max-width: 640px; margin: 0 auto; text-align: center; }
.flow-game-hero-title { font-size: 20px; font-weight: 800; color: var(--text-title); margin-bottom: 4px; }
.flow-game-hero-sub { font-size: 14px; color: var(--text-muted); margin-bottom: var(--space-md); }
.flow-hero-actions { margin-bottom: var(--space-md); }
.flow-back-btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--text-title); background: var(--bg-secondary); border: 1px solid var(--border-light); border-radius: var(--radius-full); }
.flow-back-btn:active { background: var(--bg-tertiary); }
.flow-game-promo { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; font-size: 12px; color: var(--warning); background: var(--warning-light); border-radius: var(--radius-full); font-weight: 600; }

.order-flow-layout { display: grid; grid-template-columns: 1fr; gap: var(--space-lg); padding: 0 var(--space-md) var(--space-xl); max-width: 640px; margin: 0 auto; }
@media (min-width: 768px) { .order-flow-layout { grid-template-columns: 1fr 320px; align-items: start; } }

.order-flow-products { min-width: 0; }
.item-list { display: flex; flex-direction: column; gap: 12px; }

/* Product Item Card */
.product-item {
  background: var(--bg-surface); border: 2px solid var(--border-light);
  border-radius: var(--radius-lg); overflow: hidden;
  transition: all var(--transition-base);
  position: relative;
}
.product-item:hover { border-color: var(--border-medium); }
.product-item.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15); }
.product-item:active { transform: scale(0.99); }
.product-item.out-of-stock { opacity: 0.6; }
.product-item.out-of-stock::after {
  content: '售罄'; position: absolute; top: 12px; right: 12px;
  padding: 4px 10px; font-size: 11px; font-weight: 700;
  background: var(--error); color: white; border-radius: var(--radius-full);
}
.product-item-main { display: flex; gap: var(--space-md); padding: var(--space-md); }
.product-item-img { width: 72px; height: 72px; border-radius: var(--radius-md); object-fit: cover; flex-shrink: 0; }
.product-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.product-item-name { font-size: 15px; font-weight: 700; color: var(--text-title); }
.product-item-tag { font-size: 12px; color: var(--text-muted); }
.product-item-facevalue { font-size: 12px; color: var(--primary); font-weight: 600; }
.product-item-lightning { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: var(--warning); background: var(--warning-light); padding: 2px 8px; border-radius: var(--radius-full); width: fit-content; }
.product-item-price { font-size: 18px; font-weight: 800; color: var(--text-title); text-align: right; }
.product-item-price .original { text-decoration: line-through; color: var(--text-muted); font-size: 13px; font-weight: 500; margin-right: 6px; }

/* Sidebar Cards */
.order-flow-sidebar { display: flex; flex-direction: column; gap: var(--space-md); }
.flow-side-card {
  background: var(--bg-surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); padding: var(--space-lg);
}
.flow-side-title { font-size: 15px; font-weight: 700; color: var(--text-title); margin-bottom: var(--space-md); }
.flow-side-help { font-size: 13px; color: var(--text-muted); line-height: 1.6; }

.flow-cart-list { display: flex; flex-direction: column; gap: 10px; }
.flow-cart-item { display: flex; justify-content: space-between; align-items: center; gap: var(--space-sm); padding-bottom: 10px; border-bottom: 1px solid var(--border-light); }
.flow-cart-item:last-child { border-bottom: none; padding-bottom: 0; }
.flow-cart-item-info { flex: 1; min-width: 0; }
.flow-cart-item-name { font-size: 13px; font-weight: 600; color: var(--text-title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-cart-item-qty { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.flow-cart-item-price { font-size: 14px; font-weight: 700; color: var(--text-title); white-space: nowrap; }

.flow-side-price-card { background: var(--primary-gradient); color: white; }
.flow-side-price-card .flow-side-title { color: white; }
.flow-side-price-card .flow-price-row span { color: rgba(255,255,255,0.8); }
.flow-side-price-card .flow-price-row strong { font-size: 24px; color: white; }
.flow-side-actions { display: flex; gap: 8px; margin-top: var(--space-lg); }
.flow-side-ghost-btn, .flow-submit-btn { flex: 1; padding: 14px; font-size: 14px; font-weight: 700; border-radius: var(--radius-full); transition: all var(--transition-fast); }
.flow-side-ghost-btn { background: rgba(255,255,255,0.15); color: white; border: 1px solid rgba(255,255,255,0.3); }
.flow-side-ghost-btn:active { background: rgba(255,255,255,0.25); }
.flow-submit-btn { background: white; color: var(--primary); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.flow-submit-btn:active { transform: scale(0.98); }
.flow-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========================================
   Step 3 - Form Styles
   ======================================== */

.form-section { padding: var(--space-md); max-width: 640px; margin: 0 auto; }
.section-title { font-size: 16px; font-weight: 700; color: var(--text-title); border-left: 4px solid var(--primary); padding-left: var(--space-md); margin-bottom: var(--space-lg); }

.input-group { margin-bottom: var(--space-lg); }
.input-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-title); margin-bottom: 6px; }
.input-wrapper { display: flex; gap: 8px; }
.input-wrapper input { flex: 1; }
.input-wrapper button { flex-shrink: 0; white-space: nowrap; }

.input-help { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.btn-verify-inside {
  padding: 12px 16px; font-size: 12px; font-weight: 700;
  color: var(--primary); background: var(--primary-light);
  border-radius: var(--radius-md); display: inline-flex; align-items: center; gap: 4px;
  transition: all var(--transition-fast);
}
.btn-verify-inside:hover { background: var(--primary); color: white; }
.btn-verify-inside:disabled { opacity: 0.5; cursor: not-allowed; }

/* Dynamic Forms */
.dynamic-form { animation: fadeIn 0.3s ease; }
.form-loading-state { display: flex; flex-direction: column; align-items: center; gap: var(--space-md); padding: var(--space-xl); color: var(--text-muted); }
.form-loading-spinner { width: 28px; height: 28px; border: 3px solid var(--border-light); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.form-loading-message { font-size: 14px; }
.form-loading-retry { padding: 10px 20px; font-size: 13px; font-weight: 600; color: var(--primary); background: var(--primary-light); border-radius: var(--radius-full); }

/* SMS Verify Inline */
.sms-verify-inline { margin-bottom: var(--space-lg); }
.sms-verify-card { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); padding: var(--space-md); background: var(--info-light); border: 1px solid rgba(59, 130, 246, 0.2); border-radius: var(--radius-lg); }
.sms-verify-title { font-size: 14px; font-weight: 700; color: var(--info); }
.sms-verify-status { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.sms-verify-phone { font-size: 13px; font-weight: 600; color: var(--text-title); margin-top: 2px; }
.sms-verify-launch { flex-shrink: 0; padding: 10px 18px; font-size: 13px; font-weight: 700; color: white; background: var(--info); border-radius: var(--radius-full); }

/* Order Flow Main/Sidebar */
.order-flow-main { min-width: 0; }
.order-flow-sidebar { width: 100%; }
@media (min-width: 768px) { .order-flow-sidebar { position: sticky; top: 100px; } }

/* Help Tip Button */
.help-tip-button { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; font-size: 12px; font-weight: 600; color: var(--primary); background: var(--primary-light); border-radius: var(--radius-full); }

/* Warning Box */
.warning-box { background: var(--error-light); border: 1px solid rgba(239, 68, 68, 0.2); border-radius: var(--radius-lg); padding: var(--space-md); margin-top: var(--space-lg); }
.warning-box-title { font-size: 13px; font-weight: 700; color: var(--error); margin-bottom: 6px; }
.warning-box ul { font-size: 12px; color: var(--text-body); line-height: 1.8; padding-left: var(--space-lg); }
.warning-box li { margin-bottom: 4px; }

/* ========================================
   Step 4 - Confirm Order
   ======================================== */

.confirm-box { padding: var(--space-md); max-width: 640px; margin: 0 auto; }
.confirm-box h4 { margin-bottom: var(--space-lg); }

.review-item { display: flex; gap: var(--space-md); padding: var(--space-md); background: var(--bg-secondary); border: 1px solid var(--border-light); border-radius: var(--radius-lg); margin-bottom: var(--space-md); }
.review-item-img { width: 56px; height: 56px; border-radius: var(--radius-md); object-fit: cover; flex-shrink: 0; }
.review-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.review-item-name { font-size: 14px; font-weight: 600; color: var(--text-title); }
.review-item-detail { font-size: 12px; color: var(--text-muted); }
.review-item-price { font-size: 15px; font-weight: 700; color: var(--text-title); white-space: nowrap; }

/* Coupon */
.coupon-row { display: flex; gap: 8px; margin-bottom: var(--space-md); }
.coupon-input { flex: 1; padding: 12px 14px; font-size: 14px; }
.btn-coupon { padding: 12px 20px; font-size: 13px; font-weight: 700; color: white; background: var(--primary); border-radius: var(--radius-md); white-space: nowrap; }
.btn-coupon:active { background: var(--primary-hover); }
.coupon-msg { font-size: 12px; min-height: 18px; margin-top: 4px; }
.coupon-msg.success { color: var(--success); }
.coupon-msg.error { color: var(--error); }

.coupon-success-box { display: none; align-items: center; justify-content: space-between; padding: var(--space-md); background: var(--success-light); border: 1px solid rgba(16, 185, 129, 0.2); border-radius: var(--radius-lg); color: var(--success); font-size: 14px; font-weight: 600; margin-bottom: var(--space-md); }
.coupon-success-box span[onclick] { color: var(--text-muted); font-weight: 400; cursor: pointer; }

/* Payment Options */
#payment-section h4 { margin-bottom: var(--space-md); }
.payment-option { display: flex; align-items: center; gap: var(--space-md); padding: var(--space-md); background: var(--bg-surface); border: 2px solid var(--border-light); border-radius: var(--radius-lg); margin-bottom: var(--space-md); cursor: pointer; transition: all var(--transition-base); }
.payment-option:hover { border-color: var(--border-medium); }
.payment-option.selected { border-color: var(--primary); background: var(--primary-light); }
.payment-option:active { transform: scale(0.99); }
.payment-circle { width: 22px; height: 22px; border: 2px solid var(--border-medium); border-radius: 50%; position: relative; flex-shrink: 0; transition: all var(--transition-fast); }
.payment-option.selected .payment-circle { border-color: var(--primary); }
.payment-option.selected .payment-circle::after { content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 10px; height: 10px; background: var(--primary); border-radius: 50%; }
.payment-option img { height: 40px; margin-left: auto; }
.payment-option div { flex: 1; min-width: 0; }
.payment-option div:first-of-type { font-size: 15px; font-weight: 700; color: var(--text-title); }
.payment-option div:last-of-type { font-size: 12px; color: var(--text-muted); }

/* Payment Info Boxes */
#atm-info, #cathay-no-card-info, #taishin-no-card-info, #ctbc-no-card-info, #custom-info-familymart, #payment-info, #newebpay-cvs-info, #expedite-option { animation: slideDown 0.3s ease; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ========================================
   Step 5 - Success
   ======================================== */

.success-box { padding: var(--space-xl) var(--space-md); max-width: 640px; margin: 0 auto; text-align: center; }
.success-icon { width: 80px; height: 80px; border-radius: 50%; background: var(--success-light); color: var(--success); display: flex; align-items: center; justify-content: center; font-size: 36px; margin: 0 auto var(--space-lg); }
.success-title { font-size: 22px; font-weight: 800; color: var(--text-title); margin-bottom: var(--space-sm); }
.success-subtitle { font-size: 15px; color: var(--text-muted); margin-bottom: var(--space-xl); }
.success-order-info { background: var(--bg-secondary); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: var(--space-lg); margin-bottom: var(--space-lg); text-align: left; }
.success-order-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-light); font-size: 14px; }
.success-order-row:last-child { border-bottom: none; }
.success-order-row span { color: var(--text-muted); }
.success-order-row strong { color: var(--text-title); }
.success-actions { display: flex; gap: 12px; }
.success-btn { flex: 1; padding: 14px; font-size: 15px; font-weight: 700; border-radius: var(--radius-full); }
.success-btn-primary { background: var(--primary-gradient); color: white; }
.success-btn-secondary { background: var(--bg-secondary); color: var(--text-title); border: 1px solid var(--border-light); }

/* ========================================
   Modals
   ======================================== */

.modal-overlay { position: fixed; inset: 0; z-index: var(--z-modal-backdrop); display: none; align-items: center; justify-content: center; padding: var(--space-md); background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px); animation: fadeIn 0.2s ease; }
.modal-overlay.active { display: flex; }
.modal-box { background: var(--bg-surface); border-radius: var(--radius-xl); padding: var(--space-xl); width: 100%; max-width: 400px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-xl); animation: slideUp 0.3s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.modal-title { font-size: 18px; font-weight: 800; color: var(--text-title); text-align: center; margin-bottom: var(--space-lg); }
.modal-box .btn-primary { width: 100%; padding: 14px; font-size: 15px; font-weight: 700; background: var(--primary-gradient); color: white; border-radius: var(--radius-full); }
.modal-box .btn-primary:active { transform: scale(0.98); }

.sms-modal-box { max-width: 360px; }
.sms-modal-description { text-align: center; font-size: 14px; color: var(--text-muted); margin-bottom: var(--space-lg); }

.otp-area { margin: var(--space-lg) 0; }
.otp-inputs { display: flex; gap: 8px; justify-content: center; margin-bottom: var(--space-md); }
.otp-field { width: 44px; height: 52px; font-size: 20px; font-weight: 700; text-align: center; border-radius: var(--radius-md); border: 2px solid var(--border-light); background: var(--bg-surface); color: var(--text-title); transition: all var(--transition-fast); }
.otp-field:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15); outline: none; }
.otp-field.filled { border-color: var(--primary); background: var(--primary-light); }
.otp-error { font-size: 12px; color: var(--error); text-align: center; min-height: 18px; }
.btn-modal-close { width: 100%; padding: 12px; font-size: 14px; font-weight: 600; color: var(--text-muted); margin-top: var(--space-md); }

/* Custom Alert/Confirm */
.custom-alert-overlay { position: fixed; inset: 0; z-index: var(--z-modal-backdrop); display: none; align-items: center; justify-content: center; padding: var(--space-md); background: rgba(0, 0, 0, 0.5); }
.custom-alert-overlay.active { display: flex; }
.custom-confirm-overlay { position: fixed; inset: 0; z-index: var(--z-modal-backdrop); display: none; align-items: center; justify-content: center; padding: var(--space-md); background: rgba(0, 0, 0, 0.5); }
.custom-confirm-overlay.active { display: flex; }
.custom-alert-box, .custom-confirm-box { background: var(--bg-surface); border-radius: var(--radius-xl); padding: var(--space-xl); width: 100%; max-width: 340px; box-shadow: var(--shadow-xl); text-align: center; animation: slideUp 0.3s ease; }
.custom-alert-icon { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; margin: 0 auto var(--space-md); }
.custom-alert-icon.success { background: var(--success-light); color: var(--success); }
.custom-alert-icon.error { background: var(--error-light); color: var(--error); }
.custom-alert-icon.warning { background: var(--warning-light); color: var(--warning); }
.custom-alert-icon.info { background: var(--info-light); color: var(--info); }
.custom-alert-title, .custom-confirm-title { font-size: 17px; font-weight: 800; color: var(--text-title); margin-bottom: var(--space-sm); }
.custom-alert-message, .custom-confirm-message { font-size: 14px; color: var(--text-body); line-height: 1.6; margin-bottom: var(--space-lg); }
.custom-alert-btn { display: flex; justify-content: center; }
.custom-alert-btn .btn-primary { min-width: 100px; padding: 12px 28px; font-size: 14px; font-weight: 700; background: var(--primary); color: white; border-radius: var(--radius-full); }
.custom-confirm-btns { display: flex; gap: 12px; }
.custom-confirm-btns button { flex: 1; padding: 12px; font-size: 14px; font-weight: 700; border-radius: var(--radius-full); }
.btn-cancel { background: var(--bg-secondary); color: var(--text-title); border: 1px solid var(--border-light); }
.btn-cancel:active { background: var(--bg-tertiary); }
.btn-confirm { background: var(--primary); color: white; }
.btn-confirm:active { background: var(--primary-hover); }

.custom-confirm-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--warning-light); color: var(--warning); display: flex; align-items: center; justify-content: center; font-size: 20px; margin: 0 auto var(--space-md); }

/* ========================================
   Toasts
   ======================================== */

.toast-container { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 18px; background: var(--bg-surface); border: 1px solid var(--border-light); border-radius: var(--radius-lg); box-shadow: var(--shadow-large); font-size: 14px; color: var(--text-title); animation: slideUp 0.3s ease; pointer-events: auto; max-width: 90vw; }
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--error); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--info); }
.toast i { font-size: 18px; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--error); }
.toast.warning i { color: var(--warning); }
.toast.info i { color: var(--info); }

/* ========================================
   FAB & Point Card
   ======================================== */

.point-card-fab { position: fixed; bottom: 90px; right: var(--space-md); z-index: var(--z-fixed); width: 56px; height: 56px; border-radius: 50%; background: var(--primary-gradient); box-shadow: var(--shadow-large); display: flex; align-items: center; justify-content: center; overflow: hidden; animation: pulse 2s infinite; }
.point-card-fab img { width: 100%; height: 100%; object-fit: cover; }
@keyframes pulse { 0%, 100% { box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4); } 50% { box-shadow: 0 4px 30px rgba(99, 102, 241, 0.6); } }

/* ========================================
   External Login Overlay
   ======================================== */

.external-login-overlay { position: fixed; inset: 0; z-index: var(--z-modal-backdrop); display: none; align-items: center; justify-content: center; padding: var(--space-md); background: rgba(0, 0, 0, 0.6); }
.external-login-overlay.active { display: flex; }
.external-login-box { background: var(--bg-surface); border-radius: var(--radius-xl); padding: var(--space-xl); width: 100%; max-width: 340px; text-align: center; box-shadow: var(--shadow-xl); }
.external-login-title { font-size: 18px; font-weight: 800; color: var(--text-title); margin-bottom: var(--space-sm); }
.external-login-text { font-size: 14px; color: var(--text-muted); margin-bottom: var(--space-lg); }
.external-login-btn { width: 100%; padding: 14px; font-size: 15px; font-weight: 700; background: #06C755; color: white; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; gap: 8px; }
.external-login-btn:active { background: #05b04c; }

/* ========================================
   Help Tip Modal
   ======================================== */

#helpTipImage { max-width: 100%; border-radius: var(--radius-md); }

/* ========================================
   Utility Classes
   ======================================== */

.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 480px) {
  :root { --space-md: 12px; --space-lg: 16px; --space-xl: 24px; }
  .game-list { grid-template-columns: 1fr; }
  .product-item-main { flex-direction: column; align-items: center; text-align: center; }
  .product-item-img { width: 80px; height: 80px; }
  .product-item-price { text-align: center; }
  .otp-field { width: 36px; height: 44px; font-size: 18px; }
  .modal-box { padding: var(--space-lg); margin: var(--space-md); }
}

@media (min-width: 768px) {
  .step-header { padding: var(--space-md) var(--space-xl); }
  .container { padding: 0 var(--space-xl); }
  .footer { padding: var(--space-md) var(--space-xl) calc(var(--space-md) + env(safe-area-inset-bottom)); }
  .point-card-fab { bottom: 110px; right: var(--space-xl); }
}

/* ========================================
   LINE 登入遮罩
   ======================================== */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background: linear-gradient(160deg, #fdf6ec 0%, #fdf1ff 55%, #eef2ff 100%);
}

.login-box {
  width: 100%;
  max-width: 340px;
  background: #fff;
  border-radius: 24px;
  padding: 40px 28px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
  animation: loginPop 0.35s ease;
}

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

.login-logo {
  width: 84px;
  height: 84px;
  margin: 0 auto 16px;
  border-radius: 24px;
  background: linear-gradient(135deg, #ffb3c8, #f9a8d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  box-shadow: 0 8px 20px rgba(249, 168, 212, 0.4);
}

.login-title {
  font-size: 24px;
  font-weight: 900;
  color: #333;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.login-sub {
  font-size: 13px;
  color: #888;
  line-height: 1.7;
  margin-bottom: 28px;
}

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 700;
  color: #333;
  background: #06C755;
  border-radius: 50px;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(6, 199, 85, 0.35);
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.login-btn:active { transform: scale(0.97); opacity: 0.9; }

/* ========================================
   桌機版（寬螢幕滿版）
   ======================================== */

@media (min-width: 1024px) {
  .container { max-width: 1200px; margin: 0 auto; }
  .top-nav,
  .order-step-progress,
  .footer,
  .home-banner,
  .search-box-container,
  #all-games-render-list,
  .flow-game-hero,
  .order-flow-layout,
  .success-box {
    max-width: 1200px;
  }

  .game-list { grid-template-columns: repeat(4, 1fr); gap: 16px; }

  .category-tabs { justify-content: center; flex-wrap: wrap; overflow-x: visible; }

  .order-flow-layout { grid-template-columns: 1fr 360px; gap: var(--space-xl); }

  .form-section,
  .confirm-box {
    max-width: 900px;
  }

  .home-banner { max-width: 900px; }
}

/* ========================================
   回頂端小球
   ======================================== */

.back-to-top {
  position: fixed;
  bottom: 160px;
  right: var(--space-md);
  z-index: var(--z-fixed);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: white;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.45);
  cursor: pointer;
  animation: floatY 2.5s ease-in-out infinite;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.back-to-top:active { transform: scale(0.92); }
.back-to-top:hover { box-shadow: 0 8px 24px rgba(99, 102, 241, 0.6); }

@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@media (min-width: 1024px) {
  .back-to-top { bottom: 180px; right: var(--space-xl); }
}