  :root {
    --bg: #05070d;
    --glass: rgba(14, 18, 28, 0.62);
    --glass-strong: rgba(14, 18, 28, 0.82);
    --line: rgba(255, 255, 255, 0.09);
    --text: #eef1f7;
    --muted: #8b93a7;
    --accent: #ff6b3d;
    --radius: 18px;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
    font-family: 'Inter', system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
  button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
  a { color: inherit; }

  #globe { position: fixed; inset: 0; }
  #globe canvas { outline: none; }

  .glass { background: var(--glass); backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%); border: 1px solid var(--line); }

  /* ---------- Top bar ---------- */
  .top { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between;
    align-items: flex-start; padding: 22px 26px; pointer-events: none; z-index: 5; }
  .brand { pointer-events: auto; }
  .brand h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px; }
  .brand h1 .mark { width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
    box-shadow: 0 0 0 0 rgba(255,107,61,.6); animation: beat 2s infinite; }
  @keyframes beat { 0% { box-shadow: 0 0 0 0 rgba(255,107,61,.55); } 70% { box-shadow: 0 0 0 12px rgba(255,107,61,0); } 100% { box-shadow: 0 0 0 0 rgba(255,107,61,0); } }
  .brand p { margin-top: 6px; font-size: 13px; color: var(--muted); }
  .brand p b { color: var(--text); font-weight: 600; }
  .space-btn { margin-top: 12px; padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 500;
    transition: background .2s, transform .15s; }
  .space-btn:hover { background: var(--glass-strong); transform: translateY(-1px); }

  .stats { pointer-events: auto; display: flex; gap: 10px; }
  .stat { padding: 12px 16px; border-radius: 14px; min-width: 110px; }
  .stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
  .stat .v { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
  .stat .s { font-size: 12px; color: var(--muted); margin-top: 1px; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* ---------- Bottom dock ---------- */
  .dock { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 5;
    display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(760px, calc(100vw - 32px)); }

  .biggest { display: flex; gap: 8px; overflow-x: auto; max-width: 100%; padding: 2px; scrollbar-width: none; }
  .biggest::-webkit-scrollbar { display: none; }
  .big-chip { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 8px;
    border-radius: 999px; font-size: 13px; white-space: nowrap; transition: transform .15s, background .15s; }
  .big-chip:hover { transform: translateY(-2px); background: var(--glass-strong); }
  .big-chip .m { font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 500; padding: 3px 7px;
    border-radius: 999px; color: #0b0d12; }
  .big-chip .p { max-width: 210px; overflow: hidden; text-overflow: ellipsis; }
  .big-chip .t { color: var(--muted); }

  .controls { display: flex; align-items: center; gap: 18px; padding: 10px 12px 10px 10px; border-radius: 999px; }
  .seg { display: flex; gap: 2px; background: rgba(255,255,255,.04); border-radius: 999px; padding: 3px; }
  .seg button { padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--muted); transition: all .2s; }
  .seg button:hover { color: var(--text); }
  .seg button.on { background: var(--text); color: #0b0d12; }

  .mag { display: flex; align-items: center; gap: 12px; padding-right: 8px; }
  .mag label { font-size: 13px; color: var(--muted); white-space: nowrap; }
  .mag label b { color: var(--text); font-family: 'JetBrains Mono', monospace; font-weight: 500; }
  input[type=range] { -webkit-appearance: none; appearance: none; width: 150px; height: 4px; border-radius: 4px;
    background: linear-gradient(90deg, #ffd166, #ff9f43, #ff6b3d, #ff3b5c, #e83cff); outline: none; }
  input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
    background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.5); cursor: pointer; }
  input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: #fff; cursor: pointer; }
  .note { font-size: 12px; color: var(--muted); text-align: center; min-height: 0; }

  /* ---------- Detail card ---------- */
  .card { position: fixed; top: 96px; right: 26px; width: 340px; border-radius: var(--radius); padding: 22px; z-index: 6;
    transform: translateX(calc(100% + 40px)); opacity: 0; transition: transform .45s cubic-bezier(.2,.8,.2,1), opacity .3s; }
  .card.open { transform: none; opacity: 1; }
  .card .close { position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 50%;
    display: grid; place-items: center; color: var(--muted); background: rgba(255,255,255,.05); }
  .card .close:hover { color: var(--text); background: rgba(255,255,255,.1); }
  .mag-big { display: flex; align-items: baseline; gap: 12px; }
  .mag-big .num { font-size: 56px; font-weight: 700; letter-spacing: -0.04em; line-height: 1; }
  .mag-big .word { font-size: 15px; font-weight: 600; }
  .card .place { font-size: 17px; font-weight: 600; margin-top: 10px; line-height: 1.35; padding-right: 20px; }
  .card .when { font-size: 13px; color: var(--muted); margin-top: 4px; }
  .card .plain { margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.04);
    font-size: 14px; line-height: 1.5; color: #d6dbe6; }
  .facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; margin-top: 16px; }
  .fact .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
  .fact .v { font-size: 14px; font-weight: 500; margin-top: 3px; }
  .badge { display: inline-block; margin-top: 14px; padding: 6px 10px; border-radius: 8px; font-size: 13px; font-weight: 600;
    background: rgba(255,59,92,.15); color: #ff8aa0; }
  .card .more { display: inline-flex; align-items: center; gap: 6px; margin-top: 18px; font-size: 13px; font-weight: 500;
    color: var(--muted); text-decoration: none; }
  .card .more:hover { color: var(--text); }

  /* ---------- Tooltip ---------- */
  .tip { font-family: 'Inter', sans-serif; background: var(--glass-strong); border: 1px solid var(--line);
    padding: 8px 11px; border-radius: 10px; font-size: 12.5px; line-height: 1.4; backdrop-filter: blur(10px); }
  .tip b { font-size: 13.5px; }
  .tip span { color: var(--muted); }

  /* ---------- Loading / error ---------- */
  .loading { position: fixed; inset: 0; display: grid; place-items: center; z-index: 4; pointer-events: none;
    transition: opacity .6s; color: var(--muted); font-size: 14px; letter-spacing: .02em; }
  .loading.hide { opacity: 0; }
  .foot { font-size: 11.5px; color: #5d6578; text-align: center; }
  .foot a { color: #7b8397; }

  /* ---------- Mobile ---------- */
  @media (max-width: 760px) {
    .top { padding: 16px; }
    .brand h1 { font-size: 19px; }
    .stats .stat:last-child { display: none; }
    .stat { min-width: 0; padding: 9px 12px; }
    .stat .v { font-size: 18px; }
    .dock { bottom: 14px; gap: 10px; }
    .controls { flex-direction: column; gap: 10px; border-radius: 22px; padding: 10px; width: 100%; }
    .seg { width: 100%; justify-content: space-between; }
    .seg button { flex: 1; padding: 8px 6px; }
    .mag { width: 100%; justify-content: space-between; padding: 0 6px 2px; }
    input[type=range] { flex: 1; width: auto; }
    .card { top: auto; bottom: 0; right: 0; left: 0; width: auto; border-radius: 22px 22px 0 0;
      transform: translateY(105%); max-height: 70vh; overflow-y: auto; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
    .card.open { transform: none; }
    .foot { font-size: 10.5px; }
  }

  /* ---------- Tools (Near me / Plates / Replay) ---------- */
  .tools { position: fixed; left: 26px; top: 50%; transform: translateY(-50%); z-index: 5; display: flex; flex-direction: column; gap: 8px; }
  .tool { display: flex; align-items: center; gap: 9px; padding: 10px 15px 10px 12px; border-radius: 999px; font-size: 13px; font-weight: 500;
    color: #c9cfdc; transition: background .2s, color .2s, transform .15s; }
  .tool:hover { background: var(--glass-strong); color: var(--text); transform: translateX(2px); }
  .tool.on { background: var(--text); color: #0b0d12; }
  .tool.busy svg { animation: pulse 1s infinite ease-in-out; }
  @keyframes pulse { 50% { opacity: .3; } }

  /* ---------- Near you panel ---------- */
  .near-head { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
  .near-head .you { width: 12px; height: 12px; border-radius: 50%; background: #3d9bff; box-shadow: 0 0 0 4px rgba(61,155,255,.25); }
  .near-list { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; max-height: 46vh; overflow-y: auto; margin-right: -8px; padding-right: 8px; }
  .near-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; text-align: left; transition: background .15s; }
  .near-row:hover { background: rgba(255,255,255,.06); }
  .near-row .m { flex: none; font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 500; padding: 3px 7px; border-radius: 999px; color: #0b0d12; }
  .near-row .p { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .near-row .p b { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .near-row .p small { font-size: 12px; color: var(--muted); margin-top: 1px; }
  .near-row .felt { flex: none; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: rgba(61,155,255,.16); color: #8cc4ff; }
  .fine { margin-top: 14px; font-size: 12px; line-height: 1.5; color: var(--muted); }
  .fine a { color: #aeb5c6; }
  .card .back { font-size: 13px; color: var(--muted); margin-bottom: 12px; padding: 4px 0; }
  .card .back:hover { color: var(--text); }

  /* ---------- Card actions ---------- */
  .card-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
  .card-actions .more { margin-top: 0; }
  .share-btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
    background: var(--text); color: #0b0d12; transition: transform .15s, opacity .15s; }
  .share-btn:hover { transform: translateY(-1px); opacity: .92; }

  /* ---------- Replay bar ---------- */
  .replay { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px 10px 10px; border-radius: 999px; }
  .replay[hidden], .biggest[hidden] { display: none; }
  .rp-play { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: #0b0d12; }
  .rp-play svg { margin-left: 1px; }
  .rp-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
  .rp-meta { display: flex; justify-content: space-between; font-size: 12.5px; }
  .rp-time { font-weight: 600; font-variant-numeric: tabular-nums; }
  .rp-count { color: var(--muted); font-variant-numeric: tabular-nums; }
  input.rp-scrub { width: 100%; height: 4px;
    background: linear-gradient(90deg, #eef1f7 0 var(--p, 0%), rgba(255,255,255,.16) var(--p, 0%) 100%); }
  input.rp-scrub::-webkit-slider-thumb { width: 14px; height: 14px; }
  input.rp-scrub::-moz-range-thumb { width: 14px; height: 14px; }
  .rp-close { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); background: rgba(255,255,255,.05); }
  .rp-close:hover { color: var(--text); background: rgba(255,255,255,.1); }

  @media (max-width: 760px) {
    .tools { left: 12px; top: auto; bottom: 190px; transform: none; }
    .tool { padding: 11px; }
    .tool span { display: none; }
    .near-list { max-height: 34vh; }
    .replay { border-radius: 22px; }
  }

  /* ---------- v3: clickable Strongest, even chips, depth diagram, card below the stats ---------- */
  .stat-btn { text-align: left; transition: background .2s, transform .15s, border-color .2s; }
  .stat-btn:hover:not(:disabled) { background: var(--glass-strong); border-color: rgba(255,255,255,.18); transform: translateY(-1px); }
  .stat-btn:disabled { cursor: default; }
  .stat-btn .go { opacity: 0; margin-left: 2px; transition: opacity .2s; }
  .stat-btn:hover:not(:disabled) .go { opacity: 1; }

  .biggest { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; overflow: visible; }
  .big-chip { min-width: 0; }
  .big-chip .p { flex: 1; min-width: 0; max-width: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .big-chip .t { flex: none; font-variant-numeric: tabular-nums; }

  .card { top: 124px; max-height: calc(100vh - 148px); overflow-y: auto; scrollbar-width: thin; }
  .card .depth { margin-top: 16px; }
  .card .depth .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
  .card .depth .k span { text-transform: none; letter-spacing: 0; }
  .depth-svg { display: block; width: 100%; height: auto; margin-top: 6px; border-radius: 10px; overflow: hidden; }
  .depth-svg text { font-family: Inter, system-ui, sans-serif; }
  .depth-svg .dd-l { font-size: 10.5px; fill: #8b93a7; }
  .depth-svg .dd-l.on { fill: #eef1f7; font-weight: 600; }
  .depth-svg .dd-r { font-size: 9.5px; fill: #5f6779; }
  .depth-svg .dd-v { font-size: 11.5px; font-weight: 600; fill: #eef1f7; }

  @media (max-width: 760px) {
    .biggest { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .biggest .big-chip:nth-child(3) { display: none; }
    .card { top: auto; max-height: 70vh; }
  }
