/* 配電工坊 平台樣式（深色工業風：深藍底＋警示黃） */
:root {
  --bg: #0b1220;
  --bg-2: #0f1830;
  --surface: #131d33;
  --surface-2: #1a2742;
  --line: #26365a;
  --line-2: #33476e;
  --text: #e8edf6;
  --muted: #9fb0cc;
  --faint: #6f82a3;
  --accent: #ffc24a;
  --accent-ink: #1a1204;
  --accent-soft: rgba(255, 194, 74, 0.14);
  --ok: #3ccf8e;
  --ok-soft: rgba(60, 207, 142, 0.14);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);
  --info-soft: rgba(90, 160, 255, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(255, 194, 74, 0.08), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(58, 160, 255, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--font);
}
main { flex: 1; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { width: min(1120px, 100%); margin: 0 auto; padding: 0 16px; }
.narrow { width: min(460px, 100%); }
.prose { width: min(760px, 100%); }

/* ---------- 頁首 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(11, 18, 32, 0.82);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; letter-spacing: 0.06em; font-size: 18px; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.site-nav { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: none; }

/* 分頁：桌機在頁首 */
.tab-nav { display: flex; align-items: stretch; gap: 2px; margin-left: 24px; height: 100%; }
.tab-nav a {
  position: relative; display: inline-flex; align-items: center; padding: 0 14px;
  color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 700; white-space: nowrap;
}
.tab-nav a:hover { color: var(--text); }
.tab-nav a[aria-current="page"] { color: var(--text); }
.tab-nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent);
}

/* 分頁：手機在畫面下方 */
.tab-bar { display: none; }
@media (max-width: 760px) {
  .tab-nav { display: none; }
  .tab-bar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding: 6px 4px max(6px, env(safe-area-inset-bottom));
    background: rgba(11, 18, 32, 0.94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
  }
  .tab-bar a {
    display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0;
    color: var(--faint); text-decoration: none; font-size: 11px; font-weight: 700; border-radius: 10px;
  }
  .tab-bar svg { width: 22px; height: 22px; }
  .tab-bar a[aria-current="page"] { color: var(--accent); }
  body.has-tab-bar { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
}
.site-nav a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; padding: 8px 10px; border-radius: 8px; }
.site-nav a:hover { color: var(--text); background: var(--surface); }
.site-nav .btn { color: var(--accent-ink); }
.user-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 180px; }
.user-chip .avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 12px; font-weight: 800; flex: none; }
.user-chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 頁尾 ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 64px; padding: 24px 0 32px; color: var(--faint); font-size: 13px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); }
.site-footer .spacer { flex: 1; }

/* ---------- 按鈕、表單 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  font: 700 15px/1 var(--font); text-decoration: none; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #ffcf6e; border-color: #ffcf6e; }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: rgba(255, 107, 107, 0.5); color: var(--danger); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-google { background: #fff; color: #1f1f1f; border-color: #fff; }
.btn-google:hover { background: #f1f1f1; border-color: #f1f1f1; }
.btn-google svg { width: 18px; height: 18px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 14px; font-weight: 600; color: var(--muted); }
.field input {
  width: 100%; min-height: 46px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text);
  font: 16px var(--font);
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .hint { font-size: 13px; color: var(--faint); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 64px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); font: 600 13px var(--font); padding: 8px; cursor: pointer; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 13px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- 訊息 ---------- */
.notice { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; line-height: 1.6; margin-bottom: 14px; border: 1px solid transparent; }
.notice:empty { display: none; }
.notice-info { background: var(--info-soft); border-color: rgba(90, 160, 255, 0.3); color: #cfe1ff; }
.notice-ok { background: var(--ok-soft); border-color: rgba(60, 207, 142, 0.35); color: #c8f5df; }
.notice-error { background: var(--danger-soft); border-color: rgba(255, 107, 107, 0.4); color: #ffd1d1; }
.notice-warn { background: var(--accent-soft); border-color: rgba(255, 194, 74, 0.4); color: #ffe3a6; }
.notice .btn { margin-top: 10px; }

/* ---------- 卡片面板 ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 20px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.panel h2 { margin: 0 0 4px; font-size: 18px; }
.panel .sub { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.page-head { padding: 40px 0 20px; }
.page-head h1 { margin: 0 0 6px; font-size: 26px; }
.page-head p { margin: 0; color: var(--muted); }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 20px; }
.tabs button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: 700 15px var(--font); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 0 var(--line-2) inset; }

.links-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; margin-top: 4px; }
.links-row a { text-decoration: none; }

/* ---------- 首頁 ---------- */
.hero { padding-top: 56px; padding-bottom: 28px; }
.hero-eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; letter-spacing: 0.12em; color: var(--accent); text-transform: uppercase; }
.hero-eyebrow::before { content: ""; width: 22px; height: 3px; background: repeating-linear-gradient(135deg, var(--accent) 0 6px, transparent 6px 10px); }
.hero h1 { margin: 12px 0 12px; font-size: clamp(30px, 6vw, 48px); line-height: 1.15; letter-spacing: 0.02em; }
.hero p { margin: 0; color: var(--muted); max-width: 560px; font-size: 17px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 20px; color: var(--faint); font-size: 14px; }
.hero-meta span { display: inline-flex; align-items: center; gap: 6px; }
.hero-meta span::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }

.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 28px 0 14px; }
.section-title h2 { margin: 0; font-size: 20px; }
.section-title span { color: var(--faint); font-size: 14px; }

.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.game-card {
  --c: var(--accent);
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; color: var(--text); text-decoration: none;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.game-card:hover { border-color: color-mix(in srgb, var(--c) 60%, var(--line)); transform: translateY(-2px); box-shadow: var(--shadow); }
.game-cover {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--c) 34%, transparent), transparent 70%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 22px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 22px),
    var(--bg-2);
  display: grid; place-items: center;
}
.game-cover img { width: 46%; max-width: 120px; aspect-ratio: 1; object-fit: contain; border-radius: 22%; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }
.game-cover .mono { font-size: 44px; font-weight: 900; color: var(--c); letter-spacing: 0.04em; text-shadow: 0 6px 30px color-mix(in srgb, var(--c) 50%, transparent); }
.game-body { display: flex; flex-direction: column; gap: 8px; padding: 16px 16px 18px; flex: 1; }
.game-body h3 { margin: 0; font-size: 18px; }
.game-body p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; color: var(--muted); background: var(--bg-2); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; }
.badge { position: absolute; top: 10px; left: 10px; font-size: 12px; font-weight: 800; padding: 4px 9px; border-radius: 7px; background: rgba(11, 18, 32, 0.78); border: 1px solid var(--line-2); color: var(--text); backdrop-filter: blur(4px); }
.badge-free { color: var(--ok); border-color: rgba(60, 207, 142, 0.45); }
.badge-trial { color: var(--accent); border-color: rgba(255, 194, 74, 0.45); }
.play { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; color: var(--c); margin-top: 4px; }

