/* 今晚你最有戲｜最佳裝扮票選 — 深紫 × 南瓜橘 × 米白 */
:root {
  /* 取自主視覺：黑板炭灰、萊姆綠、南瓜橘、紫、金黃 */
  --bg: #1e1b1a;
  --bg-2: #262221;
  --surface: #2c2826;
  --surface-2: #38322f;
  --line: #4a4340;
  --orange: #ee7940;
  --orange-2: #f59a63;
  --orange-ink: #2a1206;
  --lime: #d7e69e;
  --green: #98c022;
  --purple: #7564ab;
  --purple-2: #9a8acb;
  --yellow: #f4b52e;
  --cream: #fff8ec;
  --muted: #c9c0b4;
  --ok: #b6d96a;
  --warn: #f4b52e;
  --err: #ff8a7a;
  --line-green: #06c755;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .4);
  --font: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--cream); font-family: var(--font);
  font-size: 16px; line-height: 1.55;
  background-image:
    radial-gradient(900px 420px at 50% -120px, rgba(215, 230, 158, .10), transparent 70%),
    radial-gradient(700px 380px at 105% 20%, rgba(117, 100, 171, .18), transparent 70%),
    radial-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: auto, auto, 6px 6px;
  background-attachment: fixed;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--orange-2); }
