@font-face {
  font-family: "Geist";
  src: url("assets/geist-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --void: #120F0A;
  --velvet: #1A1610;
  --ivory: #ECE6D9;
  --bone: #F2E8D7;
  --dust: #A69C8A;
  --faint: #6E6555;
  --ember: #C57420;
  --ember-hi: #E08C35;
  --hair: rgba(242, 232, 215, 0.12);
  --glass: rgba(18, 15, 10, 0.72);
  --sans: "Geist", ui-sans-serif, system-ui, sans-serif;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --gap: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--void); color: var(--ivory); }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  font-feature-settings: "tnum" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 1.5px solid var(--ember-hi); outline-offset: 2px; }
a { color: var(--bone); text-decoration-color: var(--faint); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ember); }

#field { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* labels projected from the scene */
#labels { position: fixed; inset: 0; pointer-events: none; }
.lbl {
  position: absolute; left: 0; top: 0;
  font-size: 11.5px; letter-spacing: 0.02em; color: var(--dust);
  white-space: nowrap; transform: translate(-50%, 0); will-change: transform;
}
.lbl.sel { color: var(--ember-hi); font-weight: 500; }
.hover {
  position: fixed; left: 0; top: 0; pointer-events: none; z-index: 5;
  padding: 6px 9px; background: var(--glass); border: 1px solid var(--hair); border-radius: 6px;
  font-size: 12px; color: var(--bone); white-space: nowrap; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.hover small { display: block; color: var(--dust); font-size: 11px; }

.mark { position: fixed; top: max(var(--gap), env(safe-area-inset-top)); right: var(--gap); z-index: 4; }
.mark img { display: block; opacity: 0.92; }

/* rank ledger */
.ledger {
  position: fixed; z-index: 3; top: var(--gap); left: var(--gap); bottom: 92px; width: 300px;
  display: flex; flex-direction: column;
}
.ledger-toggle {
  display: none; align-self: flex-start; padding: 8px 12px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--hair); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.ledger-body {
  display: flex; flex-direction: column; min-height: 0; flex: 1;
  padding: 20px 18px 14px; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--hair);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.ledger h1 { margin: 0 0 6px; font-size: 19px; line-height: 1.2; font-weight: 500; letter-spacing: -0.015em; color: var(--bone); }
.lede { margin: 0 0 14px; color: var(--dust); font-size: 12.5px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--dust); font-size: 12.5px; margin-bottom: 10px; cursor: pointer; }
.check input { accent-color: var(--ember); margin: 0; }
.ranks { list-style: none; margin: 0 -6px; padding: 0; overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: var(--faint) transparent; }
.ranks li button {
  display: grid; grid-template-columns: 26px 1fr auto; align-items: baseline; gap: 6px; width: 100%;
  padding: 7px 6px; border: 0; background: none; text-align: left; border-radius: 6px;
}
.ranks li button:hover { background: rgba(242, 232, 215, 0.05); }
.ranks li button[aria-current="true"] { background: rgba(197, 116, 32, 0.14); }
.ranks .n { color: var(--faint); font-size: 11.5px; }
.ranks .nm { color: var(--bone); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranks .v { color: var(--dust); font-size: 12px; }
.ranks .sub { grid-column: 2 / 4; color: var(--faint); font-size: 11.5px; margin-top: -1px; }
.count { margin: 10px 0 0; color: var(--faint); font-size: 11.5px; }

/* detail sheet */
.sheet {
  position: fixed; z-index: 3; top: 64px; right: var(--gap); bottom: 92px; width: 360px; overflow-y: auto;
  padding: 22px 20px 20px; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--hair);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  scrollbar-width: thin; scrollbar-color: var(--faint) transparent;
  transform-origin: right center; animation: sheet-in 380ms var(--ease);
}
@keyframes sheet-in { from { opacity: 0; transform: translateX(12px); } }
.close {
  position: absolute; top: 14px; right: 14px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--hair); background: none; color: var(--dust); font-size: 12px;
}
.sheet h2 { margin: 0 64px 4px 0; font-size: 22px; line-height: 1.15; font-weight: 500; letter-spacing: -0.02em; color: var(--bone); }
.sheet .desig { margin: 0 0 14px; color: var(--dust); }
.sheet .rankline { margin: 0 0 18px; color: var(--ember-hi); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 20px; }
.facts dt { color: var(--faint); }
.facts dd { margin: 0; color: var(--ivory); }
.sheet h3 { margin: 22px 0 10px; font-size: 13px; font-weight: 500; color: var(--bone); }
.yield { display: grid; gap: 10px; }
.yield .row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.yield .k { color: var(--ivory); }
.yield .t { color: var(--bone); text-align: right; }
.yield .range { grid-column: 1 / 3; position: relative; height: 4px; border-radius: 2px; background: rgba(242, 232, 215, 0.08); }
.yield .range i { position: absolute; top: 0; bottom: 0; border-radius: 2px; background: rgba(197, 116, 32, 0.45); }
.yield .range b { position: absolute; top: -2px; width: 2px; height: 8px; background: var(--ember-hi); border-radius: 1px; }
.yield .rr { grid-column: 1 / 3; color: var(--faint); font-size: 11.5px; }
.note { color: var(--faint); font-size: 12px; margin: 10px 0 0; }
.refs { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.refs li { color: var(--dust); font-size: 12.5px; }
.refs li span { color: var(--ivory); }
.imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.imgs a { display: block; border-radius: 8px; overflow: hidden; border: 1px solid var(--hair); background: var(--velvet); aspect-ratio: 1; }
.imgs img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 500ms var(--ease); }
.imgs a:hover img { transform: scale(1.04); }
.src { margin-top: 18px; font-size: 12.5px; }

