/* =========================================================
   黃家齊一日市議員 — 主樣式
   ========================================================= */
:root {
  --c-primary: #3F8E47;
  --c-primary-dark: #1B8A35;
  --c-primary-light: #4a73a3;
  --c-accent: #7ED957;
  --c-accent-dark: #5DBB63;
  --c-warm: #ed8936;
  --c-warm-dark: #c05621;
  --c-danger: #e53e3e;
  --c-energy: #805ad5;
  --c-hunger: #dd6b20;
  --c-health: #e53e3e;
  --c-success: #48bb78;
  --c-bg: #fefcf3;
  --c-bg-warm: #F4FFEF;
  --c-card: #ffffff;
  --c-text: #1a202c;
  --c-text-soft: #4a5568;
  --c-text-mute: #718096;
  --c-border: #e2e8f0;
  --shadow-sm: 0 2px 4px rgba(26,32,44,0.08);
  --shadow-md: 0 4px 12px rgba(26,32,44,0.12);
  --shadow-lg: 0 8px 24px rgba(26,32,44,0.16);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 999px;
  --font-tc: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font-tc);
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

button { font-family: inherit; cursor: pointer; }

/* =========================================================
   App Shell
   ========================================================= */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--c-bg);
  position: relative;
  box-shadow: 0 0 40px rgba(26,32,44,0.08);
  overflow: hidden;
}

@media (min-width: 768px) {
  body { background: linear-gradient(135deg, #F4FFEF 0%, #fce5d8 100%); padding: 20px 0; }
  .app { border-radius: 20px; min-height: calc(100vh - 40px); }
}

/* =========================================================
   Top Bar
   ========================================================= */
.topbar {
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-dark) 100%);
  color: #fff;
  padding: 14px 16px 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 3px solid var(--c-accent);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.topbar-title .badge {
  background: var(--c-accent);
  color: var(--c-primary-dark);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 900;
}

.day-indicator {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.day-indicator .day-num {
  background: var(--c-accent);
  color: var(--c-primary-dark);
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
}

/* =========================================================
   屬性 HUD（生理三槽）
   ========================================================= */
.stats-hud {
  background: rgba(255,255,255,0.95);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border-bottom: 1px solid var(--c-border);
}

.stat-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-bar-head {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text-soft);
}

.stat-bar-head svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.stat-bar-value {
  margin-left: auto;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--c-text);
  font-size: 12px;
}

.stat-bar-track {
  height: 10px;
  background: var(--c-border);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.stat-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(90deg, var(--bar-color), var(--bar-color-light));
}

