/* ============ APP RANK · NEON — 霓虹賽博 dashboard ============ */
:root {
  --void: #060912;
  --void-2: #0a0e1a;
  --panel: rgba(13, 19, 36, 0.72);
  --panel-solid: #0c1224;
  --line: rgba(0, 229, 255, 0.14);
  --line-strong: rgba(0, 229, 255, 0.4);
  --fg: #e8f6ff;
  --dim: #5d7290;
  --cyan: #00e5ff;
  --magenta: #ff2d95;
  --purple: #b026ff;
  --lime: #39ff14;
  --gold: #ffd23f;
  --up: var(--lime);
  --down: var(--magenta);
  --new: var(--gold);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--void);
  color: var(--fg);
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 13px;
  line-height: 1.45;
  overflow-x: hidden;
  position: relative;
}

/* ---------- 氛圍層（固定、GPU 合成，不隨捲動重繪）---------- */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 0; transform: translateZ(0); will-change: transform; }
.fx-grid {
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 35%, transparent 85%);
}
.fx-glow {
  background:
    radial-gradient(40% 35% at 12% 8%, rgba(176, 38, 255, 0.24), transparent 70%),
    radial-gradient(45% 40% at 88% 0%, rgba(0, 229, 255, 0.2), transparent 70%),
    radial-gradient(50% 45% at 50% 110%, rgba(255, 45, 149, 0.13), transparent 70%);
  /* 靜態（移除全螢幕 filter + 動畫）以省捲動開銷 */
}
.fx-scan {
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0.18) 3px, rgba(0, 0, 0, 0) 4px);
  opacity: 0.45;
}

/* ---------- 頂列 ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  padding: 12px 20px;
  background: linear-gradient(180deg, #0a0e1c, rgba(10, 14, 28, 0.96));
  border-bottom: 1px solid var(--line-strong);
  box-shadow: 0 1px 0 rgba(0, 229, 255, 0.25);
}
.logo {
  font-family: "Chakra Petch", sans-serif; font-weight: 700;
  font-size: 18px; letter-spacing: 3px; text-transform: uppercase;
  color: #fff; white-space: nowrap;
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.7), 0 0 22px rgba(0, 229, 255, 0.45);
}
.logo-mark { color: var(--magenta); text-shadow: 0 0 10px var(--magenta); animation: blink 2.4s steps(1) infinite; }
@keyframes blink { 0%, 70% { opacity: 1; } 71%, 100% { opacity: 0.35; } }
.logo-dim { color: var(--purple); font-size: 12px; letter-spacing: 2px; margin-left: 4px; text-shadow: 0 0 10px var(--purple); }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-left: auto; }
.ctl { display: flex; align-items: center; gap: 6px; }
.ctl > span { font-size: 10px; letter-spacing: 1.5px; color: var(--cyan); text-transform: uppercase; opacity: 0.8; }
.bar select, .bar input {
  font-family: inherit; font-size: 12px; color: var(--fg);
  background: rgba(0, 229, 255, 0.05);
  border: 1px solid var(--line-strong);
  padding: 6px 10px; border-radius: 6px;
  outline: none; transition: box-shadow .2s, border-color .2s, background .2s;
}
.bar select:hover, .bar input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan), 0 0 16px rgba(0, 229, 255, 0.45);
  background: rgba(0, 229, 255, 0.1);
}
.bar option { background: var(--panel-solid); color: var(--fg); }
.search-wrap { position: relative; }
.search-wrap::before {
  content: "⌕"; position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  color: var(--cyan); font-size: 14px; pointer-events: none; text-shadow: 0 0 8px var(--cyan);
}
.bar input { padding-left: 26px; min-width: 180px; }

/* ---------- 多榜 grid ---------- */
.grid { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.grid-cats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1180px) { .grid-cats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 總榜：獨立一列、全寬、內部 2 欄 */
.chart.overall { border-color: var(--line-strong); box-shadow: 0 0 0 1px rgba(176,38,255,.18), 0 18px 50px -34px rgba(0,229,255,.5); }
.chart.overall > h3 { font-size: 14px; }
/* 總榜全寬單欄表格：欄位多（含類別/評論數），單欄讓表頭對齊、資訊完整 */

/* 顯示全部 / 收合 */
.toggle { margin-left: auto; font: 600 10px/1 "JetBrains Mono", monospace; letter-spacing: 1px;
  color: var(--cyan); background: rgba(0,229,255,.08); border: 1px solid var(--line-strong);
  padding: 4px 8px; border-radius: 6px; cursor: pointer; transition: box-shadow .15s, background .15s; }
.toggle:hover { background: rgba(0,229,255,.18); box-shadow: 0 0 12px rgba(0,229,255,.4); }
.row.extra { display: none; }
.chart.expanded .row.extra { display: flex; }
.chart {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: transform .22s cubic-bezier(.2,.7,.3,1), box-shadow .22s, border-color .22s;
  opacity: 0; transform: translateY(14px);
  animation: cardIn .5s forwards;
}
.grid-cats .chart:nth-child(1){animation-delay:.04s} .grid-cats .chart:nth-child(2){animation-delay:.08s}
.grid-cats .chart:nth-child(3){animation-delay:.12s} .grid-cats .chart:nth-child(4){animation-delay:.16s}
.grid-cats .chart:nth-child(5){animation-delay:.20s} .grid-cats .chart:nth-child(6){animation-delay:.24s}
.grid-cats .chart:nth-child(7){animation-delay:.28s} .grid-cats .chart:nth-child(8){animation-delay:.32s}
.grid-cats .chart:nth-child(9){animation-delay:.36s} .grid-cats .chart:nth-child(10){animation-delay:.40s}
@keyframes cardIn { to { opacity: 1; transform: none; } }
.chart:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.3), 0 24px 60px -28px rgba(0, 229, 255, 0.55);
}
.chart h3 {
  margin: 0; padding: 9px 12px;
  font-family: "Chakra Petch", sans-serif; font-weight: 600;
  font-size: 12px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--cyan);
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.12), transparent);
  border-bottom: 1px solid var(--line);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.55);
  display: flex; align-items: center; gap: 8px;
}
.chart h3::before { content: "◈"; color: var(--purple); text-shadow: 0 0 8px var(--purple); }

