:root {
  --bg-base: #0b1120;
  --bg-surface: #131c31;
  --bg-elevated: #1b2742;
  --bg-hover: #233354;
  --bg-topbar: rgba(11, 17, 32, 0.9);
  --bg-nav: rgba(15, 23, 42, 0.95);
  --bg-sidebar: rgba(15, 23, 42, 0.92);
  --bg-extra-card: rgba(30, 41, 59, 0.72);
  --border-subtle: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.3);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-gold: #fde68a;
  --text-green: #86efac;
  --text-blue: #7dd3fc;
  --text-red: #fca5a5;
  --text-purple: #e9d5ff;
  --text-orange: #fdba74;

  --accent-gold: #f59e0b;
  --accent-gold-soft: rgba(245, 158, 11, 0.16);
  --accent-blue: #38bdf8;
  --accent-green: #22c55e;
  --accent-purple: #a855f7;
  --accent-red: #ef4444;
  --accent-red-soft: rgba(239, 68, 68, 0.14);

  --shell-glow-1: rgba(56, 189, 248, 0.08);
  --shell-glow-2: rgba(245, 158, 11, 0.08);
  --hero-bg: linear-gradient(135deg, #1e1b4b 0%, #172554 48%, #0f172a 100%);
  --hero-border: rgba(245, 158, 11, 0.38);
  --hero-num-grad: linear-gradient(180deg, #fef3c7 0%, #f59e0b 100%);
  --hero-label: #cbd5e1;

  --btn-primary-bg: linear-gradient(135deg, #f59e0b, #d97706);
  --btn-primary-hover: linear-gradient(135deg, #fbbf24, #f59e0b);
  --btn-primary-text: #0b1120;

  --cat-work: #3b82f6;
  --cat-daily: #14b8a6;
  --cat-health: #22c55e;
  --cat-learning: #a855f7;
  --cat-social: #f97316;

  --rarity-rough: #94a3b8;
  --rarity-common: #e2e8f0;
  --rarity-fine: #22c55e;
  --rarity-rare: #38bdf8;
  --rarity-epic: #a855f7;
  --rarity-legendary: #f59e0b;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-glow-gold: 0 0 24px rgba(245, 158, 11, 0.2);

  --sidebar-width: 272px;
  --bottom-nav-height: 68px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* ==================== Layout Shell ==================== */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 15% 0%, var(--shell-glow-1), transparent 50%),
    radial-gradient(ellipse at 85% 10%, var(--shell-glow-2), transparent 45%),
    var(--bg-base);
}

/* Mobile Topbar */
.mobile-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-topbar);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

.brand-compact {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.02em;
}

.brand-logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
}

.mobile-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.balance-pill-mini {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: var(--radius-full);
  background: var(--accent-gold-soft);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--text-gold);
  font-weight: 700;
  font-size: 13px;
}

/* Desktop Sidebar */
.desktop-sidebar {
  display: none;
}

.main-content {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 14px calc(var(--bottom-nav-height) + var(--safe-bottom) + 28px);
}

/* Mobile Bottom Nav */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: calc(var(--bottom-nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-nav);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-subtle);
}

.bottom-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  transition: color 0.15s ease;
  position: relative;
}

.bottom-nav-btn.active {
  color: var(--accent-gold);
}

.bottom-nav-btn.active::before {
  content: "";
  position: absolute;
  top: 0;
  width: 34px;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--accent-gold);
}

.nav-badge-dot {
  position: absolute;
  top: 9px;
  right: calc(50% - 16px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-red);
  box-shadow: 0 0 0 2px var(--bg-surface);
}

@media (min-width: 860px) {
  .mobile-topbar,
  .mobile-bottom-nav {
    display: none;
  }

  .app-shell {
    flex-direction: row;
  }

  .desktop-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px 16px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    overflow-y: auto;
  }

  .main-content {
    flex: 1;
    padding: 28px 32px 48px;
  }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
}

