/* Lodestar — dark, map-first design. All colours and motion timings live here. */

:root {
  color-scheme: dark;
  --bg: #0b1118;
  --bg-2: #0f1822;
  --ocean-1: #0e1b28;
  --ocean-2: #08111a;
  --panel: rgba(18, 28, 40, 0.72);
  --panel-solid: #141f2c;
  --card: rgba(255, 255, 255, 0.035);
  --card-hover: rgba(255, 255, 255, 0.065);
  --line: rgba(160, 190, 220, 0.14);
  --line-strong: rgba(160, 190, 220, 0.28);
  --text: #e3ecf5;
  --text-2: #a9bacb;
  --muted: #74889c;
  --accent: #6ec3ff;
  --accent-2: #9b8cff;
  --gold: #ffd77a;
  --good: #3fae6b;
  --bad: #e06c66;

  --fam-good: #3fae6b;
  --fam-mid: #e0b341;
  --fam-bad: #d9534f;
  --fam-none: #33506b;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255, 255, 255, 0.04) inset;

  --dur-fast: 150ms;
  --dur: 250ms;
  --dur-slow: 600ms;
  --ease: cubic-bezier(.2, .8, .2, 1);

  --font: "Noto Sans TC", system-ui, "Microsoft JhengHei", sans-serif;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 20;
  display: flex; align-items: center; gap: 18px; padding: 0 20px;
  background: linear-gradient(180deg, rgba(11, 17, 24, 0.92), rgba(11, 17, 24, 0.6));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; white-space: nowrap; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 28px; height: 28px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #8fe3b0, #2a7d55 60%, #123b2a);
  box-shadow: 0 0 18px rgba(63, 174, 107, 0.45);
}
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; color: var(--text-2); }
.crumbs a, .crumbs span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a { color: var(--text-2); }
.crumbs a:hover { color: var(--text); text-decoration: none; }
.crumbs .sep { color: var(--muted); }
.crumbs .current { color: var(--text); font-weight: 500; }
.crumbs .crumb-enter { animation: crumb-in var(--dur) var(--ease) both; }
.topnav { margin-left: auto; display: flex; gap: 6px; }
.topnav a {
  padding: 7px 14px; border-radius: 999px; color: var(--text-2);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.topnav a:hover, .topnav a.active { background: var(--card-hover); color: var(--text); text-decoration: none; }

/* ---------- main layout ---------- */
.layout { position: fixed; inset: var(--topbar-h) 0 0 0; display: grid; grid-template-columns: minmax(0, 1fr) 420px; }
.map-wrap { position: relative; min-width: 0; }
#map {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 45%, var(--ocean-1) 0%, var(--ocean-2) 75%);
}
.sidebar {
  position: relative; overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-left: 1px solid var(--line);
  padding: 22px 22px 40px;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }

.page.review { position: fixed; inset: var(--topbar-h) 0 0 0; overflow-y: auto; padding: 28px 20px 60px; }
.review-inner { max-width: 1080px; margin: 0 auto; }

@media (max-width: 767px) {
  body { overflow: auto; }
  .topbar { gap: 10px; padding: 0 12px; }
  .brand .name { display: none; }
  .topnav a { padding: 6px 10px; }
  .layout { position: static; display: block; padding-top: var(--topbar-h); }
  .map-wrap { height: 52vh; }
  .sidebar { border-left: 0; border-top: 1px solid var(--line); padding: 18px 16px 40px; overflow: visible; }
  .page.review { position: static; padding: calc(var(--topbar-h) + 16px) 16px 60px; overflow: visible; }
}

/* ---------- typography & blocks ---------- */
h1 { font-size: 24px; line-height: 1.3; margin: 0 0 4px; font-weight: 700; letter-spacing: .01em; }
h2 { font-size: 15px; margin: 26px 0 10px; color: var(--text-2); font-weight: 500; letter-spacing: .04em; }
.sub { color: var(--muted); font-size: 13px; }
.section { margin-top: 22px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 12px 10px;
}
.stat .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .label { font-size: 12px; color: var(--muted); }

.ring { --p: 0; --c: var(--fam-none); width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), rgba(255, 255, 255, 0.07) 0);
  transition: --p var(--dur-slow) var(--ease);
}
.ring::after { content: attr(data-label); width: 44px; height: 44px; border-radius: 50%; background: var(--panel-solid);
  display: grid; place-items: center; font-size: 12px; color: var(--text-2); }