[hidden] { display: none !important; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* ---------- 頁首 ---------- */
.env-banner { background: #0d7a5f; color: #fff; text-align: center; font-size: 13px; padding: 4px 8px; font-weight: 700; letter-spacing: .05em; }
.hero { text-align: center; padding: 28px 16px 12px; }
.hero .event-name { margin: 0; color: var(--orange-2); font-weight: 700; letter-spacing: .12em; font-size: 14px; }
.hero { padding-top: 12px; }
.kv { display: block; max-width: 1100px; margin: 0 auto 14px; }
.kv img { width: 100%; height: auto; border-radius: 18px; box-shadow: var(--shadow); }
.hero h1 { margin: 6px 0 12px; font-size: clamp(24px, 6vw, 42px); line-height: 1.2; font-weight: 900; letter-spacing: .02em;
  color: var(--lime); text-shadow: 0 3px 0 #000, 0 0 22px rgba(215, 230, 158, .25); }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hero h1 .spark { color: var(--orange); }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 15px;
  background: var(--surface); border: 1px solid var(--line); }
.pill .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.pill.open .dot { background: var(--green); box-shadow: 0 0 0 4px rgba(152, 192, 34, .25); }
.pill.closed .dot { background: var(--err); }
.pill.not_started .dot { background: var(--warn); }
.deadline-text { display: block; margin-top: 6px; color: var(--muted); font-size: 14px; }

/* ---------- 區塊 ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 14px 0; box-shadow: var(--shadow); }
.panel h2 { margin: 0 0 10px; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.notice { border-radius: var(--radius); padding: 14px 16px; margin: 14px 0; font-weight: 700; font-size: 17px; text-align: center;
  background: linear-gradient(135deg, var(--orange-2), var(--orange)); color: var(--orange-ink); box-shadow: var(--shadow); }
.notice.soft { background: var(--surface-2); color: var(--cream); border: 1px solid var(--line); font-weight: 600; }
.notice.err { background: #5a1830; color: #ffd9d9; border: 1px solid #93304f; }
.notice.ok { background: #2f3d14; color: #eef6cf; border: 1px solid #6b8a1c; }
.notice.warn { background: #4f3d0d; color: #fff0c2; border: 1px solid #8a6b16; }
.notice small { display: block; font-weight: 500; font-size: 14px; margin-top: 4px; opacity: .9; }

/* ---------- 得獎名單 ---------- */
.winners { background: linear-gradient(160deg, #3a2414, #4d2a14); border: 2px solid var(--orange); }
.winners pre { white-space: pre-wrap; font-family: var(--font); margin: 0; font-size: 18px; line-height: 1.7; }

/* ---------- 排行榜 ---------- */
.board-empty { color: var(--muted); text-align: center; padding: 10px; }
.rank-row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; background: var(--bg-2); margin-bottom: 8px; }
.rank-badge { flex: 0 0 auto; width: 48px; text-align: center; font-weight: 900; font-size: 15px; line-height: 1.15; }
.rank-badge .medal { display: block; font-size: 26px; }
.rank-row img { width: 54px; height: 54px; border-radius: 12px; object-fit: cover; background: var(--surface-2); flex: 0 0 auto; }
.rank-info { flex: 1; min-width: 0; }
.rank-info .nm { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-info .cs { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-votes { font-weight: 900; font-size: 22px; color: var(--orange-2); white-space: nowrap; }
.rank-votes small { font-size: 13px; color: var(--muted); font-weight: 600; }
.tie-tag { display: inline-block; font-size: 12px; background: var(--orange); color: var(--orange-ink); border-radius: 6px; padding: 0 6px; margin-left: 4px; vertical-align: middle; }

/* ---------- 同步列與搜尋 ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin: 12px 0; }
.sync { font-size: 14px; color: var(--muted); }
.sync.fail { color: var(--err); font-weight: 700; }
.search { flex: 1 1 220px; }
.search input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); font-size: 16px; }
.search input::placeholder { color: #9d88c2; }

/* ---------- 按鈕 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 800; font-size: 16px;
  cursor: pointer; background: var(--surface-2); color: var(--cream); border: 1px solid var(--line); min-height: 48px; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--orange-2), var(--orange)); color: var(--orange-ink); border-color: #f8b089; }
.btn.danger { background: #8d2341; border-color: #b23a5d; color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 38px; padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn.big { min-height: 58px; font-size: 19px; padding: 14px 22px; border-radius: 14px; }
.btn.block { width: 100%; }

/* ---------- 參賽卡片 ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding-bottom: 24px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }
.card { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card.selected { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255, 138, 29, .35); }
.card .photo { position: relative; aspect-ratio: 3 / 4; background: var(--bg-2); border: 0; padding: 0; cursor: zoom-in; width: 100%; }
.card .photo img { width: 100%; height: 100%; object-fit: cover; }
.card .num { position: absolute; left: 8px; top: 8px; background: rgba(20, 18, 17, .85); color: var(--lime); font-weight: 900; border-radius: 10px; padding: 2px 10px; font-size: 20px; }
.card .zoom { position: absolute; right: 8px; bottom: 8px; background: rgba(20, 18, 17, .7); border-radius: 50%; width: 32px; height: 32px; display: grid; place-items: center; font-size: 16px; }
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.card .nm { font-weight: 800; font-size: 17px; line-height: 1.3; word-break: break-word; }
.card .cs { color: var(--muted); font-size: 14px; line-height: 1.35; word-break: break-word; }
.card .votes { margin-top: auto; padding-top: 6px; font-size: 15px; color: var(--muted); }
.card .votes b { font-size: 22px; color: var(--orange-2); font-weight: 900; }
.card .pick { margin: 0 12px 12px; }
.card.selected .pick { background: var(--orange); color: var(--orange-ink); border-color: var(--orange-2); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* ---------- 投票頁底部操作列 ---------- */
.vote-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(30, 27, 26, .96); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); backdrop-filter: blur(6px); }
.vote-bar .inner { max-width: 1100px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.vote-bar .sel { flex: 1; min-width: 0; font-size: 15px; }
.vote-bar .sel b { color: var(--orange-2); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 17px; }
body.has-bar { padding-bottom: 96px; }

/* ---------- 對話框 ---------- */
dialog { border: 1px solid var(--line); background: var(--surface); color: var(--cream); border-radius: 20px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(8, 6, 5, .8); }
.dlg-body { padding: 18px; overflow: auto; max-height: calc(100vh - 24px); }
.dlg-body h3 { margin: 0 0 10px; font-size: 21px; }
.dlg-actions { display: flex; gap: 10px; margin-top: 16px; }
.dlg-actions .btn { flex: 1; }
.confirm-photo { width: 100%; max-height: 52vh; object-fit: contain; background: var(--bg-2); border-radius: 14px; }
.confirm-meta { margin: 12px 0 4px; text-align: center; }
.confirm-meta .n { font-size: 30px; font-weight: 900; color: var(--orange-2); }
.confirm-meta .nm { font-size: 22px; font-weight: 800; }
.confirm-meta .cs { color: var(--muted); }
.lightbox { width: min(900px, calc(100vw - 16px)); background: #000; }
.lightbox img { width: 100%; max-height: 80vh; object-fit: contain; }
.lightbox .cap { padding: 10px 14px; background: var(--surface); }
.lightbox .close-x { position: absolute; right: 10px; top: 10px; }

/* ---------- 投票結果畫面 ---------- */
.result { text-align: center; padding: 20px 16px; }
.result .big-icon { font-size: 56px; line-height: 1; }
.result h2 { font-size: 26px; margin: 10px 0 6px; justify-content: center; }
.result .voted-card { display: inline-flex; gap: 12px; align-items: center; text-align: left; background: var(--bg-2); border-radius: 14px; padding: 10px 14px; margin-top: 10px; }
.result .voted-card img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }

.spinner { display: inline-block; width: 18px; height: 18px; border: 3px solid rgba(255, 255, 255, .3); border-top-color: currentColor; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

.rules-text { white-space: pre-wrap; color: var(--muted); margin: 8px 0 0; }
details.panel summary { cursor: pointer; font-weight: 800; font-size: 17px; }
.footer { text-align: center; color: #8f7bb3; font-size: 13px; padding: 20px 16px 40px; }

/* ---------- 提示訊息 ---------- */
.toast-box { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(480px, calc(100vw - 24px)); pointer-events: none; }
.toast { background: var(--cream); color: #2a1347; padding: 12px 16px; border-radius: 12px; font-weight: 700; box-shadow: var(--shadow); }
.toast.err { background: #ffd6d6; color: #5a0d1f; }
.toast.ok { background: #d5f7e5; color: #0c4a2c; }

/* ================= 管理後台 ================= */
.admin-top { position: sticky; top: 0; z-index: 30; background: rgba(30, 27, 26, .97); border-bottom: 1px solid var(--line); }
.admin-top .row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; max-width: 1100px; margin: 0 auto; }
.admin-top .title { font-weight: 900; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 10px; max-width: 1100px; margin: 0 auto; scrollbar-width: none; }
.tabs button { flex: 0 0 auto; border-radius: 999px; padding: 8px 14px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; }
.tabs button.active { background: var(--lime); color: #1e1b1a; border-color: var(--lime); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-weight: 700; font-size: 15px; }
.field .hint { color: var(--muted); font-size: 13px; }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=number],
.field input[type=datetime-local], .field textarea, .field select {
  padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); font-size: 16px; width: 100%; }
.field textarea { min-height: 110px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 700; padding: 6px 0; }
.check input { width: 22px; height: 22px; accent-color: var(--orange); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--bg-2); border-radius: 12px; padding: 12px; }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 26px; font-weight: 900; color: var(--orange-2); }
.admin-list { display: flex; flex-direction: column; gap: 10px; }
.a-item { display: flex; gap: 12px; background: var(--bg-2); border-radius: 14px; padding: 10px; align-items: flex-start; }
.a-item.withdrawn { opacity: .65; border: 1px dashed var(--err); }
.a-item img { width: 72px; height: 96px; object-fit: cover; border-radius: 10px; background: var(--surface-2); flex: 0 0 auto; }
.a-item .info { flex: 1; min-width: 0; }
.a-item .info .t { font-weight: 800; }
.a-item .info .s { color: var(--muted); font-size: 14px; }
.tag { display: inline-block; font-size: 12px; font-weight: 800; border-radius: 6px; padding: 1px 7px; margin-left: 4px; }
.tag.red { background: #8d2341; color: #fff; }
.tag.green { background: #145a3e; color: #cfffe5; }
.tag.yellow { background: #6b5210; color: #fff3c4; }
.tag.grey { background: #4b3b68; color: #e8dcff; }
.jobs { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.job { display: flex; gap: 10px; align-items: center; background: var(--bg-2); border-radius: 10px; padding: 8px 10px; font-size: 14px; }
.job .bar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.job .bar i { display: block; height: 100%; width: 0; background: var(--orange); transition: width .2s; }
.job.ok { color: var(--ok); }
.job.fail { color: var(--err); }
.preview-img { max-height: 220px; border-radius: 12px; margin-top: 8px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tbl th { color: var(--muted); font-weight: 700; position: sticky; top: 0; background: var(--surface); }
.tbl-wrap { max-height: 60vh; overflow: auto; border-radius: 10px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
.big-status { font-size: 24px; font-weight: 900; }
.login-box { max-width: 420px; margin: 40px auto; }
.muted { color: var(--muted); }
.ok-text { color: var(--ok); font-weight: 800; }
.err-text { color: var(--err); font-weight: 800; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ===== LINE 版新增 ===== */
.card .nm.only-num { font-size: 22px; color: var(--lime); }
.card.voted { border-color: var(--green); }
.card.voted .pick { background: #3c4a17; color: var(--lime); border-color: var(--green); opacity: 1; }
.card .pick { margin: 0 12px 12px; }
.rank-row.win { background: linear-gradient(90deg, rgba(238, 121, 64, .22), var(--bg-2)); border: 1px solid rgba(238, 121, 64, .5); }
.win-line { display: flex; align-items: center; gap: 10px; color: var(--orange-2); font-size: 13px; font-weight: 800; margin: 4px 0 10px; }
.win-line::before, .win-line::after { content: ""; flex: 1; border-top: 2px dashed rgba(238, 121, 64, .6); }
.btn.line { background: var(--line-green); border-color: #2bdc77; color: #fff; }
.line-logo { background: #fff; color: var(--line-green); font-weight: 900; font-size: 13px; border-radius: 6px; padding: 1px 6px; letter-spacing: .02em; }
.login-panel { text-align: center; }
.me-panel { border-color: var(--green); }
.me-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 18px; }
.line-ok { background: var(--line-green); color: #fff; font-size: 13px; font-weight: 800; border-radius: 999px; padding: 2px 10px; }
.dots { display: inline-flex; gap: 6px; }
.dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--lime); display: inline-block; }
.dots i.on { background: var(--lime); }
.voted-list { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.voted-chip { display: flex; gap: 10px; align-items: center; background: var(--bg-2); border: 1px solid var(--green); border-radius: 12px; padding: 6px 12px 6px 6px; }
.voted-chip img { width: 44px; height: 58px; object-fit: cover; border-radius: 8px; }
.voted-chip small { display: block; color: var(--muted); font-size: 12px; }
.voted-chip b { color: var(--lime); font-size: 18px; }
.me-msg { margin: 12px 0 0; }
.raffle-card { text-align: center; border-radius: var(--radius); padding: 16px; margin: 14px 0; background: linear-gradient(160deg, #3b3360, #2c2645);
  border: 2px solid var(--purple-2); box-shadow: var(--shadow); }
.raffle-card .label { font-weight: 800; color: var(--purple-2); }
.raffle-code { font: 900 clamp(40px, 13vw, 64px)/1.1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .06em; color: var(--yellow); margin: 6px 0; }
.raffle-card p { margin: 6px 0 0; }
.raffle-card.win { background: linear-gradient(160deg, #6b3a12, #3a2414); border-color: var(--yellow); }
.raffle-card.win h2 { justify-content: center; margin: 4px 0; font-size: 26px; }
.raffle-card .prize { font-size: 20px; font-weight: 800; color: var(--lime); }
.draw-list { display: flex; flex-direction: column; gap: 8px; }
.draw-row { display: flex; gap: 12px; align-items: center; background: var(--bg-2); border-radius: 10px; padding: 8px 12px; }
.draw-row b { font: 900 22px ui-monospace, Menlo, Consolas, monospace; color: var(--yellow); }
.draw-row span { flex: 1; }
.draw-row small { color: var(--muted); }
.draw-row.absent { opacity: .5; text-decoration: line-through; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.big-code { font: 900 72px/1 ui-monospace, Menlo, Consolas, monospace; color: var(--yellow); text-align: center; margin: 10px 0; letter-spacing: .05em; }