.sidebar-brand h1 {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.sidebar-brand span {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-nav-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  transition: all 0.15s ease;
}

.sidebar-nav-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.sidebar-nav-btn.active {
  background: var(--accent-gold-soft);
  color: var(--text-gold);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.sidebar-levels-card {
  margin-top: auto;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.sidebar-levels-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

/* ==================== Monthly Target Red Text ==================== */
.monthly-target-text {
  color: #ef4444 !important;
  font-weight: 800 !important;
}

/* ==================== Common Cards & Buttons ==================== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-card);
}

.card-sm {
  padding: 14px;
  border-radius: var(--radius-md);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-title {
  font-size: 17px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  transition: transform 0.1s ease, background 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--btn-primary-hover);
}

.btn-success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #052e16;
}

.btn-success:hover:not(:disabled) {
  background: linear-gradient(135deg, #4ade80, #22c55e);
}

.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn-danger {
  background: var(--accent-red-soft);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: var(--text-red);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
}

.btn-ghost {
  color: var(--text-secondary);
  padding: 7px 10px;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

/* ==================== Hero Balance Banner ==================== */
.hero-balance-card {
  position: relative;
  overflow: hidden;
  background: var(--hero-bg);
  border: 1px solid var(--hero-border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-glow-gold), var(--shadow-card);
  margin-bottom: 10px;
}

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

.hero-label {
  font-size: 12px;
  color: var(--hero-label);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}

.hero-balance-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 2px;
}

.hero-balance-number {
  font-size: clamp(30px, 6.5vw, 44px);
  font-weight: 900;
  letter-spacing: -0.02em;
  background: var(--hero-num-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.05;
}

.hero-balance-unit {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-gold);
}

.hero-balance-hm {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-left: 2px;
}

.hero-sub-meta {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.buffs-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.buff-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  background: rgba(168, 85, 247, 0.18);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: var(--text-purple);
}

.buff-badge.buff-gold {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.45);
  color: var(--text-gold);
}

.buff-badge.buff-red {
  background: var(--accent-red-soft);
  border-color: rgba(239, 68, 68, 0.45);
  color: var(--text-red);
}

/* ==================== Category Level Grid (Compact) ==================== */
.cat-levels-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 10px;
}

.cat-level-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 6px 6px;
  min-width: 0;
}

.cat-level-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.cat-level-name-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.cat-level-lv {
  color: var(--text-gold);
  font-size: 10.5px;
  flex-shrink: 0;
}

.cat-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.xp-bar-track {
  height: 4px;
  width: 100%;
  border-radius: var(--radius-full);
  background: rgba(148, 163, 184, 0.18);
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.xp-bar-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9.5px;
  color: var(--text-secondary);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
}

.xp-total-label {
  display: none;
}

@media (min-width: 640px) {
  .cat-levels-grid {
    gap: 8px;
  }
  .cat-level-card {
    padding: 8px 10px;
  }
  .cat-level-head {
    font-size: 12px;
  }
  .cat-level-lv {
    font-size: 11.5px;
  }
  .xp-bar-meta {
    font-size: 10.5px;
  }
  .xp-total-label {
    display: inline;
  }
}

/* ==================== Monthly Target Box ==================== */
.monthly-target-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  margin-bottom: 12px;
}

.monthly-target-card.locked {
  border-color: rgba(239, 68, 68, 0.35);
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.08), var(--bg-surface) 60%);
}

/* ==================== Filters & Pills ==================== */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.pill-btn {
  padding: 5px 11px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.pill-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.mode-toggle-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 100%;
}

.mode-toggle-row .pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  padding: 6px 8px;
  font-size: 11.5px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill-btn.active {
  background: var(--accent-gold-soft);
  border-color: var(--accent-gold);
  color: var(--text-gold);
}

.pill-btn.makeup-active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--accent-blue);
  color: var(--text-blue);
}

/* ==================== Task Groups & Cards ==================== */
.category-group {
  margin-bottom: 24px;
  padding: 10px 10px 11px;
  border-radius: var(--radius-md);
  background: rgba(19, 28, 49, 0.55);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--group-color, var(--border-strong));
}

