/* Crimson Noir Theme — Native Mobile Responsive & Desktop Polish */

:root {
  --color-surface: #121214;
  --color-surface-dark: #0a0a0c;
  --color-surface-container: #18181c;
  --color-primary-crimson: #dc143c;
  --color-primary-glow: rgba(220, 20, 60, 0.2);
  --color-text-main: #ffffff;
  --color-text-muted: #a0a0a5;
  --font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
}

html {
  scroll-behavior: smooth;
  font-family: var(--font-family);
  background-color: var(--color-surface);
  color: var(--color-text-main);
  -webkit-tap-highlight-color: transparent;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 5px;
}
::-webkit-scrollbar-track {
  background: #0a0a0c;
}
::-webkit-scrollbar-thumb {
  background: #252528;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #dc143c;
}

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

.animate-fadeIn {
  animation: fadeIn 0.3s ease-out forwards;
}

/* 1. Hero Atmosphere — Minimal & Editorial */
.hero-atmosphere {
  position: relative;
  background-color: #121214;
  background-image: radial-gradient(circle 350px at 85% 40%, rgba(220, 20, 60, 0.1) 0%, transparent 80%);
}

/* 2. Primary CTA Crimson Button */
.btn-primary-crimson {
  background-color: #dc143c;
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(220, 20, 60, 0.3);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary-crimson:hover {
  background-color: #e51740;
  box-shadow: 0 6px 20px rgba(220, 20, 60, 0.45);
  transform: translateY(-1px);
}

.btn-primary-crimson:active {
  transform: translateY(0) scale(0.98);
}

/* 3. Section Transition — Editorial Light White Contrast */
.section-work-container {
  background-color: #f4f4f6;
  box-shadow: 
    0 -20px 40px -10px rgba(0, 0, 0, 0.5),
    0 -1px 0 rgba(255, 255, 255, 0.8);
}

/* 4. Featured Project Cards — Pristine White Surface */
.project-card-depth {
  background-color: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 
    0 10px 28px -8px rgba(0, 0, 0, 0.08),
    0 2px 6px -1px rgba(0, 0, 0, 0.04);
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.project-card-depth:hover {
  transform: translateY(-6px);
  box-shadow: 
    0 20px 40px -12px rgba(0, 0, 0, 0.16),
    0 6px 20px rgba(220, 20, 60, 0.12);
  border-color: rgba(220, 20, 60, 0.3);
}

.card-arrow-btn {
  background-color: #dc143c;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(220, 20, 60, 0.35);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.35s ease, background-color 0.35s ease;
}

.project-card-depth:hover .card-arrow-btn {
  transform: rotate(45deg) scale(1.08);
  box-shadow: 0 6px 20px rgba(220, 20, 60, 0.6);
}

/* Tech Tag Pills */
.tech-pill {
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: #444444;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  transition: all 0.2s ease;
}

.project-card-depth:hover .tech-pill {
  background: rgba(220, 20, 60, 0.08);
  border-color: rgba(220, 20, 60, 0.2);
  color: #dc143c;
}

/* 5. Metric Cards Lift */
.metric-card-lift {
  background-color: #18181c;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top: 2px solid #dc143c;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.metric-card-lift:hover {
  transform: translateY(-4px);
  border-top-color: #e51740;
  box-shadow: 
    0 16px 36px -10px rgba(0, 0, 0, 0.7),
    0 0 20px rgba(220, 20, 60, 0.15);
}

/* 6. Refined Compact Skill Cards */
.skill-card-compact {
  background-color: #18181c;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.75rem;
  transition: border-color 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

.skill-card-compact:hover {
  border-color: rgba(220, 20, 60, 0.3);
  background-color: #1c1c20;
  transform: translateY(-2px);
}

/* 7. Native Mobile & Desktop Floating AI Chat Widget Window */
.floating-chat-window {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100vw;
  max-width: 100vw;
  height: 84vh;
  height: 84dvh;
  max-height: 84vh;
  max-height: 84dvh;
  z-index: 60;
  background-color: #18181c;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  border-top-left-radius: 1.25rem;
  border-top-right-radius: 1.25rem;
  box-shadow: 
    0 -10px 40px rgba(0, 0, 0, 0.9),
    0 0 40px rgba(220, 20, 60, 0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, visibility 0.3s ease;
}

.floating-chat-window.active {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

/* Desktop Floating Chat Positioning */
@media (min-width: 640px) {
  .floating-chat-window {
    bottom: 5.5rem;
    left: auto;
    right: 1.5rem;
    width: 390px;
    max-width: calc(100vw - 2rem);
    height: 540px;
    max-height: calc(100vh - 7rem);
    max-height: calc(100dvh - 7rem);
    border-radius: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    transform: scale(0.9) translateY(20px);
  }

  .floating-chat-window.active {
    transform: scale(1) translateY(0);
  }
}

.floating-chat-fab {
  position: fixed;
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  right: 1.25rem;
  z-index: 40;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 9999px;
  background-color: #dc143c;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 
    0 8px 25px rgba(220, 20, 60, 0.55),
    0 2px 10px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease;
}

.floating-chat-fab:hover {
  transform: scale(1.08);
  background-color: #e51740;
}

.floating-chat-fab:active {
  transform: scale(0.95);
}

/* 8. Mobile-Optimized Application Demo Workspace */
.demo-iframe-wrapper {
  width: 100%;
  height: 100%;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #0d0d0f;
}

.demo-iframe-wrapper iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Interactive Mobile Phone Device Frame Mode for Desktop */
.demo-frame-mobile {
  width: 100%;
  max-width: 390px;
  height: 100%;
  max-height: 780px;
  margin: 0 auto;
  border-radius: 36px;
  border: 8px solid #222226;
  box-shadow: 
    0 25px 60px -15px rgba(0, 0, 0, 0.9),
    0 0 35px rgba(220, 20, 60, 0.25);
  overflow: hidden;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* On physical mobile screens (<640px), render native edge-to-edge touch screen */
@media (max-width: 639px) {
  .demo-frame-mobile {
    max-width: 100%;
    max-height: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

/* Modal Overlay & Drawers */
.modal-overlay {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  transform: translateY(40px) scale(0.97);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-container {
  transform: translateY(0) scale(1);
}

.drawer-overlay {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.drawer-overlay.active {
  opacity: 1;
  visibility: visible;
}

.drawer-content {
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.drawer-overlay.active .drawer-content {
  transform: translateX(0);
}

/* 10. Pixel-gothic atmosphere (hero embers, blood moon, bats, dividers) */
.ember-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.hero-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.028) 0px,
    rgba(255, 255, 255, 0.028) 1px,
    transparent 1px,
    transparent 4px
  );
}

.blood-moon {
  position: absolute;
  top: 9%;
  right: 7%;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  overflow: hidden;
  z-index: 1;
  opacity: 0.92;
  background: radial-gradient(circle at 38% 32%, #ff5d73 0%, #dc143c 42%, #5d0a1c 76%, #2a050d 100%);
  box-shadow:
    0 0 60px 12px rgba(220, 20, 60, 0.35),
    0 0 140px 44px rgba(220, 20, 60, 0.14);
  animation: moon-breathe 7s ease-in-out infinite;
}

.blood-moon::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 48%;
  bottom: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 8px,
    #121214 8px 11px
  );
}

@keyframes moon-breathe {
  0%, 100% { box-shadow: 0 0 60px 12px rgba(220,20,60,0.35), 0 0 140px 44px rgba(220,20,60,0.14); filter: brightness(1); }
  50% { box-shadow: 0 0 74px 16px rgba(220,20,60,0.45), 0 0 160px 52px rgba(220,20,60,0.2); filter: brightness(1.14); }
}

.bat {
  position: absolute;
  left: 0;
  fill: #050507;
  z-index: 2;
  opacity: 0.9;
  pointer-events: none;
}

.bat-1 {
  top: 15%;
  width: 62px;
  animation:
    bat-fly-1 26s linear infinite,
    bat-flap 0.5s ease-in-out infinite alternate;
  animation-delay: -8s, 0s;
}

.bat-2 {
  top: 42%;
  width: 42px;
  animation:
    bat-fly-2 39s linear infinite,
    bat-flap 0.42s ease-in-out infinite alternate-reverse;
  animation-delay: -21s, -3s;
  opacity: 0.7;
}

@keyframes bat-fly-1 {
  0% { transform: translate(-8vw, 0); }
  25% { transform: translate(24vw, -16px); }
  50% { transform: translate(56vw, 10px); }
  75% { transform: translate(84vw, -12px); }
  100% { transform: translate(114vw, 0); }
}

@keyframes bat-fly-2 {
  0% { transform: translate(112vw, 0); }
  30% { transform: translate(72vw, 12px); }
  60% { transform: translate(38vw, -10px); }
  100% { transform: translate(-10vw, 0); }
}

@keyframes bat-flap {
  from { scale: 1 1; }
  to { scale: 1.16 0.55; }
}

.pixel-kicker {
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  letter-spacing: 3px;
  color: #dc143c;
  text-shadow: 0 0 14px rgba(220, 20, 60, 0.5);
}

.flicker {
  animation: candle-flicker 4.5s infinite;
}

@keyframes candle-flicker {
  0%, 100% { opacity: 1; text-shadow: 0 0 22px rgba(220, 20, 60, 0.55); }
  8% { opacity: 0.86; }
  10% { opacity: 1; }
  36% { opacity: 0.92; text-shadow: 0 0 10px rgba(220, 20, 60, 0.35); }
  38% { opacity: 1; text-shadow: 0 0 26px rgba(220, 20, 60, 0.65); }
  70% { opacity: 0.9; }
  72% { opacity: 1; }
}

.pixel-divider {
  height: 20px;
  line-height: 0;
  position: relative;
  z-index: 5;
  margin-bottom: -1px;
}

.pixel-divider svg {
  width: 100%;
  height: 100%;
  display: block;
}

.pixel-divider path {
  fill: #f4f4f6;
}

.pixel-divider-crimson path {
  fill: #dc143c;
}

/* 11. Aspect-fitted demo frames (landscape games fill the popup) */
.demo-frame-fit {
  box-sizing: border-box;
  margin: auto;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.9);
}

.demo-frame-mobile {
  box-sizing: border-box;
}

.demo-frame-mobile.landscape {
  max-width: 100%;
  max-height: 100%;
  border-radius: 26px;
}

/* 12. Floating PLAY ME game button (bottom-left, under the modal) */
.play-me-fab {
  position: fixed;
  left: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, #ff2e55, #dc143c);
  border: 0;
  border-bottom: 4px solid #7d0b22;
  border-radius: 9999px;
  padding: 10px 20px 10px 10px;
  cursor: pointer;
  color: #fff;
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  letter-spacing: 1px;
  box-shadow:
    0 10px 30px rgba(220, 20, 60, 0.45),
    0 2px 10px rgba(0, 0, 0, 0.5);
  animation: play-me-bob 2.4s ease-in-out infinite;
}

.play-me-fab:hover {
  filter: brightness(1.1);
}

.play-me-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  image-rendering: pixelated;
  background: #0a0a0c;
}

.play-me-fallback {
  font-size: 30px;
  line-height: 1;
  padding-left: 4px;
}

.hidden-icon {
  display: none !important;
}

@keyframes play-me-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* 13. RPG pixel stat bars (skill tree + portfolio XP) */
.stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
}

.lvl-badge {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  letter-spacing: 1px;
  color: #ffd23e;
  background: #1a1a20;
  border: 1px solid rgba(220, 20, 60, 0.4);
  padding: 5px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

.stat-bar {
  flex-grow: 1;
  height: 12px;
  background: #141419;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  width: var(--w, 100%);
  background: repeating-linear-gradient(
    90deg,
    #dc143c 0 7px,
    #7d0b22 7px 9px
  );
  box-shadow: 0 0 10px rgba(220, 20, 60, 0.5);
  position: relative;
  overflow: hidden;
}

/* Animated fill when the row reveals (no-JS keeps full bars) */
.js-reveal .stat-fill {
  width: 0;
  transition: width 1.1s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.js-reveal .visible .stat-fill {
  width: var(--w, 100%);
}

/* Light sweep travelling across the bars */
.stat-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.25) 50%, transparent 80%);
  transform: translateX(-100%);
  animation: bar-shimmer 3.2s ease-in-out infinite;
}

@keyframes bar-shimmer {
  0% { transform: translateX(-100%); }
  55%, 100% { transform: translateX(100%); }
}

.xp-wrap {
  max-width: 28rem;
  padding-top: 14px;
}

.xp-label {
  display: flex;
  justify-content: space-between;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  letter-spacing: 1px;
  color: #a0a0a5;
  padding-bottom: 6px;
}

.xp-pct {
  color: #ffd23e;
}

/* 14. Footer social buttons (GitHub + Discord) */
.social-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #18181c;
  color: #a0a0a5;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.social-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex-shrink: 0;
}

.social-btn-icon {
  width: 38px;
  padding: 0;
  justify-content: center;
}

.social-btn:hover {
  color: #fff;
  border-color: #dc143c;
  box-shadow: 0 0 18px rgba(220, 20, 60, 0.35);
}

/* 15. CLICK ME theme-shift button */
.theme-fab {
  position: fixed;
  left: 18px;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0d0714;
  color: #e8e4f0;
  border: 2px solid #8b5cf6;
  padding: 12px 16px;
  cursor: pointer;
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  letter-spacing: 1px;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.45));
  transform: rotate(-2deg);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.theme-fab:hover {
  transform: rotate(0deg) scale(1.05);
  filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.65));
}

