:root {
  --bg: #0e0a22;
  --card: #1c1545;
  --card-2: #251c57;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f5f2ff;
  --muted: #a9a1d2;
  --gold: #ffc940;
  --gold-2: #ff9f1c;
  --pink: #ff4d8d;
  --green: #2fd48a;
  --red: #ff5a6a;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 600px at 50% -10%, #3b1f8a 0%, transparent 60%),
    radial-gradient(700px 500px at 100% 100%, #4a1450 0%, transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
.hidden { display: none !important; }
/* 多語系：字典載入前先隱藏，避免閃過其他語言 */
.i18n-wait body { visibility: hidden; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ─── 導覽列 ─── */
.nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: rgba(14, 10, 34, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand-icon { font-size: 22px; }
.links { display: flex; gap: 4px; flex: 1; }
.links a {
  color: var(--muted); text-decoration: none; white-space: nowrap;
  padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: 15px;
}
.links a:hover { color: var(--text); background: var(--line); }
.links a.active { color: #1a1140; background: var(--gold); }
.user-box { display: flex; align-items: center; gap: 8px; }
.lang-select {
  padding: 6px 8px; border-radius: 999px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25);
  color: var(--text); font: inherit; font-size: 13px; cursor: pointer; max-width: 140px;
}
.lang-select option { color: #111; }
.user-box .email { color: var(--muted); font-size: 14px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
  .nav { flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  .brand { flex: 1; }
  .links { order: 3; flex-basis: 100%; overflow-x: auto; }
  .user-box { flex-wrap: wrap; justify-content: flex-end; }
  .user-box .email { display: none; }
  .lang-select { max-width: 120px; }
}

.container { max-width: 1100px; margin: 0 auto; padding: 32px 16px 64px; }
.page-title { font-size: 28px; font-weight: 800; margin-bottom: 6px; }
.page-sub { color: var(--muted); margin: 0 0 24px; }

/* ─── 按鈕 ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 20px; border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; text-decoration: none;
  transition: transform 0.1s, filter 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: #2a1600; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--line); }
.btn-success { background: var(--green); color: #05311d; }
.btn-danger { background: transparent; color: var(--red); border-color: rgba(255, 90, 106, 0.4); }
.btn-danger:hover:not(:disabled) { background: rgba(255, 90, 106, 0.12); }
.btn-sm { padding: 6px 14px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }

/* ─── 卡片 / 表單 ─── */
.card {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
.card + .card { margin-top: 20px; }
.card-title { font-size: 18px; font-weight: 800; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25); color: var(--text);
  font: inherit; font-size: 16px; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 201, 64, 0.18); }
.input::placeholder { color: #6f679a; }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; min-width: 0; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

.auth-wrap { max-width: 440px; margin: 24px auto; }
.auth-wrap .card { padding: 32px 28px; }
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head .icon { font-size: 44px; }
.auth-head h1 { font-size: 24px; margin-top: 8px; }
.auth-foot { text-align: center; margin-top: 18px; color: var(--muted); font-size: 14px; }
.row-between { display: flex; justify-content: space-between; align-items: center; }

/* ─── 首頁 / 轉盤 ─── */
.hero { text-align: center; margin-bottom: 28px; }
.hero h1 {
  font-size: clamp(30px, 6vw, 48px); font-weight: 900; letter-spacing: 1px; overflow-wrap: anywhere;
  background: linear-gradient(90deg, #ffe38a, #ffb347, #ff6fa5);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { color: var(--muted); margin: 8px 0 0; font-size: 17px; }

.home-grid { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.home-grid > * { min-width: 0; } /* 避免轉盤畫布把手機畫面撐寬 */
@media (max-width: 900px) { .home-grid { grid-template-columns: 1fr; } }

.wheel-card { display: flex; flex-direction: column; align-items: center; padding: 36px 20px 28px; }
.wheel-wrap { position: relative; width: min(460px, 100%); aspect-ratio: 1; }
.wheel-wrap canvas {
  width: 100%; height: 100%; display: block; border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(255, 201, 64, 0.12), 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 90px rgba(255, 160, 40, 0.22);
}
.wheel-wrap.spinning canvas { animation: glow 0.8s ease-in-out infinite alternate; }
@keyframes glow {
  to { box-shadow: 0 0 0 6px rgba(255, 201, 64, 0.25), 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 130px rgba(255, 160, 40, 0.5); }
}
.pointer {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%); z-index: 3;
  width: 0; height: 0;
  border-left: 18px solid transparent; border-right: 18px solid transparent;
  border-top: 36px solid #ff3b5c;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.5));
}
.spin-btn {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 3;
  width: 25%; aspect-ratio: 1; border-radius: 50%;
  border: 5px solid #fff3c4;
  background: radial-gradient(circle at 35% 30%, #ff7aa8, #e0115f 70%);
  color: #fff; font: inherit; font-weight: 900; font-size: clamp(16px, 4.2vw, 24px); letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), inset 0 -4px 0 rgba(0, 0, 0, 0.2);
  transition: transform 0.15s;
}
.spin-btn:hover:not(:disabled) { transform: translate(-50%, -50%) scale(1.05); }
.spin-btn:disabled { filter: grayscale(0.5) brightness(0.85); cursor: not-allowed; }

.spin-info { margin-top: 24px; text-align: center; }
.chip {
  display: inline-flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; padding: 8px 18px; border-radius: 999px;
  background: rgba(255, 201, 64, 0.12); border: 1px solid rgba(255, 201, 64, 0.3);
  color: var(--gold); font-weight: 700;
}
.chip b { font-size: 20px; }
.spin-info .hint { margin-top: 10px; }

.win-list { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: hidden; }
.win-list li { display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.win-list li:last-child { border-bottom: 0; }
.win-list .prize { color: var(--gold); font-weight: 700; white-space: nowrap; }
.empty { color: var(--muted); text-align: center; padding: 20px 0; font-size: 14px; }

.rules { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; }
.rules li { margin-bottom: 6px; }
.rules b { color: var(--text); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }

/* ─── 統計卡片 ─── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.stat .label { color: var(--muted); font-size: 14px; font-weight: 600; }
.stat .value { font-size: 28px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 14px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.stat.highlight { background: linear-gradient(135deg, #5b2bd6, #b0247a); border-color: transparent; }
.stat.highlight .label { color: rgba(255, 255, 255, 0.8); }

/* ─── 推薦 ─── */
.ref-box { display: flex; gap: 8px; flex-wrap: wrap; }
.ref-box .input { flex: 1; min-width: 220px; font-family: ui-monospace, Consolas, monospace; font-size: 15px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.step { text-align: center; padding: 8px; }
.step .n {
  width: 44px; height: 44px; border-radius: 50%; margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 201, 64, 0.15); color: var(--gold); font-weight: 900; font-size: 18px;
}
.step p { margin: 0; color: var(--muted); font-size: 14px; }
.step b { display: block; color: var(--text); margin-bottom: 2px; font-size: 15px; }

.progress { height: 14px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); overflow: hidden; margin-bottom: 8px; }
.progress-bar { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--gold-2), var(--gold)); transition: width 0.6s ease; }
.progress-bar.off { background: #5b5480; }
.notice {
  padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; font-size: 14px;
  background: rgba(255, 201, 64, 0.1); border: 1px solid rgba(255, 201, 64, 0.35); color: #ffe39a;
}

/* ─── 表格 ─── */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; font-size: 13px; }
.table td.wrap { white-space: normal; word-break: break-all; min-width: 160px; }
.table .pos { color: var(--green); font-weight: 700; }
.table .neg { color: var(--red); font-weight: 700; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.pending { background: rgba(255, 201, 64, 0.15); color: var(--gold); }
.badge.approved { background: rgba(47, 212, 138, 0.15); color: var(--green); }
.badge.rejected { background: rgba(255, 90, 106, 0.15); color: var(--red); }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 7px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
}
.tab.active { background: var(--gold); color: #2a1600; border-color: transparent; }

.account-grid { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
.account-grid .card + .card { margin-top: 0; }
.account-grid > * { min-width: 0; } /* 表格太寬時在框內左右滑動，不撐寬手機畫面 */
@media (max-width: 900px) { .account-grid { grid-template-columns: 1fr; } }

/* ─── 提示訊息 / 彈窗 ─── */
#toast {
  position: fixed; top: 18px; left: 50%; transform: translate(-50%, -140%); z-index: 100;
  max-width: calc(100vw - 32px); padding: 12px 20px; border-radius: 12px;
  background: #2a2160; border: 1px solid var(--line); color: var(--text); font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); transition: transform 0.25s ease;
}
#toast.show { transform: translate(-50%, 0); }
#toast.error { border-color: rgba(255, 90, 106, 0.6); }
#toast.success { border-color: rgba(47, 212, 138, 0.6); }

.modal {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(5, 3, 15, 0.7); backdrop-filter: blur(4px);
}
.modal-card {
  width: 100%; max-width: 360px; text-align: center; padding: 32px 24px;
  background: linear-gradient(180deg, #3a2485, #1f1650); border: 1px solid rgba(255, 201, 64, 0.35); border-radius: 22px;
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.modal-card .emoji { font-size: 64px; line-height: 1; }
.modal-card h3 { font-size: 22px; margin: 14px 0 6px; }
.modal-card .amount { font-size: 40px; font-weight: 900; color: var(--gold); margin: 6px 0; }
.modal-card p { color: var(--muted); margin: 0 0 22px; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .modal-card, .wheel-wrap.spinning canvas { animation: none; }
}