@property --p { syntax: "<number>"; inherits: false; initial-value: 0; }

.fam-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 6px;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04); }
.legend { position: absolute; left: 16px; bottom: 16px; z-index: 5; display: flex; gap: 14px; flex-wrap: wrap;
  padding: 8px 14px; border-radius: 999px; font-size: 12px; color: var(--text-2);
  background: var(--panel); backdrop-filter: blur(10px); border: 1px solid var(--line); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px;
  background: var(--card-hover); color: var(--text-2); border: 1px solid var(--line); }
.pill.lesser { color: var(--gold); border-color: rgba(255, 215, 122, 0.35); background: rgba(255, 215, 122, 0.08); }
.pill.nationwide { color: var(--accent); border-color: rgba(110, 195, 255, 0.3); }
.pill.important { color: #ffb4a8; border-color: rgba(255, 120, 100, 0.35); }

.list { display: grid; gap: 8px; }
.row-link {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm); background: var(--card); border: 1px solid var(--line);
  color: var(--text); cursor: pointer;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), border-color var(--dur-fast);
}
.row-link:hover { background: var(--card-hover); border-color: var(--line-strong); transform: translateX(2px); text-decoration: none; }
.row-link .count { color: var(--muted); font-size: 13px; }

.empty { margin-top: 30px; padding: 22px; border-radius: var(--radius); border: 1px dashed var(--line-strong); color: var(--text-2);
  background: var(--card); }
.empty strong { color: var(--text); display: block; margin-bottom: 6px; }

button.btn {
  border: 1px solid var(--line-strong); background: var(--card-hover); border-radius: 999px; padding: 6px 14px; cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast);
}
button.btn:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--accent); }
button.btn:disabled { opacity: .5; cursor: default; }

/* ---------- feature cards ---------- */
.feature {
  position: relative; padding: 14px 14px 12px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.feature:hover { background: var(--card-hover); border-color: var(--line-strong); transform: translateY(-1px); }
.feature.is-lesser { border-color: rgba(255, 215, 122, 0.28); }
.feature.is-lesser .pill.lesser { animation: glow 1.6s var(--ease) 1 both; }
.feature .head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.feature .tag { font-weight: 700; }
.feature .desc { margin: 6px 0 0; color: var(--text-2); }
.feature .meta { margin-top: 8px; display: flex; gap: 12px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.conf { display: inline-flex; gap: 3px; align-items: center; }
.conf i { width: 6px; height: 10px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); }
.conf.c3 i, .conf.c2 i:nth-child(-n+2), .conf.c1 i:first-child { background: var(--accent); }
.thumbs { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; padding-bottom: 2px; }
.thumb {
  flex: 0 0 auto; width: 78px; height: 52px; border-radius: 7px; object-fit: cover; cursor: zoom-in; border: 1px solid var(--line);
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast);
}
.thumb:hover { transform: scale(1.04); border-color: var(--accent); }
.thumb.important { outline: 2px solid rgba(255, 120, 100, 0.6); outline-offset: 1px; }

/* ---------- summary ---------- */
.summary {
  margin-top: 18px; padding: 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(110, 195, 255, 0.10), rgba(155, 140, 255, 0.08));
  border: 1px solid rgba(110, 195, 255, 0.22);
}
.summary .title { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; }
.summary .text { margin-top: 8px; white-space: pre-line; color: var(--text); }
.summary .foot { margin-top: 8px; font-size: 12px; color: var(--muted); }
.summary.is-error { background: rgba(224, 108, 102, 0.08); border-color: rgba(224, 108, 102, 0.3); }

/* ---------- map tooltip & markers ---------- */
.map-tip {
  position: absolute; z-index: 10; pointer-events: none; padding: 6px 10px; border-radius: 8px; font-size: 13px; white-space: nowrap;
  background: rgba(10, 16, 24, 0.92); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  transform: translate(-50%, calc(-100% - 12px)); opacity: 0; transition: opacity var(--dur-fast) var(--ease);
}
.map-tip.show { opacity: 1; }
.map-tip .muted { color: var(--muted); margin-left: 6px; }
.pin {
  width: 16px; height: 16px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  animation: pin-drop 520ms var(--ease) both;
}
.pin.actual { background: var(--good); }
.pin.guess { background: var(--bad); animation-delay: 220ms; }
.marker-host { width: 0; height: 0; display: grid; place-items: center; }
.round-dot {
  width: 12px; height: 12px; border-radius: 50%; background: #fff; cursor: pointer;
  box-shadow: 0 0 0 3px rgba(217, 83, 79, 0.85), 0 0 14px rgba(255, 255, 255, 0.5);
  animation: pop-in 380ms var(--ease) both; transition: transform var(--dur-fast) var(--ease);
}
.round-dot:hover { transform: scale(1.35); }

