:root {
  --bg: #070907;
  --fg: #f2f5ee;
  --dim: rgba(242, 245, 238, 0.45);
  --line: rgba(255, 255, 255, 0.1);
  --accent: #a6ff4d;
  --glass: rgba(28, 31, 28, 0.62);
  --sans: "Space Grotesk", "Noto Sans TC", system-ui, sans-serif;
  --zh: "Noto Sans TC", "Space Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Noto Sans TC", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--fg); }
body { font-family: var(--zh); overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; line-height: 1.45; text-transform: uppercase; }
.dim { color: var(--dim); }
.accent { color: var(--accent); }

/* ---------- loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: grid; place-items: center; align-content: center; gap: 18px;
  transition: opacity .6s ease;
}
#loader.done { opacity: 0; pointer-events: none; }
.loader-slime { width: 72px; animation: squish 0.9s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes squish {
  0%, 100% { transform: scale(1.12, 0.88) translateY(0); }
  50% { transform: scale(0.92, 1.08) translateY(-14px); }
}

/* ---------- stage ---------- */
#stage {
  position: fixed; inset: 0; width: 100vw; height: 100vh; display: block;
  touch-action: none; cursor: grab; opacity: 0; transition: opacity 1s ease;
}
#stage.ready { opacity: 1; }
#stage.dragging { cursor: grabbing; }
#stage.pointer { cursor: pointer; }

/* ---------- header ---------- */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto auto 1fr; align-items: start; gap: 48px;
  padding: 20px 24px; pointer-events: none;
}
.top > * { pointer-events: auto; position: relative; }
.top::before {
  content: ""; position: absolute; inset: 0 0 -40px 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(7,9,7,.85), rgba(7,9,7,.5) 55%, transparent);
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); }
.logo svg { width: 40px; color: var(--accent); }
.wordmark { font-family: var(--sans); font-weight: 700; font-size: 15px; line-height: 0.95; letter-spacing: -0.01em; }
.tagline { text-transform: none; }
.status p { display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.cta {
  justify-self: end; background: var(--fg); color: var(--bg); font-weight: 500; font-size: 14px;
  padding: 12px 20px; border-radius: 999px; transition: background .2s, transform .2s;
}
.cta:hover { background: var(--accent); transform: translateY(-1px); }

/* ---------- bottom controls ---------- */
.view-toggle, .bottom-nav, .filter-btn {
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-radius: 999px;
}
.view-toggle { position: fixed; left: 20px; bottom: 20px; z-index: 30; display: flex; padding: 4px; gap: 2px; }
.view-toggle button { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; transition: background .2s; }
.view-toggle svg { width: 15px; fill: var(--fg); }
.view-toggle button.active { background: var(--fg); }
.view-toggle button.active svg { fill: var(--bg); }

.bottom-nav {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30;
  display: flex; padding: 4px; gap: 2px;
}
.bottom-nav button { padding: 11px 22px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--dim); transition: color .2s, background .2s; }
.bottom-nav button:hover { color: var(--fg); }
.bottom-nav button.active { background: var(--fg); color: var(--bg); }

.filter-wrap { position: fixed; right: 20px; bottom: 20px; z-index: 30; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.filter-btn { padding: 14px 22px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.filter-btn:hover, .filter-btn.open { background: var(--fg); color: var(--bg); }
.badge { background: var(--accent); color: var(--bg); font-family: var(--mono); font-size: 10px; border-radius: 999px; padding: 1px 7px; }
.filter-panel {
  width: min(340px, calc(100vw - 40px)); padding: 18px; border-radius: 20px;
  background: rgba(20, 22, 20, 0.85); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line); animation: pop .25s ease;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  font-family: var(--mono); font-size: 12px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18); color: var(--dim); transition: all .15s;
}
.chip:hover { color: var(--fg); border-color: rgba(255,255,255,.4); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--bg); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.hint { position: fixed; left: 50%; bottom: 82px; transform: translateX(-50%); z-index: 10; color: var(--dim); pointer-events: none; transition: opacity .8s; }
.hint.gone { opacity: 0; }

