/*
  MOLI v3 — 魔導終端 (Arcane HUD) design system
  深色為預設，[data-theme="light"] 為羊皮紙淺色主題。
  元素色沿用魔力寶貝：地＝綠、水＝藍、火＝紅、風＝黃。
*/

/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;
  --bg: #070c18;
  --bg-elev: #0c1527;
  --panel: rgba(14, 25, 47, 0.8);
  --panel-solid: #0e192f;
  --panel-2: #13213d;
  --panel-3: #1a2b4c;
  --field: #091325;
  --line: rgba(129, 167, 230, 0.16);
  --line-2: rgba(129, 167, 230, 0.3);
  --text: #e8eefb;
  --text-2: #aab8d4;
  --text-3: #7d8db0;

  --aqua: #35d6ee;
  --aqua-2: #1aa6c4;
  --aqua-soft: rgba(53, 214, 238, 0.13);
  --on-aqua: #031420;
  --gold: #e4c27a;
  --gold-2: #b98f3e;
  --gold-soft: rgba(228, 194, 122, 0.13);

  --earth: #4fd27c;
  --water: #4aa8ff;
  --fire: #ff6b5e;
  --wind: #f6c344;

  --st-vit: #ff7a93;
  --st-str: #ff9f4a;
  --st-def: #6fa8ff;
  --st-dex: #4fd27c;
  --st-int: #b98cff;

  --ok: #3fd38a;
  --warn: #f6c344;
  --danger: #ff6b6b;

  --shadow: 0 24px 48px -28px rgba(0, 0, 0, 0.8);
  --glow: 0 0 0 1px rgba(53, 214, 238, 0.35), 0 0 24px -6px rgba(53, 214, 238, 0.55);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --topbar-h: 64px;
  --tabbar-h: 62px;
  --ad-anchor-bottom: 0px;
  --page-max: 1280px;
  --gutter: clamp(16px, 3vw, 28px);

  --font-ui: "Noto Sans TC", system-ui, -apple-system, "Segoe UI", "Microsoft JhengHei", "PingFang TC", sans-serif;
  --font-display: "Cinzel", "Noto Serif TC", "Noto Sans TC", serif;
  --font-hud: "Chakra Petch", "Noto Sans TC", ui-monospace, "Consolas", monospace;

  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2335d6ee' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --sky-1: rgba(53, 214, 238, 0.15);
  --sky-2: rgba(228, 194, 122, 0.08);
  --grid-line: rgba(129, 167, 230, 0.055);
  --star: rgba(220, 235, 255, 0.75);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f3eee2;
  --bg-elev: #faf7ef;
  --panel: rgba(255, 252, 246, 0.9);
  --panel-solid: #fffcf6;
  --panel-2: #f6f0e3;
  --panel-3: #eee5d2;
  --field: #ffffff;
  --line: rgba(92, 74, 38, 0.16);
  --line-2: rgba(92, 74, 38, 0.3);
  --text: #1c2740;
  --text-2: #46546f;
  --text-3: #5f6b86;

  --aqua: #087489;
  --aqua-2: #065d6e;
  --aqua-soft: rgba(8, 116, 137, 0.1);
  --on-aqua: #ffffff;
  --gold: #8a6314;
  --gold-2: #6f4f0e;
  --gold-soft: rgba(138, 99, 20, 0.1);

  --earth: #157a3c;
  --water: #1f6fd1;
  --fire: #c5352a;
  --wind: #8f6400;

  --st-vit: #c63a59;
  --st-str: #b85a14;
  --st-def: #2f6fd0;
  --st-dex: #157a3c;
  --st-int: #7a4bd3;

  --ok: #13804b;
  --warn: #8f6400;
  --danger: #c22f2f;

  --shadow: 0 18px 40px -26px rgba(70, 50, 20, 0.45);
  --glow: 0 0 0 1px rgba(8, 116, 137, 0.35), 0 0 18px -6px rgba(8, 116, 137, 0.4);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23087489' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --sky-1: rgba(8, 116, 137, 0.1);
  --sky-2: rgba(138, 99, 20, 0.1);
  --grid-line: rgba(92, 74, 38, 0.06);
  --star: rgba(138, 99, 20, 0.35);
}

