:root {
  --chap-0:#9ED638;
  --chap-1:#AEEC3F;
  --chap-2:#79c327;
  --chap-3:#65b021;
  --chap-4:#58a01d;
  --chap-5:#4a8f19;
  --chap-6:#3b7e15;
  --chap-7:#2d6d12;
  --chap-default:#2e6a55;
}

body { font-family: ui-sans-serif, system-ui, Arial, sans-serif; margin:0; background:#0f1115; color:#e5e7eb; }
.top { display:flex; justify-content:space-between; align-items:center; padding:10px 14px; background:#0b0d12; border-bottom:1px solid #1f2430; flex-wrap:wrap; gap:10px; }
.brand { font-family:'Montserrat',sans-serif; font-weight:700; color:#e5e7eb; letter-spacing:.3px; display:flex; align-items:center; gap:10px; }
.brand .brand-logo { height:28px; }
.brand .subtitle { color:#e5e7eb; opacity:.9; font-weight:600; }
.countdown { color:#9ED638; font-weight:600; letter-spacing:.4px; flex:1; text-align:center; min-width:180px; }
.actions button { background:#142229; color:#e5e7eb; border:1px solid #9ED638; border-radius:6px; padding:6px 10px; cursor:pointer; }
.actions button:hover { background:#19303a; box-shadow: 0 0 0 1px #AEEC3F inset; }
.auth { display:flex; gap:6px; align-items:center; margin-right: 10px; }
.auth input { background:#111623; color:#e5e7eb; border:1px solid #9ED638; border-radius:6px; padding:6px 8px; }
.auth #authInfo { color:#9fb3c8; margin-right: 4px; }
.auth-error { color:#fca5a5; font-size:12px; margin:4px 0 0 4px; min-height:14px; }
.auth-success { color:#bbf7d0; font-size:12px; margin:4px 0 0 4px; min-height:14px; }
main { padding: 16px; }
.quick-links {
  position: fixed;
  top: 140px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 40;
}
.quick-links-head {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color:#9fb3c8;
  text-align: center;
  background: rgba(20,34,41,0.85);
  border:1px solid rgba(158,214,56,0.4);
  border-radius: 10px;
  padding: 6px 12px;
}
.quick-link {
  display: block;
  background: #142229;
  color: #e5e7eb;
  text-decoration: none;
  border: 1px solid #9ED638;
  border-radius: 12px;
  padding: 10px 14px;
  min-width: 180px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.35);
  font-weight: 600;
  letter-spacing: .2px;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.quick-link span {
  display: block;
  font-size: 12px;
  color: #9fb3c8;
  font-weight: 400;
  margin-top: 2px;
  letter-spacing: .1px;
}
.quick-link:hover {
  background: #19303a;
  transform: translateY(-2px);
  box-shadow: 0 10px 18px rgba(0,0,0,0.45);
}
.quick-toggle {
  background:#0f1b22;
  color:#9ED638;
  border:1px solid #9ED638;
  border-radius: 12px;
  padding: 10px 12px;
  cursor:pointer;
  font-weight:600;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.quick-toggle:hover {
  background:#132834;
  transform: translateY(-2px);
  box-shadow: 0 10px 18px rgba(0,0,0,0.45);
}
.world { max-width: 1480px; margin: 0 auto; padding: 0 32px 0 16px; }
.world h2 { color:#9fb3c8; margin: 6px 0 12px; font-size: 14px; text-transform: uppercase; letter-spacing: .6px; }
.world-grid { display:grid; grid-template-columns: minmax(0, 1fr) 320px; gap:24px; align-items:start; }
.world-main { display:flex; flex-direction:column; gap:24px; }
.glossary h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color:#9fb3c8; }
.glossary-note { font-size: 12px; color:#94a3b8; margin-bottom: 10px; }
.glossary-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 10px; }
.g-item { border:1px solid #1f2430; border-radius:12px; background:#0d141b; padding:10px; box-shadow:0 6px 14px rgba(0,0,0,0.25); }
.g-item .g-title { font-weight:700; color:#e5e7eb; margin-bottom:4px; }
.g-item .g-type { font-size:11px; color:#9fb3c8; letter-spacing:.4px; }
.g-item .g-desc { font-size:12px; color:#cbd5e1; margin-top:6px; line-height:1.5; }
.g-item .g-pins { font-size:11px; color:#9fb3c8; margin-top:6px; }
.meta-row {
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  align-items:center;
  margin-bottom:12px;
}
.meta-pill {
  background:#111923;
  color:#d1d5db;
  border:1px solid rgba(158,214,56,0.4);
  border-radius:999px;
  padding:6px 14px;
  font-size:13px;
  letter-spacing:.2px;
  display:flex;
  align-items:center;
  gap:6px;
}
.meta-pill.link {
  text-decoration:none;
  color:#9ED638;
  border-color:rgba(158,214,56,0.8);
}
.leaderboard-preview {
  margin-top:28px;
  border:1px solid #1f2430;
  border-radius:12px;
  background:#0d141b;
  padding:14px;
  box-shadow:0 10px 24px rgba(0,0,0,0.35);
}
.filters {
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  align-items:center;
  margin-bottom:14px;
}
.filter-search input {
  background:#111923;
  border:1px solid rgba(158,214,56,0.4);
  border-radius:999px;
  padding:8px 14px;
  color:#dbeafe;
  min-width:240px;
}
.filter-search input::placeholder { color:#94a3b8; }
.filter-checkbox {
  display:flex;
  align-items:center;
  gap:6px;
  font-size:13px;
  color:#d1d5db;
  background:#111923;
  border:1px solid rgba(158,214,56,0.3);
  border-radius:999px;
  padding:6px 12px;
}
.filter-checkbox input { accent-color:#9ED638; }
.preview-head {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom:10px;
}
.preview-head h3 {
  margin:0;
  font-size:14px;
  text-transform:uppercase;
  letter-spacing:.4px;
  color:#9fb3c8;
}
.link-inline {
  color:#9ED638;
  font-size:12px;
  text-decoration:none;
}
.link-inline:hover { text-decoration:underline; }
.preview-list { display:flex; flex-direction:column; gap:6px; font-size:13px; }
.preview-item {
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:8px 10px;
  border-radius:8px;
  background:#101b24;
  border:1px solid rgba(158,214,56,0.2);
}
.preview-item:nth-child(1) { border-color:rgba(255,215,0,0.5); }
.preview-item:nth-child(2) { border-color:rgba(192,192,192,0.4); }
.preview-item:nth-child(3) { border-color:rgba(205,127,50,0.4); }
.preview-item span { display:block; }
.preview-item .name { font-weight:600; color:#e5e7eb; }
.preview-item .stats { font-size:12px; color:#94a3b8; }
.level-details {
  margin-top:30px;
  border:1px solid #1f2430;
  border-radius:12px;
  background:#0d141b;
  padding:16px;
  box-shadow:0 10px 28px rgba(0,0,0,0.35);
}
.level-details h3 {
  margin-top:0;
  font-size:14px;
  letter-spacing:.4px;
  text-transform:uppercase;
  color:#9fb3c8;
}
.details-body { font-size:13px; line-height:1.55; display:flex; flex-direction:column; gap:12px; }
.details-body .field { display:flex; flex-direction:column; gap:4px; }
.details-body .field strong { color:#9ED638; text-transform:uppercase; font-size:11px; letter-spacing:.3px; }
.details-body ul { margin:0; padding-left:18px; }
.details-body .actions { display:flex; gap:10px; flex-wrap:wrap; }
.details-body .actions a { background:#142229; color:#9ED638; border:1px solid #9ED638; border-radius:8px; padding:6px 10px; text-decoration:none; }
.details-body .actions a:hover { background:#19303a; }
.hidden-node { display:none !important; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); border:0; }

/* Tree */
.tree-section { margin-top: 36px; padding-top: 18px; border-top: 1px solid #1f2430; }
.tree-section h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color:#9fb3c8; }
.tree-hint { font-size: 12px; color:#94a3b8; margin-bottom: 12px; max-width: 820px; }
.tree-wrap { position: relative; overflow-x: auto; padding: 18px 14px 12px; border: 1px solid #1f2430; border-radius: 12px; background: #0d141b; }
.tree-layer { position: relative; display: grid; grid-template-columns: 108px minmax(0, 1fr); align-items: start; column-gap: 24px; margin-bottom: 32px; }
.tree-layer:last-child { margin-bottom: 0; }
.tree-layer-label { min-width: 84px; font-size: 12px; color: #9fb3c8; text-transform: uppercase; letter-spacing: .4px; text-align: right; padding-top: 12px; justify-self: end; }
.tree-layer-nodes {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(200px, 220px);
  gap: 24px;
  position: relative;
  align-items: stretch;
  justify-content: center;
  justify-items: stretch;
  width: 100%;
  max-width: calc(4 * 220px + 3 * 24px);
  margin: 0 auto;
}
.tree-layer:not(:first-child) .tree-layer-nodes { padding-top: 16px; }
.tree-layer:not(:first-child) .tree-node::before { content: ""; position: absolute; top: -16px; left: 50%; transform: translateX(-50%); width: 2px; height: 16px; background: rgba(158,214,56,0.4); }
.tree-node { position: relative; width: 100%; min-width: 200px; max-width: 220px; background:#101b24; border:1px solid #1f2430; border-radius: 12px; padding: 12px 12px 16px; transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.tree-node::after { content:""; position:absolute; top:0; left:0; right:0; height:4px; border-radius:12px 12px 0 0; background: var(--chapter-color, var(--chap-default)); }
.tree-node.chapter-tag-0 { --chapter-color: var(--chap-0); }
.tree-node.chapter-tag-1 { --chapter-color: var(--chap-1); }
.tree-node.chapter-tag-2 { --chapter-color: var(--chap-2); }
.tree-node.chapter-tag-3 { --chapter-color: var(--chap-3); }
.tree-node.chapter-tag-4 { --chapter-color: var(--chap-4); }
.tree-node.chapter-tag-5 { --chapter-color: var(--chap-5); }
.tree-node.chapter-tag-6 { --chapter-color: var(--chap-6); }
.tree-node.chapter-tag-7 { --chapter-color: var(--chap-7); }
.tree-node.chapter-tag-default { --chapter-color: var(--chap-default); }
.tree-node.available { border-color:#fde047; box-shadow: 0 0 16px rgba(254, 224, 71, 0.3); }
.tree-node.available:hover { transform: translateY(-2px); box-shadow: 0 0 20px rgba(254, 224, 71, 0.45); }
.tree-node.done { border-color:#34d399; box-shadow: 0 0 18px rgba(52, 211, 153, 0.35); }
.tree-node.done::after { background: linear-gradient(90deg, rgba(52,211,153,0.9), rgba(14,159,110,0.9)); }
.tree-node.locked { opacity:.45; filter: grayscale(40%); }
.tree-node.highlight { border-color:#facc15; box-shadow:0 0 18px rgba(250,204,21,0.35); }
.tree-node.selected { border-color:#60a5fa; box-shadow:0 0 20px rgba(96,165,250,0.35); }
.tree-node .meta { margin-top: 8px; }
.tree-node .req-info { font-size: 11px; color:#64748b; margin-top: 6px; }
.tree-node .chapter-dot { width: 10px; height: 10px; border-radius: 50%; display:inline-block; margin-right: 4px; background:#9ED638; }
.tree-section .nodebox .open { margin-top: 8px; }

/* Column flowchart menu */
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; align-items: start; }
.column { position: relative; }
.col-header { text-align: center; background: #0e2c22; color:#d1f2e5; border:1px solid #9ED638; border-radius: 10px; padding: 6px 8px; margin-bottom: 10px; font-weight: 700; letter-spacing: .3px; }
.col-header.locked { opacity: .5; filter: grayscale(40%); }
.stack { position: relative; list-style: none; margin: 0; padding: 0 16px; }
.stack li { position: relative; margin: 10px 0; }
.nodebox { background:#10231e; border:1px solid #9ED638; color:#d1f2e5; border-radius: 10px; padding: 8px 10px; text-align: center; }
.nodebox.locked { opacity:.45; }
.nodebox.done { box-shadow: 0 0 0 2px rgba(46,106,85,0.6) inset; }
.nodebox .name { font-weight: 600; }
.nodebox .chips { margin-top:6px; display:flex; gap:6px; flex-wrap: wrap; justify-content: center; }
.nodebox .meta { display:flex; justify-content:center; gap:6px; margin-top:6px; flex-wrap:wrap; }
.chip { font-size:11px; padding:2px 6px; border-radius: 10px; border:1px solid #9ED638; color:#cbd5e1; background:#142229; }
.nodebox .open { display:inline-block; margin-top:6px; padding:4px 8px; border-radius:6px; border:1px solid #9ED638; background:#142229; color:#e5e7eb; text-decoration:none; }
.nodebox .open:hover { background:#19303a; box-shadow: 0 0 0 1px #AEEC3F inset; }
.nodebox .note-locked { margin-top: 6px; font-size: 12px; color: #fca5a5; }
/* connectors */
.stack li::before { content: ""; position:absolute; left: calc(50% - 1px); top: -10px; width:2px; height: 10px; background: #2e6a55; }
.stack li:first-child::before { display:none; }

/* Chapter visualization */
.legend { display:flex; gap:10px; align-items:center; margin: 4px 0 10px; flex-wrap: wrap; }
.chap-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.2); color: #e5e7eb; }
.chap-0 { background:#9ED638; color:#0b0d12; }
.chap-1 { background:#AEEC3F; color:#0b0d12; }
.chap-2 { background:#79c327; color:#0b0d12; }
.chap-3 { background:#65b021; color:#0b0d12; }
.chap-4 { background:#58a01d; color:#0b0d12; }
.chap-5 { background:#4a8f19; color:#0b0d12; }
.chap-6 { background:#3b7e15; color:#0b0d12; }
.chap-7 { background:#2d6d12; color:#0b0d12; }
.chap-badge.is-hovered { box-shadow:0 0 0 2px rgba(158,214,56,0.6); }
.modal-backdrop {
  position:fixed;
  inset:0;
  background:rgba(0,0,0,0.55);
  display:flex;
  justify-content:center;
  align-items:center;
  z-index:200;
}
.modal-backdrop[hidden] { display:none !important; }
.modal-sheet {
  width:min(420px, 92vw);
  background:#0e141c;
  border:1px solid #1f2430;
  border-radius:12px;
  box-shadow:0 20px 40px rgba(0,0,0,0.5);
}
.modal-sheet header {
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:12px 16px;
  border-bottom:1px solid #1f2430;
}
.modal-sheet header h3 { margin:0; font-size:16px; color:#9fb3c8; }
.modal-sheet header button {
  background:none;
  border:none;
  color:#9fb3c8;
  font-size:18px;
  cursor:pointer;
}
.modal-content { padding:16px; font-size:14px; color:#dbeafe; line-height:1.6; }
.modal-content ul { margin:0 0 12px; padding-left:20px; }
.modal-content li { margin-bottom:6px; }

@media (max-width: 1300px) {
  .world { padding-right: 120px; }
  .world-grid { grid-template-columns: minmax(0, 1fr) 300px; }
}

@media (max-width: 1100px) {
  .world { padding-right: 80px; }
  .world-grid { grid-template-columns: minmax(0, 1fr) 280px; }
}

@media (max-width: 980px) {
  .quick-links {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    margin: 12px 0 18px;
  }
  .quick-links-head { display:none; }
  .quick-link {
    flex: 1 1 180px;
    min-width: 0;
    text-align: center;
  }
  .world { padding: 0 16px; }
  .meta-row { justify-content:center; }
  .world-grid { grid-template-columns: minmax(0, 1fr); }
  .level-details { order:-1; }
  .tree-layer { grid-template-columns: minmax(0, 1fr); row-gap: 12px; }
  .tree-layer-label { text-align: left; justify-self: start; padding-top: 0; }
  .tree-layer-nodes { grid-auto-flow: row; grid-auto-columns: unset; justify-content: stretch; max-width: none; margin: 0; }
}

@media (max-width: 600px) {
  .quick-link span { display: none; }
  .quick-link { font-size: 14px; padding: 8px 12px; }
  .filters { flex-direction:column; align-items:stretch; }
  .filter-search input { width:100%; }
}

/* Theme toggle (light mode) */
body.light { background:#f4f6f9; color:#1f2937; }
body.light .top { background:#e5e7eb; color:#1f2937; border-bottom:1px solid #cbd5e1; }
body.light .brand .subtitle { color:#334155; }
body.light .countdown { color:#2f855a; }
body.light .actions button { background:#dbeafe; color:#1e293b; border-color:#3b82f6; }
body.light .actions button:hover { background:#bfdbfe; box-shadow:0 0 0 1px #60a5fa inset; }
body.light .auth input { background:#fff; color:#1f2937; border-color:#94a3b8; }
body.light .world { padding: 0 32px 0 16px; }
body.light .tree-wrap { background:#f8fafc; border-color:#cbd5e1; }
body.light .tree-node { background:#fff; border-color:#cbd5e1; }
body.light .tree-node.available { border-color:#facc15; box-shadow:0 0 16px rgba(250,204,21,0.3); }
body.light .tree-node.done { border-color:#22c55e; }
body.light .quick-link, body.light .quick-toggle { background:#e0f2fe; color:#0f172a; border-color:#38bdf8; }
body.light .quick-link:hover, body.light .quick-toggle:hover { background:#bae6fd; }
body.light .quick-links-head { background:#bfdbfe; border-color:rgba(56,189,248,0.6); color:#1e3a8a; }
body.light .meta-pill { background:#e2e8f0; color:#1f2937; border-color:#94a3b8; }
body.light .meta-pill.link { color:#1d4ed8; border-color:#60a5fa; }
body.light .leaderboard-preview { background:#e2e8f0; border-color:#cbd5e1; }
body.light .g-item { background:#f8fafc; border-color:#cbd5e1; }
body.light .g-item .g-desc { color:#1f2937; }
body.light .preview-item { background:#f8fafc; border-color:rgba(96,165,250,0.4); }
body.light .preview-item .name { color:#0f172a; }
body.light .preview-item .stats { color:#475569; }
body.light .legend .chap-badge { color:#0f172a; border-color:rgba(15,23,42,0.1); }
body.light .filters input { background:#f8fafc; border-color:#94a3b8; color:#1f2937; }
body.light .filter-checkbox { background:#e2e8f0; border-color:#cbd5e1; color:#1f2937; }
body.light .level-details { background:#f8fafc; border-color:#cbd5e1; }
body.light .details-body .actions a { background:#e2e8f0; color:#1f2937; border-color:#94a3b8; }
body.light .details-body .actions a:hover { background:#cbd5e1; }
body.light .modal-sheet { background:#e2e8f0; border-color:#94a3b8; }
body.light .modal-sheet header { border-bottom-color:#94a3b8; }
body.light .modal-sheet header button { color:#1e293b; }
body.light .modal-content { color:#1e293b; }
