:root {
  color-scheme: light;

  --bg: #ffffff;
  --bg-soft: #f7f7f8;
  --card: #ffffff;
  --card-hover: #fbfbfc;
  --line: #e8e9ec;
  --line-soft: #f2f3f5;

  --text: #1a1a1a;
  --muted: #8a8f99;
  --muted-dim: #b0b4bd;

  /* DeepSeek 蓝 */
  --brand: #4d6bfe;
  --brand-strong: #3b5bfd;
  --brand-deep: #16308f;
  --brand-soft: #eef2ff;
  --brand-line: #dbe3ff;

  /* 正文/价格用的深一点，白底上看得清 */
  --accent: #2b47e0;

  --ok: #059669;
  --err: #dc2626;

  --shadow-sm: 0 1px 2px rgba(20, 24, 40, 0.03);
  --shadow-md: 0 4px 16px rgba(20, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(20, 24, 40, 0.08);

  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", "Noto Sans TC", "Hiragino Sans CNS", "Heiti TC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

::selection { background: #dbe3ff; color: var(--brand-deep); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.2px;
  color: var(--text);
  min-width: 0;
}

.brand-mark {
  display: block;
  width: 38px;
  height: 38px;
  flex: none;
}

.brand-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .spacer { flex: 1; }

.topbar .tag {
  font-size: 12px;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  transition: color 0.15s, border-color 0.15s;
}

.topbar a.tag:hover { border-color: var(--brand-line); color: var(--brand); }

/* ---------- 容器 ---------- */
.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.narrow { max-width: 720px; }

/* ---------- 首屏 ---------- */
.hero { padding: 56px 0 36px; }

.hero h1 {
  margin: 0 0 12px;
  font-size: 34px;
  line-height: 1.25;
  letter-spacing: -0.5px;
  color: var(--text);
}

.hero h1 em {
  font-style: normal;
  color: var(--brand-strong);
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  max-width: 560px;
}

/* ---------- 商品网格 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.card {
  position: relative;
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
}

.card:hover {
  border-color: var(--brand-line);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(77, 107, 254, 0.1);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.card-icon {
  width: 52px;
  height: 52px;
  border-radius: 13px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  color: var(--brand-strong);
  display: grid;
  place-items: center;
  flex: none;
  overflow: hidden;
}

.card-icon img,
.detail-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
}

.card-name {
  font-size: 15.5px;
  font-weight: 650;
  line-height: 1.35;
  color: var(--text);
}

.card-ver {
  font-size: 11.5px;
  color: var(--muted-dim);
  font-variant-numeric: tabular-nums;
}

.card-desc {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.65;
  margin: 0;
  max-height: calc(1.65em * 4); /* 四行，超出就切 */
  overflow: hidden;
}

/* 按鈕浮到右下角：前兩行滿寬，後兩行給它讓位 */
.card-float {
  float: right;
  margin: 45px 0 6px 14px;
}

.price {
  font-size: 21px;
  font-weight: 750;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}

.price small {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-dim);
  margin-left: 8px;
  letter-spacing: 0;
}