.category-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 7px;
  margin-bottom: 7px;
  border-bottom: 1px solid var(--border-subtle);
}

.category-collapse-btn {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.category-group.is-collapsed .category-collapse-btn {
  margin-bottom: 0;
  padding-bottom: 2px;
  border-bottom: none;
}

.category-group-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.collapse-chevron {
  display: inline-flex;
  color: var(--text-secondary);
  transition: transform 0.15s ease;
}

.collapse-chevron.rotated {
  transform: rotate(-90deg);
}

.tag-shield {
  background: rgba(56, 189, 248, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #bae6fd;
}

.category-group-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 800;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.task-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.task-card-headline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
  flex: 1;
}

.reward-chip-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.formula-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.12);
  color: var(--text-gold);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.formula-help-btn:hover,
.formula-help-btn.active {
  background: rgba(245, 158, 11, 0.28);
  border-color: rgba(245, 158, 11, 0.85);
  color: var(--text-gold);
}

.task-tags-flow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  width: 100%;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.task-tags-flow .tag {
  padding: 1px 6px;
  font-size: 10.5px;
}

.reward-formula-box {
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 11.5px;
  line-height: 1.4;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.28);
  color: var(--text-gold);
}

.task-card:hover {
  border-color: var(--border-strong);
}

.task-card.completed {
  background: rgba(34, 197, 94, 0.06);
  border-color: rgba(34, 197, 94, 0.28);
}

.task-card.extra-task {
  background: var(--bg-extra-card);
  border-style: dashed;
  border-color: rgba(148, 163, 184, 0.28);
}

.extra-divider {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 3px 0 0;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.extra-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.task-info {
  flex: 1;
  min-width: 0;
}

.task-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 3px;
}

.task-name {
  font-size: 13.5px;
  font-weight: 700;
  word-break: break-word;
}

/* Extra-compact layout when viewing "全部類別" */
.tasks-groups-wrap.compact-all .category-group {
  margin-bottom: 28px;
  padding: 9px 9px 10px;
}

.tasks-groups-wrap.compact-all .category-group-header {
  padding: 1px 3px 6px;
  margin-bottom: 6px;
}

.tasks-groups-wrap.compact-all .task-list {
  gap: 4px;
}

.tasks-groups-wrap.compact-all .task-card {
  padding: 6px 8px;
  gap: 4px;
  border-radius: 9px;
}

.tasks-groups-wrap.compact-all .task-card-top {
  gap: 5px;
}

.tasks-groups-wrap.compact-all .task-card-headline {
  gap: 4px;
}

.tasks-groups-wrap.compact-all .task-title-row {
  gap: 4px;
  margin-bottom: 2px;
}

.tasks-groups-wrap.compact-all .task-name {
  font-size: 13px;
  line-height: 1.3;
}

.tasks-groups-wrap.compact-all .task-meta-row,
.tasks-groups-wrap.compact-all .task-tags-flow {
  gap: 4px;
  font-size: 10.5px;
}

.tasks-groups-wrap.compact-all .tag {
  padding: 1px 6px;
  font-size: 10px;
}

.tasks-groups-wrap.compact-all .extra-divider {
  margin: 2px 0 0;
  font-size: 10px;
}

.tasks-groups-wrap.compact-all .task-actions {
  gap: 3px;
}

.tasks-groups-wrap.compact-all .task-actions .btn-sm {
  padding: 5px 8px;
  font-size: 11.5px;
}

.tasks-groups-wrap.compact-all .task-actions .btn-icon {
  width: 26px;
  height: 26px;
}

