/* ==========================================================================
   ORION — PLAYER'S ALMANAC & LIVE DYNAMIC CARTOGRAPHY STYLESHEET
   Celestial Dark Palette: Deep Obsidian, Starlight Gold, Aurora Teal, Lapis Blue
   ========================================================================== */

:root {
  --bg: #0a0d1a;
  --bg-deep: #050710;
  --panel: #121a30;
  --panel-2: #182242;
  --panel-3: #0e1526;
  --rule: #2b3562;
  --rule-soft: #1c2544;
  --ink: #e9edf9;
  --ink-dim: #a9b2d4;
  --ink-faint: #6a7299;
  --gold: #e8c876;
  --gold-deep: #a9803f;
  --teal: #5cc2ac;
  --teal-deep: #39816f;
  --blue: #6f9be0;
  --blue-deep: #3f5d99;
  --rose: #c07bb0;
  --paper: #f1e9d2;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 18px 45px rgba(0, 0, 0, 0.65);

  --font-heading: 'Cinzel', Georgia, serif;
  --font-serif: 'Spectral', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; color-scheme: dark; }

body {
  background: radial-gradient(ellipse at top left, #131c38 0%, var(--bg) 45%, var(--bg-deep) 100%);
  color: var(--ink);
  font-family: var(--font-serif);
  display: flex;
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

::selection { background: var(--blue-deep); color: #f4f6ff; }
a { color: inherit; text-decoration: none; }

code, .cmd {
  font-family: var(--font-mono);
  font-weight: 600;
  background: #080a14;
  color: var(--gold);
  padding: 0.18rem 0.5rem;
  border-radius: 3px;
  border: 1px solid #29315a;
  font-size: 0.88rem;
  white-space: nowrap;
}

.mono { font-family: var(--font-mono); }

/* Animations */
@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity .7s ease, transform .7s ease;
  }
  .reveal.in-view { opacity: 1; transform: translateY(0); }
  .card { transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease; }
  .card:hover { transform: translateY(-5px); box-shadow: 0 16px 34px rgba(0,0,0,0.55); border-color: var(--blue-deep); }
  tbody tr { transition: background .2s ease; }
  nav.rail a { transition: background .2s ease, color .2s ease, border-color .2s ease, padding-left .2s ease; }
  nav.rail a:hover { padding-left: 1.45rem; }
  .rk { transition: transform .2s ease, border-color .2s ease; }
  .rk:hover { transform: translateY(-2px); border-color: var(--gold-deep); }
  #searchInput { transition: border-color .25s ease, box-shadow .25s ease; }
  .star { animation: twinkle var(--dur, 4s) ease-in-out var(--delay, 0s) infinite; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
}

@keyframes twinkle {
  0%, 100% { opacity: var(--min, 0.15); transform: scale(0.85); }
  50% { opacity: var(--max, 0.9); transform: scale(1.15); }
}

/* ==========================================================================
   SIDEBAR RAIL NAVIGATION
   ========================================================================== */
.railwrap {
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  width: 255px;
  background: linear-gradient(180deg, var(--panel-3), #060810);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.rail-brand {
  padding: 1.7rem 1.4rem 1.2rem;
  border-bottom: 1px solid var(--rule-soft);
}

.mark-link { display: block; }
.rail-brand .mark {
  display: flex; align-items: center; gap: 0.65rem;
  margin-bottom: 0.35rem;
}

.brand-emblem-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 10px rgba(232, 200, 118, 0.6);
  border: 1px solid var(--gold-deep);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  flex: 0 0 32px;
}

.mark-link:hover .brand-emblem-img {
  transform: scale(1.08) rotate(4deg);
  box-shadow: 0 0 16px rgba(232, 200, 118, 0.9);
}

.rail-brand h1 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.5rem;
  margin: 0;
  color: var(--gold);
  letter-spacing: 1px;
  line-height: 1.15;
}

.rail-brand p {
  margin: 0.3rem 0 0;
  font-size: 0.72rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-faint);
}

