:root {
  --bg: #050505;
  --fg: #00ffcc;
  --accent: #ff00ff;
  --glass: rgba(10, 10, 10, 0.6);
  --glass-border: rgba(255, 255, 255, 0.1);
  --font-main: 'Space Grotesk', sans-serif;
  --font-mono: 'Space Mono', monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-main);
}

/* 3D Background */
#canvas-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
}

/* Cyber Grid */
.cyber-grid {
  position: fixed;
  bottom: -50%;
  left: -50%;
  width: 200%;
  height: 100%;
  background-image: 
    linear-gradient(var(--glass-border) 1px, transparent 1px),
    linear-gradient(90deg, var(--glass-border) 1px, transparent 1px);
  background-size: 40px 40px;
  transform: perspective(500px) rotateX(60deg);
  animation: grid-move 20s linear infinite;
  z-index: -1;
  opacity: 0.3;
  mask-image: linear-gradient(to top, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 60%);
  pointer-events: none;
}

@keyframes grid-move {
  0% { transform: perspective(500px) rotateX(60deg) translateY(0); }
  100% { transform: perspective(500px) rotateX(60deg) translateY(40px); }
}

/* CRT Effects */
.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,0),
    rgba(255,255,255,0) 50%,
    rgba(0,0,0,0.2) 50%,
    rgba(0,0,0,0.2)
  );
  background-size: 100% 4px;
  z-index: 999;
  pointer-events: none;
  opacity: 0.6;
}

.vignette {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, transparent 50%, black 150%);
  z-index: 998;
  pointer-events: none;
}

/* Layout */
.scroller {
  height: 100vh;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  position: relative;
  z-index: 1;
}

.section {
  min-height: 100vh;
  width: 100%;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}

.hero-section {
  height: 100vh;
}

.widgets-section {
  min-height: 100vh;
  height: auto;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  padding: 60px 20px 60px 20px;
}

/* Typography & Glitch */
h1 {
  font-family: var(--font-mono);
  font-size: 2rem;
  letter-spacing: 0.5rem;
  text-transform: uppercase;
  margin: 0;
  position: relative;
}

.glitch {
  position: relative;
  color: var(--fg);
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
}

.glitch::before {
  left: 2px;
  text-shadow: -1px 0 var(--accent);
  clip: rect(44px, 450px, 56px, 0);
  animation: glitch-anim 5s infinite linear alternate-reverse;
}

.glitch::after {
  left: -2px;
  text-shadow: -1px 0 var(--fg);
  clip: rect(44px, 450px, 56px, 0);
  animation: glitch-anim2 5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
  0% { clip: rect(34px, 9999px, 11px, 0); }
  20% { clip: rect(68px, 9999px, 96px, 0); }
  40% { clip: rect(12px, 9999px, 5px, 0); }
  60% { clip: rect(89px, 9999px, 44px, 0); }
  80% { clip: rect(2px, 9999px, 88px, 0); }
  100% { clip: rect(56px, 9999px, 23px, 0); }
}

@keyframes glitch-anim2 {
  0% { clip: rect(14px, 9999px, 81px, 0); }
  20% { clip: rect(28px, 9999px, 16px, 0); }
  40% { clip: rect(92px, 9999px, 35px, 0); }
  60% { clip: rect(19px, 9999px, 64px, 0); }
  80% { clip: rect(42px, 9999px, 18px, 0); }
  100% { clip: rect(76px, 9999px, 93px, 0); }
}

/* Mood Display */
.mood-container {
  perspective: 1000px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: relative;
}

.mood-container::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  height: 80%;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  opacity: 0.08;
  filter: blur(60px);
  z-index: -1;
  animation: pulse-glow 4s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.08; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.15; transform: translate(-50%, -50%) scale(1.05); }
}

.mood {
  font-size: 6rem;
  font-weight: 700;
  text-transform: uppercase;
  text-align: center;
  color: var(--accent);
  text-shadow: 
    0 0 10px var(--accent),
    0 0 20px var(--accent);
  animation: float 6s ease-in-out infinite;
  mix-blend-mode: normal;
  letter-spacing: 0.05em;
}

.mood-note {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 10px;
  opacity: 0.9;
  animation: float 6s ease-in-out infinite reverse;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotateX(0); }
  50% { transform: translateY(-10px) rotateX(5deg); }
}

/* HUD Panel */
.glass-panel {
  background: var(--glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  padding: 20px;
  border-radius: 4px;
}

.hud-panel {
  position: absolute;
  bottom: 40px;
  right: 40px;
  width: 300px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.hud-header {
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 10px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
}

.hud-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent);
  animation: blink 2s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.hud-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.hud-label {
  opacity: 0.7;
}

.hud-value {
  font-weight: bold;
  color: var(--fg);
}

.hud-footer {
  margin-top: 15px;
  font-size: 0.7rem;
  opacity: 0.5;
  border-top: 1px solid var(--glass-border);
  padding-top: 10px;
}

.blinking-cursor {
  animation: blink 1s step-end infinite;
}

/* Widgets Section */
.widgets-container {
  width: 100%;
  max-width: 1200px;
}

.section-title {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  margin-bottom: 40px;
  border-left: 4px solid var(--accent);
  padding-left: 20px;
}

.widgets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
}