.task-card.completed .task-name {
  text-decoration: line-through;
  opacity: 0.78;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.tag-streak {
  background: rgba(249, 115, 22, 0.16);
  color: var(--text-orange);
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.tag-reward {
  background: var(--accent-gold-soft);
  color: var(--text-gold);
}

.tag-extra {
  background: rgba(56, 189, 248, 0.15);
  color: var(--text-blue);
}

.tag-makeup {
  background: rgba(234, 179, 8, 0.18);
  color: var(--text-gold);
}

.tag-source-task {
  background: rgba(34, 197, 94, 0.16);
  color: var(--text-green);
}

.tag-source-achievement {
  background: rgba(245, 158, 11, 0.2);
  color: var(--text-gold);
}

.tag-source-use {
  background: rgba(56, 189, 248, 0.16);
  color: var(--text-blue);
}

.tag-source-cash {
  background: rgba(168, 85, 247, 0.2);
  color: var(--text-purple);
}

.task-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.task-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ==================== Timer & Redemption Page ==================== */
.timer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 860px) {
  .timer-grid {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: start;
  }
}

.timer-clock-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0 12px;
}

.timer-ring {
  position: relative;
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-ring svg {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}

.timer-ring-text {
  text-align: center;
  z-index: 1;
}

.timer-digits {
  font-size: 42px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

.timer-status-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.ringing-pulse {
  animation: pulseRing 1s infinite;
  border-color: var(--accent-gold) !important;
  box-shadow: 0 0 32px rgba(245, 158, 11, 0.45) !important;
}

@keyframes pulseRing {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.015); }
}

.quick-preset-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 12px 0;
}

.cash-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  margin: 12px 0;
}

.cash-amount-display {
  text-align: center;
}

.cash-amount-display strong {
  display: block;
  font-size: 26px;
  font-weight: 900;
  color: var(--text-purple);
}

.cash-amount-display span {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ==================== Calendar Page ==================== */
.calendar-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 920px) {
  .calendar-layout {
    grid-template-columns: 1.25fr 0.75fr;
    align-items: start;
  }
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.cal-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.cal-cell {
  min-height: 60px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  transition: all 0.12s ease;
}

.cal-cell:hover:not(.empty) {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.cal-cell.empty {
  background: transparent;
  cursor: default;
}

.cal-cell.today {
  border-color: var(--accent-blue);
}

.cal-cell.selected {
  border-color: var(--accent-gold);
  background: var(--accent-gold-soft);
}

.cal-day-num {
  font-size: 13px;
  font-weight: 700;
}

.cal-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  max-width: 100%;
}

.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.cal-count-mini {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 700;
}

/* ==================== Records & Achievements Page ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

@media (min-width: 720px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 22px;
  font-weight: 900;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.subtabs {
  display: inline-flex;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  margin-bottom: 14px;
}

.subtab-btn {
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.subtab-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.timeline-time {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  margin-bottom: 3px;
}

.timeline-delta {
  font-size: 16px;
  font-weight: 900;
  white-space: nowrap;
}

.delta-pos { color: var(--text-green); }
.delta-neg { color: var(--text-red); }

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

@media (min-width: 720px) {
  .ach-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.ach-card {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ach-card.unlocked {
  border-color: rgba(245, 158, 11, 0.45);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), var(--bg-surface));
}

.ach-card.pending {
  border-color: rgba(56, 189, 248, 0.5);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.08), var(--bg-surface));
}

.ach-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.ach-title {
  font-size: 14.5px;
  font-weight: 800;
}

.ach-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* ==================== Forms & Modals ==================== */
.form-group {
  margin-bottom: 13px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-input,
.form-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--accent-gold);
}

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

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.checkbox-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent-gold);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-panel {
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 17px;
  font-weight: 800;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* ==================== Toast ==================== */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  padding: 12px 15px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.2s ease;
}

.toast.success { border-color: rgba(34, 197, 94, 0.55); }
.toast.gold { border-color: rgba(245, 158, 11, 0.65); background: #261f10; color: var(--text-gold); }
.toast.error { border-color: rgba(239, 68, 68, 0.6); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty-state {
  text-align: center;
  padding: 36px 18px;
  color: var(--text-secondary);
  font-size: 13.5px;
}

.helper-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 14px 0;
}

/* ==================== RPG Boss, Radar, Gear & Codex ==================== */
.hero-rpg-panel {
  background: linear-gradient(135deg, rgba(30, 27, 75, 0.72), var(--bg-surface));
}

.hero-rpg-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: center;
}

