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

:root {
  --primary: #6366f1;
  --secondary: #8b5cf6;
  --accent: #f472b6;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --bg-dark: #0f0a1a;
  --bg-darker: #070410;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --neon-blue: #00d4ff;
  --neon-pink: #ff00ff;
  --neon-green: #00ff88;
}

body {
  font-family: 'JetBrains Mono', monospace;
  background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 50%, #1a0a2e 100%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.game-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.game-container::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.shake {
  animation: shake 0.2s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.heavy-glitch .main-title,
.heavy-glitch .message-content {
  animation: glitch 0.3s infinite;
}

@keyframes glitch {
  0% { text-shadow: 2px 0 var(--neon-pink), -2px 0 var(--neon-blue); }
  25% { text-shadow: -2px 0 var(--neon-pink), 2px 0 var(--neon-blue); }
  50% { text-shadow: 2px 2px var(--neon-pink), -2px -2px var(--neon-blue); }
  75% { text-shadow: -2px 2px var(--neon-pink), 2px -2px var(--neon-blue); }
  100% { text-shadow: 2px 0 var(--neon-pink), -2px 0 var(--neon-blue); }
}

/* Header */
.game-header {
  padding: 1rem;
  background: linear-gradient(180deg, rgba(15, 10, 26, 0.95) 0%, transparent 100%);
  position: relative;
  z-index: 10;
}

.title-section {
  text-align: center;
  margin-bottom: 1rem;
}

.main-title {
  font-family: 'Creepster', cursive;
  font-size: clamp(1.8rem, 5vw, 3rem);
  background: linear-gradient(90deg, var(--neon-pink), var(--neon-blue), var(--neon-pink));
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradient-shift 3s linear infinite, pulse 2s ease-in-out infinite;
  text-shadow: 0 0 30px rgba(255, 0, 255, 0.5);
}

@keyframes gradient-shift {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

.glitch-text {
  animation: glitch 0.1s infinite, pulse 2s ease-in-out infinite;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.stats-bar {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sanity-bar {
  width: 100px;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.sanity-fill {
  height: 100%;
  background: var(--success);
  transition: width 0.3s ease, background 0.3s ease;
  border-radius: 4px;
}

.sanity-fill.warning {
  background: var(--warning);
}

.sanity-fill.critical {
  background: var(--danger);
  animation: critical-pulse 0.5s infinite;
}

@keyframes critical-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.stat-number {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.token-count {
  color: var(--warning);
}

/* Main game area */
.game-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  position: relative;
  z-index: 5;
}

.time-display {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 500px;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.clock {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.2rem;
  color: var(--neon-blue);
}

.hearts {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hearts-label {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.heart {
  transition: transform 0.2s;
}

.heart.full {
  animation: heartbeat 1s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Loop visualization */
.loop-container {
  position: relative;
  width: 280px;
  height: 280px;
  margin: 1rem 0;
}

.loop-track {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 3px dashed rgba(99, 102, 241, 0.3);
  border-radius: 50%;
  animation: rotate 20s linear infinite;
}

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

.loop-node {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  transform-origin: center center;
}

.node-content {
  width: 100%;
  height: 100%;
  background: rgba(99, 102, 241, 0.2);
  border: 2px solid var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.3s ease;
  animation: counter-rotate 20s linear infinite;
}

@keyframes counter-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(-360deg); }
}

.loop-node.active .node-content {
  background: var(--primary);
  box-shadow: 0 0 20px var(--neon-blue), 0 0 40px var(--primary);
  transform: scale(1.2);
  animation: counter-rotate 20s linear infinite, node-pulse 0.5s ease-in-out infinite;
}

@keyframes node-pulse {
  0%, 100% { box-shadow: 0 0 20px var(--neon-blue), 0 0 40px var(--primary); }
  50% { box-shadow: 0 0 30px var(--neon-blue), 0 0 60px var(--primary); }
}

.loop-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-darker) 100%);
  border: 3px solid var(--secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px rgba(139, 92, 246, 0.3);
}

.developer-emoji {
  font-size: 2.5rem;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* Message bubble */
.message-bubble {
  max-width: 350px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(139, 92, 246, 0.2) 100%);
  border: 1px solid var(--primary);
  border-radius: 12px;
  padding: 1rem;
  margin: 1rem 0;
  position: relative;
  animation: fadeIn 0.3s ease;
}

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

.message-bubble::before {
  content: '🤖';
  position: absolute;
  top: -15px;
  left: 15px;
  background: var(--bg-dark);
  padding: 0 0.5rem;
}

.message-content {
  font-size: 0.9rem;
  line-height: 1.4;
}

.loading-dots {
  animation: dots 1.5s infinite;
}

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

/* Stack Overflow answer */
.stack-answer {
  max-width: 350px;
  background: rgba(244, 128, 36, 0.1);
  border: 1px solid rgba(244, 128, 36, 0.3);
  border-radius: 8px;
  padding: 1rem;
  margin: 0.5rem 0;
  animation: fadeIn 0.3s ease;
}

.stack-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.stack-text {
  font-style: italic;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.stack-votes {
  font-size: 0.8rem;
  color: var(--success);
}

.stack-votes.negative {
  color: var(--danger);
}

/* Easter egg */
.easter-egg {
  background: linear-gradient(90deg, var(--neon-pink), var(--neon-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 0.9rem;
  margin: 0.5rem 0;
  animation: rainbow 2s linear infinite;
}

@keyframes rainbow {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

/* Falling errors */
.falling-error {
  position: fixed;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 20;
  cursor: pointer;
  transition: transform 0.1s ease;
  pointer-events: auto;
}

.falling-error:hover {
  transform: scale(1.1);
}

/* Control panel */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 300px;
  margin-top: 1rem;
}

.control-btn {
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ai-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.ai-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.ai-btn.loading {
  opacity: 0.7;
  cursor: wait;
}

.spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.framework-btn {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: white;
}

.framework-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.stack-btn {
  background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  color: white;
}

.stack-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

.break-btn {
  background: linear-gradient(135deg, #64748b 0%, #94a3b8 100%);
  color: white;
}

.break-btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.break-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.escape-btn {
  background: linear-gradient(135deg, #ec4899 0%, #f472b6 100%);
  color: white;
  box-shadow: 0 0 30px rgba(236, 72, 153, 0.5);
  animation: escape-glow 2s ease-in-out infinite;
  margin-top: 1rem;
  transition: all 0.3s ease;
}

@keyframes escape-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(236, 72, 153, 0.5); }
  50% { box-shadow: 0 0 40px rgba(236, 72, 153, 0.8), 0 0 60px rgba(236, 72, 153, 0.4); }
}

.escape-btn:hover {
  transform: scale(1.05);
}

/* Footer */
.game-footer {
  padding: 1.5rem;
  text-align: center;
  background: linear-gradient(0deg, rgba(15, 10, 26, 0.95) 0%, transparent 100%);
  position: relative;
  z-index: 10;
}

.footer-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.footer-link:hover {
  color: var(--neon-pink);
}

.footer-disclaimer {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

/* Escape screen */
.escape-screen {
  min-height: 100vh;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 50%, #fbbf24 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -20px;
  animation: confetti-fall 4s linear infinite;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

.escape-content {
  text-align: center;
  padding: 2rem;
  max-width: 500px;
  z-index: 10;
}

.glass-shatter {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at center, transparent 0%, rgba(0,0,0,0.1) 100%);
  animation: shatter 0.5s ease-out;
  pointer-events: none;
}

@keyframes shatter {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.5);
  }
}

.escape-title {
  font-family: 'Creepster', cursive;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  color: #7c3aed;
  margin-bottom: 1rem;
  animation: bounce-in 0.5s ease;
}

@keyframes bounce-in {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.escape-emoji {
  font-size: 5rem;
  margin: 1rem 0;
  animation: spin-in 0.8s ease;
}

@keyframes spin-in {
  0% { transform: rotate(-720deg) scale(0); }
  100% { transform: rotate(0) scale(1); }
}

.escape-stats {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.escape-stats .stat-item {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.escape-stats .stat-item:last-child {
  border-bottom: none;
}

.escape-stats .stat-label {
  color: #64748b;
  font-size: 0.85rem;
}

.escape-stats .stat-value {
  color: #1e293b;
  font-weight: 700;
}

.escape-stats .stat-saved {
  color: #10b981;
}

.share-button {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  border: none;
  padding: 1rem 2rem;
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 1rem;
}

.share-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.berrry-link {
  display: block;
  color: #6366f1;
  text-decoration: none;
  font-size: 0.9rem;
  margin-top: 1rem;
}

.berrry-link:hover {
  text-decoration: underline;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
  .stats-bar {
    gap: 1rem;
  }
  
  .loop-container {
    width: 220px;
    height: 220px;
  }
  
  .loop-node {
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
  }
  
  .loop-node .node-content {
    font-size: 1rem;
  }
  
  .loop-center {
    width: 60px;
    height: 60px;
  }
  
  .developer-emoji {
    font-size: 2rem;
  }
  
  .control-panel {
    max-width: 100%;
    padding: 0 1rem;
  }
  
  .time-display {
    justify-content: center;
  }
}