/* ---------- Reset & base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-h) + 12px);
}

body {
  min-height: 100vh;
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  position: relative;
}

@media (pointer: fine) {
  /* 魔力寶貝的經典紅箭頭游標（只在桌機、一般區域使用） */
  body {
    cursor: url("/static/images/cursor.png") 1 1, auto;
  }
}

img,
svg,
video {
  display: block;
  max-width: 100%;
}

svg {
  flex-shrink: 0;
}

.i {
  display: inline-block;
  vertical-align: -0.18em;
  width: 1.15em;
  height: 1.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

button {
  cursor: pointer;
}

a {
  color: var(--aqua);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

:focus-visible {
  outline: 2px solid var(--aqua);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection {
  background: var(--aqua-soft);
  color: var(--text);
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 3000;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--aqua);
  color: var(--on-aqua);
  font-weight: 700;
  transform: translateY(calc(-100% - 24px));
  transition: transform 0.2s;
}

.skip-link:focus {
  transform: none;
  text-decoration: none;
}

.num,
.hud {
  font-family: var(--font-hud);
  font-variant-numeric: tabular-nums;
}

.hud {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ---------- Night-sky background ---------- */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

body::before {
  background:
    radial-gradient(1100px 620px at 88% -12%, var(--sky-1), transparent 62%),
    radial-gradient(900px 520px at -12% 8%, var(--sky-2), transparent 60%),
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 56px 56px,
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 56px 56px;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 55%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 55%, transparent 100%);
}

body::after {
  background-image:
    radial-gradient(1.2px 1.2px at 12% 18%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 28% 72%, var(--star), transparent 60%),
    radial-gradient(1.4px 1.4px at 47% 32%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 63% 12%, var(--star), transparent 60%),
    radial-gradient(1.2px 1.2px at 78% 58%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 91% 26%, var(--star), transparent 60%),
    radial-gradient(1.3px 1.3px at 6% 88%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 84% 86%, var(--star), transparent 60%);
  opacity: 0.7;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: var(--ad-anchor-top, 0px);
  z-index: 1000;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}

.topbar::after {
  /* 金色細線：魔力寶貝視窗邊框的感覺 */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold) 20%, var(--aqua) 50%, var(--gold) 80%, transparent);
  opacity: 0.45;
}

.topbar__inner {
  max-width: var(--page-max);
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none !important;
  margin-right: auto;
}

.brand__gem {
  width: 22px;
  height: 30px;
  color: var(--aqua);
  filter: drop-shadow(0 0 8px rgba(53, 214, 238, 0.55));
}

.brand__word {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.16em;
  line-height: 1;
}

.brand__sub {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--text-3);
  margin-top: 4px;
}

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

.nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--text-2);
  font-weight: 500;
  font-size: 0.92rem;
  text-decoration: none;
  transition: color 0.2s, background-color 0.2s;
}

.nav a svg {
  width: 18px;
  height: 18px;
}

.nav a:hover {
  color: var(--text);
  background: var(--aqua-soft);
}