.row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px; cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background .15s, box-shadow .15s;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: linear-gradient(90deg, rgba(0, 229, 255, 0.1), transparent); box-shadow: inset 2px 0 0 var(--cyan); }
.row .rk { flex: 0 0 30px; color: var(--dim); text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.row .dl { flex: 0 0 38px; }
.row .name { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.row .genre { flex: 0 0 auto; max-width: 96px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--purple); font-size: 10px; opacity: .9; }
.row .price { flex: 0 0 auto; color: var(--cyan); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .cc { flex: 0 0 auto; color: var(--cyan); font-size: 10px; opacity: .85; white-space: nowrap; }
.row .rc { flex: 0 0 auto; min-width: 44px; text-align: right; color: var(--dim); font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .rt { flex: 0 0 auto; min-width: 34px; text-align: right; color: var(--gold); font-size: 10px; font-variant-numeric: tabular-nums; opacity: .85; white-space: nowrap; }
.row.empty { color: var(--dim); cursor: default; }
.row.empty:hover { background: none; box-shadow: none; }

/* 表頭列 */
.row.head { cursor: default; background: #0d1322; border-bottom: 1px solid var(--line-strong); }
.row.head:hover { background: #0d1322; box-shadow: none; }
.row.head span { color: var(--cyan); opacity: .7; font-size: 9px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.row.head .name { color: var(--cyan); }
.row.head .sortable { cursor: pointer; transition: color .12s, text-shadow .12s, opacity .12s; }
.row.head .sortable:hover { color: #fff; opacity: 1; text-shadow: 0 0 8px var(--cyan); }

/* modal: 數據 chips / 連結 / 簡介 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.chip { display: flex; flex-direction: column; gap: 1px; padding: 6px 10px;
  background: rgba(0, 229, 255, 0.06); border: 1px solid var(--line); border-radius: 8px; }
.chip-k { font-size: 9px; letter-spacing: 1px; color: var(--cyan); text-transform: uppercase; opacity: .8; }
.chip-v { font-size: 14px; font-weight: 700; color: #fff; }
.links { display: flex; gap: 14px; margin-bottom: 10px; }
.desc { max-height: 120px; overflow: auto; font-size: 12px; line-height: 1.6; color: #aebbcf;
  padding: 10px 12px; background: rgba(255, 255, 255, 0.02); border-left: 2px solid var(--purple); border-radius: 4px; margin-bottom: 6px; white-space: pre-wrap; }
svg.trend-rating polyline { stroke: var(--lime); filter: drop-shadow(0 0 6px rgba(57, 255, 20, 0.9)); }
svg.trend-rating circle { fill: var(--gold); filter: drop-shadow(0 0 5px var(--gold)); }

/* 各國名次（全部國家檢視的彈窗） */
.cbreak { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; margin-bottom: 10px; }
.cbreak-cell { display: flex; justify-content: space-between; gap: 6px; padding: 5px 8px;
  background: rgba(0, 229, 255, 0.06); border: 1px solid var(--line); border-radius: 6px; font-size: 11px; }
.cb-c { color: var(--dim); }
.cb-r { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }

/* 最新評論 */
.reviews { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.review { padding: 8px 10px; background: rgba(255, 255, 255, 0.02); border: 1px solid var(--line);
  border-left: 2px solid var(--cyan); border-radius: 6px; }
.review-top { display: flex; align-items: baseline; gap: 8px; }
.review-stars { color: var(--gold); font-size: 11px; letter-spacing: 1px; flex: 0 0 auto; white-space: nowrap; }
.review-title { color: #fff; font-weight: 700; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.review-meta { color: var(--dim); font-size: 10px; margin: 2px 0 5px; }
.review-content { color: #aebbcf; font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }

/* 升降標記 */
.up, .down, .flat, .new { font-weight: 700; font-size: 11px; font-variant-numeric: tabular-nums; }
.up { color: var(--up); text-shadow: 0 0 9px rgba(57, 255, 20, 0.8); }
.down { color: var(--down); text-shadow: 0 0 9px rgba(255, 45, 149, 0.8); }
.flat { color: var(--dim); }
.new { color: var(--new); text-shadow: 0 0 10px rgba(255, 210, 63, 0.9); animation: newPulse 1.6s ease-in-out infinite; }
@keyframes newPulse { 50% { opacity: 0.55; } }

/* ---------- 狀態列 ---------- */
.status {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 22px 28px; color: var(--dim);
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
}
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 10px var(--lime); animation: newPulse 1.8s infinite; }

/* ---------- 彈窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(3, 5, 12, 0.78); backdrop-filter: blur(6px); animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal-box {
  position: relative; width: min(560px, 92vw); padding: 22px;
  background: linear-gradient(160deg, rgba(14, 20, 40, 0.96), rgba(8, 12, 24, 0.96));
  border: 1px solid var(--line-strong); border-radius: 16px;
  box-shadow: 0 0 0 1px rgba(176, 38, 255, 0.25), 0 30px 80px -30px rgba(0, 229, 255, 0.6);
  animation: popIn .26s cubic-bezier(.2,.8,.2,1);
}
@keyframes popIn { from { opacity: 0; transform: translateY(16px) scale(.97); } }
.close { position: absolute; top: 12px; right: 14px; background: none; border: 0; color: var(--dim);
  font-size: 18px; cursor: pointer; transition: color .15s, text-shadow .15s; }
.close:hover { color: var(--magenta); text-shadow: 0 0 12px var(--magenta); }
.modal-box h2 { margin: 0 0 4px; font-family: "Chakra Petch", sans-serif; font-size: 19px; letter-spacing: .5px;
  color: #fff; text-shadow: 0 0 14px rgba(0, 229, 255, 0.5); }
.modal-box .dev { color: var(--cyan); margin-bottom: 14px; font-size: 12px; }
.modal-box a { color: var(--magenta); text-decoration: none; text-shadow: 0 0 10px rgba(255, 45, 149, 0.5); }
.modal-box a:hover { text-decoration: underline; }
.modal-box .chart-label { color: var(--dim); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; margin: 16px 0 6px; }

/* ---------- 搜尋面板 ---------- */
.search-panel {
  position: fixed; top: 60px; right: 20px; width: 340px; z-index: 30;
  max-height: 62vh; overflow: auto;
  background: linear-gradient(160deg, rgba(14, 20, 40, 0.97), rgba(8, 12, 24, 0.97));
  border: 1px solid var(--line-strong); border-radius: 12px;
  box-shadow: 0 24px 60px -28px rgba(0, 229, 255, 0.6);
}
.search-panel .item { padding: 9px 14px; cursor: pointer; border-bottom: 1px solid rgba(255, 255, 255, 0.04); transition: background .12s; }
.search-panel .item:last-child { border-bottom: 0; }
.search-panel .item:hover { background: rgba(0, 229, 255, 0.12); box-shadow: inset 2px 0 0 var(--cyan); }

/* ---------- SVG 趨勢 ---------- */
svg polyline { fill: none; stroke: var(--cyan); stroke-width: 2.5; filter: drop-shadow(0 0 6px rgba(0, 229, 255, 0.9)); }
svg circle { fill: var(--magenta); filter: drop-shadow(0 0 5px var(--magenta)); }

.hidden { display: none; }

/* ---------- scrollbar / 選取 ---------- */
::selection { background: var(--magenta); color: #fff; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 229, 255, 0.3); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--cyan); }

/* ---------- 手機 RWD（≤640px）---------- */
@media (max-width: 640px) {
  .bar { padding: 10px 12px; gap: 8px; }
  .logo { font-size: 15px; letter-spacing: 1.5px; }
  .controls { margin-left: 0; width: 100%; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .ctl { flex: 0 0 auto; }
  .ctl > span { display: none; }              /* 省直幅；下拉值本身已自明 */
  .search-wrap { flex: 1 0 130px; }
  .bar input { min-width: 110px; }
  .grid { padding: 12px; gap: 12px; }
  .grid-cats { grid-template-columns: 1fr; }
  .chart.overall .card-body { column-count: 1; }
  .row { gap: 10px; padding: 7px 12px; }        /* 觸控好點 */
  .row .dl, .row .genre, .row .price, .row .cc, .row .rc { display: none; }  /* 手機只留 名次 / 名稱 / 評分 */
  .row .rt { font-size: 11px; }
  .search-panel { width: calc(100vw - 24px); right: 12px; top: 56px; }
  .modal-box { width: 94vw; padding: 16px; }
  .chips { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
