/* 星約冒險 Demo：樣式（魔法森林的綠色、木色、淺色系，與設計書一致） */
:root {
  --bg: #f6f1df; --bg2: #e4eed0; --panel: #fffdf3; --panel2: #e8f0d6; --inset: #f1ead2;
  --line: #cdb98c; --wood: #7a5230; --text: #3a2d1c; --muted: #7a6a4f;
  --gold: #9a5f2a; --star: #2f7d44; --good: #3a8f4e; --warn: #c0582f; --pink: #a95a86; --on-accent: #fff;
}
* { box-sizing: border-box; }
body {
  margin: 0; padding-bottom: 110px; /* 預留示範工具列的高度，避免擋住最下面的按鈕 */
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%) fixed;
  color: var(--text); line-height: 1.65;
}
a { color: var(--star); }
h1 { font-size: 26px; margin: 6px 0; color: #2c5e38; }
h2 { font-size: 20px; margin: 22px 0 8px; color: var(--gold); border-left: 5px solid #6a9a46; padding-left: 10px; }
h3 { font-size: 16px; margin: 12px 0 6px; color: var(--star); }
small, .muted { color: var(--muted); }

/* ===== 頂部列 ===== */
header.top { position: sticky; top: 0; z-index: 20; background: linear-gradient(180deg, #8a6038, #6f4a2b); border-bottom: 3px solid #4f6b2f; box-shadow: 0 2px 8px rgba(80, 60, 30, .25); }
header.top .bar { max-width: 1100px; margin: 0 auto; padding: 8px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
header.top .brand { font-weight: 700; color: #f5e6b8; font-size: 17px; }
header.top .badge { background: #cfe5a8; color: #2c4a1a; font-size: 12px; font-weight: 700; padding: 1px 10px; border-radius: 999px; }
header.top .spacer { flex: 1; }
header.top .who { color: #f0e2bd; font-size: 14px; }
header.top select { padding: 2px 6px; }
nav.tabs { max-width: 1100px; margin: 0 auto; padding: 0 14px 8px; display: flex; flex-wrap: wrap; gap: 4px; }
nav.tabs button { background: transparent; border: 0; color: #f0e2bd; padding: 4px 12px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 14px; }
nav.tabs button:hover { background: rgba(255, 255, 255, .15); }
nav.tabs button.on { background: #cfe5a8; color: #2c4a1a; font-weight: 700; }
nav.tabs .dot { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; font-size: 11px; background: var(--warn); color: #fff; border-radius: 999px; text-align: center; }

main { max-width: 1100px; margin: 0 auto; padding: 16px 14px 40px; }

/* ===== 卡片與版面 ===== */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 10px 0; box-shadow: 0 1px 3px rgba(122, 82, 48, .12); }
.card.inset { background: var(--inset); }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); margin: 1px 4px 1px 0; }
.tag.gold { color: var(--gold); border-color: var(--gold); background: #f8ead2; }
.tag.good { color: var(--good); border-color: var(--good); background: #e5f3de; }
.tag.warn { color: var(--warn); border-color: var(--warn); background: #fbe6dc; }
.note { border-left: 4px solid var(--warn); background: #fbeee4; padding: 8px 12px; border-radius: 8px; margin: 8px 0; font-size: 14px; }
.note.ok { border-color: var(--good); background: #e8f4de; }
table { border-collapse: collapse; width: 100%; font-size: 14px; background: var(--panel); }
th, td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; }
th { background: var(--panel2); color: #2c5e38; }
.scroll { overflow-x: auto; }
.empty { color: var(--muted); text-align: center; padding: 16px 6px; }

/* ===== 控制元件 ===== */
button.btn { background: var(--star); color: var(--on-accent); border: 0; border-radius: 999px; padding: 5px 15px; font: inherit; font-weight: 700; cursor: pointer; }
button.btn:hover { filter: brightness(1.1); }
button.btn:disabled { background: #b9b39e; cursor: not-allowed; filter: none; }
button.btn.ghost { background: transparent; color: var(--star); border: 1px solid var(--star); }
button.btn.warn { background: var(--warn); }
button.btn.wood { background: var(--wood); }
button.btn.small { padding: 2px 11px; font-size: 13px; }
input[type=text], input[type=password], input[type=number], select, textarea { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; font: inherit; }
input[type=number] { width: 80px; }
textarea { width: 100%; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); min-width: 120px; }
label.f.wide { flex: 1; min-width: 220px; }
label.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; margin-right: 12px; }

/* ===== 進度條 ===== */
.bar-wrap { background: #e4dcc0; border: 1px solid var(--line); border-radius: 999px; height: 14px; overflow: hidden; position: relative; }
.bar-wrap > i { display: block; height: 100%; border-radius: 999px; }
.bar-wrap.hp > i { background: linear-gradient(90deg, #e07a52, #c0582f); }
.bar-wrap.hp.me > i { background: linear-gradient(90deg, #6fbf6f, #3a8f4e); }
.bar-wrap.exp > i { background: linear-gradient(90deg, #8cc06b, #2f7d44); }
.bar-wrap.time > i { background: linear-gradient(90deg, #e8c060, #d19a2a); }
.bar-label { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }

/* ===== 登入畫面 ===== */
.login-box { max-width: 460px; margin: 30px auto; }
.login-hero { text-align: center; margin-top: 24px; }
.login-hero .big { font-size: 40px; }
.tabs-mini { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs-mini button { flex: 1; }
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.role-pick .opt { border: 2px solid var(--line); border-radius: 14px; padding: 12px; cursor: pointer; background: var(--panel); text-align: center; }
.role-pick .opt.on { border-color: var(--star); background: #e8f4de; }
.role-pick .opt .ico { font-size: 34px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; }
.sw.on { border-color: var(--star); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--star); }
.demo-accounts button { margin: 3px 6px 3px 0; }

/* ===== 主頁與角色 ===== */
.hero { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.hero .avatar { background: radial-gradient(circle at 50% 70%, #e4eed0, #f1ead2); border: 1px solid var(--line); border-radius: 16px; padding: 6px 10px 0; }
.hero .info { flex: 1; min-width: 220px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.stats div { background: var(--inset); border: 1px solid var(--line); border-radius: 10px; text-align: center; padding: 3px; font-size: 13px; }
.stats b { display: block; font-size: 17px; color: #2c5e38; }
.gold-chip { font-weight: 700; color: var(--gold); }
ul.msgs { list-style: none; padding: 0; margin: 0; }
ul.msgs li { padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
ul.msgs li time { color: var(--muted); font-size: 12px; margin-right: 6px; }

/* ===== 任務 ===== */
.quest { border-left: 5px solid var(--star); }
.quest.pending { border-left-color: var(--gold); }
.quest.submitted { border-left-color: var(--pink); }
.quest.done { border-left-color: #b9b39e; opacity: .75; }
.quest.rejected { border-left-color: var(--warn); opacity: .75; }
.quest .title { font-weight: 700; }

/* ===== 地圖與戰鬥 ===== */
.map { position: relative; width: 100%; aspect-ratio: 16 / 9; background: radial-gradient(circle at 20% 80%, #dcebc0, #f0e8cc 60%, #e8dcb6); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.node { position: absolute; transform: translate(-50%, -50%); background: var(--panel); border: 2px solid var(--star); border-radius: 12px; padding: 1px 8px; font-size: 12px; cursor: pointer; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.node.locked { border-color: #b9b39e; color: #a79f86; background: #efe9d3; }
.node.sel { background: #cfe5a8; }
.node.boss { border-color: var(--warn); }
.battle { background: linear-gradient(180deg, #e8f4de, #f1ead2); border: 2px solid #6a9a46; border-radius: 16px; padding: 14px; }
.battle .field { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: end; }
.battle .mon { text-align: center; }
.battle .mon .emoji { font-size: 64px; line-height: 1.1; }
.battle .log { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; height: 140px; overflow-y: auto; font-size: 14px; margin-top: 10px; }
.battle .log div { padding: 1px 0; }
.battle .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.buff-chip { font-size: 11px; background: #f8ead2; border: 1px solid var(--gold); color: var(--gold); border-radius: 999px; padding: 0 7px; margin-left: 3px; }

/* ===== 商店 ===== */
.shelf { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.item { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.item.owned { background: #eef6e4; }
.btn.shop-locked { opacity: .6; border-style: dashed; }
button.btn small { color: inherit; opacity: .8; }
.btn.herb.heal { background: #5fa84a; color: #fff; }
.btn.herb.poison { background: #8a5ab8; color: #fff; }
.btn.herb.paralyze { background: #c9a227; color: #fff; }
.btn.herb:disabled { opacity: .45; }
.battle .actions.herbs { align-items: center; margin-top: 6px; }
.buff-chip.st-poison { background: #f0e4fa; border-color: #8a5ab8; color: #6a3a98; }
.buff-chip.st-para { background: #fff6cc; border-color: #c9a227; color: #8a6a10; }
.tabs button.locked-tab { opacity: .7; }

/* ===== 指派成功橫幅與待完成清單 ===== */
.assigned-banner { display: flex; align-items: flex-start; gap: 12px; background: #e3f5d4; border: 2px solid #3a8f4e; border-radius: 14px; padding: 12px 14px; margin: 8px 0 12px; box-shadow: 0 0 0 0 rgba(58, 143, 78, .5); animation: 橫幅彈出 .45s ease-out, 橫幅脈動 1.6s ease-out .45s 2; }
.assigned-banner .ab-icon { font-size: 34px; line-height: 1; }
.assigned-banner .ab-body { flex: 1; line-height: 1.7; }
@keyframes 橫幅彈出 { from { opacity: 0; transform: translateY(-14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes 橫幅脈動 { 0% { box-shadow: 0 0 0 0 rgba(58, 143, 78, .55); } 100% { box-shadow: 0 0 0 16px rgba(58, 143, 78, 0); } }
.pending-assigned .pa-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; padding: 5px 6px; border-bottom: 1px dashed var(--line); }
.pending-assigned .pa-row:last-of-type { border-bottom: 0; }
.pending-assigned .pa-row.fresh { background: #fff6c8; border-radius: 8px; animation: 新列閃 2s ease-out; }
@keyframes 新列閃 { 0%, 40% { background: #ffe58a; } 100% { background: #fff6c8; } }
@media (prefers-reduced-motion: reduce) { .assigned-banner, .pending-assigned .pa-row.fresh { animation: none; } }

/* ===== 示範工具列與提示 ===== */
.demo-tools { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #4a3420; color: #f0e2bd; padding: 6px 12px; font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; justify-content: center; border-top: 3px solid #6a9a46; }
.demo-tools button { background: #6f4a2b; color: #f5e6b8; border: 1px solid #a8864e; border-radius: 999px; padding: 2px 11px; font: inherit; cursor: pointer; }
.demo-tools button:hover { background: #8a6038; }
.toast-wrap { position: fixed; top: 70px; right: 14px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #2c5e38; color: #fff; padding: 8px 14px; border-radius: 10px; box-shadow: 0 3px 10px rgba(0,0,0,.3); max-width: 320px; font-size: 14px; }
.toast.err { background: var(--warn); }
.modal-bg { position: fixed; inset: 0; background: rgba(40, 30, 15, .55); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 14px; }
.modal { background: var(--panel); border: 2px solid var(--wood); border-radius: 16px; padding: 18px 20px; max-width: 460px; width: 100%; }
@media (max-width: 600px) { .stats { grid-template-columns: repeat(2, 1fr); } .battle .field { grid-template-columns: 1fr; } }

/* ===== 通知系統 ===== */
button.bell { position: relative; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: 16px; cursor: pointer; line-height: 1.4; }
button.bell:hover { background: rgba(255,255,255,.25); }
button.bell.has { animation: bell-ring 2.4s ease-in-out infinite; }
button.bell .cnt { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 4px; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; background: var(--warn); color: #fff; border-radius: 999px; border: 2px solid #6f4a2b; }
@keyframes bell-ring { 0%, 88%, 100% { transform: rotate(0); } 90% { transform: rotate(14deg); } 93% { transform: rotate(-12deg); } 96% { transform: rotate(8deg); } }
.notif-panel { position: absolute; right: 14px; top: 100%; width: min(430px, 94vw); max-height: 70vh; overflow-y: auto; background: var(--panel); color: var(--text); border: 2px solid var(--wood); border-radius: 14px; box-shadow: 0 8px 24px rgba(40, 30, 15, .4); padding: 8px 12px 10px; z-index: 40; }
.notif-panel .np-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 4px 0 8px; border-bottom: 2px solid var(--line); }
.notif-panel .spacer { flex: 1; }
ul.msgs li.notif { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; padding: 7px 6px; border-radius: 8px; position: relative; }
ul.msgs li.notif:hover { background: var(--panel2); }
ul.msgs li.notif .ico { font-size: 18px; line-height: 1.3; }
ul.msgs li.notif .txt { flex: 1; }
ul.msgs li.notif time { margin: 0; }
ul.msgs li.notif.unread { background: #f4f9e8; font-weight: 600; }
ul.msgs li.notif .dot-new { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); margin-top: 7px; flex: none; }
ul.msgs li.notif.t-overdue.unread { background: #fbe6dc; }
ul.msgs li.notif.t-deadline.unread { background: #f8ead2; }
.tag.dl { white-space: nowrap; }
