:root {
  --bg-deep: #0a0f1a;
  --bg-card: #131a2b;
  --cyan: #00d4ff;
  --purple: #8b5cf6;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
}

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

body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: rgba(19, 26, 43, 0.95);
  border-bottom: 1px solid rgba(0, 212, 255, 0.2);
  backdrop-filter: blur(10px);
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.app-title {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.online-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 9999px;
  font-size: 0.85rem;
  color: var(--green);
}

.online-dot {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.2); }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.settings-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.7;
  transition: all 0.3s;
}

.settings-btn:hover {
  opacity: 1;
  transform: rotate(90deg);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.memoji-large {
  font-size: 1.5rem;
}

/* Main Content */
.main-content {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.map-container {
  width: 100%;
  height: 100%;
}

/* Map Markers */
.map-marker {
  width: 50px;
  height: 50px;
  position: relative;
  cursor: pointer;
  transition: transform 0.3s ease;
  animation: float 3s ease-in-out infinite;
}

.map-marker:hover, .map-marker.hovered {
  transform: scale(1.3);
  z-index: 100;
}

.marker-glow {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  opacity: 0.5;
  animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.1); }
}

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

.marker-memoji {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: var(--bg-card);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Setup Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 26, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.setup-modal {
  background: var(--bg-card);
  border-radius: 1.5rem;
  padding: 2rem;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid rgba(0, 212, 255, 0.2);
  box-shadow: 0 0 60px rgba(0, 212, 255, 0.2);
}

.setup-title {
  font-size: 1.75rem;
  text-align: center;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.setup-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.setup-section {
  margin-bottom: 1.5rem;
}

.setup-label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.memoji-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
}

.memoji-option {
  width: 100%;
  aspect-ratio: 1;
  font-size: 1.5rem;
  background: var(--bg-deep);
  border: 2px solid transparent;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.memoji-option:hover {
  background: rgba(0, 212, 255, 0.1);
  border-color: rgba(0, 212, 255, 0.3);
}

.memoji-option.selected {
  background: rgba(0, 212, 255, 0.2);
  border-color: var(--cyan);
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

.setup-input, .setup-select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-deep);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.75rem;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.3s;
}

.setup-input:focus, .setup-select:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.2);
}

.setup-select option {
  background: var(--bg-card);
}

.join-btn {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  font-family: inherit;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  border: none;
  border-radius: 0.75rem;
  color: white;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 0 30px rgba(0, 212, 255, 0.3);
}

.join-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 0 40px rgba(0, 212, 255, 0.5);
}

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

/* User Panel */
.user-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 350px;
  background: rgba(19, 26, 43, 0.98);
  border-left: 1px solid rgba(0, 212, 255, 0.2);
  backdrop-filter: blur(20px);
  animation: slideIn 0.3s ease;
  z-index: 50;
  display: flex;
  flex-direction: column;
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.panel-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.3s;
}

.panel-close:hover {
  background: rgba(239, 68, 68, 0.3);
}

.panel-content {
  padding: 2rem;
  text-align: center;
}

.panel-avatar {
  width: 100px;
  height: 100px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--status-color, var(--cyan));
  box-shadow: 0 0 30px var(--status-color, var(--cyan));
  animation: statusGlow 2s infinite;
}

@keyframes statusGlow {
  0%, 100% { box-shadow: 0 0 20px var(--status-color); }
  50% { box-shadow: 0 0 40px var(--status-color); }
}

.panel-memoji {
  font-size: 3.5rem;
}