.nav a[aria-current="page"] {
  color: var(--aqua);
  background: var(--aqua-soft);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--aqua) 35%, transparent);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--text-2);
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.icon-btn:hover {
  color: var(--aqua);
  border-color: color-mix(in srgb, var(--aqua) 50%, transparent);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.theme-toggle .i-sun,
[data-theme="light"] .theme-toggle .i-moon {
  display: none;
}

[data-theme="light"] .theme-toggle .i-sun {
  display: block;
}

/* ---------- Mobile tab bar ---------- */
.tabbar {
  display: none;
}

@media (max-width: 820px) {
  .nav {
    display: none;
  }

  .brand__sub {
    display: none;
  }

  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--ad-anchor-bottom);
    z-index: 1000;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    backdrop-filter: blur(14px) saturate(140%);
    border-top: 1px solid var(--line);
    transition: bottom 0.25s ease;
  }

  .tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-3);
    font-size: 0.72rem;
    font-weight: 500;
    text-decoration: none;
    position: relative;
  }

  .tabbar a svg {
    width: 22px;
    height: 22px;
  }

  .tabbar a[aria-current="page"] {
    color: var(--aqua);
  }

  .tabbar a[aria-current="page"]::before {
    content: "";
    position: absolute;
    top: 0;
    left: 30%;
    right: 30%;
    height: 2px;
    border-radius: 0 0 2px 2px;
    background: var(--aqua);
    box-shadow: 0 0 10px var(--aqua);
  }

  body {
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--ad-anchor-bottom));
  }
}

/* ---------- Layout ---------- */
.app-container {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 28px var(--gutter) 56px;
}

.page-head {
  margin-bottom: 22px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-hud);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}

.eyebrow svg {
  width: 12px;
  height: 16px;
  color: var(--gold);
}

.page-head h1 {
  font-size: clamp(1.6rem, 3.2vw, 2.2rem);
}

.page-head .lede {
  color: var(--text-2);
  margin-top: 6px;
  max-width: 62ch;
}

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent);
  animation: pulse 2.4s infinite;
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 8px transparent;
  }

  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

/* ---------- Panel：魔力寶貝視窗 × HUD 邊框 ---------- */
.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.panel::before {
  /* 四角金色 L 形框角 */
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  --c: color-mix(in srgb, var(--gold) 80%, transparent);
  background:
    linear-gradient(var(--c), var(--c)) top left / 16px 1.5px no-repeat,
    linear-gradient(var(--c), var(--c)) top left / 1.5px 16px no-repeat,
    linear-gradient(var(--c), var(--c)) top right / 16px 1.5px no-repeat,
    linear-gradient(var(--c), var(--c)) top right / 1.5px 16px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / 16px 1.5px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / 1.5px 16px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 16px 1.5px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 1.5px 16px no-repeat;
  opacity: 0.8;
}

.panel__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.panel__head h2,
.panel__head h3 {
  font-size: 1.02rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel__head .hud {
  margin-left: auto;
}

.panel__head .gem {
  width: 13px;
  height: 18px;
}

.panel__body {
  padding: 18px;
}

.panel__foot {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.gem {
  color: var(--aqua);
  filter: drop-shadow(0 0 6px color-mix(in srgb, currentColor 65%, transparent));
}

.gem--earth { color: var(--earth); }
.gem--water { color: var(--water); }
.gem--fire { color: var(--fire); }
.gem--wind { color: var(--wind); }
.gem--gold { color: var(--gold); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  text-decoration: none !important;
  transition: transform 0.15s ease, box-shadow 0.2s, background-color 0.2s, border-color 0.2s, color 0.2s;
  white-space: nowrap;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn:hover {
  border-color: color-mix(in srgb, var(--aqua) 55%, transparent);
  color: var(--aqua);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--aqua), var(--aqua-2));
  color: var(--on-aqua);
  box-shadow: 0 8px 22px -10px color-mix(in srgb, var(--aqua) 80%, transparent);
}

.btn--primary:hover {
  color: var(--on-aqua);
  box-shadow: var(--glow);
}

.btn--gold {
  border-color: color-mix(in srgb, var(--gold) 55%, transparent);
  background: var(--gold-soft);
  color: var(--gold);
}

.btn--gold:hover {
  color: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 18px -6px color-mix(in srgb, var(--gold) 70%, transparent);
}

.btn--ghost {
  background: transparent;
}

.btn--sm {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.84rem;
}

.btn--block {
  width: 100%;
}

/* ---------- Form controls ---------- */
.field {
  display: grid;
  gap: 6px;
}

.field__label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field__hint {
  font-size: 0.78rem;
  color: var(--text-3);
}

.input,
.select {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background-color: var(--field);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input::placeholder {
  color: var(--text-3);
}

.input:focus,
.select:focus {
  border-color: var(--aqua);
  box-shadow: 0 0 0 3px var(--aqua-soft);
}

.input[readonly] {
  background: var(--panel-2);
}

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  cursor: pointer;
}

.input--num {
  font-family: var(--font-hud);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

input[type="number"].input--num {
  -moz-appearance: textfield;
}

input[type="number"].input--num::-webkit-outer-spin-button,
input[type="number"].input--num::-webkit-inner-spin-button {
  opacity: 0.5;
}

/* Range slider */
.range {
  --pct: 100%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  cursor: pointer;
}

.range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--aqua) 0 var(--pct), var(--panel-3) var(--pct) 100%);
}