/* ---------- pages (list / about) ---------- */
.page { position: fixed; inset: 0; z-index: 15; overflow-y: auto; background: var(--bg); animation: fadein .4s ease; }
@keyframes fadein { from { opacity: 0; } }
.page-inner { padding: 22vh 24px 140px; max-width: 1600px; margin: 0 auto; }
.list-head { display: grid; grid-template-columns: 1fr 2fr; margin-bottom: 7vh; }
.list-head h1, .big { font-family: var(--sans); font-weight: 700; font-size: clamp(32px, 4.2vw, 64px); letter-spacing: -0.03em; line-height: 1.05; }
.year-group { display: grid; grid-template-columns: 1fr 2fr; border-top: 1px solid var(--line); padding: 22px 0 56px; }
.year-group h3 { font-family: var(--sans); font-size: 20px; font-weight: 700; }
.row {
  display: grid; grid-template-columns: 1.3fr 1.2fr 0.9fr; align-items: center; gap: 16px;
  padding: 11px 0; border-bottom: 1px solid var(--line); text-decoration: none; cursor: pointer;
  transition: padding .25s ease, color .2s;
}
.row:hover { padding-left: 12px; color: var(--accent); }
.row .t { font-weight: 500; font-size: 16px; }
.row .t small { color: var(--dim); font-weight: 400; margin-left: 8px; font-size: 13px; }
.row .d { text-align: right; color: var(--dim); font-size: 14px; }
.row:hover .d { color: var(--fg); }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { font-family: var(--mono); font-size: 10.5px; padding: 4px 9px; border-radius: 999px; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.05); color: rgba(242,245,238,.75); }
#hoverPreview {
  position: fixed; left: 0; top: 0; width: 200px; height: 200px; pointer-events: none; z-index: 16;
  border-radius: 8px; opacity: 0; transition: opacity .2s; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
#hoverPreview.show { opacity: 1; }

.about .big { margin: 18px 0 56px; max-width: 18em; }
.about-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; max-width: 980px; font-size: 17px; line-height: 1.8; color: rgba(242,245,238,.8); }
.submit { margin-top: 14vh; border-top: 1px solid var(--line); padding-top: 28px; max-width: 980px; }
.submit h2 { font-family: var(--sans); font-size: clamp(26px, 3vw, 42px); letter-spacing: -0.02em; line-height: 1.15; margin: 16px 0 20px; }
.submit > p:not(.mono) { font-size: 17px; line-height: 1.8; color: rgba(242,245,238,.8); max-width: 36em; }
.rules { list-style: none; margin-top: 28px; display: grid; gap: 10px; font-size: 13px; }
.rules li { border-bottom: 1px solid var(--line); padding-bottom: 10px; }

/* ---------- detail modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); animation: fadein .3s; }
.detail-card {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; width: min(980px, 100%); max-height: calc(100vh - 40px);
  background: #0d100d; border: 1px solid var(--line); border-radius: 24px; overflow: hidden; animation: pop .35s cubic-bezier(.2,.9,.3,1.2);
}
.detail-cover { background: #000; aspect-ratio: 1; }
.detail-cover canvas { width: 100%; height: 100%; display: block; }
.detail-info { padding: 36px 34px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.meta { display: flex; justify-content: space-between; color: var(--dim); }
.detail-info h2 { font-family: var(--sans); font-size: clamp(28px, 3.2vw, 44px); letter-spacing: -0.03em; line-height: 1; margin-top: 8px; }
.facts { border-top: 1px solid var(--line); }
.facts > div { display: grid; grid-template-columns: 72px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.facts dt { color: var(--dim); align-self: center; }
.facts dd { word-break: break-word; }
.zh { font-size: 18px; color: var(--dim); font-weight: 500; }
.blurb { font-size: 16px; line-height: 1.8; color: rgba(242,245,238,.85); }
.play {
  margin-top: auto; flex-shrink: 0; display: inline-flex; justify-content: space-between; align-items: center;
  background: var(--accent); color: var(--bg); text-decoration: none; font-weight: 700; font-size: 17px;
  padding: 16px 22px; border-radius: 999px; transition: transform .2s, box-shadow .2s;
}
.play span { font-size: 12px; font-weight: 500; opacity: .7; }
.play:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(166,255,77,.3); }
.small { font-size: 10px; text-transform: none; word-break: break-all; }
.detail-nav { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 14px; }
.detail-nav button { color: var(--dim); }
.detail-nav button:hover { color: var(--fg); }
.icon-btn.close {
  position: absolute; right: 14px; top: 14px; z-index: 2; width: 38px; height: 38px; border-radius: 50%;
  background: var(--glass); backdrop-filter: blur(8px); font-size: 14px;
}
.icon-btn.close:hover { background: var(--fg); color: var(--bg); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .top { grid-template-columns: 1fr auto; gap: 16px; padding: 16px; }
  .tagline, .status { display: none; }
  .list-head, .year-group { grid-template-columns: 1fr; gap: 12px; }
  .row { grid-template-columns: 1fr; gap: 6px; }
  .row .d { text-align: left; }
  .about-cols { grid-template-columns: 1fr; gap: 16px; }
  .detail-card { grid-template-columns: 1fr; overflow-y: auto; }
  .detail-cover { aspect-ratio: 16 / 9; max-height: 34vh; width: 100%; }
  .detail-info { padding: 20px 20px 22px; overflow: visible; gap: 12px; }
  .detail-info .play { position: sticky; bottom: 0; box-shadow: 0 -12px 24px #0d100d; }
  .bottom-nav button { padding: 10px 14px; }
  .filter-btn { padding: 13px 16px; }
  .hint { bottom: 76px; }
  #hoverPreview { display: none; }
}
@media (max-width: 520px) {
  .view-toggle { left: 12px; bottom: 14px; }
  .bottom-nav { bottom: 14px; }
  .filter-wrap { right: 12px; bottom: 14px; }
  .view-toggle button { width: 36px; height: 36px; }
  .bottom-nav button { padding: 10px 11px; font-size: 13px; }
  .filter-btn { padding: 12px 13px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- list toolbar：搜尋 + 篩選 ---------- */
