@import url('https://fonts.googleapis.com/css2?family=Archivo+Black&family=Space+Grotesk:wght@400;500;700&display=swap');

:root {
  --skin: #FFD849;
  --skin-dim: #E8B92E;
  --denim: #2764CC;
  --denim-lt: #9FC4FF;
  --steel: #C7CDD6;
  --panel: #1A1D26;
  --panel-2: #232733;
  --panel-3: #2E3341;
  --ink: #F2F0E8;
  --ink-dim: #9AA0AE;
  --line: #39404F;
  --display: 'Archivo Black', system-ui, sans-serif;
  --body: 'Space Grotesk', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}

/* 頂部導覽 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--display);
  font-size: 19px;
  letter-spacing: .01em;
}

.brand-dot {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--skin);
  border: 3px solid var(--steel);
  box-shadow: inset 0 0 0 3px var(--panel);
  flex: none;
}

.nav { display: flex; gap: 8px; }

.nav a {
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .09em;
  text-transform: uppercase;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: .18s;
}

.nav a:hover { color: var(--ink); border-color: var(--steel); }
.nav a[aria-current="page"] { background: var(--skin); border-color: var(--skin); color: #17181C; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 36px 24px 80px; }

.eyebrow {
  font-size: 11px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--skin); font-weight: 700; margin: 0 0 10px;
}

h1 { font-family: var(--display); font-size: clamp(28px, 4.6vw, 46px); margin: 0 0 12px; line-height: 1.08; }
.lede { color: var(--ink-dim); max-width: 60ch; margin: 0 0 30px; line-height: 1.65; font-size: 15px; }

/* ===== 建構器 ===== */
.builder {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 360px);
  gap: 28px;
  align-items: start;
}

.stage {
  position: relative;
  background:
    radial-gradient(ellipse 60% 42% at 50% 78%, rgba(255,216,73,.14), transparent 70%),
    var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}

/* 三段式切換列 */
.slot {
  display: grid;
  grid-template-columns: 68px 1fr 68px;
  align-items: center;
  min-height: 122px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.slot:last-child { border-bottom: 0; }

.arrow {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  height: 100%;
  transition: .15s;
  font-family: var(--body);
  font-weight: 700;
  z-index: 3;
}
.arrow:hover { background: rgba(255,216,73,.12); color: var(--skin); }
.arrow:focus-visible { outline: 2px solid var(--skin); outline-offset: -3px; }

.slot-label {
  position: absolute;
  left: 74px;
  top: 12px;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  z-index: 3;
  pointer-events: none;
}

.slot-value {
  position: absolute;
  left: 74px;
  top: 30px;
  font-family: var(--display);
  font-size: 17px;
  color: var(--skin);
  z-index: 3;
  pointer-events: none;
}

/* 小小兵疊在三段列上方 */
.minion-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 2;
}

.minion-svg { width: min(300px, 62%); height: auto; display: block; }
.minion-layer .minion-svg { filter: drop-shadow(0 18px 30px rgba(0,0,0,.42)); transition: opacity .16s; }

/* 控制面板 */
.panel {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
}

.panel h2 {
  font-family: var(--display);
  font-size: 15px;
  margin: 0 0 4px;
  letter-spacing: .02em;
}

.panel .sub { color: var(--ink-dim); font-size: 12.5px; margin: 0 0 18px; line-height: 1.55; }

.spec { border-top: 1px solid var(--line); padding: 13px 0; }
.spec:last-of-type { border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.spec-k { font-size: 10px; letter-spacing: .17em; text-transform: uppercase; color: var(--ink-dim); }
.spec-v { font-family: var(--display); font-size: 15px; margin-top: 4px; }
.spec-d { font-size: 12.5px; color: var(--ink-dim); margin-top: 3px; line-height: 1.5; }

.btn {
  width: 100%;
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 15px 18px;
  font-family: var(--display);
  font-size: 15px;
  cursor: pointer;
  background: var(--skin);
  color: #17181C;
  transition: .16s;
  letter-spacing: .02em;
}
.btn:hover { background: #FFE47A; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 3px solid var(--denim-lt); outline-offset: 2px; }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  margin-top: 10px;
  font-size: 13px;
  padding: 12px;
}
.btn-ghost:hover { border-color: var(--steel); background: rgba(255,255,255,.04); transform: none; }

.idtag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  margin-bottom: 14px;
}

/* 隨機時的抖動 */
@keyframes shuffle {
  0%, 100% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-9px) rotate(-3deg); }
  50% { transform: translateY(3px) rotate(2deg); }
  75% { transform: translateY(-5px) rotate(-1.5deg); }
}
.shuffling .minion-svg { animation: shuffle .42s ease-in-out; }

/* ===== 圖鑑 ===== */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  align-items: center;
}

.filters .fgroup { display: flex; gap: 6px; align-items: center; }

.flabel {
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-dim); margin-right: 4px;
}

.chip {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-family: var(--body);
  cursor: pointer;
  transition: .15s;
}
.chip:hover { border-color: var(--steel); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--skin); border-color: var(--skin); color: #17181C; font-weight: 700; }
.chip:focus-visible { outline: 2px solid var(--denim-lt); outline-offset: 2px; }

.count { margin-left: auto; font-size: 12.5px; color: var(--ink-dim); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
}