.range::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--panel-3);
}

.range::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--aqua);
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border-radius: 6px;
  transform: rotate(45deg);
  background: var(--panel-solid);
  border: 2px solid var(--aqua);
  box-shadow: 0 0 12px color-mix(in srgb, var(--aqua) 70%, transparent);
}

.range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  transform: rotate(45deg);
  background: var(--panel-solid);
  border: 2px solid var(--aqua);
  box-shadow: 0 0 12px color-mix(in srgb, var(--aqua) 70%, transparent);
}

/* Segmented radio group */
.seg {
  --c: var(--aqua);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.seg label {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
}

.seg input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.seg span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 8px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: var(--field);
  color: var(--text-2);
  font-family: var(--font-hud);
  font-weight: 600;
  font-size: 0.86rem;
  transition: all 0.15s ease;
  user-select: none;
}

.seg label:hover span {
  border-color: color-mix(in srgb, var(--aqua) 50%, transparent);
  color: var(--text);
}

.seg input:checked + span {
  /* --c 由外層 .seg 或各 label 指定（例如五項 BP 的顏色） */
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 18%, transparent);
  color: var(--c);
  box-shadow: 0 0 14px -4px color-mix(in srgb, var(--c) 70%, transparent);
}

.seg input:focus-visible + span {
  outline: 2px solid var(--aqua);
  outline-offset: 2px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--field);
  border: 1px solid var(--line);
}

.tab {
  flex: 1;
  min-height: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  font-size: 0.88rem;
  transition: background-color 0.2s, color 0.2s;
}

.tab[aria-selected="true"] {
  background: var(--panel-3);
  color: var(--aqua);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--aqua) 35%, transparent);
}

/* Chips & badges */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--field);
  color: var(--text-2);
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
}

button.chip {
  cursor: pointer;
}

button.chip:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--aqua) 50%, transparent);
}

.chip[aria-pressed="true"] {
  color: var(--aqua);
  border-color: var(--aqua);
  background: var(--aqua-soft);
}

.chip .count {
  font-family: var(--font-hud);
  font-size: 0.74rem;
  color: var(--text-3);
}

.chip[aria-pressed="true"] .count {
  color: inherit;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-family: var(--font-hud);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  border: 1px solid currentColor;
  color: var(--aqua);
  line-height: 1.5;
}

.badge--gold { color: var(--gold); }
.badge--ok { color: var(--ok); }
.badge--warn { color: var(--warn); }
.badge--muted { color: var(--text-3); }

.kbd {
  font-family: var(--font-hud);
  font-size: 0.75rem;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  color: var(--text-2);
}

/* Callout */
.callout {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--aqua) 30%, transparent);
  background: var(--aqua-soft);
  color: var(--text-2);
  font-size: 0.88rem;
}

.callout svg {
  width: 18px;
  height: 18px;
  color: var(--aqua);
  margin-top: 2px;
}

.callout--warn {
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
}

.callout--warn svg {
  color: var(--warn);
}

/* Details / disclosure */
.disclosure {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--field);
}

