@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;800&display=swap");

* { margin: 0; padding: 0; box-sizing: border-box; }

:root{
  /* 2AM depressed palette */
  --bg: #040306;
  --panel: rgba(10, 6, 14, 0.86);
  --panel2: rgba(10, 6, 14, 0.72);

  --pink: #C2185B;       /* sad rose */
  --pink2: #E45A84;      /* dusty pink highlight */
  --bruise: #2A1126;     /* border bruise */
  --lav: #9B7BC9;        /* dim lavender */
  --ice: #7FE7FF;        /* tiny cold accent */

  --text: #F2EAF5;
  --muted: rgba(242,234,245,0.72);
}

/* base */
body{
  font-family: "Montserrat", sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(900px 560px at 18% 12%, rgba(194,24,91,0.18), transparent 65%),
    radial-gradient(880px 520px at 78% 22%, rgba(155,123,201,0.10), transparent 60%),
    linear-gradient(rgba(4,3,6,0.94), rgba(4,3,6,0.97));
  position: relative;
  overflow-x: hidden;
}

/* ========= OVERLAYS ========= */
.overlay{
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* rain streaks */
.overlay-rain{
  opacity: 0.30;
  background-image:
    repeating-linear-gradient(
      115deg,
      rgba(255,255,255,0.06) 0px,
      rgba(255,255,255,0.06) 1px,
      transparent 2px,
      transparent 14px
    );
  filter: blur(0.2px);
  animation: rainMove 0.8s linear infinite;
}
@keyframes rainMove{
  0%{ transform: translate3d(-10px, -40px, 0); }
  100%{ transform: translate3d(10px, 40px, 0); }
}

/* drifting particles */
.overlay-particles{
  opacity: 0.55;
  background:
    radial-gradient(circle at 20% 30%, rgba(194,24,91,0.25), transparent 35%),
    radial-gradient(circle at 60% 70%, rgba(228,90,132,0.18), transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(155,123,201,0.16), transparent 38%),
    radial-gradient(circle at 30% 80%, rgba(255,255,255,0.10), transparent 40%);
  mix-blend-mode: screen;
  animation: drift 9s ease-in-out infinite alternate;
}
@keyframes drift{
  0%{ transform: translate3d(-8px, -6px, 0) scale(1); }
  100%{ transform: translate3d(10px, 8px, 0) scale(1.04); }
}

/* vignette = more depressed */
.overlay-vignette{
  background:
    radial-gradient(1200px 800px at 50% 35%, transparent 35%, rgba(0,0,0,0.65) 78%, rgba(0,0,0,0.86) 100%);
  opacity: 0.95;
}

/* ensure content sits above overlays */
.hud-top, .grid, .sao-toast{
  position: relative;
  z-index: 2;
}

/* ========= TOP HUD ========= */
.hud-top{
  position: sticky;
  top: 0;
  z-index: 999;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: center;
  padding: 18px 28px;
  background: rgba(6, 3, 9, 0.90);
  border-bottom: 1px solid rgba(194,24,91,0.22);
  box-shadow: 0 0 22px rgba(194,24,91,0.14);
  backdrop-filter: blur(12px);
}

.hud-title{
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--pink2);
  text-shadow: 0 0 16px rgba(194,24,91,0.28);
}

.hud-sub{
  font-size: 12px;
  opacity: 0.86;
  letter-spacing: 2px;
  color: var(--muted);
}

.hud-nav{
  display: flex;
  gap: 14px;
  justify-content: center;
}

.hud-link{
  text-decoration: none;
  color: rgba(242,234,245,0.92);
  font-weight: 800;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid rgba(194,24,91,0.14);
  background: rgba(194,24,91,0.06);
  box-shadow: 0 0 10px rgba(194,24,91,0.08);
  border-radius: 12px;
}

.hud-link:hover{
  box-shadow: 0 0 18px rgba(194,24,91,0.14);
}

.hud-link.active{
  border-color: rgba(194,24,91,0.26);
  background: rgba(194,24,91,0.08);
  box-shadow: 0 0 20px rgba(194,24,91,0.16);
}

.hud-stats{
  display: flex;
  gap: 14px;
  justify-content: end;
  font-size: 12px;
  opacity: 0.95;
}

.stat b{ color: var(--pink2); }

/* ========= GRID ========= */
.grid{
  padding: 26px 28px 90px;
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  grid-template-areas:
    "profile quest party"
    "profile battle party"
    "syslog syslog syslog";
  gap: 18px;
}

.profile{ grid-area: profile; }
.quest{ grid-area: quest; }
.party{ grid-area: party; }
.battle{ grid-area: battle; }
.syslog{ grid-area: syslog; }

