/* 聖誕籤詩：松綠夜空＋禮物吊牌籤紙 */
:root {
  --pine: #1d4a37;
  --pine-deep: #143628;
  --paper: #fbf3e2;
  --paper-2: #f2e4c6;
  --ink: #2b1d14;
  --ink-soft: #6b5544;
  --red: #b3261e;
  --gold: #c9a14a;
  --leaf: #2f6b4a;
  --ok: #2f7d4a;
  --line: #e0cfae;
  --on-pine: #f6ecd6;
  --on-pine-soft: #b9cbb9;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --pine: #10281e;
    --pine-deep: #0a1c14;
    --paper: #f1e6cd;
    --paper-2: #e6d5b1;
    --line: #d6c19a;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--on-pine);
  font-family: "Noto Serif TC", "Songti TC", serif;
  line-height: 1.7;
  background-color: var(--pine);
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.22) 1.3px, transparent 1.8px),
    radial-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1.5px);
  background-size: 46px 46px, 73px 73px;
  background-position: 0 0, 21px 33px;
  min-height: 100vh;
}
main { max-width: 640px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 1.5rem; margin: 0; letter-spacing: 0.12em; font-weight: 900; }
h2 { font-size: 1.1rem; margin: 0 0 10px; letter-spacing: 0.05em; }
.sub { color: var(--on-pine-soft); margin: 2px 0 20px; font-size: 0.95rem; }
a { color: var(--red); }
main > a, .on-pine a { color: var(--on-pine); }

.card {
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}
label { display: block; font-weight: 600; margin: 14px 0 4px; }
label small { font-weight: 400; color: var(--ink-soft); }
input, textarea {
  width: 100%;
  font-family: system-ui, sans-serif;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
}
textarea { min-height: 88px; resize: vertical; }
textarea.links { min-height: 64px; font-size: 14px; }
/* 按鈕分三層（12/03 Casey 選 A 後再調：次要改成籤紙米色，不用綠底；圓角從膠囊改成 8px，跟卡片比較協調）
   主要：實心紅（送出、鎖定、出題、開一場）——一個畫面只該有一兩顆
   次要 .ghost：米色底＋深咖啡字＋細框（複製全部連結、重新出題）
   輕量 .text：只有字（改名、刪除、上一步這類不常按的） */
button {
  font: inherit;
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.3;
  min-height: 34px;
  padding: 6px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--red);
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
button:hover:not(:disabled) { background: #951e17; }
button:active:not(:disabled) { transform: scale(0.94); box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.25); }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
button.ghost { background: var(--paper-2); color: var(--ink); border-color: var(--line); }
button.ghost:hover:not(:disabled) { background: #eadab6; }
/* 重寫這支籤：松綠實心＋籤紙米色字（12/03 Casey 要它更像按鈕；用米色不用純白，跟整體比較協調） */
button.green { background: var(--leaf); color: var(--paper); }
button.green:hover:not(:disabled) { background: #245a3d; }
button.text { background: none; border-color: transparent; color: var(--ink-soft); padding: 6px 10px; font-weight: 400; }
button.text:hover:not(:disabled) { background: rgba(43, 29, 20, 0.07); color: var(--ink); }
button.text.danger { color: var(--red); }
button.small { min-height: 26px; padding: 2px 8px; font-size: 0.82rem; }
/* 只有 icon 的按鈕（改名、複製連結）：圓形、平常透明，滑過／按下有底色 */
button.icon { min-height: 0; width: 34px; height: 34px; padding: 0; flex: none; display: inline-flex; align-items: center; justify-content: center; background: none; color: var(--ink-soft); border-radius: 8px; }
button.icon:hover:not(:disabled) { background: rgba(43, 29, 20, 0.08); color: var(--ink); }
button.icon.done { background: none; color: var(--ok); }
button:disabled { opacity: 0.45; cursor: default; }
/* 按下去之後在跑：保持清楚可見（不要跟 disabled 一樣變淡），前面加一個轉圈 */
button.is-loading,
button.is-loading:disabled { opacity: 1; cursor: progress; }
button.is-loading::before {
  content: ""; display: inline-block; width: 0.9em; height: 0.9em; margin-right: 6px; vertical-align: -0.12em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* 重要按鈕按第一次：變金色、晃一下，提示「再按一次才會執行」 */
button.armed { background: var(--gold); color: var(--ink); animation: nudge 0.3s ease; }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-4px); } 70% { transform: translateX(4px); } }
/* 剛完成的那一下：綠色閃一下 */
button.done { color: var(--ok); border-color: var(--ok); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.msg { margin-top: 12px; font-size: 0.95rem; min-height: 1.5em; }
.msg.err { color: var(--red); }
.msg.ok { color: var(--ok); }
.muted { color: var(--ink-soft); font-size: 0.9rem; }
.hidden { display: none !important; }

/* ---------- 吊牌籤 ---------- */
.tag-wrap { position: relative; max-width: 330px; margin: 0 auto 28px; padding-top: 58px; }
.cord { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 140px; height: 86px; z-index: 2; pointer-events: none; }
.tag-border,
.tag { clip-path: polygon(22% 0, 78% 0, 100% 11%, 100% 100%, 0 100%, 0 11%); }
.tag-border { background: var(--red); padding: 3px; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.35)); }
.tag {
  position: relative;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(0deg, transparent 0 27px, rgba(184, 134, 43, 0.08) 27px 28px);
  color: var(--ink);
  padding: 58px 22px 74px;
  text-align: center;
}
.eyelet {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--pine); border: 4px solid var(--gold);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}
.holly { position: absolute; top: 34px; right: 14px; width: 62px; transform: rotate(12deg); }
.seal {
  position: absolute; right: 18px; bottom: 18px;
  width: 40px; height: 40px; border-radius: 5px;
  background: var(--red); color: #fff3e6;
  writing-mode: vertical-rl; font-weight: 900; font-size: 0.95rem; line-height: 1.05;
  display: flex; align-items: center; justify-content: center;
  transform: rotate(-6deg); opacity: 0.88;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}