.price.is-free { color: #b45309; }

.price.none {
  font-size: 20px;
  font-weight: 650;
  color: var(--muted-dim);
  letter-spacing: 0;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.btn:hover { background: var(--bg-soft); border-color: #dcdfe4; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(77, 107, 254, 0.28);
}

.btn-primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

.btn-block { width: 100%; padding: 13px 16px; font-size: 15px; }

.btn-ghost { background: transparent; }

/* ---------- 详情页 ---------- */
.detail {
  margin-top: 40px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px;
}

.detail-top {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.detail-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  color: var(--brand-strong);
  display: grid;
  place-items: center;
  flex: none;
}

.detail h1 {
  margin: 0 0 4px;
  font-size: 23px;
  letter-spacing: -0.3px;
  color: var(--text);
}

.detail .meta {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.detail .body {
  color: #3d4046;
  font-size: 14.5px;
  line-height: 1.85;
  white-space: pre-wrap;
  border-top: 1px solid var(--line-soft);
  padding-top: 20px;
  margin-top: 4px;
}

.buy-box {
  margin-top: 26px;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.buy-box .amount {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.buy-box .amount .price { font-size: 30px; }

.buy-box .hint {
  color: var(--muted-dim);
  font-size: 12.5px;
}

.buy-box .hint s { color: var(--muted-dim); }

/* ---------- 支付页 ---------- */
.pay-wrap {
  margin-top: 40px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px;
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted-dim);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.pay-amount {
  font-size: 42px;
  font-weight: 780;
  color: var(--accent);
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 2px;
}

.pay-meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.pay-meta b { color: var(--text); font-weight: 600; }

.qr-box {
  aspect-ratio: 1;
  max-width: 260px;
  margin: 0 auto 18px;
  border-radius: 14px;
  border: 1px dashed #dcdfe4;
  background: var(--bg-soft);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
}

.qr-box img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; }

.qr-box .ph {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
}

.qr-box .ph strong {
  display: block;
  color: var(--accent);
  font-size: 14px;
  margin-bottom: 6px;
  letter-spacing: 0.4px;
}

.status-line {
  text-align: center;
  font-size: 13.5px;
  color: var(--muted);
  padding: 12px 0 0;
  min-height: 22px;
}

.status-line .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  margin-right: 7px;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.order-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.order-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}

.order-list li:last-child { border-bottom: 0; }

.order-list .k { color: var(--muted-dim); flex: none; }

.order-list .v {
  color: var(--text);
  text-align: right;
  word-break: break-all;
  font-variant-numeric: tabular-nums;
}

.ok-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ok);
  font-weight: 650;
  font-size: 14px;
}

.hidden { display: none !important; }

.dl-box {
  text-align: center;
  padding: 8px 0 4px;
}

.dl-box .ok-title {
  font-size: 19px;
  font-weight: 700;
  margin: 4px 0 6px;
  color: var(--text);
}

.dl-box .ok-sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 22px;
  line-height: 1.7;
}

.dl-link {
  display: block;
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted-dim);
  word-break: break-all;
}

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(12px);
  background: #1f2229;
  border: 1px solid #111827;
  color: #f9fafb;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  max-width: 90vw;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--err); border-color: #b91c1c; color: #fff; }

/* ---------- 其它 ---------- */
.center-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg-soft);
}

.notice {
  max-width: 460px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 40px 32px;
  box-shadow: var(--shadow-md);
}

.notice h1 { font-size: 22px; margin: 0 0 10px; color: var(--text); }
.notice p { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

.skeleton {
  height: 168px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #f4f5f7 25%, #eceef1 37%, #f4f5f7 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
}

.skeleton-tall { height: 120px; }

.empty-tip { color: var(--muted); }

@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.footer {
  text-align: center;
  color: var(--muted-dim);
  font-size: 12.5px;
  padding: 40px 24px 0;
  line-height: 2;
}

.footer a { color: var(--muted); }
.footer a:hover { color: var(--brand-strong); }

/* ---------- 轉盤 ---------- */
.wheel-stage {
  padding: 48px 0 60px;
  text-align: center;
}

.wheel-title {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.25;
  letter-spacing: -0.5px;
  color: var(--text);
  text-wrap: balance;
}

.wheel-sub {
  margin: 0 0 30px;
  color: var(--muted);
  font-size: 14px;
}

.wheel-box {
  position: relative;
  width: min(340px, 80vw);
  aspect-ratio: 1;
  margin: 0 auto;
}

#wheel {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 12px 44px rgba(77, 107, 254, 0.16), 0 2px 8px rgba(20, 24, 40, 0.06);
  will-change: transform;
}

.wheel-pointer {
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 19px solid #16308f;
  filter: drop-shadow(0 0 3px #ffffff) drop-shadow(0 1px 2px rgba(20, 24, 40, 0.25));
  z-index: 3;
}

.wheel-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 12.5px;
}

.wheel-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.wheel-legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.dot-free { background: #f5b301; }
.dot-paid { background: var(--brand); }

.wheel-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 5px solid #ffffff;
  background: var(--brand);
  color: #ffffff;
  font-family: inherit;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  text-indent: 2px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(77, 107, 254, 0.35);
  transition: transform 0.15s, background 0.15s;
  z-index: 3;
}

.wheel-btn:hover:not(:disabled) {
  background: var(--brand-strong);
  transform: translate(-50%, -50%) scale(1.05);
}

.wheel-btn:disabled { cursor: default; opacity: 0.8; }