.disclosure > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
}

.disclosure > summary::-webkit-details-marker {
  display: none;
}

.disclosure > summary::after {
  content: "";
  margin-left: auto;
  width: 18px;
  height: 18px;
  background: var(--select-arrow) center / 18px no-repeat;
  transition: transform 0.2s;
}

.disclosure[open] > summary::after {
  transform: rotate(180deg);
}

.disclosure__body {
  padding: 0 14px 14px;
  color: var(--text-2);
}

/* ---------- Data table ---------- */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.data-table thead th {
  font-family: var(--font-hud);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--panel-2);
  position: sticky;
  top: 0;
}

.data-table tbody tr:hover {
  background: var(--aqua-soft);
}

/* ---------- Ads ---------- */
.ad-slot {
  position: relative;
  margin: 22px 0;
  padding: 26px 12px 12px;
  border-radius: var(--radius);
  border: 1px dashed var(--line-2);
  background: color-mix(in srgb, var(--panel) 60%, transparent);
  min-height: 140px;
  overflow: hidden;
}

.ad-slot::before {
  content: "廣告";
  position: absolute;
  top: 6px;
  left: 12px;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--text-3);
}

/* Google 官方建議：沒有填入廣告時把容器收起來，避免空白方框 */
.ad-slot:has(ins.adsbygoogle[data-ad-status="unfilled"]) {
  display: none;
}

ins.adsbygoogle[data-ad-status="unfilled"] {
  display: none !important;
}

/* 自動廣告可能被插進 grid 版面，讓它獨佔一整列，不要擠進某一欄把版面撐壞 */
:is(.pets-layout, .craft-layout, .tool-grid, .guide__grid, .dungeon-list, .area-side, .lists) > :is(ins.adsbygoogle, .google-auto-placed) {
  grid-column: 1 / -1;
  width: 100%;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-elev) 70%, transparent);
  color: var(--text-3);
  font-size: 0.84rem;
}

.site-footer__inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 32px var(--gutter) 28px;
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 28px;
}

.site-footer h2 {
  font-size: 0.8rem;
  font-family: var(--font-hud);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 10px;
}

.site-footer ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 6px;
}

.site-footer a {
  color: var(--text-2);
}

.site-footer a:hover {
  color: var(--aqua);
}

.site-footer .brand {
  margin-bottom: 10px;
}

.site-footer__legal {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 14px var(--gutter) 22px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  justify-content: space-between;
}

@media (max-width: 820px) {
  .site-footer__inner {
    grid-template-columns: 1fr 1fr;
  }

  .site-footer__about {
    grid-column: 1 / -1;
  }
}

/* ---------- Promo toast（TripFun，不擋畫面） ---------- */
.promo-toast {
  position: fixed;
  left: 20px;
  bottom: calc(20px + var(--ad-anchor-bottom));
  z-index: 1100;
  width: min(360px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  padding: 14px 14px 14px 12px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  background: var(--panel-solid);
  box-shadow: 0 24px 48px -18px rgba(0, 0, 0, 0.6);
  transform: translateY(16px);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s;
}

.promo-toast.is-visible {
  transform: none;
  opacity: 1;
}

.promo-toast__art {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  background: #fdfbf7;
  border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
}

.promo-toast__title {
  font-weight: 700;
  font-size: 0.95rem;
  padding-right: 26px;
}

.promo-toast__text {
  font-size: 0.82rem;
  color: var(--text-2);
  margin: 2px 0 10px;
}

.promo-toast__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.promo-toast__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  display: grid;
  place-items: center;
}

.promo-toast__close:hover {
  color: var(--text);
  background: var(--aqua-soft);
}

.promo-toast__close svg {
  width: 16px;
  height: 16px;
}

.promo-toast__never {
  font-size: 0.78rem;
  color: var(--text-3);
  background: none;
  border: 0;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 820px) {
  .promo-toast {
    left: 16px;
    right: 16px;
    width: auto;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--ad-anchor-bottom) + 12px);
  }
}