.panel-username {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.panel-location {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.panel-status {
  color: var(--cyan);
  font-style: italic;
  margin-bottom: 2rem;
  padding: 0.75rem;
  background: rgba(0, 212, 255, 0.1);
  border-radius: 0.5rem;
}

.panel-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.action-btn {
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.3s;
}

.action-btn.wave {
  background: rgba(245, 158, 11, 0.2);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.action-btn.wave:hover {
  background: rgba(245, 158, 11, 0.3);
}

.action-btn.chat {
  background: rgba(139, 92, 246, 0.2);
  color: var(--purple);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.action-btn.chat:hover {
  background: rgba(139, 92, 246, 0.3);
}

.action-btn.call {
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  color: white;
}

.action-btn.call:hover {
  transform: scale(1.02);
  box-shadow: 0 0 25px rgba(0, 212, 255, 0.4);
}

/* Chat Modal */
.chat-modal {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  width: 380px;
  height: 500px;
  background: rgba(19, 26, 43, 0.98);
  border-radius: 1rem;
  border: 1px solid rgba(0, 212, 255, 0.2);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: chatSlideUp 0.3s ease;
  z-index: 60;
}

@keyframes chatSlideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--bg-deep);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chat-memoji {
  font-size: 1.5rem;
}

.chat-username {
  font-weight: 500;
}

.chat-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.chat-close:hover {
  opacity: 1;
}

.chat-messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-bubble {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  font-size: 0.95rem;
  line-height: 1.4;
}

.chat-bubble.own {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--cyan), #0099cc);
  color: white;
  border-bottom-right-radius: 0.25rem;
}

.chat-bubble.other {
  align-self: flex-start;
  background: rgba(139, 92, 246, 0.3);
  border-bottom-left-radius: 0.25rem;
}

.typing-indicator {
  display: flex;
  gap: 0.3rem;
  padding: 0.75rem 1rem;
  background: rgba(139, 92, 246, 0.2);
  border-radius: 1rem;
  width: fit-content;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--purple);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-8px); }
}

.chat-input-area {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--bg-deep);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  color: var(--text);
  font-family: inherit;
}

.chat-input:focus {
  outline: none;
  border-color: var(--cyan);
}

.send-btn {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.3s;
}

.send-btn:hover {
  transform: scale(1.1);
}

/* Video Call */
.video-call-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-deep);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.call-timer {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.25rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.5);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
}

.signal-indicator {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  font-size: 1.5rem;
}

.main-video {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-deep), var(--bg-card));
}

.connecting-screen, .demo-screen {
  text-align: center;
}

.connecting-memoji, .demo-memoji {
  font-size: 6rem;
  margin-bottom: 1rem;
  animation: float 2s ease-in-out infinite;
}

.connecting-text {
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 1rem;
}

.connecting-dots {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

.connecting-dots span {
  width: 12px;
  height: 12px;
  background: var(--cyan);
  border-radius: 50%;
  animation: bounce 1.4s infinite;
}

.connecting-dots span:nth-child(2) { animation-delay: 0.2s; }
.connecting-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1.2); opacity: 1; }
}

.demo-username {
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 1rem;
}

.demo-notice {
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 1rem;
  padding: 1.5rem 2rem;
  margin-top: 2rem;
}

.demo-notice p:first-child {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--cyan);
  margin-bottom: 0.5rem;
}

