:root {
  --bg-base: #0d101d;
  --bg-surface: rgba(22, 26, 44, 0.88);
  --bg-card: rgba(28, 34, 56, 0.82);
  --bg-card-hover: rgba(38, 46, 74, 0.94);
  --bg-card-caught: rgba(18, 46, 40, 0.78);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-highlight: rgba(255, 255, 255, 0.22);
  --text-primary: #f4f6fb;
  --text-secondary: #a5b0ce;
  --text-muted: #6f7b9c;

  --scarlet: #ff4d3d;
  --scarlet-bg: rgba(255, 77, 61, 0.16);
  --scarlet-border: rgba(255, 77, 61, 0.45);

  --violet: #a855f7;
  --violet-bg: rgba(168, 85, 247, 0.18);
  --violet-border: rgba(168, 85, 247, 0.48);

  --caught-green: #10b981;
  --caught-bg: rgba(16, 185, 129, 0.18);
  --caught-border: rgba(16, 185, 129, 0.5);

  --tera-cyan: #38bdf8;
  --amber: #f59e0b;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-lg: 0 18px 45px rgba(0, 0, 0, 0.52);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

button,
select,
input,
label {
  touch-action: manipulation;
}

/* 背景光暈 */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(110px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.25;
}
.orb-scarlet {
  width: 460px;
  height: 460px;
  background: radial-gradient(circle, #ff4d3d, transparent 70%);
  top: -140px;
  left: -120px;
}
.orb-violet {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #9333ea, transparent 70%);
  top: -100px;
  right: -140px;
}
.orb-tera {
  width: 440px;
  height: 440px;
  background: radial-gradient(circle, #0ea5e9, transparent 70%);
  bottom: -160px;
  left: 35%;
  opacity: 0.16;
}

/* 頂部導覽列 */
.app-header {
  position: relative;
  z-index: 20;
  background: rgba(14, 18, 32, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rotom-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255, 77, 61, 0.2), rgba(168, 85, 247, 0.2));
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.title-with-save {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.app-title {
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, #ffffff 0%, #ffd6cc 48%, #e9d5ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.save-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.73rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.app-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.game-selector-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.select-shell {
  position: relative;
  display: flex;
  align-items: center;
}

.game-dot {
  position: absolute;
  left: 11px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--scarlet), var(--violet));
  box-shadow: 0 0 8px var(--scarlet);
  pointer-events: none;
}

.game-select {
  appearance: none;
  background: rgba(28, 34, 58, 0.95);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 8px 32px 8px 26px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%23a5b0ce' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}

.data-actions {
  display: flex;
  gap: 8px;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border-highlight);
}

/* 主內容容器 */
.main-container {
  position: relative;
  z-index: 10;
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px 24px 72px;
}

/* 圖鑑切換卡片列 */
.dex-tabs-section {
  margin-bottom: 16px;
}

.dex-tabs-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.dex-tab-card {
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  color: var(--text-primary);
  transition: all 0.18s ease;
  position: relative;
  overflow: hidden;
}

.dex-tab-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-highlight);
}

.dex-tab-card.active {
  background: linear-gradient(135deg, rgba(40, 48, 82, 0.95), rgba(28, 34, 62, 0.95));
  border-color: var(--tera-cyan);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.22);
}

.dex-tab-card.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--scarlet), var(--tera-cyan), var(--violet));
}

.dex-tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
}

.dex-tab-title {
  font-size: 1rem;
  font-weight: 800;
}

.dex-tab-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
  white-space: nowrap;
}

.dex-tab-sub {
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.dex-progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 5px;
}

.dex-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  overflow: hidden;
}

.dex-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #38bdf8);
  border-radius: 999px;
  transition: width 0.28s ease;
}

/* 手機版精簡進度列（桌面版隱藏） */
.mobile-dex-summary {
  display: none;
}

/* 篩選與搜尋工具列 (Sticky) */
.filter-bar-section {
  position: sticky;
  top: 8px;
  z-index: 30;
  background: rgba(18, 22, 38, 0.94);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 18px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
}