/* control bar */
.bar {
  position: fixed; z-index: 3; left: var(--gap); right: var(--gap); bottom: max(var(--gap), env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--hair);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.resources, .rates { display: flex; gap: 4px; flex-wrap: wrap; }
.seg {
  padding: 7px 12px; border-radius: 999px; border: 1px solid transparent; background: none; color: var(--dust); font-size: 13px;
  transition: color 200ms, background 200ms;
}
.seg:hover { color: var(--bone); }
.seg[aria-checked="true"] { color: var(--void); background: var(--bone); }
.time { display: flex; align-items: center; gap: 8px; }
#play, #today {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--hair); background: none; color: var(--bone); font-size: 13px;
}
#play[aria-pressed="true"] { border-color: var(--ember); color: var(--ember-hi); }
#date { min-width: 104px; text-align: center; color: var(--bone); font-size: 13px; }

.status {
  position: fixed; z-index: 2; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0;
  color: var(--dust); font-size: 13px; transition: opacity 600ms var(--ease);
}
.status.done { opacity: 0; pointer-events: none; }
.provenance {
  position: fixed; z-index: 2; right: var(--gap); bottom: 84px; margin: 0; max-width: 380px; text-align: right;
  color: var(--faint); font-size: 11px;
}
.provenance a { color: var(--dust); }
body.has-sel .provenance { display: none; }

@media (max-width: 900px) {
  .ledger { width: auto; right: var(--gap); bottom: auto; max-height: 58vh; }
  .ledger-toggle { display: inline-flex; }
  .ledger[data-open="false"] .ledger-body { display: none; }
  .ledger-body { margin-top: 8px; }
  .sheet { top: auto; left: var(--gap); right: var(--gap); width: auto; max-height: 52vh; }
  .provenance { display: none; }
  .bar { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 8px; padding: 8px; }
  .resources { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .resources .seg { flex: none; }
  .time { justify-content: space-between; gap: 4px; }
  .time, .time .seg { font-size: 12.5px; }
  .time .seg { padding: 7px 8px; }
  #play, #today { padding: 7px 10px; font-size: 12.5px; }
  .time { min-width: 0; }
  .time > * { flex: none; }
  #date { flex: 1 1 0; min-width: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sheet { bottom: 128px; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
  .imgs img { transition: none; }
}