/* ========= PANELS ========= */
.panel{
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid rgba(194,24,91,0.16);
  box-shadow:
    0 0 16px rgba(194,24,91,0.10),
    inset 0 0 18px rgba(194,24,91,0.05);
  backdrop-filter: blur(12px);
  padding: 16px;
  border-radius: 18px;
}

.panel::before{
  content:"";
  position:absolute;
  inset:-2px;
  pointer-events:none;
  background: linear-gradient(90deg, transparent, rgba(194,24,91,0.10), transparent);
  opacity: 0.25;
  transform: translateX(-40%);
}
.panel:hover::before{
  transform: translateX(40%);
  transition: transform 0.9s ease;
}

.panel-head{
  display:flex;
  justify-content: space-between;
  align-items:center;
  margin-bottom: 12px;
  color: var(--pink2);
  letter-spacing: 1px;
  font-weight: 900;
  font-size: 13px;
}

/* chips */
.chip{
  color: rgba(242,234,245,0.92);
  font-weight: 900;
  font-size: 11px;
  padding: 4px 8px;
  border: 1px solid rgba(194,24,91,0.14);
  background: rgba(194,24,91,0.06);
  border-radius: 999px;
}
.chip.pink{ color: var(--pink2); }
.chip.cyan{ color: var(--ice); border-color: rgba(127,231,255,0.14); background: rgba(127,231,255,0.05); }

/* ========= PROFILE ========= */
.avatar{
  height: 190px;
  border: 1px solid rgba(194,24,91,0.14);
  background: rgba(194,24,91,0.04);
  display:flex;
  align-items:center;
  justify-content:center;
  margin-bottom: 12px;
  position: relative;
  border-radius: 18px;
  overflow:hidden;
}

.avatar::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background:
    radial-gradient(400px 240px at 30% 20%, rgba(194,24,91,0.12), transparent 60%),
    radial-gradient(420px 260px at 70% 70%, rgba(155,123,201,0.10), transparent 60%);
  opacity: 0.8;
}

.avatar-img{
  width: 140px;
  height: 140px;
  border-radius: 22px;
  object-fit: cover;
  border: 1px solid rgba(194,24,91,0.22);
  box-shadow: 0 0 18px rgba(194,24,91,0.16);
  z-index: 2;
  filter: saturate(0.9) contrast(1.02);
}

.avatar-silhouette{
  width: 132px;
  height: 132px;
  border-radius: 22px;
  background: radial-gradient(circle at 30% 30%, rgba(194,24,91,0.28), rgba(10,6,14,0.10));
  box-shadow: 0 0 16px rgba(194,24,91,0.16);
  display: none;
  z-index: 1;
}

.avatar.avatar-fallback .avatar-silhouette{ display:block; }

.avatar-glitch{
  position:absolute;
  inset: 0;
  pointer-events:none;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(242,234,245,0.05) 0px,
      rgba(242,234,245,0.05) 1px,
      transparent 2px,
      transparent 10px
    );
  opacity: 0.22;
  mix-blend-mode: overlay;
  animation: glitchScan 4.8s linear infinite;
}
@keyframes glitchScan{
  0%{ transform: translateY(-18px); }
  100%{ transform: translateY(18px); }
}

.profile-name{
  font-weight: 900;
  letter-spacing: 1px;
  font-size: 18px;
}

.profile-meta{
  opacity: 0.9;
  font-size: 12px;
  margin-top: 4px;
  color: var(--muted);
}

.divider{
  height: 1px;
  background: rgba(194,24,91,0.14);
  margin: 14px 0;
}

.mini-title{
  color: rgba(228,90,132,0.92);
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

/* Bars */
.bar-wrap{ margin-top: 10px; }
.bar-label{
  font-size: 11px;
  opacity: 0.92;
  margin-bottom: 6px;
  letter-spacing: 1px;
  color: var(--muted);
}

.bar{
  height: 10px;
  background: rgba(194,24,91,0.07);
  border: 1px solid rgba(194,24,91,0.14);
  overflow: hidden;
  border-radius: 999px;
}

.fill{
  height: 100%;
  background: linear-gradient(90deg, rgba(194,24,91,0.96), rgba(228,90,132,0.62));
  box-shadow: 0 0 12px rgba(194,24,91,0.20);
}

.fill.ep{
  background: linear-gradient(90deg, rgba(228,90,132,0.86), rgba(155,123,201,0.40));
}

.bar-value{
  font-size: 11px;
  opacity: 0.86;
  margin-top: 6px;
  color: var(--muted);
}

/* ========= LISTS / BIO ========= */
.list{
  list-style: none;
  display:flex;
  flex-direction: column;
  gap: 8px;
}
.list li{ opacity: 0.92; color: rgba(242,234,245,0.84); }

.quests{
  list-style:none;
  display:flex;
  flex-direction: column;
  gap: 10px;
}

.quests li{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 10px 10px;
  border: 1px solid rgba(194,24,91,0.14);
  background: rgba(194,24,91,0.05);
  border-radius: 14px;
}

.q-dot{
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--pink2);
  box-shadow: 0 0 10px rgba(194,24,91,0.35);
}