nav.rail { flex: 1; overflow-y: auto; padding: 0.9rem 0; }
nav.rail a {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  text-decoration: none;
  padding: 0.62rem 1.4rem 0.62rem 1.2rem;
  color: var(--ink-dim);
  font-size: 0.98rem;
  border-left: 3px solid transparent;
}

nav.rail a .num {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--blue);
  opacity: 0.8;
}

nav.rail a.map-rail-link {
  color: var(--teal);
  background: rgba(92, 194, 172, 0.06);
  border-left: 3px solid var(--teal-deep);
  font-weight: 600;
}

nav.rail a:hover {
  background: rgba(111, 155, 224, 0.08);
  color: var(--ink);
  border-left-color: var(--blue-deep);
}

nav.rail a.active {
  background: rgba(92, 194, 172, 0.12);
  color: var(--paper);
  border-left-color: var(--teal);
}

.rail-foot {
  padding: 1rem 1.4rem 1.4rem;
  border-top: 1px solid var(--rule-soft);
  font-size: 0.72rem;
  color: var(--ink-faint);
  line-height: 1.5;
}

/* ==========================================================================
   MAIN CONTENT & HERO
   ========================================================================== */
.main { margin-left: 255px; flex: 1; min-width: 0; }

.hero {
  position: relative;
  padding: 5rem 4rem 3.5rem;
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(111,155,224,0.14), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 0%, rgba(92,194,172,0.10), transparent 55%);
}

.starfield { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.star { position: absolute; border-radius: 50%; background: #fff; }

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 1rem;
  display: flex; align-items: center; gap: 0.7rem;
  position: relative; z-index: 1;
}
.hero-eyebrow::before { content: ""; width: 28px; height: 1px; background: var(--teal); display: inline-block; }

.hero h1 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: clamp(2.2rem, 4vw, 3.6rem);
  line-height: 1.15;
  margin: 0 0 1rem;
  color: var(--paper);
  max-width: 22ch;
  position: relative; z-index: 1;
}

.hero p.lede {
  font-size: 1.15rem;
  color: var(--ink-dim);
  max-width: 62ch;
  line-height: 1.65;
  margin: 0 0 2rem;
  font-style: italic;
  position: relative; z-index: 1;
}

/* Quick Server Connect Chips */
.server-connect-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 2.2rem;
  position: relative;
  z-index: 1;
}

.connect-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--rule);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

.connect-chip:hover {
  transform: translateY(-2px);
  border-color: var(--teal);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4), 0 0 15px rgba(92, 194, 172, 0.2);
}

.chip-edition {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 2px 6px;
  border-radius: 3px;
}

.chip-edition.java { background: var(--blue-deep); color: #e9f0ff; }
.chip-edition.bedrock { background: var(--teal-deep); color: #e5faf3; }
.chip-edition.map { background: var(--gold-deep); color: #fff8e8; }

.chip-ip {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: var(--gold);
  background: transparent;
  border: none;
  padding: 0;
}

.copy-icon {
  font-size: 0.78rem;
  color: var(--ink-faint);
  transition: color 0.15s ease;
}

.connect-chip:hover .copy-icon {
  color: var(--teal);
}

.chip-text {
  font-family: var(--font-heading);
  font-size: 0.92rem;
  color: var(--paper);
  font-weight: 600;
}

/* Stats */
.hero-stats {
  display: flex; gap: 2.6rem; flex-wrap: wrap; margin-bottom: 2.2rem; position: relative; z-index: 1;
}
.hero-stats div { min-width: 110px; }
.hero-stats .n { font-family: var(--font-mono); font-size: 1.4rem; color: var(--gold); font-weight: 700; }
.hero-stats .l { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink-faint); margin-top: 0.15rem; }

/* Search Box */
.search-wrap { max-width: 640px; position: relative; z-index: 1; }
.search-wrap svg { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; opacity: 0.6; }
#searchInput {
  width: 100%;
  padding: 0.95rem 1.1rem 0.95rem 2.7rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.92rem;
  outline: none;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.35);
}
#searchInput::placeholder { color: var(--ink-faint); }
#searchInput:focus { border-color: var(--teal); box-shadow: inset 0 2px 6px rgba(0,0,0,0.35), 0 0 0 3px rgba(92,194,172,0.15); }
#searchMeta { font-size: 0.75rem; color: var(--ink-faint); margin-top: 0.55rem; font-family: var(--font-mono); min-height: 1em; position: relative; z-index: 1; }