body.pixel-gothic .theme-fab {
  border-color: #ff1f38;
  filter: drop-shadow(0 0 12px rgba(255, 31, 56, 0.45));
}

.theme-fab-chip {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  overflow: hidden;
  background: #e8e4f0;
  flex-shrink: 0;
  display: flex;
}

.theme-fab-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 16. Pixel-gothic dark theme (toggled by CLICK ME) */
body.pixel-gothic {
  background-color: #030305;
  color: #ded9ea;
}

body.pixel-gothic ::selection {
  background: #8b5cf6;
  color: #fff;
}

/* CRT scanlines + vignette over everything */
body.pixel-gothic::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  background: radial-gradient(120% 100% at 50% 40%, transparent 52%, rgba(0, 0, 0, 0.55) 100%);
}

body.pixel-gothic::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.2) 0 1px,
    transparent 1px 3px
  );
}

/* Surfaces */
body.pixel-gothic header {
  background: rgba(5, 4, 10, 0.94);
  border-color: rgba(139, 92, 246, 0.25);
}

body.pixel-gothic .hero-atmosphere {
  background-color: #05050a;
  background-image:
    radial-gradient(circle 420px at 85% 30%, rgba(139, 92, 246, 0.14) 0%, transparent 75%),
    radial-gradient(circle 300px at 10% 80%, rgba(255, 31, 56, 0.08) 0%, transparent 70%);
}

