/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #3B6FE0;
  --text-dark: #2A2A2A;
  --text-mid:  #888884;
  --text-light: #AEADA9;
  --bg-overlay: transparent;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: -apple-system, 'Inter', 'Helvetica Neue', Arial, sans-serif;
  cursor: none;
  background: #F9F8F6;
}

body.night { --text-mid: #666662; }

/* ===== CANVAS ===== */
#c {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ===== LABEL LAYER (Three.js → 2D projection) ===== */
.labels-wrap {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.b-label-item {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  pointer-events: all;
  cursor: pointer;
  transition: opacity 0.2s;
  padding: 6px 8px;
}

.bl-num {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text-light);
  text-transform: uppercase;
}

.bl-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}

.bl-name {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--blue);
  text-transform: uppercase;
  white-space: nowrap;
}

.b-label-item.hovered .bl-name {
  opacity: 0.7;
}

/* ===== UI CHROME ===== */
.ui-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  z-index: 100;
  pointer-events: none;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  pointer-events: all;
  cursor: pointer;
}

.logo-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--blue);
  flex-shrink: 0;
}

.logo-name {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-dark);
  text-transform: uppercase;
}

.ui-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  pointer-events: all;
}

.nav-link {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-mid);
  text-decoration: none;
  text-transform: uppercase;
  transition: color 0.2s;
  cursor: pointer;
}
.nav-link:hover { color: var(--blue); }

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  width: 22px; height: 22px;
  color: var(--text-mid);
  position: relative;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s;
}
.theme-toggle:hover { color: var(--blue); }

.theme-toggle svg {
  width: 17px; height: 17px;
  position: absolute;
  transition: opacity 0.3s, transform 0.3s;
}
body.day  .icon-moon { opacity: 0; transform: rotate(-20deg) scale(0.7); }
body.day  .icon-sun  { opacity: 1; transform: none; }
body.night .icon-sun  { opacity: 0; transform: rotate(20deg) scale(0.7); }
body.night .icon-moon { opacity: 1; transform: none; }

/* ===== WELCOME ===== */
.welcome-block {
  position: fixed;
  top: 78px; left: 28px;
  z-index: 100;
  pointer-events: none;
}

.welcome-main {
  font-size: 21px;
  font-weight: 300;
  line-height: 1.38;
  color: var(--text-dark);
  letter-spacing: -0.01em;
}

.welcome-sub {
  margin-top: 7px;
  font-size: 10.5px;
  color: var(--text-light);
  letter-spacing: 0.04em;
}

.welcome-accent {
  margin-top: 10px;
  width: 26px; height: 2px;
  background: var(--blue);
  border-radius: 1px;
}

/* ===== YOU BLOCK ===== */
.you-block {
  position: fixed;
  bottom: 28px; left: 28px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.you-person {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.yp-head {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #A8C8F8;
}

.yp-body {
  width: 12px; height: 9px;
  border-radius: 3px 3px 2px 2px;
  background: var(--blue);
}

.you-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.you-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--blue);
  text-transform: uppercase;
}

.you-sub {
  font-size: 9px;
  color: var(--text-light);
  letter-spacing: 0.03em;
}

/* ===== TRANSITION OVERLAY ===== */
.transition-overlay {
  position: fixed;
  inset: 0;
  background: var(--blue);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transform-origin: center;
  border-radius: 0;
}

/* ===== MOBILE ===== */
@media (max-width: 680px) {
  html, body { overflow: auto; cursor: auto; }

  #c { position: fixed; }

  .labels-wrap { display: none; }

  .you-block { display: none; }

  .welcome-block { top: 68px; }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  .b-label-item, .welcome-block, .you-block, .ui-header { transition: none !important; }
}

/* ===== LOGO USER TAG ===== */
.logo-user {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-light);
  letter-spacing: 0.06em;
  margin-left: 2px;
}

/* ===== LOGIN OVERLAY ===== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(249,248,246,0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 600;
  transition: opacity 0.5s ease;
}
.login-overlay.hidden { opacity: 0; pointer-events: none; }

.login-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  text-align: center;
  padding: 52px 48px 48px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 48px rgba(0,0,0,0.08), 0 2px 12px rgba(0,0,0,0.04);
  max-width: 360px;
  width: 90%;
}

.login-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--blue);
  margin-bottom: 24px;
  display: block;
}

.login-title {
  font-size: 24px;
  font-weight: 300;
  color: var(--text-dark);
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}

.login-sub {
  font-size: 12px;
  color: var(--text-light);
  letter-spacing: 0.04em;
  margin-bottom: 28px;
}

.login-input {
  width: 100%;
  border: none;
  border-bottom: 1.5px solid #E8E7E4;
  padding: 10px 0;
  font-size: 16px;
  font-weight: 400;
  color: var(--text-dark);
  background: transparent;
  outline: none;
  text-align: center;
  font-family: inherit;
  letter-spacing: 0.02em;
  transition: border-color 0.2s;
  margin-bottom: 32px;
}
.login-input:focus { border-bottom-color: var(--blue); }
.login-input::placeholder { color: var(--text-light); }

.login-btn {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 28px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  font-family: inherit;
}
.login-btn:hover { opacity: 0.85; transform: translateY(-1px); }
.login-btn:active { transform: none; }

/* ===== STATS PANEL ===== */
.stats-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 360px;
  background: rgba(250,249,247,0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid rgba(0,0,0,0.06);
  z-index: 400;
  transform: translateX(100%);
  transition: transform 0.42s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.stats-panel.open { transform: translateX(0); }

.sp-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  flex-shrink: 0;
}