@media (min-width: 680px) {
  .hero-rpg-grid {
    grid-template-columns: 270px 1fr;
  }
}

.radar-wrap {
  display: flex;
  justify-content: center;
}

.radar-svg {
  width: 100%;
  max-width: 270px;
  height: auto;
}

.hero-combat-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mini-stat-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
}

.mini-stat-box span {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
}

.mini-stat-box strong {
  font-size: 16px;
  font-weight: 900;
}

.boss-arena-card {
  border-color: rgba(245, 158, 11, 0.28);
  border-top: 3px solid var(--boss-color, var(--accent-gold));
  margin-bottom: 16px;
}

.boss-arena-card.monthly-boss {
  background: linear-gradient(135deg, rgba(127, 29, 29, 0.25), var(--bg-surface) 60%);
  border-color: rgba(245, 158, 11, 0.55);
}

.boss-header-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.boss-avatar {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: var(--bg-elevated);
  border: 2px solid var(--boss-color, var(--accent-gold));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  flex-shrink: 0;
}

.boss-hp-section {
  margin-bottom: 14px;
}

.boss-hp-track {
  height: 14px;
  width: 100%;
  border-radius: var(--radius-full);
  background: rgba(148, 163, 184, 0.16);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.boss-hp-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.35s ease;
}

.boss-lock-alert {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 9px;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: var(--text-red);
  font-size: 12px;
}

.boss-chest-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(34, 197, 94, 0.12));
  border: 1px solid rgba(245, 158, 11, 0.55);
  margin-bottom: 14px;
}

.boss-mechanics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 720px) {
  .boss-mechanics-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.boss-subbox {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
}

.boss-subbox-title {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
}

.quota-row {
  margin-bottom: 8px;
}

.quota-row:last-child {
  margin-bottom: 0;
}

.shield-task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--bg-surface);
  margin-bottom: 6px;
}

.shield-task-row:last-child {
  margin-bottom: 0;
}

.shield-task-row.cleared {
  opacity: 0.68;
}

.boss-bottom-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 820px) {
  .boss-bottom-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.consumable-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

.battle-log-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.battle-log-row {
  font-size: 12px;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.battle-log-row.boss-heal {
  border-left: 3px solid var(--accent-red);
}

.battle-log-row.boss-kill,
.battle-log-row.chest {
  border-left: 3px solid var(--accent-gold);
}

.battle-log-time {
  font-size: 10.5px;
  color: var(--text-muted);
}

.gear-slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.gear-slot-card {
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--rarity-color, var(--border-subtle));
}

.gear-slot-card.empty {
  border-style: dashed;
  border-color: var(--border-subtle);
  opacity: 0.78;
}

.gear-slot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
}

.gear-inv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--rarity-color, var(--border-strong));
}

.gear-affix-list {
  list-style: none;
  margin: 5px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.gear-affix-list li::before {
  content: "◆ ";
  color: var(--rarity-color, var(--accent-gold));
  font-size: 10px;
}

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

@media (min-width: 680px) {
  .codex-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.codex-card {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  opacity: 0.72;
}

.codex-card.unlocked {
  opacity: 1;
  border-color: rgba(245, 158, 11, 0.45);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), var(--bg-surface));
}

.codex-emoji {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.forge-panel {
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid rgba(245, 158, 11, 0.32);
}

.forge-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.forge-bar-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  overflow: hidden;
}

.forge-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  transition: width 0.25s ease;
}

.forge-bar-fill.ready {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.forge-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.gear-inv-row.locked {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), var(--bg-elevated));
  border-color: rgba(245, 158, 11, 0.35);
}

.gear-inv-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-gold-outline {
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-gold);
  border: 1px solid rgba(245, 158, 11, 0.45);
}

@media (max-width: 480px) {
  .gear-inv-row {
    flex-direction: column;
    align-items: stretch;
  }
  .gear-inv-actions {
    justify-content: flex-end;
  }
}

.period-progress-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--text-blue);
  font-size: 11px;
  font-weight: 700;
}

.period-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.period-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid rgba(125, 211, 252, 0.6);
  background: transparent;
}