.lot-no {
  display: inline-block; color: var(--red); border: 1.5px solid var(--red);
  padding: 2px 14px; letter-spacing: 0.3em; font-weight: 700; margin-bottom: 18px;
}
.poem {
  writing-mode: vertical-rl; margin: 0 auto; font-size: 1.65rem;
  letter-spacing: 0.35em; line-height: 2.15; height: 9.6em; font-weight: 700;
}
.poem span { display: block; }

.hint-zone { position: relative; margin-top: 20px; border-top: 1px dashed #d8c39b; padding-top: 16px; min-height: 104px; text-align: left; }
.hint-zone b { color: var(--red); letter-spacing: 0.2em; }
.hint-text { margin: 6px 0 0; font-size: 1.08rem; }
.hint-note { margin: 10px 0 0; font-size: 0.92rem; color: var(--ink-soft); border-left: 3px solid var(--gold); padding-left: 10px; }
.ribbon {
  position: absolute; inset: 10px -22px -26px; border: 0; padding: 0 0 12px; cursor: pointer; border-radius: 0;
  background:
    linear-gradient(90deg, transparent 0 calc(50% - 15px), var(--gold) calc(50% - 15px) calc(50% - 12px), var(--red) calc(50% - 12px) calc(50% + 12px), var(--gold) calc(50% + 12px) calc(50% + 15px), transparent calc(50% + 15px)),
    linear-gradient(0deg, transparent 0 calc(50% - 15px), var(--gold) calc(50% - 15px) calc(50% - 12px), var(--red) calc(50% - 12px) calc(50% + 12px), var(--gold) calc(50% + 12px) calc(50% + 15px), transparent calc(50% + 15px)),
    var(--pine);
  color: var(--on-pine);
  display: flex; align-items: flex-end; justify-content: center;
  transition: transform 0.7s cubic-bezier(0.6, -0.2, 0.7, 1), opacity 0.7s;
}
.ribbon .label { background: var(--pine-deep); padding: 2px 12px; border-radius: 999px; font-size: 0.9rem; }
.ribbon .bow { position: absolute; top: 50%; left: 50%; width: 64px; transform: translate(-50%, -62%); }
.ribbon.armed .label { background: var(--red); }
.ribbon.gone { transform: translateY(-14px) scale(1.04); opacity: 0; pointer-events: none; }
.ribbon:disabled { opacity: 1; }

/* ---------- 主辦 ---------- */
.players { list-style: none; padding: 0; margin: 0; }
.players li { border-bottom: 1px solid var(--line); padding: 18px 0; }
.players li > * + * { margin-top: 8px; }
.link-row { display: flex; align-items: center; gap: 8px; }
.link-row .link { flex: 1; min-width: 0; }
.player-actions { margin-top: 12px !important; }
.players li:last-child { border-bottom: 0; }
.badge { display: inline-block; font-size: 0.8rem; padding: 0 8px; border-radius: 999px; background: var(--paper-2); color: var(--ink-soft); border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: #9a6b12; border-color: var(--gold); }
.badge.err { color: var(--red); border-color: var(--red); }
.link { font-family: ui-monospace, monospace; font-size: 0.75rem; word-break: break-all; color: var(--ink-soft); }

/* ---- 公開版：後台出題進度、底部提示條、開場頁 ---- */
.badge.busy { color: var(--red); border-color: var(--red); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }
.players li.generating { background: rgba(201, 161, 74, 0.14); margin: 0 -12px; padding-left: 12px; padding-right: 12px; border-radius: 10px; }
.small { font-size: 0.82rem; }
.keynote { border: 2px dashed var(--gold); }
.keynote p { margin: 6px 0 0; }
button.linkish { background: none; border: 0; padding: 0 2px; color: var(--red); text-decoration: underline; font: inherit; cursor: pointer; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 140%);
  max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 12px;
  background: var(--ink); color: var(--paper); font-size: 0.95rem; line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); transition: transform 0.25s ease; z-index: 50;
}
.toast.show { transform: translate(-50%, 0); }
.toast.ok { background: var(--ink); }
.toast.ok::before { content: "✓ "; color: #9fd3a8; }
.toast.err { background: var(--red); }
.steps { padding-left: 1.3em; margin: 8px 0; }
.steps li { margin: 6px 0; }
.faq details { border-bottom: 1px solid var(--line); padding: 8px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin: 6px 0 2px; }
.created-link { word-break: break-all; background: var(--paper-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-family: ui-monospace, monospace; font-size: 0.85rem; }
.fineprint { color: var(--on-pine-soft); font-size: 0.85rem; text-align: center; margin-top: 28px; }