/* ==========================================================================
   LIVE MAP SECTION
   ========================================================================== */
.map-section-container {
  padding: 3.6rem 4rem;
  border-bottom: 1px solid var(--rule-soft);
  scroll-margin-top: 1.5rem;
}

.map-viewport-wrapper {
  position: relative;
  background: var(--panel-3);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin-top: 1.6rem;
}

.map-hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel-3));
  border-bottom: 1px solid var(--rule);
  gap: 12px;
  flex-wrap: wrap;
  z-index: 20;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--rule-soft);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

.chip-label {
  color: var(--ink-faint);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.chip-value {
  color: var(--paper);
  font-weight: 700;
}

.icon-teal { color: var(--teal); }
.icon-gold { color: var(--gold); }

.hud-quick-btn-group {
  display: flex;
  align-items: center;
}

.landmark-btn {
  background: rgba(232, 200, 118, 0.08);
  border: 1px solid var(--gold-deep);
  color: var(--gold);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.landmark-btn:hover {
  background: var(--gold);
  color: #080a14;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.coord-search-form {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--rule-soft);
  padding: 2px 4px 2px 6px;
  border-radius: var(--radius-sm);
}

.coord-inputs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.coord-input {
  width: 54px;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--gold);
  padding: 2px 4px;
}

.coord-input::placeholder { color: var(--ink-faint); }

.btn-hud-icon {
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm);
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-hud-icon:hover {
  background: rgba(92, 194, 172, 0.15);
  color: var(--teal);
  border-color: var(--teal);
}

.btn-fullscreen-toggle {
  background: rgba(92, 194, 172, 0.1);
  color: var(--teal);
  border-color: var(--teal-deep);
}

.btn-fullscreen-toggle:hover {
  background: var(--teal);
  color: #080a14;
}

.map-container-frame {
  position: relative;
  width: 100%;
  height: 600px;
  background: #060810;
}

#map {
  width: 100%;
  height: 100%;
  background-color: #060810 !important;
}

.leaflet-container {
  background: #060810 !important;
  font-family: var(--font-serif) !important;
}

.leaflet-tile {
  image-rendering: pixelated;
}

.leaflet-control-zoom {
  border: 1px solid var(--rule) !important;
  border-radius: var(--radius-sm) !important;
  overflow: hidden;
  box-shadow: var(--shadow) !important;
}

.leaflet-control-zoom a {
  background-color: rgba(18, 26, 48, 0.9) !important;
  color: var(--ink) !important;
  border-bottom: 1px solid var(--rule-soft) !important;
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
  transition: background 0.15s ease;
}

.leaflet-control-zoom a:hover {
  background-color: var(--panel-2) !important;
  color: var(--gold) !important;
}

.leaflet-control-attribution { display: none !important; }

.map-overlay-compass {
  position: absolute;
  top: 18px; right: 18px;
  width: 34px; height: 34px;
  background: rgba(14, 21, 38, 0.85);
  border: 1px solid var(--rule);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
  box-shadow: var(--shadow);
}

.compass-needle {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: #ef4444;
}

.map-bottom-bar {
  position: absolute;
  bottom: 12px; left: 12px; right: 12px;
  display: flex; align-items: center; justify-content: space-between;
  pointer-events: none;
  z-index: 10;
}

.map-bottom-left, .map-bottom-right {
  display: flex; align-items: center; gap: 8px; pointer-events: auto;
}

.world-title-badge, .map-res-badge {
  background: rgba(10, 13, 26, 0.85);
  border: 1px solid var(--rule-soft);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink-dim);
  font-family: var(--font-mono);
}

.map-layer-pill {
  background: rgba(10, 13, 26, 0.85);
  border: 1px solid var(--teal-deep);
  color: var(--teal);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-mono);
  transition: all 0.15s ease;
}

