:root {
  --bg: #090510;
  --panel: rgba(12, 8, 21, .72);
  --panel-strong: rgba(20, 13, 34, .9);
  --line: rgba(255,255,255,.13);
  --line-strong: rgba(192,132,252,.38);
  --text: #f8f4ff;
  --muted: #b7a9c9;
  --faint: #746783;
  --purple: #a855f7;
  --purple-2: #8b5cf6;
  --cyan: #38bdf8;
  --green: #4ade80;
  --orange: #fb923c;
  --danger: #fb7185;
  --radius: 24px;
  --blur: blur(18px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  text-decoration: none;
}

#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background:
    radial-gradient(circle at 75% 18%, rgba(139,92,246,.2), transparent 30rem),
    radial-gradient(circle at 20% 80%, rgba(56,189,248,.12), transparent 28rem),
    #090510;
}

.grain {
  position: fixed;
  inset: 0;
  opacity: .06;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 260 260' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='260' height='260' filter='url(%23n)'/%3E%3C/svg%3E");
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at center, transparent 0%, transparent 48%, rgba(0,0,0,.48) 100%);
}

.hud {
  position: fixed;
  z-index: 10;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.top-hud {
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1160px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(9,5,16,.68);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 18px 70px rgba(0,0,0,.3);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--purple), var(--purple-2), var(--cyan));
  font-weight: 950;
  letter-spacing: -.08em;
  box-shadow: 0 14px 50px rgba(168,85,247,.38);
}

.brand strong {
  letter-spacing: -.04em;
}

.top-hud nav {
  display: flex;
  gap: 8px;
}

.top-hud button {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,.055);
  padding: 10px 13px;
  font-weight: 850;
  transition: .18s ease;
}

.top-hud button:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(168,85,247,.16);
}

.intro-card {
  left: 28px;
  bottom: 28px;
  width: min(410px, calc(100% - 56px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 24px;
  box-shadow: 0 26px 90px rgba(0,0,0,.38);
  transition: .28s ease;
}

.intro-card.hidden {
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #decaff;
  border: 1px solid rgba(168,85,247,.32);
  background: rgba(168,85,247,.14);
  border-radius: 999px;
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 16px var(--green);
}

.intro-card h1 {
  margin: 18px 0 10px;
  font-size: 38px;
  line-height: .92;
  letter-spacing: -.07em;
}

.intro-card p {
  color: var(--muted);
  line-height: 1.62;
  margin: 0;
}

.intro-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.intro-actions button,
.project-panel button {
  border: 0;
  border-radius: 999px;
  color: white;
  background: linear-gradient(135deg, var(--purple), var(--purple-2));
  padding: 12px 15px;
  font-weight: 950;
  box-shadow: 0 14px 45px rgba(168,85,247,.28);
}

.intro-actions button:nth-child(2) {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.07);
  color: var(--text);
  box-shadow: none;
}

.help-card {
  top: 92px;
  right: 28px;
  width: min(340px, calc(100% - 56px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  padding: 22px;
  box-shadow: 0 26px 90px rgba(0,0,0,.38);
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: .22s ease;
}

.help-card.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.help-card h2 {
  margin: 0 0 14px;
  letter-spacing: -.04em;
}

.close-help,
.close-detail,
.drawer-head button {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,.06);
}

.control-grid {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 9px;
  align-items: center;
}

.control-grid span {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  text-align: center;
  color: #e7d7ff;
  background: rgba(255,255,255,.055);
  font-weight: 900;
}

.control-grid p {
  color: var(--muted);
  margin: 0;
}

.filter-bar {
  top: 92px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1160px, calc(100% - 28px));
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: auto;
}

.filter-bar button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(9,5,16,.58);
  color: var(--muted);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 850;
  transition: .18s ease;
}

.filter-bar button.active,
.filter-bar button:hover {
  color: #fff;
  border-color: var(--line-strong);
  background: rgba(168,85,247,.22);
}