/* ---------- review page ---------- */
.review-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.game-select { background: var(--panel-solid); color: var(--text); border: 1px solid var(--line-strong); border-radius: 999px; padding: 7px 14px; }
.round-card {
  margin-top: 22px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(10px); overflow: hidden;
}
.round-top { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.round-no { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  background: var(--card-hover); border: 1px solid var(--line-strong); }
.verdict { font-weight: 700; }
.verdict.ok { color: var(--good); }
.verdict.miss { color: var(--bad); }
.round-score { margin-left: auto; text-align: right; }
.round-score .value { font-size: 20px; font-weight: 700; }
.round-body { display: grid; grid-template-columns: 340px minmax(0, 1fr); }
.mini-map { position: relative; min-height: 260px; border-right: 1px solid var(--line);
  background: radial-gradient(ellipse at 50% 45%, var(--ocean-1) 0%, var(--ocean-2) 75%); }
.round-main { padding: 16px 18px 18px; min-width: 0; }
.answer-line { display: flex; gap: 18px; flex-wrap: wrap; color: var(--text-2); font-size: 14px; }
.answer-line b { color: var(--text); font-weight: 500; }
.explain { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--card); border-left: 3px solid var(--accent); }
.explain.miss { border-left-color: var(--bad); }
.explain .title { font-weight: 700; margin-bottom: 4px; }
.status-line { margin-top: 14px; color: var(--text-2); display: flex; align-items: center; gap: 10px; }
.spinner-dots::after { content: "…"; animation: dots 1.2s steps(4) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@media (max-width: 767px) {
  .round-body { grid-template-columns: 1fr; }
  .mini-map { min-height: 220px; border-right: 0; border-bottom: 1px solid var(--line); }
}

/* ---------- lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(4, 8, 12, 0.78);
  backdrop-filter: blur(8px); animation: fade-in var(--dur) var(--ease) both; }
.lightbox.closing { animation: fade-out var(--dur) var(--ease) both; }
.lightbox img { max-width: min(92vw, 1600px); max-height: 82vh; border-radius: 12px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  transform-origin: center; }
.lightbox .caption { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); color: var(--text-2); font-size: 14px; }
.lightbox .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: rgba(20, 30, 42, 0.7); cursor: pointer; font-size: 22px; }
.lightbox .nav.prev { left: 24px; } .lightbox .nav.next { right: 24px; }
.lightbox .close { position: absolute; top: 18px; right: 22px; width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: rgba(20, 30, 42, 0.7); cursor: pointer; font-size: 20px; }
.lightbox img.slide-next { animation: slide-from-right var(--dur) var(--ease) both; }
.lightbox img.slide-prev { animation: slide-from-left var(--dur) var(--ease) both; }

/* ---------- skeleton ---------- */
.skeleton { border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.05); position: relative; overflow: hidden; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.07), transparent); animation: shimmer 1.3s infinite; }
.sk-title { height: 28px; width: 60%; } .sk-line { height: 14px; margin-top: 10px; } .sk-card { height: 92px; margin-top: 12px; }

/* ---------- motion ---------- */
.stagger-in { animation: rise-in 420ms var(--ease) both; }
.fade-out { opacity: 0; transform: translateX(-8px); transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
.fade-in { opacity: 0; transform: translateX(16px); }
.swap-target { transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }

@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes crumb-in { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes glow { 0% { box-shadow: 0 0 0 0 rgba(255, 215, 122, 0); } 40% { box-shadow: 0 0 16px 2px rgba(255, 215, 122, 0.45); } 100% { box-shadow: 0 0 0 0 rgba(255, 215, 122, 0); } }
@keyframes pin-drop { 0% { opacity: 0; transform: translateY(-28px) scale(.6); } 60% { opacity: 1; transform: translateY(3px) scale(1.05); } 100% { transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.2); } to { opacity: 1; transform: none; } }
@keyframes slide-from-right { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes slide-from-left { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: none; } }
@keyframes dots { from { width: 0; } to { width: 1.2em; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}