.period-dot.filled {
  background: #38bdf8;
  border-color: #38bdf8;
  box-shadow: 0 0 4px rgba(56, 189, 248, 0.6);
}

.period-mini-bar {
  display: inline-block;
  width: 36px;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.25);
  overflow: hidden;
}

.period-mini-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #4ade80);
}

/* ==================== Theme Selector & Palette Overrides ==================== */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

@media (min-width: 520px) {
  .theme-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.theme-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 10px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  text-align: left;
  transition: border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.theme-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.theme-card.active {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 1px var(--accent-gold), var(--shadow-glow-gold);
}

.theme-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
}

.theme-card-desc {
  font-size: 11px;
  color: var(--text-secondary);
}

.theme-swatches {
  display: flex;
  align-items: center;
  gap: 4px;
}

.theme-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

/* 1. 翡翠森林 */
[data-theme="emerald"] {
  --bg-base: #071712;
  --bg-surface: #0e241d;
  --bg-elevated: #153329;
  --bg-hover: #1d4437;
  --bg-topbar: rgba(7, 23, 18, 0.92);
  --bg-nav: rgba(11, 31, 25, 0.95);
  --bg-sidebar: rgba(11, 31, 25, 0.94);
  --bg-extra-card: rgba(21, 51, 41, 0.72);
  --accent-gold: #10b981;
  --accent-gold-soft: rgba(16, 185, 129, 0.18);
  --text-gold: #6ee7b7;
  --shell-glow-1: rgba(16, 185, 129, 0.11);
  --shell-glow-2: rgba(52, 211, 153, 0.08);
  --hero-bg: linear-gradient(135deg, #064e3b 0%, #0f3a2e 52%, #071712 100%);
  --hero-border: rgba(16, 185, 129, 0.45);
  --hero-num-grad: linear-gradient(180deg, #d1fae5 0%, #34d399 100%);
  --btn-primary-bg: linear-gradient(135deg, #10b981, #059669);
  --btn-primary-hover: linear-gradient(135deg, #34d399, #10b981);
  --btn-primary-text: #042f2e;
  --shadow-glow-gold: 0 0 24px rgba(16, 185, 129, 0.2);
}

/* 2. 霓虹賽博 */
[data-theme="cyber"] {
  --bg-base: #090717;
  --bg-surface: #130f2b;
  --bg-elevated: #1e1842;
  --bg-hover: #292158;
  --bg-topbar: rgba(9, 7, 23, 0.92);
  --bg-nav: rgba(15, 11, 36, 0.95);
  --bg-sidebar: rgba(15, 11, 36, 0.94);
  --bg-extra-card: rgba(30, 24, 66, 0.75);
  --border-subtle: rgba(168, 85, 247, 0.22);
  --border-strong: rgba(34, 211, 238, 0.38);
  --accent-gold: #22d3ee;
  --accent-gold-soft: rgba(34, 211, 238, 0.16);
  --text-gold: #67e8f9;
  --shell-glow-1: rgba(236, 72, 153, 0.11);
  --shell-glow-2: rgba(34, 211, 238, 0.11);
  --hero-bg: linear-gradient(135deg, #3b0764 0%, #1e1b4b 52%, #083344 100%);
  --hero-border: rgba(34, 211, 238, 0.48);
  --hero-num-grad: linear-gradient(180deg, #cffafe 0%, #22d3ee 100%);
  --btn-primary-bg: linear-gradient(135deg, #22d3ee, #06b6d4);
  --btn-primary-hover: linear-gradient(135deg, #67e8f9, #22d3ee);
  --btn-primary-text: #082f49;
  --shadow-glow-gold: 0 0 24px rgba(34, 211, 238, 0.22);
}

/* 3. 炎龍酒館 */
[data-theme="crimson"] {
  --bg-base: #180d0b;
  --bg-surface: #261512;
  --bg-elevated: #361e1a;
  --bg-hover: #472822;
  --bg-topbar: rgba(24, 13, 11, 0.92);
  --bg-nav: rgba(32, 17, 14, 0.95);
  --bg-sidebar: rgba(32, 17, 14, 0.94);
  --bg-extra-card: rgba(54, 30, 26, 0.74);
  --border-subtle: rgba(251, 146, 60, 0.2);
  --border-strong: rgba(251, 146, 60, 0.38);
  --accent-gold: #fb923c;
  --accent-gold-soft: rgba(251, 146, 60, 0.18);
  --text-gold: #fed7aa;
  --shell-glow-1: rgba(239, 68, 68, 0.12);
  --shell-glow-2: rgba(251, 146, 60, 0.1);
  --hero-bg: linear-gradient(135deg, #450a0a 0%, #431407 52%, #1c1917 100%);
  --hero-border: rgba(251, 146, 60, 0.45);
  --hero-num-grad: linear-gradient(180deg, #ffedd5 0%, #fb923c 100%);
  --btn-primary-bg: linear-gradient(135deg, #f97316, #ea580c);
  --btn-primary-hover: linear-gradient(135deg, #fb923c, #f97316);
  --btn-primary-text: #1c0f08;
  --shadow-glow-gold: 0 0 24px rgba(249, 115, 22, 0.22);
}

/* 4. 羊皮紙公會 (Warm Light) */
[data-theme="parchment"] {
  --bg-base: #f4ede0;
  --bg-surface: #fffaf0;
  --bg-elevated: #efe4d2;
  --bg-hover: #e5d5bc;
  --bg-topbar: rgba(244, 237, 224, 0.94);
  --bg-nav: rgba(255, 250, 240, 0.96);
  --bg-sidebar: rgba(249, 243, 232, 0.96);
  --bg-extra-card: #f6ecdb;
  --border-subtle: rgba(120, 90, 50, 0.2);
  --border-strong: rgba(120, 90, 50, 0.36);

  --text-primary: #292018;
  --text-secondary: #6b5b47;
  --text-muted: #8c7a64;
  --text-gold: #92400e;
  --text-green: #15803d;
  --text-blue: #0369a1;
  --text-red: #b91c1c;
  --text-purple: #6d28d9;
  --text-orange: #c2410c;

  --accent-gold: #b45309;
  --accent-gold-soft: rgba(180, 83, 9, 0.14);
  --shell-glow-1: rgba(217, 119, 6, 0.08);
  --shell-glow-2: rgba(180, 83, 9, 0.07);
  --hero-bg: linear-gradient(135deg, #fef3c7 0%, #fde68a 48%, #f5e6cf 100%);
  --hero-border: rgba(180, 83, 9, 0.38);
  --hero-num-grad: linear-gradient(180deg, #92400e 0%, #b45309 100%);
  --hero-label: #78350f;
  --btn-primary-bg: linear-gradient(135deg, #d97706, #b45309);
  --btn-primary-hover: linear-gradient(135deg, #f59e0b, #d97706);
  --btn-primary-text: #ffffff;
  --shadow-card: 0 4px 16px rgba(92, 68, 38, 0.1);
  --shadow-glow-gold: 0 4px 18px rgba(180, 83, 9, 0.15);
  --rarity-rough: #64748b;
  --rarity-common: #475569;
  --rarity-fine: #15803d;
  --rarity-rare: #0284c7;
  --rarity-epic: #7e22ce;
  --rarity-legendary: #b45309;
}

/* 5. 晴空極簡 (Crisp Light) */
[data-theme="daylight"] {
  --bg-base: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-elevated: #e2e8f0;
  --bg-hover: #cbd5e1;
  --bg-topbar: rgba(255, 255, 255, 0.92);
  --bg-nav: rgba(255, 255, 255, 0.96);
  --bg-sidebar: rgba(248, 250, 252, 0.96);
  --bg-extra-card: #f8fafc;
  --border-subtle: rgba(15, 23, 42, 0.12);
  --border-strong: rgba(15, 23, 42, 0.24);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-gold: #1d4ed8;
  --text-green: #15803d;
  --text-blue: #0369a1;
  --text-red: #b91c1c;
  --text-purple: #6d28d9;
  --text-orange: #c2410c;

  --accent-gold: #2563eb;
  --accent-gold-soft: rgba(37, 99, 235, 0.12);
  --shell-glow-1: rgba(37, 99, 235, 0.07);
  --shell-glow-2: rgba(14, 165, 233, 0.06);
  --hero-bg: linear-gradient(135deg, #dbeafe 0%, #eff6ff 55%, #ffffff 100%);
  --hero-border: rgba(37, 99, 235, 0.35);
  --hero-num-grad: linear-gradient(180deg, #1e40af 0%, #2563eb 100%);
  --hero-label: #1e3a8a;
  --btn-primary-bg: linear-gradient(135deg, #2563eb, #1d4ed8);
  --btn-primary-hover: linear-gradient(135deg, #3b82f6, #2563eb);
  --btn-primary-text: #ffffff;
  --shadow-card: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-glow-gold: 0 4px 18px rgba(37, 99, 235, 0.14);
  --rarity-rough: #64748b;
  --rarity-common: #475569;
  --rarity-fine: #15803d;
  --rarity-rare: #0284c7;
  --rarity-epic: #7e22ce;
  --rarity-legendary: #b45309;
}

[data-theme="parchment"] .btn-success,
[data-theme="daylight"] .btn-success {
  color: #ffffff;
}

[data-theme="parchment"] .toast.gold,
[data-theme="daylight"] .toast.gold {
  background: var(--bg-surface);
  color: var(--text-gold);
}

[data-theme="parchment"] .period-progress-wrap,
[data-theme="daylight"] .period-progress-wrap {
  color: var(--text-blue);
  background: rgba(3, 105, 161, 0.1);
  border-color: rgba(3, 105, 161, 0.28);
}

[data-theme="parchment"] .period-dot,
[data-theme="daylight"] .period-dot {
  border-color: rgba(3, 105, 161, 0.55);
}

[data-theme="parchment"] .period-dot.filled,
[data-theme="daylight"] .period-dot.filled {
  background: #0284c7;
  border-color: #0284c7;
}

[data-theme="parchment"] .boss-arena-card.monthly-boss,
[data-theme="daylight"] .boss-arena-card.monthly-boss {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), var(--bg-surface) 60%);
}

/* ==================== Direct Spend Presets & Combo Builder ==================== */
.spend-presets-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px 12px;
}

.spend-presets-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.spend-preset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.spend-preset-chip {
  display: inline-flex;
  align-items: stretch;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.spend-preset-chip.selected {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 1px var(--accent-gold-soft);
}

.spend-preset-main {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 8px 5px 10px;
  cursor: pointer;
}

.spend-preset-main:hover {
  background: var(--bg-hover);
}

.spend-preset-mins {
  color: var(--text-gold);
  font-size: 11.5px;
  font-weight: 800;
}

.spend-preset-cnt {
  background: var(--accent-gold);
  color: var(--btn-primary-text);
  border-radius: var(--radius-full);
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 800;
}

.spend-preset-del {
  background: transparent;
  border: none;
  border-left: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  padding: 0 8px;
  cursor: pointer;
}

.spend-preset-del:hover {
  color: var(--text-red);
  background: var(--accent-red-soft);
}

.spend-add-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.spend-add-name {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 10px;
  font-size: 12.5px;
}

.spend-add-mins {
  width: 72px;
  flex-shrink: 0;
  padding: 6px 8px;
  font-size: 12.5px;
}

.spend-combo-bar {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--accent-gold-soft);
  border: 1px solid rgba(245, 158, 11, 0.35);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.spend-combo-text {
  font-size: 12.5px;
  color: var(--text-primary);
  word-break: break-word;
}

.spend-combo-text strong {
  color: var(--text-gold);
}

.spend-combo-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ==================== Game Rules Modal ==================== */
.rules-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.rules-section h4 {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-gold);
  margin-bottom: 6px;
}

.rules-section ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.rules-section strong {
  color: var(--text-primary);
}

.rules-section code {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 11.5px;
  color: var(--text-blue);
}