.map-layer-pill:hover {
  background: rgba(92, 194, 172, 0.2);
}

/* Fullscreen Map */
.map-viewport-wrapper.is-fullscreen {
  position: fixed !important;
  top: 0 !important; left: 0 !important;
  width: 100vw !important; height: 100vh !important;
  max-width: 100vw !important;
  border-radius: 0 !important;
  z-index: 99999 !important;
  margin-top: 0 !important;
}

.map-viewport-wrapper.is-fullscreen .map-container-frame {
  height: calc(100vh - 54px) !important;
}

/* Search Crosshair Marker */
.crosshair-target-marker {
  width: 22px; height: 22px;
  border: 2px solid var(--teal);
  border-radius: 50%;
  position: relative;
  animation: pulseCrosshair 1.5s infinite;
}

@keyframes pulseCrosshair {
  0% { transform: scale(0.8); box-shadow: 0 0 0 0 rgba(92, 194, 172, 0.8); }
  70% { transform: scale(1.4); box-shadow: 0 0 0 10px rgba(92, 194, 172, 0); }
  100% { transform: scale(0.8); box-shadow: 0 0 0 0 rgba(92, 194, 172, 0); }
}

.custom-map-pin {
  display: flex; flex-direction: column; align-items: center;
  transform: translate(-50%, -100%);
  cursor: pointer;
}

.pin-icon-bubble {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--panel-3);
  border: 2px solid var(--gold);
  box-shadow: 0 0 10px rgba(232, 200, 118, 0.5);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  color: var(--gold);
}

.pin-label {
  background: rgba(8, 10, 20, 0.9);
  border: 1px solid var(--rule);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--paper);
  margin-top: 3px;
  white-space: nowrap;
}

.leaflet-popup-content-wrapper {
  background: rgba(14, 21, 38, 0.95) !important;
  color: var(--ink) !important;
  border: 1px solid var(--rule) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-lg) !important;
}

.leaflet-popup-tip { background: rgba(14, 21, 38, 0.95) !important; }

.popup-landmark-box h4 {
  font-family: var(--font-heading);
  color: var(--gold);
  font-size: 1rem;
  margin-bottom: 2px;
}

.popup-landmark-coords {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--teal);
  margin-bottom: 4px;
}

.popup-landmark-desc {
  font-size: 0.85rem;
  color: var(--ink-dim);
}

/* ==========================================================================
   ALMANAC SECTIONS & COMPONENTS
   ========================================================================== */
section.page {
  padding: 3.6rem 4rem;
  border-bottom: 1px solid var(--rule-soft);
  scroll-margin-top: 1.5rem;
}
section.page:nth-of-type(odd) { background: rgba(255, 255, 255, 0.012); }