.demo-subtext {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.pip-video {
  position: absolute;
  bottom: 100px;
  right: 1.5rem;
  width: 180px;
  height: 135px;
  border-radius: 1rem;
  overflow: hidden;
  border: 3px solid rgba(0, 212, 255, 0.5);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
  background: var(--bg-card);
}

.pip-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pip-video video.camera-off {
  display: none;
}

.camera-off-overlay {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  background: var(--bg-deep);
}

.call-controls {
  position: absolute;
  bottom: 2rem;
  display: flex;
  gap: 1rem;
  padding: 1rem 2rem;
  background: rgba(19, 26, 43, 0.9);
  border-radius: 9999px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.control-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.3s;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.control-btn.active {
  background: rgba(239, 68, 68, 0.3);
}

.control-btn.end-call {
  background: var(--red);
  transform: rotate(135deg);
}

.control-btn.end-call:hover {
  background: #dc2626;
  transform: rotate(135deg) scale(1.1);
}

/* Sidebar */
.sidebar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 60px;
  background: rgba(19, 26, 43, 0.98);
  border-right: 1px solid rgba(0, 212, 255, 0.2);
  backdrop-filter: blur(20px);
  transition: width 0.3s ease;
  z-index: 40;
  overflow: hidden;
}

.sidebar.open {
  width: 300px;
}

.sidebar-toggle {
  position: absolute;
  top: 50%;
  right: -1px;
  transform: translateY(-50%);
  width: 24px;
  height: 48px;
  background: var(--bg-card);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-left: none;
  border-radius: 0 0.5rem 0.5rem 0;
  color: var(--cyan);
  cursor: pointer;
  z-index: 1;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h3 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
  color: var(--text);
}

.sidebar-search {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-deep);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.sidebar-search:focus {
  outline: none;
  border-color: var(--cyan);
}

.sidebar-list {
  padding: 0.5rem;
  overflow-y: auto;
  max-height: calc(100vh - 150px);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.sidebar-user:hover {
  background: rgba(0, 212, 255, 0.1);
}

.sidebar-user.selected {
  background: rgba(0, 212, 255, 0.2);
  border: 1px solid rgba(0, 212, 255, 0.3);
}

.sidebar-memoji {
  font-size: 1.75rem;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-username {
  display: block;
  font-weight: 500;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-country {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sidebar-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Footer */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1.5rem;
  background: rgba(19, 26, 43, 0.98);
  border-top: 1px solid rgba(0, 212, 255, 0.2);
  font-size: 0.85rem;
  z-index: 100;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.footer-count {
  color: var(--text-muted);
}

.footer-status {
  color: var(--green);
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sound-toggle {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.sound-toggle:hover {
  opacity: 1;
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

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

/* Toast */
.toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 9999px;
  padding: 0.75rem 1.5rem;
  color: var(--text);
  box-shadow: 0 0 30px rgba(0, 212, 255, 0.2);
  animation: toastIn 0.3s ease;
  z-index: 300;
}

@keyframes toastIn {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* Whale Easter Egg */
.whale-easter-egg {
  position: fixed;
  bottom: 20%;
  left: -100px;
  font-size: 5rem;
  animation: swim 4s ease-in-out forwards;
  z-index: 500;
}

@keyframes swim {
  0% { left: -100px; transform: scaleX(1); }
  45% { left: calc(50% - 50px); transform: scaleX(1); }
  55% { left: calc(50% - 50px); transform: scaleX(-1); }
  100% { left: calc(100% + 100px); transform: scaleX(-1); }
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    padding: 0.5rem 1rem;
  }
  
  .app-title {
    font-size: 1.25rem;
  }
  
  .online-badge {
    display: none;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
    bottom: auto;
    top: auto;
    bottom: 0;
    transform: translateY(calc(100% - 50px));
    border-right: none;
    border-top: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 1rem 1rem 0 0;
    transition: transform 0.3s ease;
  }
  
  .sidebar.open {
    transform: translateY(0);
    height: 60vh;
  }
  
  .sidebar-toggle {
    top: -12px;
    left: 50%;
    transform: translateX(-50%) rotate(90deg);
    right: auto;
  }
  
  .user-panel {
    width: 100%;
    bottom: 0;
    top: auto;
    height: auto;
    max-height: 70vh;
    border-left: none;
    border-top: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 1rem 1rem 0 0;
    animation: slideUp 0.3s ease;
  }
  
  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  
  .chat-modal {
    width: 100%;
    height: 60vh;
    right: 0;
    bottom: 0;
    border-radius: 1rem 1rem 0 0;
  }
  
  .pip-video {
    width: 120px;
    height: 90px;
    bottom: 120px;
    right: 1rem;
  }
  
  .call-controls {
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
  }
  
  .control-btn {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
  }
  
  .footer {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
  }
  
  .footer-left {
    gap: 0.75rem;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-deep);
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 212, 255, 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 212, 255, 0.5);
}