.stat-bar[data-stat="hp"]      { --bar-color: #e53e3e; --bar-color-light: #fc8181; }
.stat-bar[data-stat="en"]      { --bar-color: #805ad5; --bar-color-light: #b794f4; }
.stat-bar[data-stat="hunger"]  { --bar-color: #dd6b20; --bar-color-light: #f6ad55; }

.stat-bar.critical .stat-bar-fill {
  animation: pulse-warn 0.8s ease-in-out infinite;
}

@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* =========================================================
   評分 HUD（橫向）
   ========================================================= */
.score-hud {
  display: flex;
  background: var(--c-bg-warm);
  padding: 10px 12px;
  gap: 8px;
  border-bottom: 1px solid var(--c-border);
  font-size: 12px;
}

.score-cell {
  flex: 1;
  text-align: center;
  background: #fff;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.score-cell svg { width: 20px; height: 20px; }
.score-cell-label { font-size: 10px; color: var(--c-text-mute); font-weight: 600; }
.score-cell-value {
  font-family: var(--font-mono);
  font-weight: 900;
  color: var(--c-primary);
  font-size: 14px;
}

/* =========================================================
   場景區（角色 + 背景）
   ========================================================= */
.scene-stage {
  position: relative;
  height: 260px;
  overflow: hidden;
  background: linear-gradient(180deg, #cce4f9 0%, #F4FFEF 80%, #fbd38d 100%);
}

.scene-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scene-character {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  height: 220px;
  width: auto;
  filter: drop-shadow(0 8px 12px rgba(26,32,44,0.2));
  z-index: 2;
}

.scene-label {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(26,32,44,0.75);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  backdrop-filter: blur(8px);
  z-index: 3;
}

.scene-time {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--c-accent);
  color: var(--c-primary-dark);
  font-size: 11px;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 4px;
}

.scene-time svg { width: 14px; height: 14px; }

/* =========================================================
   對話框（事件描述）
   ========================================================= */
.event-card {
  margin: 12px;
  background: #fff;
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--c-border);
}

.event-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 2px dashed var(--c-border);
}

.event-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.event-tag[data-type="question"]  { background: #c6f6d5; color: #22543d; }
.event-tag[data-type="petition"]  { background: #feebc8; color: #7b341e; }
.event-tag[data-type="news"]      { background: #fed7d7; color: #822727; }
.event-tag[data-type="policy"]    { background: #bee3f8; color: #2a4365; }
.event-tag[data-type="visit"]     { background: #fefcbf; color: #744210; }

.event-title {
  font-size: 16px;
  font-weight: 900;
  color: var(--c-text);
}

.event-desc {
  font-size: 14px;
  color: var(--c-text-soft);
  line-height: 1.6;
}

/* =========================================================
   行動選擇（按鈕組）
   ========================================================= */
.actions {
  padding: 0 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-btn {
  background: #fff;
  border: 2px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.action-btn:hover, .action-btn:focus-visible {
  border-color: var(--c-primary);
  background: var(--c-bg-warm);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.action-btn:active {
  transform: translateY(0);
}

.action-icon {
  width: 36px;
  height: 36px;
  background: var(--c-bg-warm);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.action-icon svg { width: 24px; height: 24px; }

.action-body { flex: 1; }
.action-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--c-text);
  margin-bottom: 2px;
}
.action-cost {
  font-size: 11px;
  color: var(--c-text-mute);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.action-cost span { display: inline-flex; align-items: center; gap: 2px; }

.action-cost .cost-en { color: var(--c-energy); }
.action-cost .cost-hp { color: var(--c-health); }
.action-cost .cost-hg { color: var(--c-hunger); }
.action-cost .gain-app { color: var(--c-warm-dark); }
.action-cost .gain-ovr { color: var(--c-primary); }

/* 突顯重要選項 */
.action-btn.primary {
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-dark) 100%);
  border-color: var(--c-primary-dark);
  color: #fff;
}
.action-btn.primary .action-icon { background: rgba(255,255,255,0.2); }
.action-btn.primary .action-title { color: #fff; }
.action-btn.primary .action-cost { color: rgba(255,255,255,0.85); }
.action-btn.primary .action-cost span { color: #fff; }

/* =========================================================
   結算考核單
   ========================================================= */
.scorecard {
  margin: 16px;
  background: linear-gradient(180deg, #fff 0%, #F4FFEF 100%);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 3px solid var(--c-accent);
  position: relative;
  box-shadow: var(--shadow-lg);
}

.scorecard::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px dashed var(--c-accent-dark);
  border-radius: 14px;
  pointer-events: none;
}

.scorecard-head {
  text-align: center;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 2px dashed var(--c-accent-dark);
}

.scorecard-title {
  font-size: 20px;
  font-weight: 900;
  color: var(--c-primary-dark);
  letter-spacing: 0.05em;
}

.scorecard-subtitle {
  font-size: 11px;
  color: var(--c-text-soft);
  margin-top: 4px;
}

.scorecard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.score-row {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 10px;
  border: 1px solid var(--c-border);
}

.score-row-label {
  font-size: 11px;
  color: var(--c-text-mute);
  display: flex;
  align-items: center;
  gap: 4px;
}

.score-row-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 900;
  color: var(--c-primary);
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.score-row-value small { font-size: 12px; color: var(--c-text-mute); }

.scorecard-total {
  text-align: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 2px solid var(--c-primary);
}

.scorecard-grade {
  display: inline-block;
  font-size: 56px;
  font-weight: 900;
  font-family: var(--font-mono);
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.scorecard-rank {
  font-size: 14px;
  color: var(--c-text-soft);
  font-weight: 700;
  margin-top: -10px;
}

.scorecard-total-score {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 900;
  color: var(--c-primary-dark);
  margin: 6px 0;
}

/* =========================================================
   抽獎登錄頁
   ========================================================= */
.lottery-section {
  margin: 16px;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 2px solid var(--c-warm);
  box-shadow: var(--shadow-md);
}

.lottery-banner {
  background: linear-gradient(135deg, var(--c-warm) 0%, #f56565 100%);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.lottery-banner::before {
  content: '🎁';
  position: absolute;
  right: -10px;
  top: -10px;
  font-size: 80px;
  opacity: 0.2;
}

.lottery-banner h3 {
  font-size: 18px;
  font-weight: 900;
  margin-bottom: 6px;
}
.lottery-banner p {
  font-size: 12px;
  opacity: 0.95;
}
.lottery-banner strong { font-weight: 900; }

.form-group {
  margin-bottom: 12px;
}

.form-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text-soft);
  margin-bottom: 4px;
  display: block;
}
.form-label .required { color: var(--c-danger); }

.form-input {
  width: 100%;
  border: 2px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--c-bg);
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--c-primary);
  background: #fff;
}

.privacy-note {
  font-size: 11px;
  color: var(--c-text-mute);
  background: var(--c-bg-warm);
  padding: 10px;
  border-radius: var(--radius-sm);
  margin: 12px 0;
  line-height: 1.6;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-dark) 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.05em;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn-primary:active { transform: translateY(0); }

.btn-share {
  background: linear-gradient(135deg, var(--c-warm) 0%, #f56565 100%);
}

/* =========================================================
   排行榜
   ========================================================= */
.leaderboard {
  margin: 16px;
}

.leaderboard-tab {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  background: var(--c-bg-warm);
  padding: 4px;
  border-radius: var(--radius-full);
}

.leaderboard-tab button {
  flex: 1;
  border: none;
  padding: 8px 12px;
  border-radius: var(--radius-full);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text-soft);
}
.leaderboard-tab button.active {
  background: #fff;
  color: var(--c-primary);
  box-shadow: var(--shadow-sm);
}

.rank-list {
  background: #fff;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--c-border);
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-border);
}
.rank-row:last-child { border-bottom: none; }

.rank-row.top1 { background: linear-gradient(90deg, #F4FFEF 0%, transparent 100%); }
.rank-row.top2 { background: linear-gradient(90deg, #e2e8f0 0%, transparent 100%); }
.rank-row.top3 { background: linear-gradient(90deg, #fed7aa 0%, transparent 100%); }

.rank-no {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--c-bg-warm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-family: var(--font-mono);
  color: var(--c-text-soft);
  flex-shrink: 0;
}
.rank-row.top1 .rank-no { background: var(--c-accent); color: #fff; }
.rank-row.top2 .rank-no { background: #a0aec0; color: #fff; }
.rank-row.top3 .rank-no { background: var(--c-warm); color: #fff; }

.rank-name { flex: 1; font-weight: 700; font-size: 14px; }
.rank-score {
  font-family: var(--font-mono);
  font-weight: 900;
  color: var(--c-primary);
  font-size: 16px;
}
.rank-grade {
  background: var(--c-primary);
  color: #fff;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 900;
}

/* =========================================================
   通用元件
   ========================================================= */
.section-title {
  font-size: 16px;
  font-weight: 900;
  margin: 16px 16px 8px;
  color: var(--c-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  width: 4px;
  height: 18px;
  background: var(--c-accent);
  border-radius: 2px;
}

.divider {
  height: 1px;
  background: var(--c-border);
  margin: 16px;
}

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
}
.pill-blue   { background: #bee3f8; color: #3F8E47; }
.pill-warm   { background: #feebc8; color: #7b341e; }
.pill-green  { background: #c6f6d5; color: #22543d; }
.pill-red    { background: #fed7d7; color: #822727; }
.pill-purple { background: #e9d8fd; color: #553c9a; }

/* =========================================================
   入場 / 退場動畫
   ========================================================= */
@keyframes slideUp { from { transform: translateY(20px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }
.slide-up { animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1); }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.fade-in { animation: fadeIn 0.3s ease; }

@keyframes bounce-in {
  0%   { transform: scale(0.8); opacity: 0; }
  60%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); }
}
.bounce-in { animation: bounce-in 0.5s cubic-bezier(0.16, 1, 0.3, 1); }