.signpost { display: flex; align-items: flex-end; gap: 1rem; margin-bottom: 0.6rem; }
.signpost .plank {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.7rem;
  color: var(--paper);
  background: linear-gradient(180deg, var(--panel-2), var(--panel-3));
  border: 1px solid var(--rule);
  border-left: 5px solid var(--teal);
  padding: 0.55rem 1.3rem;
  box-shadow: var(--shadow);
  position: relative;
}
.signpost .idx {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--blue);
  font-weight: 700;
  letter-spacing: 1px;
  padding-bottom: 0.6rem;
}
.page > .dek { color: var(--ink-dim); max-width: 70ch; margin: 1.1rem 0 2rem; font-size: 1.04rem; line-height: 1.7; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.3rem; margin-top: 1.4rem; }
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-3));
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.5rem 1.6rem;
  box-shadow: var(--shadow);
  position: relative;
}
.card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  border-radius: 6px 6px 0 0;
}
.card h3 {
  margin: 0 0 0.55rem;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--gold);
  display: flex; align-items: center; gap: 0.55rem;
}
.card p { margin: 0; color: var(--ink-dim); line-height: 1.65; font-size: 0.97rem; }
.card .foot-cmd { margin-top: 0.85rem; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.2rem;
  background: var(--panel-3);
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
thead th {
  background: var(--panel-2);
  color: var(--teal);
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 0.85rem 1.2rem;
  border-bottom: 2px solid var(--rule);
}
tbody td { padding: 0.85rem 1.2rem; border-bottom: 1px solid var(--rule-soft); color: var(--ink-dim); font-size: 0.94rem; vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(111, 155, 224, 0.07); }
tbody tr:hover td { color: var(--ink); }
td.cmd-cell { white-space: nowrap; }

.note {
  display: flex; gap: 0.8rem;
  background: rgba(92, 194, 172, 0.07);
  border: 1px solid var(--teal-deep);
  border-left: 4px solid var(--teal);
  padding: 1rem 1.3rem;
  border-radius: 4px;
  margin-top: 1.4rem;
  font-size: 0.93rem;
  color: var(--ink-dim);
  line-height: 1.6;
}
.note b { color: var(--paper); }
.note.warn { border-color: var(--gold-deep); border-left-color: var(--gold); background: rgba(232, 200, 118, 0.07); }

.taglist { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.4rem; }
.taglist span {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  border: 1px solid var(--rule);
  color: var(--ink-faint);
}
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0.22rem 0.6rem;
  border-radius: 3px;
  font-weight: 700;
}
.badge.bedrock { background: var(--teal-deep); color: #e5faf3; }
.badge.java { background: var(--blue-deep); color: #e9f0ff; }
.badge.staff { background: #6e3f66; color: #fbe9f6; }

.rank-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 1.2rem; }
.rank-chain .rk {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.5rem 0.9rem;
  background: var(--panel-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--ink);
}
.rank-chain .arrow { color: var(--gold); font-size: 1rem; }

.two-col { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 2rem; align-items: start; }

.step-list { list-style: none; padding: 0; margin: 1.2rem 0 0; counter-reset: step; }
.step-list li { counter-increment: step; display: flex; gap: 1rem; padding: 0.8rem 0; border-bottom: 1px solid var(--rule-soft); }
.step-list li:last-child { border-bottom: none; }
.step-list li::before {
  content: counter(step);
  font-family: var(--font-mono);
  flex: 0 0 26px; height: 26px;
  background: var(--panel-2);
  border: 1px solid var(--blue-deep);
  color: var(--blue);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700;
}
.step-list b { color: var(--paper); }
.step-list span { color: var(--ink-dim); font-size: 0.93rem; }

.noresult { display: none; color: var(--ink-faint); font-style: italic; padding: 2rem 0; text-align: center; }

.tbl-wrap {
  margin-top: 1.2rem;
  border-radius: 6px;
  box-shadow: var(--shadow);
}
.tbl-wrap table { margin-top: 0; box-shadow: none; }

footer.pagefoot {
  padding: 2.6rem 4rem 4rem;
  color: var(--ink-faint);
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Modals & Toasts */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 10000;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal-card {
  background: var(--panel-2);
  border: 1px solid var(--gold-deep);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 460px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px;
}
.modal-header h3 {
  font-family: var(--font-heading);
  color: var(--gold);
  font-size: 1.2rem;
}
.modal-close {
  background: none; border: none; color: var(--ink-faint); font-size: 1.4rem; cursor: pointer;
}
.modal-close:hover { color: var(--ink); }

.form-group { margin-bottom: 14px; }
.form-row { display: flex; gap: 10px; }
.col-half { flex: 1; }
.form-group label {
  display: block; font-size: 0.82rem; font-family: var(--font-mono); color: var(--ink-dim); margin-bottom: 4px;
}
.form-control {
  width: 100%;
  background: var(--panel-3);
  border: 1px solid var(--rule);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 0.95rem;
  outline: none;
}
.form-control:focus { border-color: var(--teal); }

.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-heading); font-weight: 600; font-size: 0.9rem;
  padding: 8px 18px; border-radius: var(--radius-sm); cursor: pointer; border: none;
  transition: all 0.15s ease;
}
.btn-primary { background: var(--teal); color: #050710; }
.btn-primary:hover { background: #6fe4cb; }
.btn-secondary { background: var(--panel-3); color: var(--ink-dim); border: 1px solid var(--rule); }
.btn-secondary:hover { background: var(--panel); }

.toast-container {
  position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 100000;
}
.toast {
  background: var(--panel-2);
  border: 1px solid var(--teal);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  color: var(--paper);
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  animation: toastIn 0.3s ease, toastOut 0.3s 2.7s forwards;
}

@keyframes toastIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-8px); } }