.card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 12px 12px;
  text-align: center;
  cursor: pointer;
  transition: .18s;
  position: relative;
  font-family: var(--body);
  color: inherit;
  appearance: none;
  display: block;
  width: 100%;
}
.card:hover { border-color: var(--skin); transform: translateY(-3px); background: var(--panel-3); }
.card:focus-visible { outline: 2px solid var(--skin); outline-offset: 2px; }

.card .no {
  position: absolute; top: 9px; left: 11px;
  font-size: 10px; letter-spacing: .1em; color: var(--ink-dim);
}
.card .minion-svg { width: 100%; max-width: 118px; margin: 6px auto 8px; }
.card .cname { font-family: var(--display); font-size: 12.5px; margin-bottom: 3px; }
.card .cmeta { font-size: 11px; color: var(--ink-dim); letter-spacing: .04em; }

/* 詳情彈窗 */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10,11,15,.78);
  display: grid; place-items: center;
  padding: 22px;
}
.modal[hidden] { display: none; }

.modal-box {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  max-width: 560px;
  width: 100%;
  padding: 26px;
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 24px;
  align-items: center;
  position: relative;
}

.modal-close {
  position: absolute; top: 12px; right: 14px;
  background: transparent; border: 0; color: var(--ink-dim);
  font-size: 24px; cursor: pointer; line-height: 1; padding: 4px 8px;
}
.modal-close:hover { color: var(--ink); }

.modal-box .minion-svg { width: 100%; }
.modal h3 { font-family: var(--display); font-size: 22px; margin: 0 0 6px; }

.stat { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.stat:last-child { border-bottom: 0; }
.stat span:first-child { color: var(--ink-dim); }
.stat span:last-child { font-weight: 700; }

footer {
  border-top: 1px solid var(--line);
  padding: 22px 28px;
  color: var(--ink-dim);
  font-size: 12px;
  text-align: center;
  line-height: 1.7;
}
footer a { color: var(--ink-dim); }

@media (max-width: 860px) {
  .builder { grid-template-columns: 1fr; }
  .minion-svg { width: min(230px, 54%); }
  .modal-box { grid-template-columns: 1fr; text-align: center; }
  .modal-box .minion-svg { max-width: 160px; margin: 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .card:hover, .btn:hover { transform: none; }
}

/* ===== 具名角色強調 ===== */
.match {
  border: 1px solid var(--skin);
  background: rgba(255,216,73,.07);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.match .mtag {
  font-size: 10px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--skin); font-weight: 700; margin-bottom: 6px;
}
.match .mname { font-family: var(--display); font-size: 18px; margin-bottom: 2px; }
.match .mzh { font-size: 12px; color: var(--ink-dim); margin-bottom: 8px; }
.match .mnote { font-size: 12.5px; line-height: 1.6; margin-bottom: 8px; }
.match .mfilms { font-size: 12px; color: var(--ink-dim); line-height: 1.7; }
.match .mfilms b { color: var(--ink); font-weight: 500; }
.match + .match { margin-top: -8px; }

.match-none {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
  font-size: 12.5px;
  color: var(--ink-dim);
  line-height: 1.6;
}

.card.named { border-color: rgba(255,216,73,.5); }
.card.named:hover { border-color: var(--skin); }
.card .badge {
  position: absolute; top: 8px; right: 10px;
  font-size: 10px; letter-spacing: .08em;
  color: #17181C; background: var(--skin);
  border-radius: 999px; padding: 3px 8px; font-weight: 700;
}
.card .cfilm { font-size: 10.5px; color: var(--ink-dim); margin-top: 3px; line-height: 1.5; }

/* ===== 淺色展示區（標本櫃）：讓黑色頭髮、手套、靴子讀得出來 ===== */
.stage {
  background:
    radial-gradient(ellipse 62% 40% at 50% 80%, rgba(255,216,73,.28), transparent 70%),
    linear-gradient(180deg, #F4F2EB, #E9E6DC);
  border-color: #3A3F4C;
}
.slot { border-bottom: 1px solid rgba(23,24,28,.10); }
.arrow { color: #575C66; }
.arrow:hover { background: rgba(255,216,73,.45); color: #17181C; }
.arrow:focus-visible { outline-color: #A87900; }
.slot-label { color: #8A8E96; }
.slot-value { color: #A87900; }
.minion-layer .minion-svg { filter: drop-shadow(0 14px 22px rgba(23,24,28,.22)); }

.card .minion-svg {
  background: linear-gradient(180deg, #F4F2EB, #E9E6DC);
  border-radius: 10px;
  padding: 8px 4px;
}
#modal-figure .minion-svg {
  background: linear-gradient(180deg, #F4F2EB, #E9E6DC);
  border-radius: 14px;
  padding: 12px 6px;
}


/* ===== 舞台下方固定按鈕列 ===== */
.stage-actions { display: flex; gap: 10px; margin-top: 14px; }
.stage-actions .btn { flex: 1.4; width: auto; }
.stage-actions .btn-ghost {
  flex: 1;
  margin-top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  text-align: center;
}
.spec:last-of-type { margin-bottom: 0; }


/* ===== 圖鑑卡片等高對齊 ===== */
.card { display: flex; flex-direction: column; align-items: center; }
.card .minion-svg {
  width: auto;
  height: 172px;
  max-width: none;
  flex: none;
  margin: 6px auto 8px;
}
.card .cinfo {
  min-height: 66px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
}
.card .cfilm {
  margin-top: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