body.pixel-gothic #about {
  background: #040407;
}

body.pixel-gothic footer {
  background: #030305;
  border-color: rgba(139, 92, 246, 0.18);
}

/* Utility re-mapping (dark surfaces, bone text, blood accents) */
body.pixel-gothic .bg-\[\#121214\] { background-color: #0b0b14; }
body.pixel-gothic .bg-\[\#18181c\] { background-color: #10101a; }
body.pixel-gothic .bg-\[\#0a0a0c\] { background-color: #05050a; }
body.pixel-gothic .bg-\[\#0d0d0f\] { background-color: #07070d; }
body.pixel-gothic .bg-\[\#dc143c\]\/10 { background-color: rgba(139, 92, 246, 0.1); }
body.pixel-gothic .bg-\[\#dc143c\]\/15 { background-color: rgba(139, 92, 246, 0.15); }
body.pixel-gothic .text-white { color: #e8e4f2; }
body.pixel-gothic .text-\[\#a0a0a5\] { color: #8f8aa3; }
body.pixel-gothic .text-\[\#dc143c\] { color: #ff2e4d; }
body.pixel-gothic .border-white\/10 { border-color: rgba(139, 92, 246, 0.22); }
body.pixel-gothic .border-white\/5 { border-color: rgba(139, 92, 246, 0.12); }
body.pixel-gothic .border-\[\#dc143c\]\/30 { border-color: rgba(139, 92, 246, 0.35); }
body.pixel-gothic .border-\[\#dc143c\]\/40 { border-color: rgba(139, 92, 246, 0.4); }
body.pixel-gothic .divide-white\/10 > :not([hidden]) ~ :not([hidden]) {
  border-color: rgba(139, 92, 246, 0.22);
}

/* Pixel headings */
body.pixel-gothic #home h1 {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(26px, 5.5vw, 58px);
  line-height: 1.4;
}

body.pixel-gothic #about h2 {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(17px, 3.2vw, 30px);
  line-height: 1.6;
}

body.pixel-gothic #about h3 {
  font-family: "Press Start 2P", monospace;
  font-size: 16px;
  line-height: 1.7;
}

body.pixel-gothic #about h4 {
  letter-spacing: 0.5px;
}

/* Components go squared + purple */
body.pixel-gothic .btn-primary-crimson {
  background: linear-gradient(180deg, #b31230, #6d0a1e);
  border-radius: 4px;
}

body.pixel-gothic .play-me-fab {
  background: linear-gradient(180deg, #8b5cf6, #5b21b6);
  border-bottom-color: #2e1065;
  border-radius: 6px;
}

body.pixel-gothic .floating-chat-fab {
  background-color: #2a1650;
  border: 2px solid #8b5cf6;
}

body.pixel-gothic .social-btn {
  background: #0b0b14;
  border-radius: 6px;
}

body.pixel-gothic .blood-moon {
  background: radial-gradient(circle at 38% 32%, #c4b5fd 0%, #8b5cf6 42%, #3b1470 76%, #150826 100%);
}

body.pixel-gothic .pixel-divider-crimson path {
  fill: #8b5cf6;
}

body.pixel-gothic .stat-fill {
  background: repeating-linear-gradient(
    90deg,
    #8b5cf6 0 7px,
    #4c1d95 7px 9px
  );
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

body.pixel-gothic .lvl-badge {
  color: #c4b5fd;
}

body.pixel-gothic .xp-pct {
  color: #c4b5fd;
}

/* 17. Phone hardening: overflow guard, tap polish, home-indicator clearance */
html,
body {
  overflow-x: hidden;
  overflow-x: clip;
}

html {
  touch-action: manipulation;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

#chat-form {
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
}

/* 18. Hidden scrollbars (scrolling still works everywhere) */
html {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;
  width: 0;
}

#chat-messages,
.demo-iframe-wrapper,
.floating-chat-window {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#chat-messages::-webkit-scrollbar,
.demo-iframe-wrapper::-webkit-scrollbar,
.floating-chat-window::-webkit-scrollbar {
  display: none;
  width: 0;
}

/* 19. Drifting hero fog */
.fog {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
  z-index: 1;
  opacity: 0.5;
}

.fog-1 {
  width: 420px;
  height: 200px;
  left: -120px;
  bottom: -60px;
  background: rgba(139, 92, 246, 0.1);
  animation: fog-drift 26s ease-in-out infinite alternate;
}

.fog-2 {
  width: 520px;
  height: 240px;
  right: -160px;
  top: -40px;
  background: rgba(220, 20, 60, 0.08);
  animation: fog-drift 32s ease-in-out infinite alternate-reverse;
}

@keyframes fog-drift {
  from { transform: translateX(-40px); }
  to { transform: translateX(60px); }
}

/* 20. Periodic RGB glitch on the hero name */
.glitch {
  position: relative;
  display: inline-block;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.glitch::before {
  color: #ff1f38;
  animation: glitch-a 7s infinite;
}

.glitch::after {
  color: #8b5cf6;
  animation: glitch-b 7s infinite;
}

@keyframes glitch-a {
  0%, 91%, 100% { opacity: 0; }
  92% { opacity: 0.85; transform: translate(-5px, 2px); clip-path: inset(10% 0 55% 0); }
  94% { opacity: 0.85; transform: translate(5px, -2px); clip-path: inset(50% 0 20% 0); }
  96% { opacity: 0.85; transform: translate(-3px, 1px); clip-path: inset(30% 0 40% 0); }
  98% { opacity: 0; }
}

@keyframes glitch-b {
  0%, 91%, 100% { opacity: 0; }
  93% { opacity: 0.85; transform: translate(4px, -2px); clip-path: inset(60% 0 10% 0); }
  95% { opacity: 0.85; transform: translate(-4px, 2px); clip-path: inset(15% 0 65% 0); }
  97% { opacity: 0.85; transform: translate(3px, -1px); clip-path: inset(40% 0 35% 0); }
  98% { opacity: 0; }
}

/* 21. Scroll reveals (JS adds .js-reveal; no-JS keeps content visible) */
.js-reveal .reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.7s ease, transform 0.7s ease;
  transition-delay: var(--rd, 0ms);
}

.js-reveal .reveal.visible {
  opacity: 1;
  transform: none;
}

/* 22. Cursor glow follower + click sparks (fine pointers only) */
.cursor-glow {
  position: fixed;
  left: -90px;
  top: -90px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 65;
  background: radial-gradient(circle, rgba(220, 20, 60, 0.14), transparent 65%);
}

body.pixel-gothic .cursor-glow {
  background: radial-gradient(circle, rgba(139, 92, 246, 0.16), transparent 65%);
}

.spark-canvas {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
}

@media (pointer: coarse) {
  .cursor-glow,
  .spark-canvas {
    display: none;
  }
}

/* 23. Theme-swap polish: smooth crossfade + flash + wipe */
.theme-anim,
.theme-anim *,
.theme-anim *::before,
.theme-anim *::after {
  transition: background-color 0.6s ease, color 0.6s ease, border-color 0.6s ease, box-shadow 0.6s ease, fill 0.6s ease !important;
}

.theme-flash {
  position: fixed;
  inset: 0;
  z-index: 9997;
  pointer-events: none;
  background: radial-gradient(circle at 50% 60%, rgba(139, 92, 246, 0.35), transparent 70%);
  animation: theme-flash-fade 0.65s ease forwards;
}

@keyframes theme-flash-fade {
  from { opacity: 1; }
  to { opacity: 0; }
}

.theme-wipe {
  position: fixed;
  top: 0;
  bottom: 0;
  left: -20%;
  width: 16%;
  z-index: 9997;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.28), transparent);
  animation: theme-wipe-go 0.7s ease forwards;
}

@keyframes theme-wipe-go {
  from { transform: translateX(0); }
  to { transform: translateX(90vw); }
}

@media (prefers-reduced-motion: reduce) {
  .fog,
  .glitch::before,
  .glitch::after,
  .theme-flash,
  .theme-wipe {
    animation: none;
    display: none;
  }

  .fog {
    display: none;
  }

  .js-reveal .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .stat-fill {
    transition: none;
  }

  .stat-fill::after {
    animation: none;
    display: none;
  }
}

/* 24. Compact floating buttons on phones (icon-only, tighter stack) */
@media (max-width: 640px) {
  .blood-moon {
    width: 72px;
    height: 72px;
    top: 6%;
    right: 8%;
  }

  .bat-1 { width: 46px; }
  .bat-2 { width: 32px; }

  .pixel-kicker {
    font-size: 8px;
    letter-spacing: 2px;
  }

  .play-me-fab {
    left: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    width: 54px;
    height: 54px;
    padding: 0;
    justify-content: center;
    gap: 0;
    border-radius: 50%;
  }

  body.pixel-gothic .play-me-fab {
    border-radius: 50%;
  }

  .play-me-fab .play-me-label {
    display: none;
  }

  .play-me-fab .play-me-icon {
    width: 30px;
    height: 30px;
  }

  .play-me-fab .play-me-fallback {
    font-size: 26px;
    padding-left: 0;
  }

  .theme-fab {
    left: 14px;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    padding: 11px;
    gap: 0;
    transform: rotate(0deg);
  }

  .theme-fab .theme-fab-label {
    display: none;
  }

  .theme-fab-chip {
    width: 30px;
    height: 30px;
  }

  .floating-chat-fab {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
}

/* 25. Auto-hide floating buttons while scrolling down (all screens) */
.play-me-fab,
.theme-fab,
.floating-chat-fab {
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, filter 0.15s ease, background-color 0.2s ease;
}

body.fabs-hidden .play-me-fab,
body.fabs-hidden .theme-fab,
body.fabs-hidden .floating-chat-fab {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .bat,
  .flicker,
  .blood-moon,
  .play-me-fab {
    animation: none;
  }

  .bat {
    display: none;
  }
}