.widget-major {
  grid-column: 1 / -1;
  min-height: 400px;
}

.widget-card {
  min-height: 300px;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.widget-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 40px rgba(0,0,0,0.5);
  border-color: var(--fg);
}

.widget-content {
  flex: 1;
  position: relative;
  width: 100%;
  min-height: 200px;
  overflow: hidden;
}

#wordCloudContainer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  padding: 10px;
  overflow: hidden;
  align-content: center;
}

.widget-content canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.word-cloud-item {
  display: inline-block;
  margin: 4px 8px;
  transition: all 0.3s ease;
  cursor: default;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--fg);
  text-shadow: 0 0 5px var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.word-cloud-item:hover {
  transform: scale(1.3) !important;
  color: var(--accent);
  text-shadow: 0 0 15px var(--accent), 0 0 25px var(--accent);
  z-index: 10;
  filter: none !important;
}

/* Emotion Matrix Widget */
.emotion-matrix-content {
  display: flex;
  gap: 30px;
  padding: 20px;
}

.dominant-emotion-display {
  flex: 0 0 250px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 30px;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  border: 1px solid var(--glass-border);
}

.dominant-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  opacity: 0.6;
  letter-spacing: 3px;
  margin-bottom: 15px;
}

.dominant-value {
  font-family: var(--font-main);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent);
  margin-bottom: 10px;
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { text-shadow: 0 0 10px var(--accent); }
  50% { text-shadow: 0 0 30px var(--accent), 0 0 40px var(--accent); }
}

.dominant-percentage {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  color: var(--fg);
}

.emotion-visualizations {
  flex: 1;
  display: flex;
  gap: 30px;
}

.emotion-radar-container {
  flex: 1;
  position: relative;
  min-height: 300px;
}

.emotion-bars-container {
  flex: 0 0 200px;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  padding: 10px 0;
}

.emotion-bar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 5px 0;
}

.emotion-bar-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  width: 70px;
  text-align: right;
  opacity: 0.8;
  text-transform: uppercase;
}

.emotion-bar-track {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.emotion-bar-fill {
  height: 100%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  transition: width 0.5s ease;
  border-radius: 4px;
}

.emotion-bar-value {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  width: 35px;
  text-align: right;
  opacity: 0.7;
}

.widget-footnote {
  margin-top: 15px;
  padding-top: 10px;
  border-top: 1px solid var(--glass-border);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  opacity: 0.5;
  text-align: center;
}

/* Topic Cluster Widget */
.topic-cluster-content {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 40px 20px;
}

.cluster-stat {
  text-align: center;
  flex: 1;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  opacity: 0.6;
  letter-spacing: 2px;
  margin-bottom: 15px;
}

.stat-value {
  font-family: var(--font-main);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent);
  animation: pulse-glow 3s ease-in-out infinite;
}

/* World Map Placeholder */
.map-placeholder-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: 1.2rem;
  letter-spacing: 3px;
  opacity: 0.3;
  pointer-events: none;
  animation: blink 2s infinite;
}

@media (max-width: 900px) {
  .emotion-matrix-content {
    flex-direction: column;
  }
  
  .dominant-emotion-display {
    flex: auto;
  }
  
  .emotion-visualizations {
    flex-direction: column;
  }
  
  .emotion-bars-container {
    flex: auto;
  }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 10px;
}

.card-header h3 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--accent);
}

.status-light {
  width: 6px;
  height: 6px;
  background: var(--fg);
  box-shadow: 0 0 5px var(--fg);
}

/* Sound Button */
.sound {
  position: fixed;
  bottom: 40px;
  left: 40px;
  z-index: 100;
  background: transparent;
  border: 1px solid var(--fg);
  color: var(--fg);
  padding: 10px 20px;
  font-family: var(--font-mono);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.3s ease;
}

.sound:hover {
  background: var(--fg);
  color: var(--bg);
  box-shadow: 0 0 20px var(--fg);
}

/* Scroll Indicator */
.scroll-indicator {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  opacity: 0.7;
}

.scroll-text {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 2px;
  display: block;
  margin-bottom: 10px;
}

.arrow {
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
  40% {transform: translateY(-10px);}
  60% {transform: translateY(-5px);}
}

/* Debug */
.debug {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 1000;
  background: rgba(0,0,0,0.8);
  color: lime;
  padding: 10px;
  font-family: monospace;
  max-width: 300px;
  max-height: 200px;
  overflow: auto;
  border: 1px solid lime;
}

/* Mobile adjustments */
@media (max-width: 600px) {
  .center-card {
    padding: 40px 24px;
    border-radius: 36px;
    width: calc(100% - 48px);
    margin-bottom: 0;
  }
  
  .mood {
    font-size: 12vw;
  }
  
  .sound {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: auto;
    padding: 12px 16px;
  }
  
  .top-header {
    top: 20px;
  }

  .hud-panel {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    transform: none;
    width: 100%;
    max-width: 320px;
    margin-top: 40px;
  }
  
  .scroll-indicator {
    display: flex;
    bottom: 20px;
    left: 20px;
    transform: none;
    align-items: flex-start;
  }
  
  .scroll-text {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  body, .center-card, .mood, .sound, .background-noise::after, .scroll-indicator {
    animation: none;
    transition: none;
  }
}