.project-panel {
  right: 28px;
  bottom: 28px;
  width: min(390px, calc(100% - 56px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 22px;
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
  box-shadow: 0 26px 90px rgba(0,0,0,.38);
  transition: .22s ease;
}

.project-panel.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.project-panel small,
.detail-card small,
.drawer-head small {
  color: var(--purple);
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.project-panel h2 {
  margin: 8px 0 8px;
  font-size: 30px;
  letter-spacing: -.055em;
}

.project-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 15px 0;
}

.tag-row span,
.detail-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #dfd0f2;
  background: rgba(255,255,255,.06);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 850;
}

.project-drawer {
  top: 92px;
  left: 28px;
  bottom: 28px;
  width: min(430px, calc(100% - 56px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  box-shadow: 0 26px 90px rgba(0,0,0,.42);
  padding: 20px;
  transform: translateX(-110%);
  transition: .26s cubic-bezier(.2,.8,.2,1);
  overflow: hidden;
}

.project-drawer.open {
  transform: translateX(0);
}

.drawer-head {
  position: relative;
  padding-right: 46px;
  margin-bottom: 15px;
}

.drawer-head h2 {
  margin: 4px 0 0;
  font-size: 30px;
  letter-spacing: -.055em;
}

.drawer-list {
  height: calc(100% - 64px);
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 5px;
}

.drawer-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.045);
  padding: 13px;
  cursor: pointer;
  transition: .16s ease;
}

.drawer-item:hover {
  border-color: var(--line-strong);
  background: rgba(168,85,247,.12);
}

.drawer-item strong {
  display: block;
  letter-spacing: -.03em;
}

.drawer-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.detail-modal {
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(3,2,7,.68);
  opacity: 0;
  pointer-events: none;
  transition: .24s ease;
}

.detail-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.detail-card {
  position: relative;
  width: min(900px, 100%);
  max-height: min(760px, calc(100vh - 56px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 30px;
  background:
    radial-gradient(circle at 18% 0%, rgba(168,85,247,.18), transparent 30rem),
    rgba(13,8,23,.94);
  box-shadow: 0 30px 120px rgba(0,0,0,.58);
  padding: clamp(24px, 5vw, 48px);
}

.detail-card h1 {
  margin: 14px 0;
  font-size: clamp(46px, 7vw, 82px);
  line-height: .88;
  letter-spacing: -.08em;
}

.detail-card p {
  color: var(--muted);
  line-height: 1.68;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 20px;
}

.detail-grid article {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,.045);
  padding: 18px;
}

.detail-grid h3 {
  margin: 0 0 10px;
}

.detail-grid ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.touch-controls {
  display: none;
}

.loading {
  position: fixed;
  inset: 0;
  z-index: 99;
  display: grid;
  place-items: center;
  background: #090510;
  color: var(--muted);
  transition: .25s ease;
}

.loading.done {
  opacity: 0;
  pointer-events: none;
}

.loading span {
  width: 54px;
  height: 54px;
  border: 3px solid rgba(255,255,255,.1);
  border-top-color: var(--purple);
  border-radius: 999px;
  animation: spin .8s linear infinite;
}

.loading p {
  position: absolute;
  margin-top: 96px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 760px) {
  .top-hud {
    top: 10px;
    width: calc(100% - 20px);
  }

  .top-hud nav button:first-child {
    display: none;
  }

  .brand strong {
    display: none;
  }

  .filter-bar {
    top: 76px;
    width: calc(100% - 20px);
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 6px;
  }

  .intro-card,
  .project-panel {
    left: 10px;
    right: 10px;
    bottom: 128px;
    width: auto;
  }

  .project-drawer {
    left: 10px;
    right: 10px;
    width: auto;
    top: 76px;
    bottom: 118px;
  }

  .help-card {
    top: 76px;
    right: 10px;
    width: calc(100% - 20px);
  }

  .intro-card h1 {
    font-size: 32px;
  }

  .touch-controls {
    display: flex;
    z-index: 15;
    left: 0;
    right: 0;
    bottom: 16px;
    justify-content: space-between;
    align-items: end;
    padding: 0 18px;
    pointer-events: none;
  }

  .touch-pad {
    width: 92px;
    height: 92px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(9,5,16,.54);
    backdrop-filter: blur(14px);
    position: relative;
    pointer-events: auto;
  }

  .touch-stick {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, var(--purple), var(--purple-2));
    box-shadow: 0 10px 34px rgba(168,85,247,.34);
  }

  #mobile-open {
    border: 0;
    border-radius: 999px;
    color: white;
    background: linear-gradient(135deg, var(--purple), var(--purple-2));
    padding: 15px 20px;
    font-weight: 950;
    pointer-events: auto;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* Bigger exploration world additions */
.minimap {
  position: fixed;
  left: 28px;
  top: 150px;
  width: 178px;
  height: 178px;
  z-index: 11;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(9,5,16,.58);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 70px rgba(0,0,0,.28);
  overflow: hidden;
}

.minimap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.world-tip {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 12;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(9,5,16,.68);
  backdrop-filter: blur(18px);
  padding: 10px 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  pointer-events: none;
  opacity: .92;
}

.world-tip strong {
  color: #fff;
}

.distance-pill {
  display: inline-flex;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.055);
  color: var(--muted);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 850;
}

.project-panel.open.nearby {
  border-color: rgba(168,85,247,.5);
  box-shadow:
    0 26px 90px rgba(0,0,0,.38),
    0 0 0 1px rgba(168,85,247,.18) inset,
    0 0 44px rgba(168,85,247,.14);
}

@media (max-width: 760px) {
  .minimap {
    display: none;
  }

  .world-tip {
    left: 10px;
    right: 10px;
    bottom: 112px;
    transform: none;
    text-align: center;
  }
}

/* calmer exploration-world overrides */
.minimap {
  width: 142px !important;
  height: 142px !important;
  opacity: .86;
}

.filter-bar {
  background: rgba(9,5,16,.28);
  border-radius: 999px;
  padding: 6px;
  backdrop-filter: blur(14px);
}

.filter-bar button {
  background: rgba(255,255,255,.045);
}

.world-tip {
  opacity: .8;
}

.project-panel {
  width: min(360px, calc(100% - 56px));
}

.project-panel:not(.open) {
  display: block;
}

@media (max-width: 760px) {
  .world-tip {
    bottom: 112px !important;
  }
}

/* Collision/map UI fixes */
.minimap {
  transition: opacity .2s ease, transform .2s ease;
}

.minimap.drawer-hidden {
  opacity: 0 !important;
  transform: translateX(-16px) scale(.96);
  pointer-events: none;
}

.project-drawer.open {
  z-index: 40;
}

.collision-debug {
  display: none;
}
