:root {
    color-scheme: dark;
    --bg: #12141a;
    --panel: #1b1e26;
    --panel-2: #232733;
    --line: #2e3342;
    --text: #e6e9ef;
    --muted: #8b93a7;
    --accent: #4ade80;
    --bad: #f87171;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Noto Sans TC", "Segoe UI", sans-serif;
    font-size: 15px;
}

.page { max-width: 1100px; margin: 0 auto; padding: 0 16px 48px; }

/* ── top bar ─────────────────────────────────────────── */
.topbar {
    display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
    padding: 16px 0; border-bottom: 1px solid var(--line); margin-bottom: 24px;
}
.brand { font-size: 1.15rem; font-weight: 700; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a {
    color: var(--muted); text-decoration: none; padding: 6px 12px;
    border-radius: 8px; font-weight: 500;
}
.topbar nav a:hover { background: var(--panel-2); color: var(--text); }
.topbar nav a.active { background: var(--accent); color: #0b0d12; }

footer { margin-top: 40px; color: var(--muted); font-size: .85rem; text-align: center; }

/* ── tiles ───────────────────────────────────────────── */
.tiles {
    display: grid; gap: 12px; margin-bottom: 24px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.tile-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.tile-value { font-size: 2rem; font-weight: 700; line-height: 1.2; margin: 4px 0; }
.tile-value .unit { font-size: 1rem; font-weight: 500; color: var(--muted); }
.tile-sub { color: var(--muted); font-size: .85rem; }
.tile.ok .tile-value { color: var(--accent); }
.tile.bad .tile-value { color: var(--bad); }

/* ── panels & tables ─────────────────────────────────── */
.panel {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 12px; padding: 20px; margin-bottom: 20px;
}
.panel h2 { margin: 0 0 14px; font-size: 1.05rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.muted { color: var(--muted); }
.stamp { color: var(--muted); font-size: .8rem; margin: 14px 0 0; }

.banner {
    border-radius: 10px; padding: 12px 16px; margin-bottom: 20px;
    border: 1px solid var(--line); background: var(--panel);
}
.banner.error { border-color: var(--bad); color: var(--bad); }

/* ── blazor error ui ─────────────────────────────────── */
#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    background: #b91c1c; color: #fff; padding: 12px 20px;
}
#blazor-error-ui .reload, #blazor-error-ui .dismiss { color: #fff; cursor: pointer; margin-left: 12px; }

/* ── live map ────────────────────────────────────────── */
.map-canvas {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-height: 70vh;
    margin: 0 auto 18px;
    background: #0e1926;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}
.map-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.map-grid { position: absolute; inset: 0; }
.grid-line { position: absolute; background: rgba(255,255,255,.07); }
.grid-line.vert { top: 0; bottom: 0; width: 1px; }
.grid-line.horz { left: 0; right: 0; height: 1px; }
.grid-line.axis { background: rgba(74,222,128,.35); }
.grid-label {
    position: absolute; color: var(--muted); font-size: 10px;
    font-variant-numeric: tabular-nums; pointer-events: none;
}
.grid-label.lbl-x { bottom: 2px; transform: translateX(2px); }
.grid-label.lbl-y { left: 3px; transform: translateY(-100%); }

.pin { position: absolute; transform: translate(-50%, -50%); z-index: 5; }
.pin .dot {
    display: block; width: 13px; height: 13px; border-radius: 50%;
    background: var(--accent); border: 2px solid #0b0d12;
    box-shadow: 0 0 0 4px rgba(74,222,128,.25);
}
.pin-label {
    position: absolute; left: 50%; top: 16px; transform: translateX(-50%);
    white-space: nowrap; font-size: 12px; font-weight: 600; color: var(--text);
    background: rgba(11,13,18,.8); padding: 1px 6px; border-radius: 6px;
}

/* ── filters & pal table ─────────────────────────────── */
.filters {
    display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end;
    padding: 14px; margin-bottom: 16px;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
}
.filters label {
    display: flex; flex-direction: column; gap: 5px;
    font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em;
}
.filters label.check {
    flex-direction: row; align-items: center; gap: 7px;
    text-transform: none; font-size: .9rem; color: var(--text); padding-bottom: 7px;
}
.filters select, .filters input[type="search"], .filters input[type="number"] {
    background: var(--bg); color: var(--text);
    border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px;
    font-size: .95rem; font-family: inherit; min-width: 150px;
}
.filters .w-short { min-width: 90px; }
.filters input:focus, .filters select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.tag {
    display: inline-block; margin: 1px 3px 1px 0; padding: 1px 7px;
    background: var(--panel-2); border: 1px solid var(--line);
    border-radius: 999px; font-size: .75rem; white-space: nowrap;
}
.rank {
    display: inline-block; margin-left: 5px; padding: 0 6px;
    background: #7c3aed; color: #fff; border-radius: 999px; font-size: .7rem; font-weight: 700;
}
.iv-hi  { color: var(--accent); font-weight: 700; }
.iv-mid { color: #fbbf24; }

.more {
    margin-top: 12px; padding: 9px 16px; cursor: pointer;
    background: var(--panel-2); color: var(--text);
    border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
.more:hover { border-color: var(--accent); color: var(--accent); }

/* ── clickable rows / back link ──────────────────────── */
table.rows-link tbody tr { cursor: pointer; }
.chev { color: var(--muted); margin-left: 4px; }
.back { color: var(--muted); text-decoration: none; }
.back:hover { color: var(--accent); }

/* ── pal cards (player detail) ───────────────────────── */
.pal-grid {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.pal-card {
    background: var(--panel-2); border: 1px solid var(--line);
    border-radius: 10px; padding: 13px 14px;
}
.pal-card header {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 8px; margin-bottom: 10px;
}
.pal-name { font-weight: 700; }
.pal-lv { color: var(--muted); font-size: .85rem; white-space: nowrap; }

.section-title {
    color: var(--muted); font-size: .7rem; text-transform: uppercase;
    letter-spacing: .05em; margin: 11px 0 5px;
}
.small { font-size: .85rem; margin: 0; }

.iv-rows { display: flex; flex-direction: column; gap: 4px; }
.iv-row { display: flex; align-items: center; gap: 8px; font-size: .82rem; }
.iv-lbl { color: var(--muted); width: 30px; flex: none; }
.iv-bar { flex: 1; height: 7px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.iv-bar > span { display: block; height: 100%; border-radius: 999px; }
.iv-bar > span.hi  { background: var(--accent); }
.iv-bar > span.mid { background: #fbbf24; }
.iv-bar > span.lo  { background: #64748b; }
.iv-val { width: 26px; text-align: right; font-variant-numeric: tabular-nums; flex: none; }
.iv-total {
    margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--line);
    font-size: .85rem; display: flex; justify-content: space-between; gap: 8px;
}
.tag.skill { border-color: #3b82f6; color: #93c5fd; }
.caught { color: var(--muted); font-size: .78rem; margin: -4px 0 2px; }
.nowrap { white-space: nowrap; }

/* ── radar ───────────────────────────────────────────── */
.blip {
    position: absolute; width: 9px; height: 9px; border-radius: 50%;
    transform: translate(-50%, -50%);
    background: #38bdf8; border: 1px solid rgba(0,0,0,.55);
    box-shadow: 0 0 5px rgba(56,189,248,.8);
    cursor: help;
}
.blip.hi    { background: var(--accent); box-shadow: 0 0 6px rgba(74,222,128,.9); }
.blip.alpha { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,.9); width: 11px; height: 11px; }
.blip.rare  { background: #e879f9; box-shadow: 0 0 8px rgba(232,121,249,1); width: 12px; height: 12px; }
.blip.inline {
    position: static; display: inline-block; transform: none;
    margin: 0 3px 0 10px; vertical-align: middle;
}
.legend { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.filters input[type="range"] { min-width: 150px; accent-color: var(--accent); }
.hint { color: var(--accent); font-variant-numeric: tabular-nums; }

/* ── wild spawn points ───────────────────────────────── */
.spawn {
    position: absolute; width: 5px; height: 5px; border-radius: 50%;
    transform: translate(-50%, -50%);
    background: rgba(56,189,248,.85);
    box-shadow: 0 0 4px rgba(56,189,248,.9);
    pointer-events: none;
}
.spawn.inline {
    position: static; display: inline-block; transform: none;
    margin: 0 3px 0 10px; vertical-align: middle;
}
h3.sub { font-size: .95rem; margin: 22px 0 10px; }

/* ── passive tiers (matches the game's grading) ──────── */
/*  5 神樹 · 4 白金 · 3 金 · 1–2 白 · 負值 缺陷            */
.tag.t5 {
    color: #a78bfa; border-color: #7c3aed;
    background: linear-gradient(180deg, rgba(124,58,237,.22), rgba(124,58,237,.08));
    box-shadow: 0 0 6px rgba(167,139,250,.35);
    font-weight: 700;
}
.tag.t4 {
    color: #7dd3fc; border-color: #38bdf8;
    background: linear-gradient(180deg, rgba(56,189,248,.22), rgba(56,189,248,.06));
    box-shadow: 0 0 6px rgba(125,211,252,.40);
    font-weight: 700;
}
.tag.t3 {
    color: #fbbf24; border-color: #b8860b;
    background: linear-gradient(180deg, rgba(251,191,36,.18), rgba(251,191,36,.05));
    font-weight: 600;
}
.tag.t1 { color: #d7dce6; border-color: #59617a; }
.tag.tneg {
    color: #f87171; border-color: #b91c1c;
    background: rgba(185,28,28,.16);
}

/* tier legend chips */
.tier-legend { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 12px; }
.tier-legend .lbl { color: var(--muted); font-size: .78rem; margin-right: 2px; }

/* ── 手動重讀存檔（玩家帕魯頁）─────────────────────────── */
.head-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
}
.head-row h2 { margin: 0; }
.refresh {
    padding: 8px 14px; cursor: pointer; font: inherit;
    background: var(--panel-2); color: var(--text);
    border: 1px solid var(--line); border-radius: 8px;
    display: inline-flex; align-items: center; gap: 6px;
}
.refresh:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.refresh:disabled { opacity: .6; cursor: progress; }
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