.filter-bar-top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1 1 280px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: rgba(10, 13, 24, 0.8);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 9px 34px 9px 38px;
  font-size: 0.92rem;
}
.search-input:focus {
  outline: none;
  border-color: var(--tera-cyan);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

.clear-search-btn {
  position: absolute;
  right: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.8rem;
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.quick-controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* 「只看未捕捉」快速開關 */
.uncaught-toggle-card {
  display: flex;
  align-items: center;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.38);
  border-radius: 10px;
  padding: 7px 12px;
  transition: all 0.2s;
}
.uncaught-toggle-card.active {
  background: rgba(245, 158, 11, 0.26);
  border-color: #fbbf24;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.25);
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.switch-label input {
  display: none;
}

.switch-slider {
  width: 36px;
  height: 20px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.switch-slider::after {
  content: "";
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
}
.switch-label input:checked + .switch-slider {
  background: #f59e0b;
}
.switch-label input:checked + .switch-slider::after {
  transform: translateX(16px);
}

.switch-text {
  font-size: 0.86rem;
  font-weight: 700;
  color: #fde68a;
  white-space: nowrap;
}

.uncaught-count-pill {
  background: rgba(0, 0, 0, 0.38);
  color: #fef3c7;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

/* 三段式狀態篩選 */
.status-segmented {
  display: flex;
  background: rgba(10, 13, 24, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 3px;
}

.seg-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.16s;
  white-space: nowrap;
}
.seg-btn.active {
  background: rgba(56, 189, 248, 0.22);
  color: #e0f2fe;
}

/* 手機版篩選展開按鈕（桌面版隱藏） */
.mobile-filter-toggle-btn {
  display: none;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.mobile-filter-toggle-btn.active {
  border-color: var(--tera-cyan);
  background: rgba(56, 189, 248, 0.18);
}

.filter-count-badge {
  background: var(--tera-cyan);
  color: #0f172a;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
}

/* 第二排下拉篩選與批次工具 */
.filter-bar-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

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

.filter-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
}

.filter-select {
  background: rgba(10, 13, 24, 0.82);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.82rem;
  cursor: pointer;
}

.filter-summary-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-wrap: wrap;
}

.showing-count {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.batch-actions {
  display: flex;
  gap: 8px;
}

.btn-mini {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-mini:hover {
  background: rgba(16, 185, 129, 0.22);
  border-color: var(--caught-border);
}
.btn-mini-danger:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.5);
}

/* 寶可夢卡片網格 */
.pokemon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
  gap: 14px;
}

.poke-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.poke-card:hover {
  border-color: var(--border-highlight);
}

.poke-card.is-caught {
  background: linear-gradient(160deg, rgba(16, 185, 129, 0.15) 0%, rgba(20, 30, 46, 0.88) 100%);
  border-color: var(--caught-border);
}

.card-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 4px;
}

.dex-num-group {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.dex-id-badge {
  font-size: 0.9rem;
  font-weight: 800;
  color: #e2e8f0;
  font-variant-numeric: tabular-nums;
}

.nat-id-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.exclusive-pill {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 5px;
  white-space: nowrap;
}
.exclusive-pill.scarlet {
  background: var(--scarlet-bg);
  color: #fca5a5;
  border: 1px solid var(--scarlet-border);
}
.exclusive-pill.violet {
  background: var(--violet-bg);
  color: #d8b4fe;
  border: 1px solid var(--violet-border);
}

/* 寶可夢圖片區 */
.card-sprite-wrap {
  position: relative;
  height: 112px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2px 0 6px;
}

.card-sprite-bg {
  position: absolute;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.08) 0%, transparent 72%);
  pointer-events: none;
}

.card-sprite {
  width: 98px;
  height: 98px;
  object-fit: contain;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.42));
}

.card-name-area {
  text-align: center;
  margin-bottom: 6px;
}

.card-zh-name {
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--text-primary);
}

