:root {
  --bg: #050608;
  --panel: #101114;
  --panel-2: #17191d;
  --line: #2a2d33;
  --text: #ece8e1;
  --muted: #8b8f98;
  --gold: #e8c77a;
  --accent: #19d3e6;
  --red: #ff4655;
  --green: #3fd28a;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

.topbar {
  display: flex; align-items: center; gap: 16px; padding: 12px 24px;
  background: linear-gradient(90deg, #0b0c10, #0c1424 50%, #0b0c10);
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { font-weight: 800; letter-spacing: 2px; font-size: 18px; }
.brand small { font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.brand-mark { color: var(--red); }
.spacer { flex: 1; }
select, input {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px;
}
.btn {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 7px 14px;
}
.btn:hover { border-color: #555; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.btn.gold { border-color: var(--gold); color: var(--gold); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.tabs { display: flex; gap: 4px; padding: 10px 24px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  background: none; border: 0; padding: 10px 16px 12px; color: var(--muted); font-weight: 600;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--text); background: var(--panel); border-radius: 6px 6px 0 0; border-bottom-color: var(--accent); }
.tabs button[hidden] { display: none; }
.chip { font-size: 12px; font-weight: 500; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; margin-left: 6px; color: var(--muted); }
.chip.open { color: var(--green); border-color: var(--green); }
.chip.locked { color: var(--gold); border-color: var(--gold); }

#banner:empty { display: none; }
.banner { margin: 16px auto 0; max-width: 1120px; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 14px; }
.banner.warn { border-color: #6b5520; color: var(--gold); }

main { max-width: 1120px; margin: 0 auto; padding: 24px 16px 60px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* 預測卡片 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 24px; }
.card { position: relative;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px;
  display: flex; flex-direction: column; text-align: center; min-height: 340px; transition: border-color .15s, transform .15s;
}
.card.clickable:hover { border-color: var(--gold); transform: translateY(-2px); cursor: pointer; }
.card.correct { border-color: var(--green); box-shadow: 0 0 0 1px var(--green) inset; }
.card.wrong { border-color: #5a2228; }
.card.void { opacity: .65; }
.pic {
  position: relative; height: 152px; border-radius: 8px; overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #23324d, #0d0f14 70%);
  display: flex; align-items: center; justify-content: center;
}
.pic img { width: 100%; height: 100%; object-fit: cover; }
.pic .q { font-size: 64px; font-weight: 800; color: #2d3a52; }
.pic .initial { font-size: 54px; font-weight: 800; }
.pic .label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 8px; font-weight: 700;
  background: rgba(0,0,0,.65);
}
.card .title { flex: 1; display: flex; align-items: center; justify-content: center; padding: 18px 6px; font-size: 15px; line-height: 1.55; }
.card .foot { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pts { border: 1px solid var(--gold); color: var(--gold); border-radius: 999px; padding: 6px 18px; font-weight: 700; }
.card .meta { font-size: 12px; color: var(--muted); min-height: 16px; }
.card .meta b { color: var(--green); }
.card.wrong .meta b { color: var(--red); }

/* 彈窗 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal[hidden] { display: none; }
.dialog { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 22px; width: min(560px, 100%); max-height: 90vh; overflow: auto; }
.dialog h3 { margin: 0 0 6px; }
.dialog .hint { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.opt { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.opt:hover { border-color: var(--gold); }
.opt.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.ava { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; flex-shrink: 0; }
.ava.sm { width: 28px; height: 28px; font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.row label { color: var(--muted); font-size: 13px; }

/* 表格 */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: var(--panel); }
th:first-child, td:first-child { text-align: left; }
tr:last-child td { border-bottom: 0; }
td .who { display: inline-flex; gap: 8px; align-items: center; }
td.top { color: var(--gold); font-weight: 700; }
h2 { font-size: 18px; margin: 32px 0 12px; }
h2:first-child { margin-top: 0; }
.list { display: grid; gap: 8px; }
.item { display: flex; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; flex-wrap: wrap; }
.item .grow { flex: 1; min-width: 160px; }
.item .muted, .muted { color: var(--muted); font-size: 13px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 20px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.checks label { display: inline-flex; gap: 6px; align-items: center; color: var(--text); font-size: 14px; }
.qline { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.qline:last-child { border-bottom: 0; }
.qline .grow { flex: 1; }
.qline input[type=number] { width: 70px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #222; border: 1px solid var(--line); padding: 10px 18px; border-radius: 8px; z-index: 20; max-width: calc(100% - 32px); }
.toast.err { border-color: var(--red); color: #ffb3ba; }

@media (max-width: 600px) {
  .topbar { padding: 10px 16px; }
  .tabs { padding: 8px 16px 0; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .card { min-height: 280px; padding: 10px; }
  .pic { height: 110px; }
  .card .title { font-size: 14px; padding: 12px 2px; }
}
/* 加倍卡、下注比例 */
.card .dbl { position: absolute; top: 10px; right: 10px; background: var(--gold); color: #111; font-weight: 700; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.ratio { display: block; width: 100%; height: 6px; background: #22262f; border-radius: 3px; overflow: hidden; }
.ratio i { display: block; height: 100%; background: var(--gold); }
.recap-img { width: 100%; border-radius: 8px; display: block; }
.card .author { font-size: 12px; color: var(--gold); margin-top: -4px; }
.pic .custom-opt { font-size: 30px; padding: 0 10px; text-align: center; word-break: break-all; }
