:root {
  --ink: #2b211c; --paper: #fbf6ea; --dot: #e9dfc8;
  --red: #e5394a; --yellow: #fdb515; --green: #2e9e5b; --blue: #2470d6;
  --purple: #8a4bd8; --teal: #138c93; --pink: #e84a84;
  --shadow: 0 5px 0 var(--ink);
  --font: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font); color: var(--ink);
  background: #8a5a36 repeating-linear-gradient(0deg, #8a5a36 0 46px, #7f5231 46px 48px);
  display: flex; justify-content: center; padding: 14px 10px calc(14px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
.board {
  position: relative; width: 100%; max-width: 480px; min-height: calc(100dvh - 28px);
  background: var(--paper) radial-gradient(var(--dot) 1.4px, transparent 1.5px) 0 0 / 22px 22px;
  border-radius: 22px; padding: 22px 18px 26px;
  border: 8px solid transparent;
  background-clip: padding-box;
  box-shadow: 0 0 0 3px var(--ink), 0 10px 0 3px rgba(0,0,0,.35);
}
.board::before {
  content: ""; position: absolute; inset: -11px; border-radius: 26px; z-index: -1;
  background: conic-gradient(from 0deg, var(--blue) 0 25%, var(--green) 0 50%, var(--yellow) 0 75%, var(--red) 0 100%);
}
.screen { display: none; flex-direction: column; gap: 14px; animation: pop .25s ease-out; }
.screen.active { display: flex; }
#scr-play { min-height: calc(100dvh - 110px); position: relative; }
#scr-play .options { margin-top: auto; padding-bottom: 6px; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1, h2 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.45rem; font-weight: 900; }
.sub { margin: 0; color: #5d4f45; font-size: .95rem; text-align: center; }
.sub.left { text-align: left; }
.hint { margin: 0; font-size: .8rem; color: #8b7b6d; text-align: center; }
code { background: #efe5cf; padding: 1px 5px; border-radius: 5px; font-size: .85em; }

.pill { align-self: flex-start; background: var(--ink); color: var(--paper); border-radius: 99px; padding: 6px 14px; font-weight: 700; font-size: .9rem; }
.logo { font-size: 2.9rem; font-weight: 900; letter-spacing: .02em; }
.logo span { display: inline-block; margin-top: 6px; background: var(--yellow); border: 3px solid var(--ink); box-shadow: var(--shadow); border-radius: 12px; padding: 2px 14px; font-size: 2.1rem; transform: rotate(-2deg); }
.cast { display: flex; justify-content: center; gap: 10px; margin: 6px 0 2px; }
.cast img { width: 86px; height: 86px; border-radius: 18px; border: 3px solid var(--ink); box-shadow: var(--shadow); background: #fff; }
.cast img:nth-child(1) { transform: rotate(-5deg); } .cast img:nth-child(3) { transform: rotate(5deg); }

.rule-card, .panel { background: #fff; border: 3px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.rule-head, .panel-head { display: flex; justify-content: space-between; background: var(--red); color: #fff; padding: 8px 14px; font-weight: 700; border-bottom: 3px solid var(--ink); }
.panel-head { background: var(--blue); }
.rule-main { margin: 12px 14px 6px; font-size: 1.15rem; font-weight: 800; line-height: 1.5; }
.rule-main b { background: #fff1c2; padding: 0 4px; border-radius: 4px; }
.rule-list { margin: 0; padding: 4px 14px 14px; list-style: none; display: grid; gap: 6px; font-size: .95rem; }
.rule-list li { display: flex; gap: 8px; align-items: baseline; }
.rule-list li span { flex: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; border: 2px solid var(--ink); }
.dot.r { background: var(--red); } .dot.y { background: var(--yellow); } .dot.g { background: var(--green); }
.best { margin: 0; text-align: center; font-weight: 700; color: var(--teal); min-height: 1.2em; }

.btn { font: inherit; font-weight: 800; border: 3px solid var(--ink); border-radius: 14px; padding: 12px 16px; background: #fff; color: var(--ink); box-shadow: var(--shadow); cursor: pointer; transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.big { font-size: 1.3rem; padding: 15px; }
.btn.primary { background: var(--yellow); }
.btn.ghost { background: transparent; box-shadow: none; border-style: dashed; font-weight: 700; }
.btn:focus-visible, .opt:focus-visible, .guest:focus-visible { outline: 4px solid var(--purple); outline-offset: 3px; }

/* 進度格（呼應桌遊步驟格） */
.track { display: flex; align-items: center; gap: 6px; justify-content: center; }
.track span { min-width: 46px; text-align: center; padding: 7px 8px; border: 3px solid var(--ink); border-radius: 10px; background: #fff; font-weight: 800; font-size: .85rem; opacity: .45; }
.track span.done { opacity: 1; background: #e8e2d4; }
.track span.now { opacity: 1; color: #fff; box-shadow: var(--shadow); transform: translateY(-3px); }

.brief-who { display: flex; gap: 12px; align-items: center; }
.brief-who img { width: 92px; height: 92px; border-radius: 18px; border: 3px solid var(--ink); box-shadow: var(--shadow); background: #fff; flex: none; }
.bubble { background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 12px 14px; font-weight: 700; line-height: 1.5; position: relative; }
.bubble::before { content: ""; position: absolute; left: -12px; top: 26px; border: 9px solid transparent; border-right-color: var(--ink); border-left: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips span { border: 2px solid var(--ink); border-radius: 99px; padding: 4px 12px; background: #fff; font-weight: 700; font-size: .9rem; }
.brief-mods { display: grid; gap: 6px; }
.brief-mods div { border: 2px dashed var(--ink); border-radius: 10px; padding: 8px 12px; background: #fffaf0; font-size: .9rem; }

/* HUD */
.hud { display: grid; gap: 6px; }
.hud-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hud-row.small { font-size: .92rem; }
.hud-row b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.shift-chip { color: #fff; font-weight: 800; border: 3px solid var(--ink); border-radius: 10px; padding: 4px 10px; box-shadow: 0 3px 0 var(--ink); }
.hearts { font-size: 1.35rem; letter-spacing: 2px; }
.hearts .off { filter: grayscale(1); opacity: .3; }
.timebar { height: 14px; border: 3px solid var(--ink); border-radius: 99px; background: #fff; overflow: hidden; }
.timebar div { height: 100%; background: var(--green); width: 100%; transition: width .1s linear; }
.combo { font-weight: 900; color: var(--pink); min-width: 70px; text-align: right; }

/* 客人 */
.guests { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; min-height: 118px; }
.guest { position: relative; border: 3px solid var(--ink); border-radius: 16px; background: #fff; padding: 8px 6px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; box-shadow: 0 4px 0 var(--ink); font: inherit; color: inherit; }
.guest.new { animation: arrive .3s ease-out; }
@keyframes arrive { from { transform: translateY(-14px) scale(.9); opacity: 0; } }
.guest.focus { background: #fff1c2; transform: translateY(-4px); box-shadow: 0 8px 0 var(--ink); }
.guest .ring { width: 66px; height: 66px; border-radius: 50%; padding: 5px; background: conic-gradient(var(--c, var(--green)) calc(var(--p, 1) * 360deg), #e6dccb 0); }
.guest img { width: 100%; height: 100%; border-radius: 50%; border: 2px solid var(--ink); background: #fff; object-fit: cover; display: block; }
.guest .icon { position: absolute; top: -10px; right: -6px; font-size: 1.4rem; background: #fff; border: 2px solid var(--ink); border-radius: 50%; width: 36px; height: 36px; display: grid; place-items: center; }
.guest .tag { font-size: .72rem; font-weight: 700; background: #efe5cf; border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.guest.angry { animation: shake .35s; }
.guest.urgent .ring { animation: pulse .6s infinite alternate; }
@keyframes pulse { to { transform: scale(1.06); } }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.slot-empty { border: 3px dashed #cdbfa6; border-radius: 16px; }

.ask { min-height: 108px; background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.ask .topic { align-self: flex-start; font-size: .78rem; font-weight: 800; color: #fff; border-radius: 6px; padding: 2px 8px; }
.ask .q { font-size: 1.22rem; font-weight: 900; line-height: 1.45; }
.ask-empty { text-align: center; color: #9c8c7c; font-weight: 700; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt { font: inherit; font-weight: 800; font-size: 1.02rem; line-height: 1.35; min-height: 72px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; box-shadow: 0 5px 0 var(--ink); padding: 10px 10px 10px 34px; text-align: left; position: relative; cursor: pointer; color: var(--ink); }
.opt::before { content: attr(data-k); position: absolute; left: 9px; top: 9px; width: 19px; height: 19px; border-radius: 6px; background: var(--ink); color: #fff; font-size: .72rem; display: grid; place-items: center; }
.opt:nth-child(1) { background: #ffe3e6; } .opt:nth-child(2) { background: #fff1c2; } .opt:nth-child(3) { background: #dff3e6; } .opt:nth-child(4) { background: #dde9fb; }
.opt:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.opt.ok { background: var(--green) !important; color: #fff; }

.fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: 16px; }
.float { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); font-weight: 900; font-size: 1.6rem; color: var(--green); -webkit-text-stroke: 1px var(--ink); animation: up 1s ease-out forwards; white-space: nowrap; }
.float.bad { color: var(--red); }
@keyframes up { to { transform: translate(-50%, -80px); opacity: 0; } }

.feedback { position: absolute; left: 12px; right: 12px; bottom: 16px; background: #fff; border: 3px solid var(--ink); border-radius: 18px; box-shadow: 0 8px 0 var(--ink); padding: 0 0 14px; display: grid; gap: 8px; animation: pop .2s; z-index: 5; overflow: hidden; }
.feedback[hidden] { display: none; }
.fb-head { background: var(--red); color: #fff; font-weight: 900; padding: 10px 14px; border-bottom: 3px solid var(--ink); }
.feedback p { margin: 0 14px; line-height: 1.6; }
.fb-pick s { color: var(--red); text-decoration-thickness: 2px; }
.fb-tip { font-weight: 700; background: #fff8e1; border-radius: 10px; padding: 8px 10px; }
.feedback .btn { margin: 4px 14px 0; }

/* 決策 */
.pnl { display: flex; justify-content: space-around; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 10px; font-weight: 700; text-align: center; box-shadow: var(--shadow); }
.pnl b { display: block; font-size: 1.2rem; }
.decisions { display: grid; gap: 12px; }
.dcard { font: inherit; color: inherit; text-align: left; display: grid; grid-template-columns: 54px 1fr; gap: 4px 12px; align-items: center; background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 12px; box-shadow: var(--shadow); cursor: pointer; }
.dcard:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.dcard .di { grid-row: span 3; font-size: 2.2rem; text-align: center; }
.dcard .dt { font-weight: 900; font-size: 1.1rem; display: flex; justify-content: space-between; gap: 8px; }
.dcard .dt small { color: var(--red); font-weight: 800; white-space: nowrap; }
.dcard .dd { font-weight: 700; color: var(--teal); }
.dcard .dl { font-size: .85rem; color: #6b5d52; }

/* 結算 */
.report-top { text-align: center; display: grid; gap: 4px; }
.stars { font-size: 2rem; letter-spacing: 4px; }
.stars .off { filter: grayscale(1); opacity: .25; }
#rp-title { font-size: 2rem; }
.pl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.pl td { padding: 7px 14px; border-bottom: 1px dashed #d8ccb6; }
.pl td:last-child { text-align: right; font-weight: 800; }
.pl tr.total td { border-bottom: 0; font-size: 1.15rem; background: #fff8e1; }
.neg { color: var(--red); }
.skill { padding: 8px 14px; }
.skill-row { display: flex; justify-content: space-between; font-weight: 800; font-size: .95rem; }
.bar { height: 12px; border: 2px solid var(--ink); border-radius: 99px; background: #f1ead9; overflow: hidden; margin-top: 4px; }
.bar div { height: 100%; }
.review { padding: 10px 14px; border-bottom: 1px dashed #d8ccb6; }
.review:last-child { border-bottom: 0; }
.review .rq { font-weight: 800; }
.review .ra { color: var(--green); font-weight: 800; margin: 2px 0; }
.review .rt { font-size: .9rem; color: #5d4f45; line-height: 1.55; }
.empty-ok { padding: 14px; font-weight: 700; color: var(--green); }

/* 關於 */
.steps { margin: 0; padding-left: 0; list-style: none; counter-reset: s; display: grid; gap: 8px; }
.steps li { counter-increment: s; background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 8px 12px 8px 46px; position: relative; line-height: 1.5; font-size: .93rem; }
.steps li::before { content: counter(s); position: absolute; left: 9px; top: 8px; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--ink); display: grid; place-items: center; font-weight: 900; color: #fff; background: var(--c); }
.steps li:nth-child(1) { --c: var(--red); } .steps li:nth-child(2) { --c: var(--yellow); } .steps li:nth-child(3) { --c: var(--green); }
.steps li:nth-child(4) { --c: var(--blue); } .steps li:nth-child(5) { --c: var(--purple); } .steps li:nth-child(6) { --c: var(--teal); } .steps li:nth-child(7) { --c: var(--pink); }
.steps b { display: block; }
.table-wrap { overflow-x: auto; }
.sim { width: 100%; border-collapse: collapse; font-size: .82rem; white-space: nowrap; }
.sim th, .sim td { padding: 6px 8px; border-bottom: 1px dashed #d8ccb6; text-align: left; }
.sim th { background: #f4eddd; }

@media (max-height: 700px) {
  .guest .ring { width: 54px; height: 54px; }
  .opt { min-height: 60px; }
  .ask { min-height: 92px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}

.dotsep { font-style: normal; color: #b9a88f; }
