:root {
  --bg: #060503;
  --bg-deep: #000;
  --ink: #f0ebe0;
  --ink-soft: rgba(240, 235, 224, 0.6);
  --ink-dim: rgba(240, 235, 224, 0.35);
  --accent: #b30000;
  --accent-dim: rgba(179, 0, 0, 0.5);
  --accent-bg: rgba(179, 0, 0, 0.08);
  --card-bg: rgba(10, 4, 4, 0.78);
  --card-border: rgba(179, 0, 0, 0.25);
  --status-online: #9de6a8;
  --status-idle: #f0d48a;
  --status-dnd: #ec9999;
  --status-offline: #555;
  --shell-width: min(500px, 100%);
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --vhs: "VT323", var(--mono);
}

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

html,
body {
  height: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(env(safe-area-inset-top), 2rem) 1.2rem max(env(safe-area-inset-bottom), 5rem);
}

body.locked {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  padding: 0;
}

/* CMD intro gate */
.cmd-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  display: grid;
  place-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  padding: 1.2rem;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.cmd-gate.exit {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}

.cmd {
  width: min(640px, 100%);
  background: #000;
  border: 1px solid #cfcfcf;
  box-shadow: 0 0 0 1px #000, 0 20px 60px rgba(0, 0, 0, 0.8);
  font-family: "Consolas", "Courier New", var(--mono);
  color: #d6d6d6;
  animation: cmdAppear 0.3s ease;
}

@keyframes cmdAppear {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cmd-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: linear-gradient(to bottom, #2b2b2b 0%, #1a1a1a 100%);
  border-bottom: 1px solid #000;
}

.cmd-title {
  font-size: 0.78rem;
  color: #f2f2f2;
  letter-spacing: 0.02em;
}

.cmd-btns {
  display: flex;
  gap: 2px;
}

.cmd-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 22px;
  font-size: 0.75rem;
  color: #eee;
  background: transparent;
}

.cmd-btn.cmd-close:hover {
  background: #c42b1c;
}

.cmd-body {
  padding: 0.8rem 0.9rem 1.2rem;
  font-size: 0.92rem;
  line-height: 1.45;
  min-height: 260px;
  max-height: 70vh;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}

#cmd-out {
  display: inline;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  white-space: pre-wrap;
}

.cmd-cursor {
  display: inline-block;
  color: #d6d6d6;
  animation: cursorBlink 1s steps(2) infinite;
  margin-left: 2px;
}

@keyframes cursorBlink {
  0%, 50%   { opacity: 1; }
  51%, 100% { opacity: 0; }
}

@media (max-width: 520px) {
  .cmd-body { font-size: 0.82rem; }
  .cmd-title { font-size: 0.68rem; }
}

/* Background + VHS (all behind content) */
#background-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(30%) saturate(85%) blur(2px);
  z-index: 0;
}

#particles {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.vignette {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at center, transparent 20%, rgba(0, 0, 0, 0.8) 95%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.15) 40%, rgba(0, 0, 0, 0.75) 100%);
  z-index: 4;
  pointer-events: none;
}

/* Shell / content */
.shell {
  width: var(--shell-width);
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1.2s ease, transform 1.2s ease;
  position: relative;
  z-index: 20;
}

body.entered .shell {
  opacity: 1;
  transform: translateY(0);
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0 1.4rem;
  text-align: center;
}

.avatar-ring {
  position: relative;
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
}

.avatar-ring::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px dashed var(--accent);
  opacity: 0.7;
  animation: avatarSpin 9s linear infinite;
  pointer-events: none;
}

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

.avatar-inner {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  border: 1px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 3px #000, 0 0 20px rgba(179, 0, 0, 0.3);
  position: relative;
  z-index: 1;
}

#discord-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: grayscale(20%) contrast(1.05);
}

.ring-status {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--status-offline);
  border: 2px solid var(--bg);
  z-index: 2;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.ring-status.online { background: var(--status-online); box-shadow: 0 0 10px rgba(157, 230, 168, 0.6); }
.ring-status.idle   { background: var(--status-idle); }
.ring-status.dnd    { background: var(--status-dnd); }

.username {
  font-family: var(--vhs);
  font-weight: 400;
  font-size: clamp(1.8rem, 6vw, 2.3rem);
  letter-spacing: 0.06em;
  color: var(--ink);
  text-transform: lowercase;
}

.subtitle {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  text-transform: lowercase;
}

/* Block — no background, just stacked text */
.block {
  padding: 0;
  background: transparent;
  border: none;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.block-head {
  margin-bottom: 0.2rem;
}

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.block-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: lowercase;
}

