/* Base layout & components. Colours, fonts and effects come from themes.css via CSS variables. */
@layer base, components, theme;

@layer base {
  :root {
    --bg: #f5f7fb; --bg-2: #eef2fb; --surface: #fff; --surface-2: #f3f5fa; --border: #e2e6ef;
    --text: #111827; --muted: #6b7280; --accent: #2563eb; --accent-2: #4f46e5; --on-accent: #fff;
    --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
    --radius: 18px; --radius-sm: 12px; --shadow: 0 10px 30px -12px rgb(15 23 42 / .18);
    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-head: var(--font-body); --head-transform: none; --head-spacing: -0.01em;
    --glow: none; --blur: 0px; --card-bg: var(--surface);
    color-scheme: light;
  }
  * { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
  body {
    margin: 0; min-height: 100dvh; font-family: var(--font-body); color: var(--text); background: var(--bg);
    line-height: 1.5; overflow-x: hidden;
  }
  h1, h2, h3 { font-family: var(--font-head); text-transform: var(--head-transform); letter-spacing: var(--head-spacing); text-wrap: balance; margin: 0; }
  img { max-width: 100%; display: block; }
  button, input, select, textarea { font: inherit; color: inherit; }
  a { color: var(--accent); }
  .hidden { display: none !important; }
  .muted { color: var(--muted); }
  .center { text-align: center; }
  /* Decorative background layers (themes fill them in). */
  .fx-bg, .fx-bg::before, .fx-bg::after { position: fixed; inset: 0; pointer-events: none; z-index: -1; content: ""; }
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
}

@layer components {
  /* Header */
  .topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px max(16px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--surface) 72%, transparent);
    backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); border-bottom: 1px solid var(--border);
  }
  .brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 800; font-size: 18px; text-transform: var(--head-transform); letter-spacing: var(--head-spacing); }
  .brand .logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent); font-size: 16px; box-shadow: var(--glow); }
  a.brand { color: var(--text); text-decoration: none; min-width: 0; }
  a.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tb-right { display: flex; align-items: center; gap: 6px; flex: none; }
  .tb-link { display: inline-flex; align-items: center; gap: 5px; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); text-decoration: none; font-size: 14px; font-weight: 600; }
  .tb-link.on { border-color: var(--accent); }
  @media (max-width: 420px) {
    .tb-label { display: none; } .tb-link { padding: 6px 9px; } .lang-btn { padding: 6px 8px; } .lang-code { display: none; }
    /* Long site names wrap to two lines instead of being cut off. */
    .brand { font-size: 15px; line-height: 1.15; }
    a.brand span { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  }
  /* Currency picker */
  .fxsel { position: relative; }
  .fxsel-btn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 13.5px; font-weight: 700; cursor: pointer; }
  .fxsel-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: min(270px, calc(100vw - 24px)); max-height: 70dvh; overflow: auto; padding: 10px; border-radius: 14px;
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow), 0 18px 40px -12px rgb(0 0 0 / .35); }
  [data-theme="futuristic"] .fxsel-pop, [data-theme="gamer"] .fxsel-pop, [data-theme="luxe"] .fxsel-pop { background: #0d1124; }
  [data-theme="luxe"] .fxsel-pop { background: #15120e; }
  @media (max-width: 600px) { .fxsel-pop { position: fixed; left: 12px; right: 12px; top: 62px; width: auto; } }
  .fxsel-head { font-weight: 700; font-size: 13px; margin: 2px 4px 8px; color: var(--muted); }
  .fxsel-opt { display: flex; align-items: center; gap: 8px; margin: 0; padding: 8px 6px; border-radius: 10px; font-weight: 500; cursor: pointer; }
  .fxsel-opt:hover { background: var(--surface-2); }
  .fxsel-opt input { width: 18px; height: 18px; accent-color: var(--accent); }
  .fxsel-note { margin: 8px 4px 2px; font-size: 11.5px; color: var(--muted); }
  /* Contact page */
  .contact-msg { white-space: pre-line; margin: 0 0 14px; }
  .contact-btns { display: grid; gap: 10px; }
  .contact-btn { width: 100%; justify-content: center; text-decoration: none; }
  .wechat-box { margin-top: 16px; text-align: center; }
  .wechat-box .qr-wrap { max-width: 240px; margin: 0 auto; }
  /* Language drop-down with flags */
  .lang { position: relative; }
  .lang-btn { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 13.5px; font-weight: 700; cursor: pointer; }
  .lang .flag { font-size: 16px; line-height: 1; }
  .lang-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 190px; padding: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow), 0 18px 40px -12px rgb(0 0 0 / .35); }
  [data-theme="futuristic"] .lang-pop, [data-theme="gamer"] .lang-pop { background: #0d1124; }
  [data-theme="luxe"] .lang-pop { background: #15120e; }
  .lang-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 10px; border: 0; border-radius: 10px; background: none; color: var(--text); font-size: 14.5px; text-align: left; cursor: pointer; }
  .lang-opt:hover { background: var(--surface-2); }
  .lang-opt.on { background: color-mix(in srgb, var(--accent) 16%, transparent); font-weight: 700; }

  main { width: min(100%, 720px); margin: 0 auto; padding: 8px 14px 140px; }

  /* Hero */
  .hero { padding: 26px 4px 14px; }
  .hero h1 { font-size: clamp(28px, 7vw, 44px); line-height: 1.05; font-weight: 800; }
  .hero h1 .grad { background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent)); background-size: 200% auto; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shine 6s linear infinite; }
  .hero p { margin: 8px 0 0; color: var(--muted); font-size: 15px; }
  .badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
  .badge-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 6px 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text); }
  @keyframes shine { to { background-position: 200% center; } }

  /* Cards / sections */
  .card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin: 14px 0; box-shadow: var(--shadow); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur)); }
  .step-title { display: flex; align-items: center; gap: 10px; font-size: 17px; margin-bottom: 12px; }
  .step-num { flex: none; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font-size: 14px; font-weight: 800; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent); box-shadow: var(--glow); }

  /* Game tabs */
  .tabs-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
  .tab { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 14px 8px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; }
  .tab img, .tab .ph { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
  .tab.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); box-shadow: var(--glow); }

  /* Selected game banner */
  .game-banner { display: flex; align-items: center; gap: 12px; margin: 2px 0 14px; padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: linear-gradient(110deg, color-mix(in srgb, var(--accent) 16%, var(--surface)), color-mix(in srgb, var(--accent-2) 10%, var(--surface))); }
  .game-banner img, .game-banner .ph { flex: none; width: 56px; height: 56px; border-radius: 14px; object-fit: cover; box-shadow: var(--glow); }
  .game-banner .ph { display: grid; place-items: center; font-family: var(--font-head); font-weight: 800; font-size: 20px; color: var(--on-accent); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
  .game-banner small { display: block; font-size: 12px; color: var(--muted); }
  .game-banner b { display: block; font-family: var(--font-head); text-transform: var(--head-transform); letter-spacing: var(--head-spacing); font-size: 17px; line-height: 1.2; }

  /* Red "please fix" banner, pinned under the top bar */
  .err-banner { position: fixed; z-index: 35; left: 50%; translate: -50% 0; top: calc(64px + env(safe-area-inset-top)); width: min(calc(100% - 20px), 700px);
    max-height: 50dvh; overflow: auto; padding: 10px 12px; border-radius: 14px; background: #b42318; color: #fff; box-shadow: 0 14px 40px -10px rgb(180 35 24 / .7);
    animation: errIn .2s ease; }
  @keyframes errIn { from { opacity: 0; transform: translateY(-8px); } }
  .err-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14.5px; }
  .err-x { flex: none; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgb(255 255 255 / .2); color: #fff; font-size: 15px; cursor: pointer; }
  .err-banner ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
  .err-go { width: 100%; display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 0; border-radius: 10px; background: rgb(255 255 255 / .14); color: #fff; font-size: 14px; text-align: left; cursor: pointer; }
  .err-arrow { flex: none; font-weight: 700; opacity: .9; }
  /* Receipt: "sent via chat" option */
  .check-row { display: flex; align-items: flex-start; gap: 10px; margin: 12px 0 4px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 600; cursor: pointer; }
  .check-row input { width: 20px; height: 20px; margin-top: 1px; flex: none; accent-color: var(--accent); }
  .check-row .hint { display: block; font-weight: 400; margin-top: 4px; }
  .drop.dim { opacity: .45; }

  /* Payment method choice */
  .pay-options { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
  .pay-opt { padding: 10px 16px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface-2); color: var(--text); font-weight: 700; cursor: pointer; }
  .pay-opt.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--surface)); box-shadow: var(--glow); }
  .pay-desc { white-space: pre-line; }
  .pay-desc:empty { display: none; }

  /* Quick add (smart link detection) */
  .quick-add { margin: 0 0 14px; padding: 12px; border-radius: var(--radius-sm); border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--border)); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
  .quick-add label { margin-top: 0; }
  .privacy-note { font-size: 12px; margin: 10px 0 0; opacity: .8; }
  .qa-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
  .qa-head label { margin: 0; }
  .guide-row { margin: 0 0 12px; }
  .guide-btn { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px 6px 6px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
    background: var(--surface); color: var(--text); font-size: 13.5px; font-weight: 700; cursor: pointer; white-space: nowrap; text-decoration: none; }
  .guide-play { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; padding-left: 2px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent); }
  .guide-btn:hover { border-color: var(--accent); }

  /* Product grid */
  .grid { container: grid / inline-size; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(140px, calc(50% - 6px)), 1fr)); gap: 12px; }
  /* Phones: products per row chosen in Admin (data-cols on <html>). */
  @media (max-width: 599px) {
    :root[data-cols="3"] .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    :root[data-cols="4"] .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  }
  .product {
    container: card / inline-size; position: relative; display: flex; flex-direction: column; border-radius: var(--radius-sm); overflow: hidden; cursor: pointer;
    background: var(--surface); border: 1px solid var(--border); transition: transform .18s ease, border-color .18s, box-shadow .18s;
    view-transition-name: var(--vt, none);
  }
  .product:hover { transform: translateY(-2px); }
  .product.in-cart { border-color: var(--accent); box-shadow: var(--glow), var(--shadow); }
  .product .pic { aspect-ratio: 1; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 35%, var(--surface-2)), color-mix(in srgb, var(--accent-2) 35%, var(--surface-2))); display: grid; place-items: center; font-family: var(--font-head); font-size: 28px; font-weight: 800; color: var(--on-accent); }
  .product .pic img { width: 100%; height: 100%; object-fit: cover; }
  /* Game picture used as fallback: package size shown on top so cards stay distinguishable. */
  .product .pic.game-pic { position: relative; }
  .product .pic .pic-label { position: absolute; left: 6px; bottom: 6px; padding: 2px 8px; border-radius: 999px; font-size: 13px; line-height: 1.5; background: rgb(0 0 0 / .62); color: #fff; }
  @container card (max-width: 100px) { .product .pic .pic-label { font-size: 10.5px; padding: 1px 5px; left: 4px; bottom: 4px; } }
  .product .info { padding: 10px 11px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
  .product .name { font-weight: 700; font-size: 14.5px; line-height: 1.25; }
  .product .price { font-family: var(--font-head); font-weight: 800; font-size: 17px; color: var(--accent); margin-top: auto; padding-top: 4px; }
  .product .fx { font-size: 11px; color: var(--muted); line-height: 1.3; }
  .product .fx span { display: block; overflow-wrap: anywhere; }
  .qty-badge { position: absolute; top: 8px; right: 8px; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px; display: grid; place-items: center; font-weight: 800; font-size: 14px; background: var(--accent); color: var(--on-accent); box-shadow: var(--glow); animation: pop .25s ease; }
  @keyframes pop { from { transform: scale(.4); } }
  .stepper { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 8px; }
  .stepper button { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: 18px; font-weight: 700; cursor: pointer; line-height: 1; }
  .stepper button.plus { background: var(--accent); color: var(--on-accent); border-color: transparent; }
  .stepper .n { font-weight: 800; min-width: 22px; text-align: center; }
  @container grid (min-width: 520px) { .product .name { font-size: 15px; } }
  /* Compact cards when 3–4 fit across a phone. */
  @container card (max-width: 135px) {
    .product .pic { font-size: 20px; }
    .product .info { padding: 7px 7px 8px; gap: 1px; }
    .product .name { font-size: 12.5px; }
    .product .price { font-size: 14px; padding-top: 2px; }
    .product .fx { font-size: clamp(9px, 8.2cqi, 10.5px); line-height: 1.25; }
    .qty-badge { top: 5px; right: 5px; min-width: 22px; height: 22px; padding: 0 6px; font-size: 12px; }
    .stepper { margin-top: 5px; gap: 2px; }
    .stepper button { width: 26px; height: 26px; border-radius: 8px; font-size: 15px; }
    .stepper .n { min-width: 14px; font-size: 13px; }
  }
  @container card (max-width: 100px) {
    .product .pic { font-size: 16px; }
    .product .info { padding: 6px 5px 7px; }
    .product .name { font-size: 11.5px; }
    .product .price { font-size: 12.5px; }
    /* 4 per row: still show the chosen currencies, just smaller. */
    .product .fx { font-size: clamp(8px, 10.5cqi, 9.5px); line-height: 1.2; letter-spacing: -0.01em; }
    .stepper button { width: 22px; height: 24px; border-radius: 7px; font-size: 14px; }
  }

  /* Scroll reveal (progressive enhancement) */
  @supports (animation-timeline: view()) {
    .reveal { animation: reveal linear both; animation-timeline: view(); animation-range: entry 0% entry 40%; }
    @keyframes reveal { from { opacity: 0; transform: translateY(18px) scale(.98); } }
  }

  /* Forms */
  label { display: block; font-size: 13.5px; font-weight: 600; margin: 12px 0 6px; }
  input[type=text], input[type=url], input[type=password], input[type=number], select, textarea {
    width: 100%; font-size: 16px; padding: 12px 13px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); transition: border-color .15s, box-shadow .15s;
  }
  input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
  input.is-bad { border-color: var(--bad); }
  input.is-ok { border-color: var(--ok); }
  .hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
  .note { font-size: 13px; border-radius: 12px; padding: 10px 12px; margin-top: 10px; background: color-mix(in srgb, var(--warn) 12%, var(--surface)); color: color-mix(in srgb, var(--warn) 80%, var(--text)); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
  .note ul { margin: 4px 0 0; padding-left: 18px; }
  .error { color: var(--bad); font-size: 13.5px; margin: 8px 0 0; }
  .field-msg { font-size: 12.5px; margin: 5px 0 0; display: flex; align-items: center; gap: 6px; }
  .field-msg.ok { color: var(--ok); } .field-msg.bad { color: var(--bad); } .field-msg.warn { color: var(--warn); } .field-msg.busy { color: var(--muted); }
  .spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
  @keyframes spin { to { transform: rotate(1turn); } }

  /* Unit rows (one checkout link per unit) */
  .unit { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 12px; margin-top: 10px; background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
  .unit-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
  .unit-head .tag { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
  .unit label { margin-top: 8px; }

  /* Totals / pay */
  .total-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
  .amount { font-family: var(--font-head); font-size: clamp(30px, 8vw, 40px); font-weight: 800; letter-spacing: -0.02em; }
  .fx-line { font-size: 13px; color: var(--muted); }
  .summary { list-style: none; padding: 0; margin: 0 0 12px; font-size: 14px; }
  .summary li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); }
  .qr-wrap { margin: 14px auto 10px; width: min(100%, 290px); padding: 12px; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow), var(--glow); }
  .qr-wrap img { width: 100%; border-radius: 10px; }

  /* Buttons */
  .btn {
    position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; border: 0; border-radius: 14px; padding: 15px 18px;
    font-weight: 800; font-size: 16px; cursor: pointer; text-decoration: none; color: var(--on-accent); background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: var(--glow);
    transition: transform .12s ease, filter .15s, opacity .15s;
  }
  .btn:active { transform: scale(.98); }
  .btn:hover { filter: brightness(1.08); }
  .btn[disabled] { opacity: .45; cursor: not-allowed; filter: grayscale(.4); }
  .btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
  .btn.small { width: auto; padding: 9px 14px; font-size: 14px; border-radius: 11px; }

  /* Upload */
  .drop { display: flex; align-items: center; gap: 12px; padding: 14px; border: 2px dashed var(--border); border-radius: var(--radius-sm); cursor: pointer; background: var(--surface-2); }
  .drop:hover { border-color: var(--accent); }
  .drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
  .drop .ico { font-size: 26px; }
  .preview { max-width: 140px; max-height: 180px; border-radius: 10px; margin-top: 10px; border: 1px solid var(--border); }

  /* Sticky cart bar */
  .cartbar {
    position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); translate: -50% 0; z-index: 30; width: min(calc(100% - 24px), 696px);
    display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; border-radius: 18px; color: var(--text);
    background: color-mix(in srgb, var(--surface) 82%, transparent); border: 1px solid var(--border); box-shadow: var(--shadow), var(--glow);
    backdrop-filter: blur(16px) saturate(1.5); -webkit-backdrop-filter: blur(16px) saturate(1.5); transition: translate .3s cubic-bezier(.2,.9,.3,1.2), opacity .3s;
  }
  .cartbar.off { translate: -50% 140%; opacity: 0; }
  .cartbar .sum { flex: 1; line-height: 1.2; }
  .cartbar .sum b { font-family: var(--font-head); font-size: 18px; }
  .cartbar .btn { width: auto; padding: 12px 18px; }

  /* Status page */
  .status-hero { text-align: center; padding: 26px 18px; }
  .status-icon { width: 76px; height: 76px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center; font-size: 34px; background: color-mix(in srgb, var(--s, var(--accent)) 16%, transparent); box-shadow: 0 0 0 8px color-mix(in srgb, var(--s, var(--accent)) 8%, transparent); }
  .status-icon.pulse { animation: pulse 1.8s ease-in-out infinite; }
  @keyframes pulse { 50% { box-shadow: 0 0 0 16px color-mix(in srgb, var(--s, var(--accent)) 4%, transparent); } }
  .code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 24px; font-weight: 800; letter-spacing: 3px; }
  .chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
  .chip.pending, .chip.need_link { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
  .chip.processing { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
  .chip.success { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
  .chip.failed, .chip.rejected, .chip.partial { background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--bad); }
  .progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 14px auto 0; max-width: 320px; }
  .progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: inherit; transition: width .6s ease; }
  .items { list-style: none; padding: 0; margin: 0; }
  .items li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .items li:last-child { border-bottom: 0; }
  .items .link { font-size: 12px; color: var(--muted); word-break: break-all; }
  .items .item-main { flex: 1; min-width: 0; }
  .items .item-game { flex: none; width: 36px; height: 36px; border-radius: 10px; object-fit: cover; }
  .items .item-game.ph { display: grid; place-items: center; font-weight: 800; color: var(--on-accent); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

  footer.site { text-align: center; font-size: 12px; color: var(--muted); padding: 24px 12px 8px; }
  footer.site a { color: inherit; }
}