.card-sub-name {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-types-row {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.type-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* 18種屬性顏色 */
.type-一般 { background: #9099a1; }
.type-火 { background: #ff9c54; }
.type-水 { background: #4d90d5; }
.type-草 { background: #63bb5b; }
.type-電 { background: #f3d23b; color: #1e293b; text-shadow: none; }
.type-冰 { background: #74cec0; color: #0f172a; text-shadow: none; }
.type-格鬥 { background: #ce4069; }
.type-毒 { background: #ab6ac8; }
.type-地面 { background: #d97746; }
.type-飛行 { background: #8fa8dd; }
.type-超能力 { background: #f97176; }
.type-蟲 { background: #90c12c; }
.type-岩石 { background: #c7b78b; color: #1e293b; text-shadow: none; }
.type-幽靈 { background: #5269ac; }
.type-龍 { background: #0a6dc4; }
.type-惡 { background: #5a5366; }
.type-鋼 { background: #5a8ea1; }
.type-妖精 { background: #ec8fe6; color: #1e293b; text-shadow: none; }

.card-footer-loc {
  font-size: 0.73rem;
  color: var(--text-secondary);
  background: rgba(10, 14, 26, 0.55);
  border-radius: 7px;
  padding: 5px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  margin-bottom: 8px;
}

/* 卡片底部大面積單手好點「標記已捕捉」按鈕 */
.catch-toggle-btn {
  width: 100%;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 0.8rem;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(13, 18, 32, 0.78);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 2;
}
.catch-toggle-btn:hover {
  border-color: var(--caught-green);
  color: #fff;
}
.catch-toggle-btn:active {
  transform: scale(0.97);
}
.catch-toggle-btn.caught {
  background: rgba(16, 185, 129, 0.24);
  border-color: #10b981;
  color: #6ee7b7;
}

.pokeball-icon {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 1.5px solid currentColor;
  position: relative;
  flex-shrink: 0;
}
.caught .pokeball-icon {
  background: radial-gradient(circle, #fff 28%, #10b981 32%);
  border-color: #6ee7b7;
}

/* 懸浮回到頂部按鈕 */
.back-to-top-btn {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  background: rgba(20, 28, 52, 0.92);
  color: #e0f2fe;
  border: 1px solid var(--tera-cyan);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.84rem;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

/* 載入與空白狀態 */
.state-box {
  text-align: center;
  padding: 54px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--tera-cyan);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-icon {
  font-size: 2.4rem;
  margin-bottom: 8px;
}

.btn-primary {
  margin-top: 14px;
  background: linear-gradient(135deg, var(--scarlet), var(--violet));
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 9px;
  font-weight: 700;
  cursor: pointer;
}

/* 詳細攻略 Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(6, 9, 18, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop[hidden] {
  display: none !important;
}

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 920px;
  max-height: 90vh;
  background: #14192d;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Modal 頂部常駐操作列（手機與桌面皆可一鍵標記或關閉） */
.modal-sticky-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(16, 21, 38, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-sticky-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.modal-sticky-num {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--tera-cyan);
}

.modal-sticky-name {
  font-size: 1.15rem;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-sticky-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.modal-top-catch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  border: 1px solid var(--border-highlight);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}
.modal-top-catch-btn.caught {
  background: rgba(16, 185, 129, 0.25);
  border-color: #10b981;
  color: #6ee7b7;
}

.modal-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-subtle);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close-btn:hover {
  background: rgba(255, 77, 61, 0.35);
}

.modal-body {
  padding: 22px 24px 32px;
}

.modal-hero {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-artwork-box {
  background: radial-gradient(circle, rgba(56, 189, 248, 0.15) 0%, rgba(15, 20, 36, 0.8) 75%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.modal-artwork-img {
  width: 155px;
  height: 155px;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.5));
}

.artwork-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.btn-chip {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-chip.active {
  background: rgba(245, 158, 11, 0.25);
  border-color: #fbbf24;
  color: #fde68a;
}

.modal-Basic-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-dex-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dex-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}
.dex-pill.paldea { background: rgba(255, 77, 61, 0.18); color: #fecaca; }
.dex-pill.kitakami { background: rgba(16, 185, 129, 0.18); color: #a7f3d0; }
.dex-pill.blueberry { background: rgba(56, 189, 248, 0.18); color: #bae6fd; }

.modal-poke-name {
  font-size: 1.65rem;
  font-weight: 900;
}

.modal-names-sub {
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.modal-flavor-box {
  background: rgba(10, 14, 26, 0.65);
  border-left: 3px solid var(--tera-cyan);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  font-size: 0.86rem;
  color: #e2e8f0;
}

/* Modal 區塊標題 */
.modal-section {
  margin-top: 20px;
}

.modal-section-title {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f8fafc;
}

/* 出現遊戲與版本區塊 */
.games-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.game-badge {
  padding: 6px 12px;
  border-radius: 9px;
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.game-badge.scarlet {
  background: var(--scarlet-bg);
  border: 1px solid var(--scarlet-border);
  color: #fecaca;
}
.game-badge.violet {
  background: var(--violet-bg);
  border: 1px solid var(--violet-border);
  color: #e9d5ff;
}
.game-badge.dlc {
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.38);
  color: #bae6fd;
}

/* 捕捉方式與攻略卡片 */
.methods-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
}

.method-card {
  background: rgba(24, 30, 52, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 14px;
}

.method-type-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 5px;
  background: rgba(56, 189, 248, 0.18);
  color: #7dd3fc;
  margin-bottom: 5px;
}

.method-title {
  font-size: 0.92rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.method-detail {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* 出沒地點表格／清單 */
.locations-region-group {
  margin-bottom: 10px;
  background: rgba(20, 25, 44, 0.78);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 14px;
}

.loc-region-header {
  font-size: 0.86rem;
  font-weight: 800;
  color: #93c5fd;
  margin-bottom: 8px;
}

.loc-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.loc-item-chip {
  background: rgba(11, 15, 28, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 0.81rem;
}

.loc-area-name {
  font-weight: 700;
  color: #f1f5f9;
}

.loc-method-sub {
  font-size: 0.73rem;
  color: var(--text-secondary);
}

.ver-mini {
  font-size: 0.66rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
}
.ver-mini.朱 { background: #dc2626; color: #fff; }
.ver-mini.紫 { background: #7e22ce; color: #fff; }

/* 進化鏈 */
.evo-chain-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: rgba(20, 25, 44, 0.78);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 14px;
}

.evo-stage-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(12, 16, 30, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 11px;
  cursor: pointer;
  transition: all 0.16s;
}
.evo-stage-card:hover {
  border-color: var(--tera-cyan);
}
.evo-stage-card.current {
  border-color: var(--amber);
  background: rgba(245, 158, 11, 0.14);
}

.evo-stage-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.evo-stage-form {
  font-size: 0.68rem;
  font-weight: 700;
  color: #7dd3fc;
  margin-top: 1px;
}

.evo-arrow-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.73rem;
  color: #fde68a;
  max-width: 210px;
  text-align: center;
  background: rgba(15, 20, 38, 0.55);
  border: 1px dashed rgba(251, 191, 36, 0.28);
  border-radius: 8px;
  padding: 5px 9px;
}

.evo-from-tag {
  font-size: 0.68rem;
  font-weight: 800;
  color: #93c5fd;
  margin-bottom: 1px;
}

.evo-arrow-icon {
  font-size: 0.85rem;
  line-height: 1.1;
}

/* 卡片與彈窗地區形態標籤 */
.card-form-pill {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  color: #bae6fd;
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 999px;
  padding: 1px 8px;
  margin: 2px 0;
}

.modal-form-inline {
  font-size: 1.05rem;
  font-weight: 700;
  color: #7dd3fc;
}

.dex-pill.form-highlight {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: #fde68a;
}

/* 多形態／風格預覽區（帕底亞肯泰羅三種／花舞鳥四種風格） */
.extra-forms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 10px;
}

.extra-form-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(20, 25, 44, 0.82);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.extra-form-card:hover {
  border-color: var(--tera-cyan);
  background: rgba(56, 189, 248, 0.1);
}

.extra-form-img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex-shrink: 0;
}

.extra-form-name {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text-primary);
}

/* 種族值與 PokeAPI 資料 */
.stats-and-meta-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 14px;
}

.stats-box,
.meta-box {
  background: rgba(20, 25, 44, 0.78);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 13px 15px;
}

.stat-row {
  display: grid;
  grid-template-columns: 48px 36px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 0.79rem;
  margin-bottom: 6px;
}

.stat-bar-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 999px;
}

.external-links-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.ext-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #e0f2fe;
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 0.82rem;
  font-weight: 700;
}

/* Toast 通知 */
.toast-container {
  position: fixed;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: 92vw;
  pointer-events: none;
}

.toast-item {
  background: rgba(14, 20, 36, 0.96);
  border: 1px solid var(--tera-cyan);
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* =========================================================
   📱 手機與平板響應式最佳化 (<= 768px)
   ========================================================= */
@media (max-width: 768px) {
  .header-inner {
    padding: 10px 12px;
    gap: 10px;
  }

  .rotom-logo {
    width: 36px;
    height: 36px;
  }

  .app-title {
    font-size: 1.05rem;
  }

  .app-subtitle {
    display: none;
  }

  .header-controls {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .game-selector-wrap {
    flex: 1;
    min-width: 0;
  }

  .control-label {
    display: none;
  }

  .select-shell,
  .game-select {
    width: 100%;
    font-size: 0.82rem;
    padding: 7px 26px 7px 24px;
  }

  .btn-ghost {
    padding: 7px 10px;
    font-size: 0.76rem;
  }

  .main-container {
    padding: 10px 10px 80px;
  }

  /* 手機版：圖鑑切換改為橫向緊湊 4 格頁籤，不佔垂直空間 */
  .dex-tabs-section {
    margin-bottom: 10px;
  }

  .dex-tabs-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .dex-tab-card {
    padding: 8px 6px;
    border-radius: 10px;
    text-align: center;
  }

  .dex-tab-header {
    justify-content: center;
    margin-bottom: 2px;
  }

  .dex-tab-title {
    font-size: 0.82rem;
  }

  .dex-tab-badge,
  .dex-tab-sub,
  .dex-tab-card .dex-progress-row {
    display: none;
  }

  .dex-tab-card .dex-progress-bar {
    height: 4px;
    margin-top: 4px;
  }

  /* 手機版圖鑑總進度條 */
  .mobile-dex-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
    padding: 7px 12px;
    background: rgba(22, 28, 48, 0.82);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    font-size: 0.78rem;
  }

  /* 手機版 Sticky 篩選列：極簡不擋畫面 */
  .filter-bar-section {
    top: 4px;
    padding: 9px 10px;
    margin-bottom: 12px;
    border-radius: 12px;
  }

  .filter-bar-top {
    gap: 8px;
  }

  .search-box {
    flex: 1 1 100%;
  }

  .search-input {
    font-size: 16px; /* 防止 iOS 自動放大畫面 */
    padding: 8px 32px 8px 34px;
  }

  .quick-controls-row {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
    flex-wrap: nowrap;
  }

  .uncaught-toggle-card {
    padding: 6px 9px;
    flex: 1;
  }

  .switch-text {
    font-size: 0.8rem;
  }

  .status-segmented {
    display: none; /* 手機版已有「只看未捕捉」大開關，或於進階篩選內切換 */
  }

  .mobile-filter-toggle-btn {
    display: inline-flex;
  }

  /* 進階篩選預設收合，點擊「篩選」才展開 */
  .filter-bar-bottom {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .filter-bar-bottom.is-open {
    display: flex;
  }

  .filter-group {
    justify-content: space-between;
  }

  .filter-select {
    flex: 1;
    font-size: 0.85rem;
    padding: 7px 10px;
  }

  .filter-summary-right {
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }

  /* 手機版雙欄寶可夢網格 */
  .pokemon-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .poke-card {
    padding: 10px;
    border-radius: 12px;
  }

  .dex-id-badge {
    font-size: 0.82rem;
  }

  .nat-id-sub {
    font-size: 0.66rem;
  }

  .card-sprite-wrap {
    height: 92px;
    margin: 2px 0 4px;
  }

  .card-sprite {
    width: 82px;
    height: 82px;
  }

  .card-zh-name {
    font-size: 0.95rem;
  }

  .card-sub-name {
    font-size: 0.68rem;
  }

  .card-footer-loc {
    font-size: 0.68rem;
    padding: 4px 6px;
    margin-bottom: 6px;
  }

  .catch-toggle-btn {
    min-height: 38px;
    font-size: 0.78rem;
  }

  /* 手機版：攻略彈窗改為底部滑出 Bottom Sheet */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .modal-dialog {
    max-width: 100%;
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
  }

  .modal-sticky-bar {
    padding: 11px 14px;
  }

  .modal-body {
    padding: 16px 14px calc(28px + env(safe-area-inset-bottom, 12px));
  }

  .modal-hero {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .modal-artwork-img {
    width: 130px;
    height: 130px;
  }

  .modal-poke-name {
    font-size: 1.4rem;
  }

  .stats-and-meta-grid {
    grid-template-columns: 1fr;
  }

  .evo-chain-row {
    flex-direction: column;
    align-items: stretch;
  }

  .evo-arrow-box {
    max-width: 100%;
    flex-direction: row;
    justify-content: center;
    gap: 6px;
  }

  .ext-link-btn {
    width: 100%;
  }
}