.sp-title {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text-light);
  flex: 1;
}

.sp-modes {
  display: flex;
  gap: 2px;
  background: #EEEDE A;
  background: rgba(0,0,0,0.05);
  border-radius: 7px;
  padding: 3px;
}

.sp-mode {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-mid);
  background: none;
  border: none;
  border-radius: 5px;
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.18s, color 0.18s;
}
.sp-mode.active {
  background: #fff;
  color: var(--text-dark);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.sp-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-light);
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.2s;
  font-family: inherit;
}
.sp-close:hover { color: var(--text-dark); }

.sp-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 22px;
}
.sp-body::-webkit-scrollbar { width: 4px; }
.sp-body::-webkit-scrollbar-thumb { background: #E0DFDC; border-radius: 2px; }

/* Clean mode */
.sp-user-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}
.sp-username {
  font-size: 20px;
  font-weight: 300;
  color: var(--text-dark);
  letter-spacing: -0.01em;
}
.sp-level {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--blue);
  background: rgba(59,111,224,0.08);
  padding: 3px 8px;
  border-radius: 20px;
}
.sp-since {
  font-size: 10px;
  color: var(--text-light);
  letter-spacing: 0.03em;
  margin-bottom: 26px;
}

.sp-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 24px;
}
.sp-card {
  background: #F4F3F0;
  border-radius: 12px;
  padding: 16px 14px 14px;
}
.sc-val {
  font-size: 22px;
  font-weight: 300;
  color: var(--text-dark);
  letter-spacing: -0.02em;
  display: block;
  margin-bottom: 4px;
}
.sc-lbl {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-light);
  text-transform: uppercase;
}

.sp-prog-section { margin-bottom: 24px; }
.sp-prog-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-light);
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}
.sp-prog-label span { font-weight: 400; color: var(--text-mid); }
.sp-prog-track {
  height: 4px;
  background: #EAEAE8;
  border-radius: 2px;
  overflow: hidden;
}
.sp-prog-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.sp-unlocks { }
.sp-ul-title {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-light);
  text-transform: uppercase;
  margin-bottom: 12px;
}
.sp-ul-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.sp-ul-dot {
  font-size: 11px;
  color: var(--text-light);
  width: 14px;
  flex-shrink: 0;
}
.sp-ul-item.done .sp-ul-dot { color: var(--blue); }
.sp-ul-name {
  flex: 1;
  font-size: 11px;
  color: var(--text-mid);
  letter-spacing: 0.02em;
}
.sp-ul-item.done .sp-ul-name { color: var(--text-dark); }
.sp-ul-thresh {
  font-size: 9.5px;
  color: var(--text-light);
  letter-spacing: 0.03em;
}
.sp-all-done {
  font-size: 11px;
  color: var(--blue);
  letter-spacing: 0.04em;
}

/* Raw mode */
.sp-raw {
  font-family: 'SF Mono', 'Fira Code', 'Menlo', 'Courier New', monospace;
  font-size: 10.5px;
  line-height: 1.65;
  color: var(--text-dark);
  white-space: pre;
  overflow-x: auto;
  margin: 0;
  padding-bottom: 20px;
}
.sp-raw-prompt { color: var(--blue); }

/* ===== POPULATION FILTER ===== */
.pop-filter {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 7px;
  pointer-events: all;
}
.pf-label {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-light);
  text-transform: uppercase;
  margin-right: 2px;
}
.pf-btn {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-mid);
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(0,0,0,0.09);
  border-radius: 20px;
  padding: 5px 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  backdrop-filter: blur(6px);
}
.pf-btn:hover { color: var(--blue); border-color: var(--blue); }
.pf-btn.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

/* ===== UNLOCK TOAST ===== */
.unlock-toast {
  position: fixed;
  bottom: -56px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: 30px;
  padding: 10px 20px;
  z-index: 300;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.unlock-toast.show { bottom: 28px; }
.ut-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--blue);
  flex-shrink: 0;
}
.ut-text {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dark);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ===== BUILDING RENAME INPUT ===== */
.bl-rename-input {
  background: none;
  border: none;
  border-bottom: 1px solid var(--blue);
  outline: none;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--blue);
  text-align: center;
  text-transform: uppercase;
  width: 80px;
  font-family: inherit;
  padding: 1px 0;
}

/* ===== NIGHT MODE PANEL ADJUSTMENTS ===== */
body.night .login-box { background: #E8E7E4; }
body.night .sp-card { background: rgba(0,0,0,0.08); }
body.night .pf-btn { background: rgba(0,0,0,0.12); border-color: rgba(0,0,0,0.15); }
body.night .pf-btn.active { background: var(--blue); }
body.night .unlock-toast { background: rgba(220,219,216,0.95); }

@media (max-width: 680px) {
  .pop-filter { display: none; }
  .stats-panel { width: 100%; }
}