/* ---------- Members: credit box at checkout, member area (member.html) ---------- */
@layer components {
  .row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
  .row.between { justify-content: space-between; }
  .kv { font-size: 13px; color: var(--muted); word-break: break-word; }
  .credit-box { border: 1.5px solid var(--accent); border-radius: var(--radius-sm); padding: 12px 14px; margin: 6px 0 4px; background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
  .credit-box .row { padding: 3px 0; font-size: 14.5px; }
  .credit-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
  .credit-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface-2); }
  .credit-card small { display: block; color: var(--muted); font-size: 12.5px; }
  .credit-card b { display: block; font-size: 22px; margin-top: 4px; font-family: var(--font-head); }
  .credit-card.main { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
  .credit-card.main b { font-size: 28px; }
  .m-orders { list-style: none; padding: 0; margin: 0; }
  .m-order { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
  .m-order:last-child { border-bottom: 0; }
  .m-order:hover { background: var(--surface-2); }
  .m-order .item-main { flex: 1; min-width: 0; }
  .m-ico { font-size: 22px; width: 32px; text-align: center; }
  .m-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
  .m-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
  .m-table th, .m-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
  .m-table .num { text-align: right; white-space: nowrap; }
  .mfa-qr { width: 200px; height: 200px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 12px; }
  .mfa-key { font-size: 15px; letter-spacing: 1px; word-break: break-all; }
  .status-head { display: flex; gap: 14px; align-items: center; }
  .status-head .status-icon { margin: 0; flex: none; width: 60px; height: 60px; font-size: 28px; }
  .status-head h2 { margin: 0; }
  /* 📊 orders fulfilled counter (hero) */
  .stats-pill { display: inline-block; margin-top: 12px; padding: 7px 14px; border-radius: 999px; font-weight: 700; font-size: 14px;
    color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); }
  /* 🏦 bank transfer details (copy buttons) */
  .pay-details { display: grid; gap: 8px; margin: 6px 0 12px; }
  .pd-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
  .pd-val { font-weight: 700; font-size: 16px; word-break: break-all; }
  .copy-btn { flex: none; min-width: 78px; }
}

