/* 馬上辦中心小遊戲，沿用 styles.css 的色彩與按鈕 */
.game-page { min-height: 100vh; display: flex; flex-direction: column; }

.g-top {
  position: sticky; top: 0; z-index: 10;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
.g-top-in, .meters, .g-main, .g-foot { width: 100%; max-width: 720px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.g-top-in { display: flex; align-items: center; gap: 12px; min-height: 52px; }
.g-back { color: rgba(255, 255, 255, 0.8); text-decoration: none; font-size: 0.9rem; font-weight: 700; }
.g-brand { flex: 1; text-align: center; font-family: var(--serif); font-size: 1.15rem; color: var(--gold); letter-spacing: 0.08em; }
.g-pos { min-width: 64px; text-align: right; font-size: 0.85rem; font-weight: 700; opacity: 0.85; }

.meters[hidden] { display: none; }
.meters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding-bottom: 10px; }
.meter { display: grid; grid-template-columns: 1fr auto; gap: 2px 6px; font-size: 0.8rem; }
.m-label { font-weight: 700; white-space: nowrap; }
.m-val { text-align: right; font-variant-numeric: tabular-nums; }
.m-bar { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.18); overflow: hidden; }
.m-bar i { display: block; height: 100%; width: 50%; border-radius: inherit; background: var(--gold); transition: width 0.5s ease; }
.meter.low .m-bar i { background: #ff7a7a; }
.meter.bump .m-val { animation: bump 0.6s; }
@keyframes bump { 40% { transform: scale(1.35); } }

.g-main { flex: 1; padding-top: 20px; padding-bottom: 32px; }
.g-foot { padding-bottom: 32px; color: var(--muted); font-size: 0.82rem; }

.panel-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px 20px;
  box-shadow: var(--shadow);
  animation: rise 0.35s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.g-kicker { margin: 0 0 4px; color: var(--red); font-weight: 900; font-size: 0.85rem; letter-spacing: 0.1em; }
.g-title { margin: 0 0 12px; font-family: var(--serif); font-size: clamp(1.5rem, 6vw, 2.1rem); line-height: 1.3; }
.g-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.g-actions .btn { flex: 1 1 200px; }

/* ---------- 開場 ---------- */
.intro-hero {
  margin: -22px -20px 18px;
  padding: 28px 20px 22px;
  border-radius: 20px 20px 0 0;
  background: linear-gradient(160deg, var(--navy), var(--navy-2));
  color: #fff;
  text-align: center;
}
.intro-hero .sign {
  display: inline-block;
  padding: 8px 18px;
  border: 3px solid var(--gold);
  border-radius: 10px;
  color: var(--gold);
  font-family: var(--serif);
  font-size: clamp(1.8rem, 9vw, 2.6rem);
  font-weight: 900;
  letter-spacing: 0.2em;
}
.intro-hero p { margin: 12px 0 0; opacity: 0.9; }
.rules { margin: 0; padding-left: 1.2em; }
.rules li { margin: 6px 0; }
.best { margin: 14px 0 0; color: var(--muted); font-size: 0.9rem; }

/* ---------- 年度過場 ---------- */
.year-card { text-align: center; padding: 48px 20px; }
.year-card .year-title { margin: 0; font-family: var(--serif); font-size: clamp(2.2rem, 11vw, 3.2rem); color: var(--navy-2); }
.year-card .sub { margin: 6px 0 0; color: var(--muted); font-weight: 700; }
@media (prefers-color-scheme: dark) { .year-card .year-title { color: var(--gold); } }

/* ---------- 陳情案 ---------- */
.citizen-name { margin: 0; font-weight: 900; }
.citizen-tag { margin-left: 8px; color: var(--muted); font-size: 0.85rem; font-weight: 500; }
.case-title { margin: 2px 0 8px; font-family: var(--serif); font-size: 1.35rem; line-height: 1.4; }
.bubble {
  position: relative;
  margin: 0;
  padding: 14px 16px;
  border-radius: 4px 16px 16px 16px;
  background: var(--chip);
}

.timer { margin: 18px 0 6px; }
.timer-row { display: flex; justify-content: space-between; font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.timer-bar { height: 10px; margin-top: 4px; border-radius: 99px; background: var(--chip); overflow: hidden; }
.timer-bar i { display: block; height: 100%; width: 100%; background: var(--navy-2); border-radius: inherit; }
.timer.hurry .timer-bar i { background: var(--red); }
.timer.hurry .timer-row { color: var(--red); }

.choices { display: grid; gap: 10px; margin-top: 14px; }
.choice {
  display: flex; gap: 12px; align-items: flex-start;
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
  line-height: 1.5;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.12s;
}
.choice:hover { border-color: var(--navy-2); }
.choice:active { transform: scale(0.99); }
.choice:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.choice .key {
  flex: none;
  display: grid; place-items: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--navy);
  color: var(--gold);
  font-weight: 900;
  font-size: 0.9rem;
}

/* ---------- 處理結果 ---------- */
.verdict { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-weight: 900; font-size: 1.15rem; }
.stamp {
  display: inline-block;
  padding: 2px 10px;
  border: 3px solid currentColor;
  border-radius: 8px;
  font-family: var(--serif);
  transform: rotate(-4deg);
}
.verdict.good { color: #1a8a4a; }
.verdict.meh { color: #b7791f; }
.verdict.bad { color: var(--red); }
@media (prefers-color-scheme: dark) {
  .verdict.good { color: #5ad18b; }
  .verdict.meh { color: #f2c060; }
  .verdict.bad { color: #ff8a8a; }
}
.deltas { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.deltas li { padding: 4px 10px; border-radius: 99px; background: var(--chip); font-size: 0.85rem; font-weight: 700; }
.deltas .up { color: #1a8a4a; }
.deltas .down { color: var(--red); }
@media (prefers-color-scheme: dark) { .deltas .up { color: #5ad18b; } .deltas .down { color: #ff8a8a; } }

.lesson { margin-top: 18px; display: grid; gap: 12px; }
.lesson section { padding: 14px 16px; border-radius: 14px; }
.lesson h3 { margin: 0 0 4px; font-size: 0.95rem; }
.lesson p { margin: 0; }
.lesson .issue { background: var(--chip); }
.lesson .issue h3 { color: var(--muted); }
.lesson .fix { background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff; }
.lesson .fix h3 { color: var(--gold); }
.cards { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.cards a {
  padding: 6px 12px;
  border-radius: 99px;
  background: var(--gold);
  color: #0a2463;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
}
.srcs { margin: 10px 0 0; font-size: 0.78rem; color: var(--muted); }
.srcs summary { cursor: pointer; }
.srcs ul { margin: 6px 0 0; padding-left: 1.2em; }

/* ---------- 成績單 ---------- */
.report { text-align: center; }
.report .rank {
  display: inline-block;
  margin: 6px 0 4px;
  padding: 8px 18px;
  border: 4px double var(--red);
  border-radius: 12px;
  color: var(--red);
  font-family: var(--serif);
  font-size: clamp(1.5rem, 7vw, 2.1rem);
  font-weight: 900;
  transform: rotate(-2deg);
}
.report .rank-desc { margin: 8px 0 0; font-weight: 700; }
.scores { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 20px 0 0; }
.scores div { padding: 12px 6px; border-radius: 14px; background: var(--chip); }
.scores b { display: block; font-size: 1.7rem; font-family: var(--serif); }
.scores span { font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.tally { margin: 14px 0 0; color: var(--muted); }
.done-list { margin-top: 18px; text-align: left; }
.done-list h3 { margin: 0 0 8px; font-size: 1rem; }
.done-list .cards { margin-top: 0; }
.mayor-note {
  margin-top: 20px;
  padding: 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: #fff;
  text-align: left;
}
.mayor-note strong { color: var(--gold); }
.mayor-note p { margin: 6px 0 0; }

@media (prefers-reduced-motion: reduce) {
  .panel-card, .meter.bump .m-val { animation: none; }
}

/* ---------- 市長直播間 ---------- */
.live {
  position: relative;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  max-height: 46vh;
  min-height: 250px;
  overflow: hidden;
  color: #fff;
  /* 紅磚牆 */
  background: #c4614e url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='96' height='48'><rect width='96' height='48' fill='%23e8d3c4'/><g fill='%23c8624d'><rect x='2' y='2' width='44' height='20' rx='1'/><rect x='50' y='2' width='44' height='20' rx='1' fill='%23bf5946'/><rect x='-22' y='26' width='44' height='20' rx='1' fill='%23cf6c55'/><rect x='26' y='26' width='44' height='20' rx='1'/><rect x='74' y='26' width='44' height='20' rx='1' fill='%23cf6c55'/></g></svg>") 0 0 / 96px 48px;
}
.live::after { /* 左側淡淡的燈光 */
  z-index: 2;
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.12), transparent 40%, rgba(0, 0, 0, 0.12));
  pointer-events: none;
}
.live-photo {
  position: absolute; inset: 0; z-index: 1;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 48% 0%;
  transform-origin: 48% 100%;
}
/* 市長的反應：data-mood＝talk 一般、happy 開心、angry 生氣 */
.live-photo.face-happy, .live-photo.face-angry { opacity: 0; }
.live[data-mood="happy"] .face-happy, .live[data-mood="angry"] .face-angry { opacity: 1; }
.live[data-mood="happy"] .live-photo { animation: cheer 0.5s ease-in-out 3; }
.live[data-mood="angry"] .live-photo { animation: shake 0.12s linear 6; }
@keyframes cheer { 50% { transform: translateY(-6px) scale(1.02); } }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.live[data-mood="angry"]::after { background: radial-gradient(transparent 55%, rgba(200, 16, 46, 0.35)); }
.mood-pop { position: absolute; left: 60%; top: 16%; z-index: 4; pointer-events: none; }
.mood-pop span {
  display: none;
  padding: 6px 14px;
  border-radius: 999px 999px 999px 4px;
  background: #fff;
  color: #0a2463;
  font-weight: 900;
  font-size: clamp(0.85rem, 2.6vw, 1.15rem);
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: popIn 0.35s ease;
}
.mood-pop .pop-angry { color: var(--red); }
.live[data-mood="happy"] .pop-happy, .live[data-mood="angry"] .pop-angry { display: inline-block; }
@keyframes popIn { from { transform: scale(0.3); opacity: 0; } }

.live-logo {
  position: absolute; top: 10px; left: 10px; z-index: 3;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px 6px 8px;
  background: #fff;
  color: #0a2463;
  clip-path: polygon(0 0, 100% 0, 92% 100%, 0 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.live-logo svg { width: 28px; height: 28px; }
.live-logo span { display: flex; flex-direction: column; line-height: 1.05; padding-right: 8px; }
.live-logo b { font-size: 1.05rem; letter-spacing: 0.15em; }
.live-logo small { font-size: 0.5rem; font-weight: 700; letter-spacing: 0.08em; }

.live-badge {
  position: absolute; top: 12px; right: 12px; z-index: 3;
  display: flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 0.75rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.live-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #ff3b3b; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

.live-banner {
  position: absolute; top: 44px; right: 4%; z-index: 2;
  padding: 14px 8px;
  border: 3px solid #0a2463;
  outline: 2px solid #fff;
  outline-offset: -7px;
  background: #fff;
  color: #0a2463;
  font-family: var(--serif);
  font-weight: 900;
  font-size: clamp(0.8rem, 2.4vw, 1.2rem);
  line-height: 1.25;
  letter-spacing: 0.12em;
  writing-mode: vertical-rl;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.live-caption {
  position: absolute; left: 50%; bottom: 10px; z-index: 4;
  transform: translateX(-50%);
  width: min(92%, 560px);
  margin: 0;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(10, 36, 99, 0.88);
  font-size: clamp(0.78rem, 2.3vw, 0.95rem);
  font-weight: 700;
  text-align: center;
  line-height: 1.45;
}
.live-caption b { color: var(--gold); }

.live-chat {
  position: absolute; left: 8px; top: 56px; bottom: 52px; z-index: 3;
  width: min(42%, 330px);
  margin: 0; padding: 0;
  list-style: none;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 4px;
  overflow: hidden;
  font-size: clamp(0.68rem, 1.9vw, 0.82rem);
  line-height: 1.35;
  -webkit-mask: linear-gradient(transparent, #000 30%);
          mask: linear-gradient(transparent, #000 30%);
}
.live-chat li { display: flex; gap: 6px; align-items: flex-start; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7); animation: chatIn 0.3s ease; }
@keyframes chatIn { from { opacity: 0; transform: translateY(8px); } }
.live-chat .ava { flex: none; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: rgba(255, 255, 255, 0.85); font-size: 0.7rem; text-shadow: none; }
.live-chat .nm { color: #ffe7a8; font-weight: 700; margin-right: 4px; }
.live-chat li.pin { padding: 5px 7px; border-radius: 8px; background: rgba(10, 36, 99, 0.85); text-shadow: none; border-left: 4px solid var(--gold); }
.live-chat li.pin .nm { color: var(--gold); }
.live-chat li.good .nm { color: #9cf0b8; }
.live-chat li.bad .nm { color: #ffb0b0; }

.hearts { position: absolute; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
.hearts span { position: absolute; bottom: 40px; font-size: 1.4rem; animation: floatUp 2.2s ease-out forwards; }
@keyframes floatUp { to { transform: translate(var(--dx), -260px) scale(1.3); opacity: 0; } }

@media (max-width: 560px) {
  .live { aspect-ratio: 1 / 1; max-height: 46vh; min-height: 260px; }
  .live-banner { top: 40px; padding: 10px 5px; }
  .mood-pop { left: auto; right: 6px; top: 42%; }
  /* 手機上留言只占左下角，不擋住市長 */
  .live-chat { width: 46%; top: 58%; bottom: 56px; gap: 2px; }
  .live-logo b { font-size: 0.9rem; }
  .live-logo svg { width: 22px; height: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .live-photo, .mood-pop span, .live-badge .dot, .live-chat li, .hearts span { animation: none !important; }
  .hearts { display: none; }
}

/* ---------- 櫃台前的市民 ---------- */
.counter { display: flex; gap: 12px; align-items: flex-end; }
.counter-talk { flex: 1; min-width: 0; }
.fig { position: relative; flex: none; width: 104px; margin-bottom: -6px; }
.fig svg { display: block; width: 100%; height: auto; overflow: visible; }
.fig-badge {
  position: absolute; right: -4px; bottom: 6px;
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--line);
  font-size: 1rem;
}
.fig .f-wait, .fig .f-good, .fig .f-meh, .fig .f-bad, .fig .fx-good, .fig .fx-bad { display: none; }
.fig[data-mood="wait"] .f-wait, .fig[data-mood="good"] .f-good, .fig[data-mood="meh"] .f-meh, .fig[data-mood="bad"] .f-bad,
.fig[data-mood="good"] .fx-good, .fig[data-mood="bad"] .fx-bad { display: inline; }
.fig .body, .fig .head, .fig .arm-l, .fig .arm-r, .fig .leg-l, .fig .leg-r, .fig .fx-good, .fig .fx-bad { transform-box: view-box; }
.fig .arm-l { transform-origin: 42px 92px; }
.fig .arm-r { transform-origin: 78px 92px; }
.fig .head { transform-origin: 60px 80px; }
.fig .body { transform-origin: 60px 142px; }

/* 等待：焦急踱步、時間快到時更急 */
.fig[data-mood="wait"] .body { animation: fidget 1.4s ease-in-out infinite; }
.fig[data-mood="wait"] .leg-r { transform-origin: 68px 118px; animation: tap 0.5s ease-in-out infinite; }
.fig[data-mood="wait"] .arm-r { animation: rub 1.4s ease-in-out infinite; }
.fig[data-mood="wait"] .sweat { display: none; }
.fig.hurry .body { animation-duration: 0.5s; }
.fig.hurry .sweat { display: inline; animation: drip 0.8s ease-in infinite; }
@keyframes fidget { 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
@keyframes tap { 50% { transform: rotate(-14deg); } }
@keyframes rub { 50% { transform: rotate(-35deg); } }
@keyframes drip { to { transform: translateY(8px); opacity: 0; } }

/* 答對：開心跳起來、雙手高舉 */
.fig[data-mood="good"] .body { animation: jump 0.55s ease-in-out 4; }
.fig[data-mood="good"] .arm-l { transform: rotate(130deg); animation: cheer-l 0.55s ease-in-out 4; }
.fig[data-mood="good"] .arm-r { transform: rotate(-130deg); animation: cheer-r 0.55s ease-in-out 4; }
.fig[data-mood="good"] .fx-good { animation: sparkle 1.1s ease-in-out infinite; }
@keyframes jump { 40% { transform: translateY(-16px); } 60% { transform: translateY(-16px); } }
@keyframes cheer-l { 50% { transform: rotate(150deg); } }
@keyframes cheer-r { 50% { transform: rotate(-150deg); } }
@keyframes sparkle { 50% { opacity: 0.4; transform: translateY(-4px); } }

/* 治標不治本：歪頭聳肩 */
.fig[data-mood="meh"] .head { animation: tilt 2s ease-in-out infinite; }
.fig[data-mood="meh"] .arm-l { transform: rotate(40deg); }
.fig[data-mood="meh"] .arm-r { transform: rotate(-40deg); }
@keyframes tilt { 50% { transform: rotate(-10deg); } }

/* 答錯：垂頭喪氣、頭上烏雲下雨 */
.fig[data-mood="bad"] .head { transform: rotate(8deg) translateY(4px); }
.fig[data-mood="bad"] .body { animation: sob 0.6s ease-in-out infinite; }
.fig[data-mood="bad"] .arm-l { transform: rotate(-8deg); }
.fig[data-mood="bad"] .arm-r { transform: rotate(8deg); }
.fig[data-mood="bad"] .rain { animation: rain 0.7s linear infinite; }
.fig[data-mood="bad"] .tear { animation: drip 0.9s ease-in infinite; }
@keyframes sob { 50% { transform: translateY(2px) scaleY(0.97); } }
@keyframes rain { from { transform: translateY(-3px); opacity: 1; } to { transform: translateY(8px); opacity: 0; } }

.fired { margin: 0 0 4px; flex-basis: 100%; color: var(--red); font-weight: 900; }

/* ---------- 特殊結局 ---------- */
.mayor-say {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid var(--gold);
  text-align: left;
}
.mayor-say p { margin: 6px 0 0; font-weight: 700; }
.report.zero .rank { border-color: var(--muted); color: var(--muted); }
.report.full .rank { border-color: var(--gold); color: #b8860b; animation: glow 1.4s ease-in-out infinite; }
@media (prefers-color-scheme: dark) { .report.full .rank { color: var(--gold); } }
@keyframes glow { 50% { box-shadow: 0 0 24px rgba(255, 200, 61, 0.7); } }

@media (max-width: 560px) {
  .fig { width: 84px; }
  .case-title { font-size: 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  .fig .body, .fig .head, .fig .arm-l, .fig .arm-r, .fig .leg-r, .fig .fx-good, .fig .rain, .fig .tear, .fig .sweat, .report.full .rank { animation: none !important; }
}

/* ---------- 電腦版：左邊直播間、右邊答題，整頁不捲動 ---------- */
@media (min-width: 960px) {
  .game-page { height: 100vh; height: 100dvh; overflow: hidden; }
  /* 頂部改成一列：返回、標題、進度、三項指標 */
  .g-top { display: flex; align-items: center; gap: 24px; padding: 0 24px; }
  .g-top-in { flex: none; width: auto; max-width: none; margin: 0; padding: 0; gap: 20px; }
  .g-brand { flex: none; }
  .g-pos { min-width: 96px; text-align: left; }
  .meters { flex: 1; max-width: 760px; margin: 0 0 0 auto; padding: 8px 0; }
  .meters[hidden] { display: grid; visibility: hidden; }
  .g-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(400px, 1fr);
  }
  .live { max-width: none; height: 100%; aspect-ratio: auto; max-height: none; min-height: 0; }
  .live-photo { object-position: 50% 0%; }
  .live-chat { top: 64px; bottom: 64px; width: min(46%, 340px); }
  .live-caption { bottom: 16px; }
  .g-side { min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; }
  .g-main, .g-foot { max-width: 640px; padding-left: 20px; padding-right: 20px; }
  .g-main { flex: 1; padding-top: 18px; padding-bottom: 12px; }
  .g-foot { padding-bottom: 16px; font-size: 0.75rem; }
  .panel-card { padding: 18px; }
  .intro-hero { margin: -18px -18px 14px; padding: 20px 18px 16px; }
  .year-card { padding: 40px 18px; }
}

.candno-sm { flex: none; display: inline-flex; align-items: center; gap: 0.35rem; margin-left: 0.5rem; color: var(--gold); font-family: var(--serif); font-weight: 900; font-size: 0.9rem; white-space: nowrap; }
.candno-sm b { width: 1.7rem; height: 1.7rem; border-width: 0.2rem; font-size: 0.95rem; }