/* ---------- 帳號頁 ---------- */
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 10px 12px; font-size: 15px; margin: 0; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; word-break: break-all; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form .field { flex: 1 1 200px; margin: 0; }
.inline-form .btn { align-self: end; }
.owned-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.owned-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-2); font-size: 15px; }
.status { font-size: 13px; font-weight: 700; }
.status-on { color: var(--ok); }
.status-off { color: var(--faint); }
.danger-zone { border-color: rgba(255, 107, 107, 0.35); }
.code-input { font-family: var(--mono) !important; letter-spacing: 0.12em; text-transform: uppercase; }

/* ---------- 文件頁 ---------- */
.prose h1 { font-size: 28px; margin: 40px 0 8px; }
.prose h2 { font-size: 19px; margin: 32px 0 8px; }
.prose p, .prose li { color: #cdd6e6; }
.prose .updated { color: var(--faint); font-size: 14px; }

/* ---------- 首頁分類入口 ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.cat-card {
  display: flex; flex-direction: column; gap: 10px; padding: 22px 20px;
  background: linear-gradient(150deg, var(--surface-2), var(--surface)); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); text-decoration: none; transition: border-color 0.15s, transform 0.15s;
}
.cat-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.cat-card .icon { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.cat-card .icon svg { width: 24px; height: 24px; }
.cat-card h3 { margin: 0; font-size: 19px; }
.cat-card p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
.cat-card .count { color: var(--accent); font-weight: 700; font-size: 14px; }

/* ---------- 購買方案 ---------- */
.plan-list { display: grid; gap: 16px; }
.plan { --c: var(--accent); display: grid; grid-template-columns: 1fr auto; gap: 16px 24px; align-items: center; padding: 22px 20px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: var(--radius); }
.plan h3 { margin: 0 0 10px; font-size: 19px; }
.plan dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
.plan dt { color: var(--faint); white-space: nowrap; }
.plan dd { margin: 0; color: var(--muted); }
.plan dd.full { color: var(--text); }
.plan .buy { display: grid; justify-items: end; gap: 8px; min-width: 150px; }
.plan .price { font-size: 26px; font-weight: 900; color: var(--text); font-variant-numeric: tabular-nums; }
.plan .price small { font-size: 14px; color: var(--faint); font-weight: 600; margin-left: 2px; }
.plan .price.tbd { font-size: 15px; color: var(--faint); font-weight: 700; }
.plan .owned { color: var(--ok); font-weight: 700; font-size: 14px; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; color: var(--muted); font-size: 15px; }
.steps li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.pay-methods { display: flex; flex-wrap: wrap; gap: 8px; }
.faq details { border-top: 1px solid var(--line); padding: 12px 0; }
.faq details:first-child { border-top: 0; }
.faq summary { cursor: pointer; font-weight: 700; }
.faq p { margin: 8px 0 0; color: var(--muted); font-size: 15px; }

/* ---------- 訂單 ---------- */
.order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.order-list li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-2); }
.order-list .o-name { font-weight: 700; }
.order-list .o-amount { font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.order-list .o-meta { color: var(--faint); font-size: 13px; font-family: var(--mono); }
.order-list .o-status { text-align: right; font-size: 13px; font-weight: 700; }
.empty { color: var(--faint); font-size: 14px; padding: 14px; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); text-align: center; }

.skeleton { color: var(--faint); font-size: 14px; }
.hidden { display: none !important; }
.center { text-align: center; }

@media (max-width: 560px) {
  .site-header .wrap { height: 56px; }
  .brand { font-size: 16px; }
  .user-chip .name { display: none; }
  .hero { padding-top: 36px; padding-bottom: 20px; }
  .panel { padding: 20px 16px; }
  .kv { grid-template-columns: 80px 1fr; }
  .plan { grid-template-columns: 1fr; }
  .plan .buy { justify-items: stretch; }
  .plan .buy .btn { width: 100%; }
  .site-footer { margin-top: 40px; }
}