.list-head { margin-bottom: 4vh; }
.list-tools {
  position: sticky; top: var(--header-h, 78px); z-index: 5; margin: 0 -24px 36px; padding: 12px 24px 14px;
  background: var(--bg); border-bottom: 1px solid var(--line);
  display: grid; gap: 12px;
}
.search {
  display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 18px;
  border: 1px solid rgba(255,255,255,.16); border-radius: 999px; background: rgba(255,255,255,.04);
  transition: border-color .2s, background .2s;
}
.search:focus-within { border-color: var(--accent); background: rgba(166,255,77,.05); }
.search svg { width: 18px; flex-shrink: 0; color: var(--dim); }
.search input {
  flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: 0; color: var(--fg);
  font: 500 17px var(--zh);
}
.search input::placeholder { color: rgba(242,245,238,.35); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd { border: 1px solid rgba(255,255,255,.2); border-radius: 6px; padding: 2px 8px; color: var(--dim); }
.search:focus-within kbd { display: none; }
#searchClear { width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,.1); font-size: 12px; }
#searchClear:hover { background: var(--fg); color: var(--bg); }

.list-filters { display: flex; flex-wrap: wrap; gap: 14px 32px; align-items: flex-start; }
.fgroup { display: grid; gap: 8px; }
.list-filters .fgroup { display: flex; align-items: center; gap: 10px; }
.list-filters .fgroup > p { flex-shrink: 0; }
.fgroup > p span { opacity: .6; text-transform: none; }
.filter-panel .fgroup + .fgroup { margin-top: 14px; }
.filter-panel .chips { margin-top: 0; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); }
.seg button { padding: 7px 14px; border-radius: 999px; font-size: 13px; color: var(--dim); transition: all .15s; }
.seg button span { font-family: var(--mono); font-size: 10px; opacity: .7; margin-left: 2px; }
.seg button:hover { color: var(--fg); }
.seg button.on { background: var(--fg); color: var(--bg); }
.chip:disabled { opacity: .3; cursor: default; }
.chip:disabled:hover { color: var(--dim); border-color: rgba(255,255,255,.18); }

.list-meta { display: flex; gap: 16px; align-items: center; color: var(--dim); }
.list-meta button { color: var(--accent); text-transform: none; }
.list-meta button:hover { text-decoration: underline; }

.row mark { background: rgba(166,255,77,.25); color: var(--fg); border-radius: 3px; padding: 0 1px; }
.year-group h3 .dim { font-family: var(--mono); font-size: 13px; margin-left: 6px; }
.empty { padding: 8vh 0; display: grid; gap: 12px; justify-items: start; }
.big-empty { font-family: var(--sans); font-size: 28px; font-weight: 700; }

@media (max-width: 900px) {
  .list-tools { margin: 0 -16px 28px; padding: 10px 16px 14px; }
  .search { height: 50px; }
  .search kbd { display: none; }
  .list-filters { gap: 10px; flex-direction: column; flex-wrap: nowrap; }
  .list-filters .fgroup { width: 100%; }
  .list-filters .fgroup > p { display: none; }
  .list-filters .seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
  .list-filters .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
  .list-filters .chips::-webkit-scrollbar { display: none; }
  .list-filters .chip { flex-shrink: 0; }
}

/* 列表／關於頁：上方 header 改成實心底，捲動時內容不會從 header 和工具列之間露出來 */
body.solid-header .top::before { background: var(--bg); inset: 0; }
#listBody .year-group:first-child { border-top: 0; padding-top: 0; }

/* ======================================================
   List view 細修
   ====================================================== */
#list .page-inner { padding-top: 17vh; }
.list-head { grid-template-columns: 1fr 3fr; align-items: end; margin-bottom: 3.5vh; }
.year-group { grid-template-columns: 1fr 3fr; padding: 28px 0 48px; }
.year-group h3 { position: sticky; top: calc(var(--header-h, 78px) + var(--tools-h, 150px) + 16px); align-self: start; }