/* ==========================================================================
   MOBILE & RESPONSIVE
   ========================================================================== */
@media (max-width: 900px) {
  body { display: block; }
  .railwrap {
    position: sticky; top: 0; left: 0;
    width: 100%; height: auto;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--rule);
    z-index: 50;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  }
  .rail-brand {
    flex: 0 0 auto;
    border-bottom: none;
    border-right: 1px solid var(--rule-soft);
    padding: 0.85rem 1rem;
  }
  .rail-brand .mark { margin-bottom: 0.15rem; }
  .rail-brand h1 { font-size: 1.15rem; }
  .rail-brand p { display: none; }
  nav.rail {
    display: flex;
    flex: 1;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.4rem 0.5rem;
    scrollbar-width: none;
  }
  nav.rail::-webkit-scrollbar { display: none; }
  nav.rail a {
    border-left: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    padding: 0.55rem 0.8rem;
    font-size: 0.88rem;
    flex: 0 0 auto;
  }
  nav.rail a:hover { padding-left: 0.8rem; }
  nav.rail a.active { border-bottom-color: var(--teal); }
  .rail-foot { display: none; }
  .main { margin-left: 0; }

  .hero { padding: 2.2rem 1.25rem 2rem; }
  .hero h1 { font-size: 1.85rem; line-height: 1.25; max-width: none; }
  .hero p.lede { font-size: 1rem; margin-bottom: 1.6rem; }
  .hero-stats { gap: 1.4rem 1.8rem; margin-bottom: 1.8rem; }
  .hero-stats div { min-width: 0; }
  .hero-stats .n { font-size: 1.2rem; }
  #searchInput { font-size: 0.85rem; padding: 0.85rem 1rem 0.85rem 2.5rem; }

  .map-section-container { padding: 2.4rem 1.25rem; }
  .map-container-frame { height: 480px; }
  .map-hud-bar { flex-direction: column; align-items: stretch; }
  .hud-group, .hud-actions { width: 100%; justify-content: space-between; }

  section.page { padding: 2.4rem 1.25rem; }
  .signpost { gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
  .signpost .plank { font-size: 1.25rem; padding: 0.45rem 0.9rem; }
  .signpost .idx { font-size: 0.72rem; padding-bottom: 0.5rem; }
  .page > .dek { font-size: 0.96rem; margin: 0.9rem 0 1.5rem; }

  .grid { grid-template-columns: 1fr; gap: 1rem; margin-top: 1.1rem; }
  .card { padding: 1.2rem 1.3rem; }
  .card h3 { font-size: 1.05rem; flex-wrap: wrap; }

  .two-col { grid-template-columns: 1fr; gap: 1.6rem; }

  .tbl-wrap {
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    width: calc(100% + 2.5rem);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0;
  }
  .tbl-wrap table { border-radius: 0; border-left: none; border-right: none; min-width: 560px; }
  thead th { padding: 0.7rem 0.9rem; font-size: 0.66rem; }
  tbody td { padding: 0.7rem 0.9rem; font-size: 0.87rem; }

  .note { padding: 0.85rem 1.05rem; font-size: 0.88rem; }
  .rank-chain { gap: 0.4rem; }
  .rank-chain .rk { font-size: 0.78rem; padding: 0.42rem 0.7rem; }
  .taglist span { font-size: 0.63rem; }

  footer.pagefoot { padding: 2rem 1.25rem 2.6rem; flex-direction: column; gap: 0.4rem; }
}

@media (max-width: 460px) {
  .hero h1 { font-size: 1.55rem; }
  .hero-stats { gap: 1.1rem 1.4rem; }
  .tbl-wrap table { min-width: 500px; }
}