.block-title {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.block-sub {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#discord-tag {
  font-family: var(--vhs);
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  color: var(--ink);
}

#activity[hidden] { display: none; }

.activity-body {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  margin-top: 0.4rem;
}

.activity-art {
  position: relative;
  width: 64px;
  height: 64px;
  min-width: 64px;
  flex-shrink: 0;
}

#activity-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 1px solid var(--card-border);
  background: #000;
  display: block;
}

.activity-image-small {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  object-fit: cover;
  background: #000;
  display: none;
}

.activity-image-small[src] { display: block; }

.activity-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.activity-info .block-sub:empty { display: none; }

.elapsed {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: var(--ink-dim);
  text-transform: uppercase;
}

#discord-tag.typing::after,
#discord-tag.typed::after {
  content: "▊";
  margin-left: 2px;
  color: var(--accent);
  animation: cursorBlink 0.8s step-end infinite;
}

/* Signal dot */
.signal-dot {
  width: 7px;
  height: 7px;
  background: var(--status-offline);
  transition: background 0.3s ease;
  flex-shrink: 0;
}
.signal-dot[data-state="live"]     { background: var(--accent); box-shadow: 0 0 8px var(--accent-dim); animation: pulseDot 1.6s ease-out infinite; }
.signal-dot[data-state="paused"]   { background: #c0c0c0; opacity: 0.7; }
.signal-dot[data-state="history"]  { background: rgba(255, 255, 255, 0.4); opacity: 0.6; }
.signal-dot[data-state="loading"]  { background: rgba(255, 255, 255, 0.3); animation: shimmer 1.3s linear infinite; }
.signal-dot[data-state="error"],
.signal-dot[data-state="disabled"] { background: var(--status-offline); opacity: 0.45; }

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(1.25); }
}
@keyframes shimmer {
  0%   { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.08); }
  50%  { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.05); }
  100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.08); }
}

.status-pill {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}
.status-pill.online { color: var(--status-online); border-color: rgba(157, 230, 168, 0.35); }
.status-pill.idle   { color: var(--status-idle); border-color: rgba(240, 212, 138, 0.35); }
.status-pill.dnd    { color: var(--status-dnd); border-color: rgba(236, 153, 153, 0.35); }

/* Socials */
.socials .ab-body { padding-top: 0.9rem; padding-bottom: 1rem; }

.social-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.social-list a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 0.8rem;
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--ink);
  border: 1px solid rgba(179, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.4);
  min-height: 44px;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.social-list a:hover,
.social-list a:focus-visible {
  color: #000;
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.social-list a:active { transform: translateY(0); }
.social-list a:focus-visible { outline: none; }

.social-list a i {
  font-size: 1rem;
  color: var(--accent);
  transition: color 0.2s ease;
}

.social-list a .social-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  transition: color 0.2s ease;
}

.social-list a .social-icon svg {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
}

.social-list a:hover i,
.social-list a:hover .social-icon,
.social-list a:focus-visible i,
.social-list a:focus-visible .social-icon { color: #000; }

/* Footer + mute */
footer {
  position: fixed;
  bottom: max(env(safe-area-inset-bottom), 1rem);
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  font-family: var(--mono);
  letter-spacing: 0.14em;
  font-size: 0.6rem;
  color: var(--ink-dim);
  background: rgba(0, 0, 0, 0.55);
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--card-border);
  opacity: 0;
  transition: opacity 0.8s ease 0.4s;
  z-index: 30;
}

body.entered footer { opacity: 1; }

footer .dot {
  width: 5px;
  height: 5px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-dim);
  animation: pulseDot 2s ease-in-out infinite;
}

.mute-toggle {
  position: fixed;
  top: max(env(safe-area-inset-top), 0.9rem);
  right: max(env(safe-area-inset-right), 0.9rem);
  width: 42px;
  height: 42px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.55);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.6s ease 0.6s, background 0.25s ease, border-color 0.25s ease, color 0.2s ease;
  z-index: 30;
}

body.entered .mute-toggle { opacity: 1; }

.mute-toggle:hover,
.mute-toggle:focus-visible {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  outline: none;
}

.mute-toggle i { font-size: 1rem; }

/* Responsive */
@media (max-width: 480px) {
  .block { padding: 0.8rem 0.85rem; }
  .block-title { font-size: 0.9rem; }
  .block-sub { font-size: 0.74rem; }
  #discord-tag { font-size: 1.2rem; }
  .social-list { grid-template-columns: 1fr 1fr; }
  .social-list a { padding: 0.7rem 0.6rem; font-size: 0.68rem; }
  .hero { padding: 0.4rem 0 1rem; }
  .avatar-ring { width: 76px; height: 76px; }
  footer { bottom: 0.8rem; }
}

@media (max-width: 340px) {
  .social-list { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.2s !important;
  }
}