/* ---------- 懸浮贊助卡（Adsterra Direct Link） ---------- */
.boost-card {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--ad-anchor-bottom));
  z-index: 1050;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 290px;
  padding: 12px 14px 12px 12px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--gold) 55%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--gold) 14%, var(--panel-solid)), var(--panel-solid) 60%);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.65), 0 0 24px -8px color-mix(in srgb, var(--gold) 60%, transparent);
  color: var(--text);
  text-decoration: none !important;
  overflow: hidden;
  animation: boost-bob 4s ease-in-out infinite;
  transition: border-color 0.2s, box-shadow 0.2s, opacity 0.25s, visibility 0.25s;
}

.boost-card::before {
  content: "SPONSORED";
  position: absolute;
  top: 0;
  right: 12px;
  padding: 1px 6px;
  border-radius: 0 0 4px 4px;
  background: var(--gold-soft);
  font-family: var(--font-hud);
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  color: var(--text-3);
}

.boost-card::after {
  /* 斜向流光，吸引目光但不閃爍 */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, 0.1) 48%, transparent 62%);
  transform: translateX(-100%);
  animation: boost-shine 6s ease-in-out infinite;
  pointer-events: none;
}

.boost-card:hover {
  border-color: var(--gold);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.65), 0 0 32px -6px color-mix(in srgb, var(--gold) 75%, transparent);
  animation-play-state: paused;
}

.boost-card__icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: var(--panel-solid);
}

.boost-card__icon .i {
  width: 22px;
  height: 22px;
}

.boost-card__text {
  display: grid;
  min-width: 0;
  line-height: 1.35;
}

.boost-card__text b {
  font-size: 0.95rem;
}

.boost-card__text small {
  font-size: 0.8rem;
  color: var(--text-2);
}

.boost-card > .i {
  margin-left: auto;
  color: var(--gold);
  transition: transform 0.2s;
}

.boost-card:hover > .i {
  transform: translateX(4px);
}

/* 頁尾最後一行要能捲到懸浮卡上方 */
body:has(.boost-card) {
  padding-bottom: 96px;
}

/* 站長推薦小卡出現時先讓位，避免兩張卡疊在一起 */
body:has(.promo-toast.is-visible) .boost-card {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@keyframes boost-bob {
  50% {
    transform: translateY(-4px);
  }
}

@keyframes boost-shine {
  0%,
  65% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

@media (max-width: 820px) {
  .boost-card {
    right: 12px;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--ad-anchor-bottom) + 10px);
    width: auto;
    max-width: calc(100vw - 24px);
    gap: 8px;
    padding: 8px 12px 8px 8px;
    border-radius: 12px;
  }

  .boost-card__icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }

  .boost-card__icon .i {
    width: 18px;
    height: 18px;
  }

  .boost-card__text b {
    font-size: 0.82rem;
  }

  .boost-card__text small {
    font-size: 0.7rem;
  }

  .boost-card::before {
    right: 8px;
    font-size: 0.48rem;
  }

  /* 頁面底部多留一段，最後的內容才捲得出來，不會永遠被卡片蓋住 */
  body:has(.boost-card) {
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--ad-anchor-bottom) + 72px);
  }
}

/* ---------- Motion ---------- */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.rise {
  animation: rise 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes spin-rev {
  to {
    transform: rotate(-360deg);
  }
}

@keyframes float {
  50% {
    transform: translateY(-6px);
  }
}

/* 魔法陣 */
.mc {
  color: var(--aqua);
  overflow: visible;
}

.mc .mc-ring {
  transform-box: fill-box;
  transform-origin: center;
}

.mc .mc-ring--outer {
  animation: spin 140s linear infinite;
}

.mc .mc-ring--mid {
  animation: spin-rev 90s linear infinite;
}

.mc .mc-ring--inner {
  animation: spin 60s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