/* ---------- 結果彈窗 ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 22, 44, 0.45);
  backdrop-filter: blur(6px);
  animation: fade-in 0.18s ease;
}

.modal-card {
  position: relative;
  width: min(440px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 20px;
  padding: 34px 28px 24px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(16, 24, 40, 0.25);
  animation: pop-in 0.26s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to { opacity: 1; transform: none; }
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--muted-dim);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
}

.modal-close:hover { color: var(--text); background: var(--bg-soft); }

.modal-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}

.modal-price-label {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.modal-price {
  font-size: 54px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -2px;
  line-height: 1.1;
  margin: 2px 0 10px;
  font-variant-numeric: tabular-nums;
}

.modal-price.is-free { color: #b45309; }

.modal-unit {
  font-size: 28px;
  font-weight: 700;
  color: inherit;
  margin-left: 10px;
  letter-spacing: 0;
}

.modal-sub {
  color: var(--muted);
  font-size: 13.5px;
  margin-bottom: 18px;
}

.modal-action { margin-bottom: 16px; }

.modal-foot {
  color: var(--muted-dim);
  font-size: 11.5px;
  letter-spacing: 0.8px;
  font-variant-numeric: tabular-nums;
}

.notice-text {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
  margin: 14px 0 22px;
}

body.modal-open { overflow: hidden; }

/* 彈窗裡不顯示捲軸：原生捲軸會把圓角蓋成直角，滾輪照常可捲 */
.modal-card {
  scrollbar-width: none;
  overscroll-behavior: contain;
}

.modal-card::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.reopen-btn { margin-top: 18px; }

/* ---------- 選擇應用頁 ---------- */
.pick-stage { padding: 40px 0 60px; }

.pick-title {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: -0.4px;
  color: var(--text);
}

.pick-sub {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
}

.pick-sub b {
  color: var(--accent);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.price small s { color: var(--muted-dim); }

.pending-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 0 20px;
  padding: 14px 18px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  border-radius: 12px;
  color: var(--brand-deep);
  font-size: 13.5px;
}

.pending-bar b {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.pending-bar .btn {
  padding: 7px 14px;
  font-size: 13px;
}

.wheel-tip {
  margin-top: 24px;
  color: var(--muted-dim);
  font-size: 12.5px;
}

.orders-link {
  display: inline-block;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 2px;
  transition: color 0.15s, border-color 0.15s;
}

.orders-link:hover {
  color: var(--brand-strong);
  border-color: var(--brand-line);
}

/* ---------- 我的訂單 ---------- */
.order-cards {
  display: grid;
  gap: 12px;
}

.order-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.order-main { min-width: 0; }

.order-name {
  font-weight: 650;
  font-size: 15px;
  color: var(--text);
}

.order-sub {
  margin-top: 4px;
  color: var(--muted-dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.order-side {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: none;
}

.order-amount {
  color: var(--accent);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.order-state {
  color: var(--muted-dim);
  font-size: 12.5px;
}

.empty-orders {
  text-align: center;
  padding: 40px 0;
  color: var(--muted);
}

.empty-orders p { margin: 0 0 18px; }

@media (max-width: 720px) {
  .hero { padding: 36px 0 26px; }
  .hero h1 { font-size: 26px; }
  .wrap { padding: 0 16px 60px; }
  .topbar { padding: 12px 16px; gap: 8px; }
  .brand { font-size: 14px; gap: 8px; }
  .brand-mark { width: 32px; height: 32px; }
  .detail { padding: 22px; margin-top: 24px; }
  .detail-icon { width: 52px; height: 52px; }
  .pay-wrap { grid-template-columns: 1fr; margin-top: 24px; }
  .pay-amount { font-size: 34px; }
  .panel { padding: 20px; }
  .wheel-stage { padding: 32px 0 44px; }
  .wheel-title { font-size: 23px; }
  .wheel-sub { font-size: 13px; margin-bottom: 24px; }
  .wheel-btn { width: 74px; height: 74px; font-size: 19px; border-width: 4px; }
  .result-price { font-size: 38px; }
  .order-card { flex-direction: column; align-items: flex-start; }
  .order-side { width: 100%; justify-content: space-between; }
}

/* 站名比较长，窄屏把右上角标签让出来 */
@media (max-width: 560px) {
  .topbar .tag { display: none; }
}