/* ---------- Maintenance notice + member inbox ---------- */
@layer components {
  .maint { text-align: center; border: 1.5px solid color-mix(in srgb, var(--warn) 55%, transparent); background: color-mix(in srgb, var(--warn) 8%, var(--surface)); }
  .maint h2 { margin: 6px 0 8px; }
  .maint-img { display: block; max-width: min(100%, 560px); max-height: 340px; object-fit: contain; margin: 0 auto 10px; border-radius: var(--radius-sm); }
  .maint-msg { white-space: pre-wrap; margin: 0 auto; max-width: 60ch; }
  .maint-when { font-weight: 600; margin: 10px 0 0; }
  .maint.compact { text-align: left; padding: 12px 14px; }
  .maint.compact h2 { font-size: 16px; margin: 0 0 4px; }
  .maint-soon { font-size: 13.5px; border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; background: color-mix(in srgb, var(--warn) 12%, var(--surface)); color: color-mix(in srgb, var(--warn) 80%, var(--text)); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
  .inbox { list-style: none; padding: 0; margin: 0; }
  .inbox li { border-bottom: 1px solid var(--border); padding: 12px 4px; cursor: pointer; }
  .inbox li:last-child { border-bottom: 0; }
  .inbox li.unread .ib-title { font-weight: 800; }
  .inbox .ib-head { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
  .inbox .ib-body { white-space: pre-wrap; word-break: break-word; margin-top: 6px; font-size: 14px; }
  .inbox .ib-body.clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); }
  .badge-n { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 999px; font-size: 11.5px; line-height: 18px; text-align: center; background: var(--bad); color: #fff; font-weight: 700; margin-left: 4px; }
  .dot-new { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
}

/* ---------- Member top-up (2026-11-09) ---------- */
@layer components {
  .credit-card .credit-fx { display: flex; flex-direction: column; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
  .credit-card .topup-btn { margin-top: 10px; }
  .qr-box { text-align: center; margin-top: 8px; }
  .qr-box .qr-wrap img { max-width: 240px; width: 100%; }
}