.tag{
  margin-left: auto;
  font-size: 11px;
  font-weight: 900;
  padding: 4px 8px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 999px;
}

/* keep tags readable but muted */
.tag.yellow{ color: #ffd86b; border-color: rgba(255,216,107,0.18); background: rgba(255,216,107,0.05); }
.tag.green{ color: #67ffb7; border-color: rgba(103,255,183,0.16); background: rgba(103,255,183,0.05); }
.tag.red{ color: #ff6b9b; border-color: rgba(255,107,155,0.16); background: rgba(255,107,155,0.05); }

/* vibes chips */
.chips-row{
  display:flex;
  flex-wrap: wrap;
  gap: 10px;
}
.soft-chip{
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(194,24,91,0.12);
  background: rgba(194,24,91,0.04);
  color: rgba(242,234,245,0.84);
}

/* ========= FRIEND SIGNALS ========= */
.member{
  display:flex;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(194,24,91,0.12);
  background: rgba(194,24,91,0.04);
  margin-bottom: 10px;
  border-radius: 14px;
}

.pfp{
  width: 44px; height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(194,24,91,0.18);
  background: radial-gradient(circle at 30% 30%, rgba(194,24,91,0.22), rgba(10,6,14,0.10));
  box-shadow: 0 0 12px rgba(194,24,91,0.10);
}

.pfp2{ background: radial-gradient(circle at 30% 30%, rgba(228,90,132,0.18), rgba(10,6,14,0.10)); }
.pfp3{ background: radial-gradient(circle at 30% 30%, rgba(155,123,201,0.16), rgba(10,6,14,0.10)); }

.m-name{ font-weight: 900; letter-spacing: 1px; }
.lvl{ opacity: 0.85; font-weight: 900; margin-left: 6px; font-size: 12px; color: rgba(242,234,245,0.76); }

.m-bar{
  height: 8px;
  border: 1px solid rgba(194,24,91,0.12);
  background: rgba(194,24,91,0.05);
  margin-top: 8px;
  overflow:hidden;
  border-radius: 999px;
}

.m-fill{
  height:100%;
  background: linear-gradient(90deg, rgba(194,24,91,0.92), rgba(228,90,132,0.58));
  box-shadow: 0 0 10px rgba(194,24,91,0.16);
}

.m-sub{ font-size: 11px; opacity: 0.88; margin-top: 6px; color: var(--muted); }

/* ========= SYSTEM LOG ========= */
.syslog .terminal{
  position: relative;
  border: 1px solid rgba(194,24,91,0.12);
  background: rgba(0,0,0,0.22);
  border-radius: 16px;
  padding: 14px 14px;
  overflow: hidden;
  min-height: 170px;
}

.syslog .terminal::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background: linear-gradient(180deg, transparent, rgba(194,24,91,0.06), transparent);
  animation: termScan 5s linear infinite;
  opacity: 0.45;
}
@keyframes termScan{
  0%{ transform: translateY(-100%); }
  100%{ transform: translateY(100%); }
}

.term-line{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.65;
  color: rgba(242,234,245,0.84);
  display:flex;
  gap: 10px;
}

.term-time{
  color: rgba(228,90,132,0.88);
  min-width: 88px;
}
.term-gap{ height: 10px; }
.term-ok{ color: rgba(103,255,183,0.88); }
.term-warn{ color: #ffd86b; }
.term-bad{ color: #ff6b9b; font-weight: 900; }
.term-dim{ color: rgba(242,234,245,0.58); }

/* ========= TOAST ========= */
.sao-toast{
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: min(520px, calc(100vw - 48px));
  background: rgba(6, 3, 9, 0.92);
  border: 1px solid rgba(194,24,91,0.18);
  box-shadow: 0 0 22px rgba(194,24,91,0.14);
  backdrop-filter: blur(12px);
  padding: 14px 14px 18px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  overflow:hidden;
  z-index: 2000;
  border-radius: 18px;
}

.sao-toast.show{
  opacity: 1;
  transform: translateY(0);
}

.sao-toast-header{
  color: rgba(228,90,132,0.95);
  letter-spacing: 1px;
  font-weight: 900;
  margin-bottom: 6px;
}

.sao-toast-body{ opacity: 0.92; color: rgba(242,234,245,0.84); }

.sao-toast-close{
  position:absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: 1px solid rgba(194,24,91,0.14);
  color: rgba(242,234,245,0.92);
  width: 30px;
  height: 30px;
  border-radius: 12px;
  cursor: pointer;
}

.sao-toast-close:hover{
  box-shadow: 0 0 14px rgba(194,24,91,0.14);
}

/* timer line */
.sao-toast-progress{
  position:absolute;
  left:0;
  bottom:0;
  width:100%;
  height: 3px;
  background: linear-gradient(90deg, rgba(194,24,91,1), rgba(228,90,132,0.78));
  box-shadow: 0 0 10px rgba(194,24,91,0.18);
  transform-origin: left;
  transform: scaleX(1);
}
@keyframes toastTimer{
  from{ transform: scaleX(1); }
  to{ transform: scaleX(0); }
}

/* typing caret */
.caret{
  display: inline-block;
  margin-left: 2px;
  opacity: 0.9;
  animation: blink 0.9s steps(2, end) infinite;
}
@keyframes blink{
  0%, 49%{ opacity: 1; }
  50%, 100%{ opacity: 0; }
}

/* ===== GLITCH TITLE ===== */
.glitch{
  position: relative;
  display: inline-block;
  white-space: nowrap;
}
.glitch::before,
.glitch::after{
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  overflow: hidden;
  pointer-events: none;
  opacity: 0.78;
}
.glitch::before{
  transform: translate(1px, 0);
  color: rgba(127,231,255,0.55);
  clip-path: inset(0 0 60% 0);
  animation: glitchTop 2.8s infinite linear alternate-reverse;
}
.glitch::after{
  transform: translate(-1px, 0);
  color: rgba(228,90,132,0.85);
  clip-path: inset(55% 0 0 0);
  animation: glitchBot 2.2s infinite linear alternate-reverse;
}
@keyframes glitchTop{
  0%{ clip-path: inset(0 0 60% 0); transform: translate(1px, 0); }
  20%{ clip-path: inset(0 0 42% 0); transform: translate(2px, -1px); }
  40%{ clip-path: inset(0 0 72% 0); transform: translate(0px, 1px); }
  60%{ clip-path: inset(0 0 52% 0); transform: translate(2px, 0px); }
  80%{ clip-path: inset(0 0 66% 0); transform: translate(1px, -1px); }
  100%{ clip-path: inset(0 0 56% 0); transform: translate(0px, 0px); }
}
@keyframes glitchBot{
  0%{ clip-path: inset(55% 0 0 0); transform: translate(-1px, 0); }
  20%{ clip-path: inset(46% 0 0 0); transform: translate(-2px, 1px); }
  40%{ clip-path: inset(66% 0 0 0); transform: translate(0px, -1px); }
  60%{ clip-path: inset(51% 0 0 0); transform: translate(-2px, 0px); }
  80%{ clip-path: inset(63% 0 0 0); transform: translate(-1px, 1px); }
  100%{ clip-path: inset(58% 0 0 0); transform: translate(0px, 0px); }
}

/* ========= RESPONSIVE ========= */
@media (max-width: 980px){
  .grid{
    grid-template-columns: 1fr;
    grid-template-areas:
      "profile"
      "quest"
      "party"
      "battle"
      "syslog";
  }
  .hud-top{
    grid-template-columns: 1fr;
    text-align: center;
  }
  .hud-stats{ justify-content: center; flex-wrap: wrap; }
  .hud-nav{ flex-wrap: wrap; }
}

/* ===== AVATAR FIX: keep overlays BEHIND the image ===== */
.avatar{
  position: relative; /* ensure stacking context */
}

.avatar::after{
  z-index: 0;         /* background glow layer */
}

.avatar-glitch{
  z-index: 1;         /* scanlines layer */
}

.avatar-img{
  position: relative; /* make z-index apply */
  z-index: 3;         /* above overlays */
}

.avatar-silhouette{
  position: relative;
  z-index: 2;         /* fallback above overlays, below img */
}

/* OPTIONAL: if you want the scanlines to be SUPER subtle over the whole box,
   but NOT over the face, you can clip them away from the image area: */
.avatar-glitch{
  opacity: 0.12;      /* softer so it doesn’t “cover” */
}