/* 工具列：搜尋一列，篩選 + 結果數同一列 */
.list-tools { grid-template-columns: 1fr auto; column-gap: 24px; }
.list-tools .search { grid-column: 1 / -1; }
.list-meta { justify-self: end; align-self: center; white-space: nowrap; }
.list-filters .fgroup > p { min-width: 2.5em; }

/* 每一列 */
.row {
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, .9fr) 20px;
  gap: 20px; padding: 14px 8px; margin: 0 -8px; border-radius: 10px; border-bottom: 0;
  position: relative; outline: none;
  transition: background .2s ease, color .2s ease;
}
.row::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 1px; background: var(--line); }
.row:hover, .row:focus-visible { padding-left: 8px; background: rgba(255,255,255,.04); color: var(--fg); }
.row:focus-visible { box-shadow: 0 0 0 2px var(--accent) inset; }
.row .thumb { display: none; }
.row .t { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.row .t b { font-weight: 500; font-size: 17px; letter-spacing: -0.01em; transition: color .2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t small { margin: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row:hover .t b, .row:focus-visible .t b { color: var(--accent); }
.row .tags { flex-wrap: nowrap; overflow: hidden; }
.row .d { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .go { color: var(--accent); opacity: 0; transform: translateX(-6px); transition: opacity .2s, transform .2s; font-family: var(--mono); }
.row:hover .go, .row:focus-visible .go { opacity: 1; transform: none; }

/* 預覽圖 */
#hoverPreview { width: 300px; height: 188px; border-radius: 10px; border: 1px solid rgba(255,255,255,.12); background: #000; transition: opacity .18s; }

@media (max-width: 900px) {
  #list .page-inner { padding-top: 13vh; }
  .list-head { grid-template-columns: 1fr; gap: 2px; margin-bottom: 18px; }
  .list-head h1 { font-size: 34px; }
  .list-tools { grid-template-columns: 1fr; row-gap: 10px; }
  .list-meta { justify-self: start; }
  .year-group { grid-template-columns: 1fr; gap: 6px; padding: 18px 0 32px; }
  .year-group h3 { position: static; font-size: 17px; }

  /* 手機：縮圖 + 兩行文字 */
  .row {
    grid-template-columns: 76px minmax(0, 1fr) auto;
    grid-template-areas: "th t t" "th tags d";
    gap: 4px 14px; padding: 10px 8px; align-items: center;
  }
  .row .thumb {
    grid-area: th; display: grid; place-items: center; width: 76px; aspect-ratio: 16 / 10; overflow: hidden;
    border-radius: 8px; background: hsl(var(--h) 50% 22%); border: 1px solid rgba(255,255,255,.08);
  }
  .row .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .row .thumb i { font-style: normal; font-size: 22px; }
  .row .t { grid-area: t; flex-direction: column; gap: 1px; align-items: flex-start; }
  .row .t b { font-size: 15px; max-width: 100%; }
  .row .t small { font-size: 12px; max-width: 100%; }
  .row .tags { grid-area: tags; }
  .row .tag { font-size: 10px; padding: 2px 7px; }
  .row .d { grid-area: d; text-align: right; font-size: 12px; max-width: 40vw; }
  .row .go { display: none; }
  .row:hover, .row:focus-visible { padding-left: 8px; }
}
/* 防止類型列（橫向捲動）把工具列撐寬 */
.list-tools > *, .list-filters, .list-filters .fgroup, .list-filters .chips, .list-filters .seg { min-width: 0; }
.list-filters .fgroup { max-width: 100%; }

/* ---------- 類型分組 + 地區小標籤 ---------- */
.year-group h3 small { display: block; margin-top: 6px; font-family: var(--sans); font-size: 12.5px; font-weight: 400; color: var(--dim); line-height: 1.5; }
.tag-region { cursor: pointer; border-style: dashed; color: var(--dim); background: transparent; transition: color .15s, border-color .15s, background .15s; }
.tag-region::before { content: "◎ "; opacity: .6; }
.tag-region:hover, .tag-region:focus-visible { color: var(--accent); border-color: var(--accent); border-style: solid; background: rgba(166,255,77,.08); outline: none; }
.tag-cat { border-color: rgba(166,255,77,.5); color: var(--accent); background: rgba(166,255,77,.08); }
.chip-region { border-style: dashed; }
.fhint { margin-top: 12px; font-size: 10.5px; line-height: 1.6; text-transform: none; }
@media (max-width: 720px) { .year-group h3 small { display: inline; margin: 0 0 0 8px; } }
.list-filters .chip, .filter-panel .chip { white-space: nowrap; }
