

/* ===== CSS Custom Properties ===== */
:root {
  /* Colors */
  --color-primary: #7c3aed;
  --color-primary-dark: #6d28d9;
  --color-primary-light: rgba(124, 58, 237, 0.4);
  --color-secondary: #22c55e;
  --color-secondary-dark: #16a34a;
  --color-secondary-light: rgba(34, 197, 94, 0.4);
  --color-danger: #dc2626;
  --color-danger-light: rgba(220, 38, 38, 0.6);
  --color-success: #10b981;
  
  /* Grayscale */
  --color-white: #ffffff;
  --color-gray-50: #f9fafb;
  --color-gray-100: #f3f4f6;
  --color-gray-200: #e5e7eb;
  --color-gray-300: #d1d5db;
  --color-gray-400: #9ca3af;
  --color-gray-500: #6b7280;
  --color-gray-600: #4b5563;
  --color-gray-700: #374151;
  --color-gray-800: #1f2937;
  --color-gray-900: #111827;
  --color-black: #000000;
  
  /* Background Colors */
  --bg-dark: #111;
  --bg-overlay: rgba(0, 0, 0, 0.85);
  --bg-overlay-light: rgba(0, 0, 0, 0.55);
  --bg-glass: rgba(255, 255, 255, 0.1);
  --bg-glass-dark: rgba(0, 0, 0, 0.3);
  
  /* Border Colors */
  --border-primary: rgba(124, 58, 237, 0.4);
  --border-secondary: rgba(34, 197, 94, 0.6);
  --border-light: rgba(255, 255, 255, 0.1);
  --border-lighter: rgba(255, 255, 255, 0.2);
  --border-dark: #333;
  
  /* Typography */
  --font-mono: 'Monocraft', ui-monospace, Menlo, Consolas, 'Courier New', monospace;
  --font-system: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  
  /* Font Sizes */
  --text-xs: 10px;
  --text-sm: 11px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 24px;
  
  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  
  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.3);
  --shadow-glow-secondary: 0 0 20px rgba(34, 197, 94, 0.3);
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
  
  /* Z-Index Scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  --z-toast: 1080;
  --z-top: 2000;
}

/* ===== Base Styles ===== */
:root { 
  color-scheme: dark; 
}

html, body { 
  margin: 0; 
  height: 100%; 
  overflow: hidden; 
  background: var(--bg-dark); 
  font-family: var(--font-mono);
}

canvas { 
  display: block; 
  transition: filter var(--transition-base); 
}

canvas.clickable { 
  cursor: pointer; 
}

canvas.clickable:hover { 
  filter: brightness(1.05); 
}

/* ===== Font Loading ===== */
@font-face {
  font-family: 'Monocraft';
  src: url('https://play.rosebud.ai/assets/monocraft_font.ttc?LLjP') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ===== Loading Component ===== */
#loading {
  position: fixed; 
  top: 50%; 
  left: 50%; 
  transform: translate(-50%, -50%);
  padding: var(--space-4) var(--space-6); 
  background: var(--bg-overlay);
  border-radius: var(--radius-xl); 
  border: 1px solid var(--border-primary);
  font: 500 var(--text-base) var(--font-mono);
  color: var(--color-white); 
  display: none; 
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-2xl); 
  z-index: var(--z-top);
}

#loading::before {
  content: ''; 
  display: inline-block; 
  width: var(--space-4); 
  height: var(--space-4); 
  margin-right: var(--space-2);
  border: 2px solid var(--border-primary); 
  border-top: 2px solid var(--color-primary);
  border-radius: 50%; 
  animation: spin 1s linear infinite; 
  vertical-align: middle;
}

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

/* ===== Start UI ===== */
#ui { 
  position: fixed; 
  inset: 0; 
  display: grid; 
  place-items: center; 
  pointer-events: auto;
  font-family: var(--font-mono); 
  z-index: 1100;
  cursor: pointer;
}
#panel { 
  pointer-events: none; 
  background: var(--bg-overlay-light); 
  border: 1px solid var(--border-light);
  padding: var(--space-4) 18px; 
  border-radius: var(--radius-xl); 
  backdrop-filter: blur(6px); 
  text-align: center; 
  width: calc(100% - 40px); 
  max-width: 420px;
  transition: transform var(--transition-base), filter var(--transition-base);
}

#panel h1 { 
  margin: 0 0 var(--space-2); 
  font-size: var(--text-xl); 
  font-weight: 600; 
  color: var(--color-white);
}

#panel p { 
  margin: 0 0 var(--space-3); 
  color: #cfcfcf; 
  font-size: var(--text-base); 
  line-height: 1.35; 
}

#panel kbd { 
  font: var(--text-xs)/1 var(--font-mono); 
  padding: 2px var(--space-2); 
  border-radius: var(--radius-sm); 
  border: 1px solid var(--border-dark); 
  background: #1a1a1a; 
  color: var(--color-white);
}

#ui:hover #panel {
  transform: scale(1.02);
  filter: brightness(1.05);
  border-color: var(--border-primary);
}

/* ===== Canvas Hint ===== */
#canvas-hint {
  position: fixed; 
  top: 50%; 
  left: 50%; 
  transform: translate(-50%, -50%);
  pointer-events: none; 
  z-index: 100; 
  background: var(--bg-overlay);
  padding: var(--space-3) 18px; 
  border-radius: var(--radius-lg); 
  border: 1px solid var(--border-primary);
  font: var(--text-base) var(--font-mono); 
  color: var(--color-white);
  backdrop-filter: blur(8px); 
  opacity: 0; 
  transition: opacity var(--transition-slow);
}

#canvas-hint.visible { 
  opacity: 1; 
}

#canvas-hint.hidden { 
  display: none !important; 
}

/* ===== Crosshair ===== */
#crosshair { 
  position: fixed; 
  top: 50%; 
  left: 50%; 
  transform: translate(-50%, -50%);
  pointer-events: none; 
  z-index: 50; 
  opacity: 0; 
  transition: opacity var(--transition-slow); 
}

#crosshair.visible { 
  opacity: 1; 
}

#crosshair.hidden { 
  display: none !important; 
}

.crosshair-dot { 
  width: 4px; 
  height: 4px; 
  border-radius: 50%; 
  background: rgba(255,255,255,0.9);
  position: absolute; 
  top: 50%; 
  left: 50%; 
  transform: translate(-50%, -50%);
  box-shadow: 0 0 8px rgba(255,255,255,0.3), 0 0 2px rgba(0,0,0,0.8);
  animation: crosshairPulse 3s ease-in-out infinite; 
}

.crosshair-lines { 
  position: relative; 
}

.crosshair-line { 
  position: absolute; 
  background: rgba(255,255,255,0.7);
  box-shadow: 0 0 4px rgba(255,255,255,0.2), 0 0 1px rgba(0,0,0,0.6); 
}

.crosshair-horizontal { 
  width: var(--space-4); 
  height: 1px; 
  top: 50%; 
  left: 50%; 
  transform: translate(-50%, -50%); 
}

.crosshair-horizontal::before, .crosshair-horizontal::after {
  content: ''; 
  position: absolute; 
  width: 4px; 
  height: 1px; 
  background: rgba(255,255,255,0.7); 
  top: 0; 
}

.crosshair-horizontal::before { 
  left: -6px; 
}

.crosshair-horizontal::after { 
  right: -6px; 
}

.crosshair-vertical { 
  width: 1px; 
  height: var(--space-4); 
  top: 50%; 
  left: 50%; 
  transform: translate(-50%, -50%); 
}

.crosshair-vertical::before, .crosshair-vertical::after {
  content: ''; 
  position: absolute; 
  width: 1px; 
  height: 4px; 
  background: rgba(255,255,255,0.7); 
  left: 0; 
}

.crosshair-vertical::before { 
  top: -6px; 
}

.crosshair-vertical::after { 
  bottom: -6px; 
}

@keyframes crosshairPulse {
  0%, 100% { 
    opacity: 0.9; 
    transform: translate(-50%, -50%) scale(1); 
  }
  50% { 
    opacity: 0.7; 
    transform: translate(-50%, -50%) scale(1.1); 
  } 
}

/* ===== Camera Info ===== */
#camera-info {
  position: fixed; 
  top: var(--space-5); 
  right: var(--space-5);
  background: var(--bg-overlay); 
  padding: var(--space-2) var(--space-3); 
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary); 
  font: var(--text-sm) var(--font-mono); 
  line-height: 1.3; 
  color: var(--color-white);
  backdrop-filter: blur(8px); 
  display: block; 
  user-select: all; 
  cursor: text; 
  transition: opacity var(--transition-slow), transform var(--transition-slow); 
  z-index: var(--z-dropdown);
  min-width: 160px;
}

#camera-info.hidden { 
  opacity: 0; 
  transform: translateX(100%); 
  pointer-events: none; 
}

#camera-info h3 { 
  margin: 0 0 4px; 
  font-size: var(--text-xs); 
  font-weight: 600; 
  color: var(--color-white); 
}

.coord-grid { 
  display: grid; 
  grid-template-columns: 1fr 1fr 1fr; 
  gap: var(--space-2) 6px; 
  margin-bottom: var(--space-2); 
}

.coord-item { 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
}

.coord-label { 
  font-size: 9px; 
  color: var(--color-gray-400); 
  text-transform: uppercase; 
  letter-spacing: 0.5px; 
}

.coord-value { 
  font-size: var(--text-sm); 
  font-weight: 500; 
  color: var(--color-white); 
  margin-top: 1px; 
}

#copy-camera-btn, #hide-ui-btn { 
  margin-top: 6px; 
  padding: 5px var(--space-2); 
  width: 100%; 
  border: none; 
  border-radius: 4px; 
  font-family: var(--font-mono); 
  font-size: var(--text-xs); 
  font-weight: 500; 
  cursor: pointer; 
  transition: all var(--transition-base); 
  -webkit-tap-highlight-color: transparent; 
}

#copy-camera-btn { 
  background: var(--color-primary); 
  color: var(--color-white); 
}

#hide-ui-btn { 
  background: var(--color-danger); 
  color: var(--color-white); 
}

#hide-ui-btn.hidden-mode { 
  background: var(--color-success); 
}

#show-ui-fab {
  display: none; 
  position: fixed; 
  top: var(--space-5); 
  right: var(--space-5);
  width: var(--space-12); 
  height: var(--space-12); 
  border-radius: var(--radius-xl); 
  background: var(--bg-overlay); 
  border: 1px solid var(--border-primary);
  backdrop-filter: blur(8px); 
  cursor: pointer; 
  align-items: center; 
  justify-content: center; 
  color: var(--color-white); 
  z-index: 1050;
  box-shadow: 0 4px var(--space-4) rgba(0,0,0,0.3);
}

body.ui-hidden.is-mobile #show-ui-fab { 
  display: flex; 
}

#camera-info button kbd {
  font-family: var(--font-mono);
  font-size: var(--text-xs); 
  padding: 1px 4px; 
  border-radius: 3px;
  border: 1px solid var(--border-light); 
  background: var(--bg-glass-dark);
  margin-left: 2px;
}

/* ===== Audio Control ===== */
#audio-control { 
  position: fixed; 
  top: var(--space-5); 
  left: var(--space-5); 
  z-index: var(--z-dropdown); 
  transition: opacity var(--transition-slow), transform var(--transition-slow); 
}

#audio-control.hidden { 
  opacity: 0; 
  transform: translateY(-100%); 
  pointer-events: none; 
}

.audio-btn { 
  width: var(--space-12); 
  height: var(--space-12); 
  border-radius: var(--radius-xl); 
  background: var(--bg-overlay); 
  border: 1px solid var(--border-primary); 
  backdrop-filter: blur(8px);
  cursor: pointer; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  color: var(--color-white); 
  font-family: var(--font-mono); 
  box-shadow: 0 4px var(--space-4) rgba(0,0,0,0.3); 
}

.audio-btn.muted { 
  background: rgba(220,38,38,0.15); 
  border-color: var(--color-danger-light); 
  color: #ef4444; 
}

.audio-btn .audio-icon.unmuted { 
  display: block; 
}

.audio-btn .audio-icon.muted { 
  display: none; 
}

.audio-btn.muted .audio-icon.unmuted { 
  display: none; 
}

.audio-btn.muted .audio-icon.muted { 
  display: block; 
}

/* ===== Shared Hint Styles ===== */
.game-hint {
  position: fixed; 
  left: 50%; 
  transform: translateX(-50%);
  z-index: var(--z-top); 
  background: var(--bg-overlay); 
  border: 2px solid;
  border-radius: var(--radius-xl); 
  padding: var(--space-3) var(--space-4); 
  backdrop-filter: blur(12px);
  font: 600 var(--text-base)/1.2 var(--font-mono); 
  color: var(--color-white);
  opacity: 0; 
  transform: translate(-50%, 12px);
  transition: opacity 0.25s ease, transform 0.25s ease; 
  pointer-events: auto; 
  user-select: none;
  white-space: nowrap;
}

.game-hint.visible { 
  opacity: 1; 
  transform: translate(-50%, 0); 
}

.game-hint.hidden { 
  display: none !important; 
}

.game-hint .key { 
  font: var(--text-xs)/1 var(--font-mono); 
  padding: 3px 7px; 
  border-radius: var(--radius-sm); 
  border: 1px solid; 
  background: rgba(26,26,26,0.9); 
  box-shadow: 0 0 8px; 
}

/* ===== Portal Hint ===== */
#portal-hint {
  bottom: calc(120px + env(safe-area-inset-bottom, 0px));
  border-color: var(--border-primary);
  box-shadow: 0 8px var(--space-8) rgba(124,58,237,0.5), var(--shadow-glow);
  animation: portalHintPulse 2.5s ease-in-out infinite;
}

#portal-hint .key {
  border-color: var(--border-primary);
  color: var(--color-primary);
  box-shadow: 0 0 8px rgba(124,58,237,0.2);
}

@keyframes portalHintPulse {
  0%, 100% { 
    box-shadow: 0 8px var(--space-8) rgba(124,58,237,0.5), 0 0 var(--space-5) rgba(124,58,237,0.2);
    border-color: var(--border-primary);
  }
  50% { 
    box-shadow: 0 8px var(--space-8) rgba(124,58,237,0.7), 0 0 25px rgba(124,58,237,0.3);
    border-color: rgba(124,58,237,0.8);
  }
}

/* ===== Character Hint ===== */
.character-hint {
  bottom: calc(160px + env(safe-area-inset-bottom, 0px));
  border-color: var(--border-secondary);
  box-shadow: 0 8px var(--space-8) rgba(34,197,94,0.5), var(--shadow-glow-secondary);
  animation: characterHintPulse 2.5s ease-in-out infinite;
}

.character-hint .key {
  border-color: rgba(34,197,94,0.4);
  color: var(--color-secondary);
  box-shadow: 0 0 8px rgba(34,197,94,0.2);
}

@keyframes characterHintPulse {
  0%, 100% { 
    box-shadow: 0 8px var(--space-8) rgba(34,197,94,0.5), 0 0 var(--space-5) rgba(34,197,94,0.2);
    border-color: var(--border-secondary);
  }
  50% { 
    box-shadow: 0 8px var(--space-8) rgba(34,197,94,0.7), 0 0 25px rgba(34,197,94,0.3);
    border-color: rgba(34,197,94,0.8);
  }
}

/* ===== Mobile Controls ===== */
#mobile-controls { 
  display: none; 
  position: fixed; 
  bottom: var(--space-5); 
  left: 0; 
  right: 0; 
  pointer-events: none; 
  z-index: 1100; 
  height: 200px; 
}

.virtual-joystick { 
  position: absolute; 
  width: 120px; 
  height: 120px; 
  pointer-events: auto; 
}

#movement-joystick { 
  left: 50%; 
  bottom: 30px; 
  transform: translateX(-50%); 
}

.joystick-base { 
  width: 100%; 
  height: 100%; 
  border-radius: 50%; 
  background: var(--bg-glass); 
  border: 2px solid var(--border-lighter); 
  backdrop-filter: blur(10px); 
  position: relative; 
  box-shadow: 0 4px var(--space-5) rgba(0,0,0,0.3); 
}

.joystick-knob { 
  width: 50px; 
  height: 50px; 
  border-radius: 50%; 
  background: rgba(124,58,237,0.8); 
  border: 2px solid rgba(255,255,255,0.3); 
  position: absolute; 
  top: 50%; 
  left: 50%; 
  transform: translate(-50%, -50%); 
  transition: all 0.1s ease; 
  box-shadow: 0 2px 10px rgba(124,58,237,0.4); 
}

.vertical-controls { 
  position: absolute; 
  right: 40px; 
  bottom: 50px; 
  display: flex; 
  flex-direction: column; 
  gap: var(--space-3); 
  pointer-events: auto; 
  z-index: 1140; 
}

.vertical-btn { 
  width: 60px; 
  height: 60px; 
  border-radius: var(--radius-xl); 
  background: var(--bg-glass); 
  border: 2px solid var(--border-lighter); 
  backdrop-filter: blur(10px); 
  cursor: pointer; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  color: rgba(255,255,255,0.9); 
  font-family: var(--font-mono); 
  box-shadow: 0 4px var(--space-5) rgba(0,0,0,0.3); 
  transition: all var(--transition-base); 
  -webkit-tap-highlight-color: transparent; 
  pointer-events: auto; 
  position: relative; 
  z-index: 1150; 
}

.vertical-btn.active { 
  background: rgba(124,58,237,0.4); 
  border-color: rgba(124,58,237,0.6); 
  color: var(--color-white); 
  transform: scale(0.95); 
}

/* ===== Desktop WASD Controls ===== */
#desktop-wasd-controls { 
  position: fixed; 
  left: 30px; 
  bottom: 30px; 
  z-index: var(--z-dropdown); 
  pointer-events: none; 
}

.wasd-container { 
  display: flex; 
  gap: var(--space-4); 
  align-items: flex-end; 
}
.wasd-main {
  display: flex; 
  flex-direction: column; 
  gap: 4px; 
  align-items: center; 
}
.wasd-row { 
  display: flex; 
  gap: 4px; 
  align-items: center; 
}
.wasd-vertical { 
  display: flex; 
  flex-direction: row; 
  gap: 4px; 
  align-items: center; 
}

.wasd-key { 
  width: 45px; 
  height: 45px; 
  background: var(--bg-glass); 
  border: 2px solid var(--border-lighter); 
  border-radius: var(--radius-xl); 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  font: 600 var(--space-4) var(--font-mono); 
  color: rgba(255,255,255,0.9); 
  backdrop-filter: blur(10px); 
  box-shadow: 0 4px var(--space-5) rgba(0,0,0,0.3); 
}

.wasd-key.active { 
  background: rgba(124,58,237,0.4); 
  border-color: rgba(124,58,237,0.6); 
  color: var(--color-white); 
  transform: scale(0.95); 
}

/* ===== Chat Interface ===== */
.chat-interface {
  position: fixed;
  top: 50%;
  right: var(--space-5);
  transform: translateY(-50%);
  width: min(40vw, 400px);
  max-height: 85vh;
  background: rgba(0, 0, 0, 0.95);
  border: 2px solid var(--border-secondary);
  border-radius: var(--space-4);
  backdrop-filter: blur(20px);
  box-shadow: 0 var(--space-5) 60px rgba(0, 0, 0, 0.8), var(--shadow-glow-secondary);
  z-index: var(--z-top);
  opacity: 0;
  transform: translateY(-50%) translateX(100%);
  transition: opacity var(--transition-slow), transform var(--transition-slow);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  font-family: var(--font-mono);
}

.chat-interface.visible {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
  pointer-events: auto;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.1);
  border-radius: 14px 14px 0 0;
}

.chat-header h3 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-secondary);
}

.chat-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: var(--text-2xl);
  cursor: pointer;
  padding: 0;
  width: var(--space-8);
  height: var(--space-8);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition-base);
}

.chat-close-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.chat-messages {
  flex: 1;
  padding: var(--space-4) var(--space-5);
  overflow-y: auto;
  max-height: 500px;
  min-height: 300px;
  scrollbar-width: thin;
  scrollbar-color: rgba(34, 197, 94, 0.5) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(34, 197, 94, 0.5);
  border-radius: 3px;
}

.chat-message {
  margin-bottom: var(--space-3);
  padding: 10px var(--text-base);
  border-radius: var(--radius-xl);
  max-width: 85%;
  word-wrap: break-word;
  font-size: var(--text-base);
  line-height: 1.4;
  animation: messageSlideIn var(--transition-slow);
}

.chat-message.user {
  background: rgba(124, 58, 237, 0.8);
  color: var(--color-white);
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.chat-message.character {
  background: rgba(34, 197, 94, 0.2);
  color: #e5e7eb;
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-bottom-left-radius: 4px;
}

.chat-message.typing {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
  color: rgba(34, 197, 94, 0.8);
  border-bottom-left-radius: 4px;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.8);
  animation: typingPulse 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingPulse {
  0%, 60%, 100% {
    transform: scale(1);
    opacity: 0.4;
  }
  30% {
    transform: scale(1.2);
    opacity: 1;
  }
}

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

.chat-input-container {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid rgba(34, 197, 94, 0.3);
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
  background: var(--bg-glass-dark);
  border-radius: 0 0 14px 14px;
}

.chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: var(--radius-md);
  padding: 10px var(--space-3);
  color: var(--color-white);
  font-size: var(--text-base);
  font-family: var(--font-mono);
  resize: none;
  min-height: var(--space-5);
  max-height: var(--space-20);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  outline: none;
}

.chat-input:focus {
  border-color: rgba(34, 197, 94, 0.6);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.chat-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.chat-send-btn {
  background: linear-gradient(135deg, var(--color-secondary), var(--color-secondary-dark));
  border: none;
  color: var(--color-white);
  padding: 10px var(--space-4);
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  font-size: var(--text-base);
  min-width: 60px;
}

.chat-send-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--color-secondary-dark), #15803d);
  transform: translateY(-1px);
  box-shadow: 0 4px var(--space-3) rgba(34, 197, 94, 0.4);
}

.chat-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ===== Responsive Design ===== */

/* Mobile adjustments */
body.is-mobile #mobile-controls { 
  display: block; 
}

body.is-mobile #portal-hint { 
  top: auto; 
  bottom: calc(230px + env(safe-area-inset-bottom, 0px)); 
  padding: 10px var(--text-base); 
  font-size: 13px; 
}

body.is-mobile .character-hint {
  bottom: calc(270px + env(safe-area-inset-bottom, 0px));
  padding: 10px var(--text-base);
  font-size: 13px;
}

body.is-mobile #desktop-wasd-controls { 
  display: none; 
}

body.is-mobile #audio-control { 
  top: 15px; 
  left: 15px; 
  right: auto; 
}

body.is-mobile #camera-info { 
  top: 15px; 
  right: 15px; 
  padding: 6px 10px; 
  font-size: var(--text-xs); 
  max-width: calc(100vw - 90px); 
  box-sizing: border-box; 
  min-width: 140px; 
}

body.is-mobile #camera-info .coord-grid { 
  gap: 6px 4px; 
}

body.is-mobile #camera-info .coord-label { 
  font-size: 8px; 
}

body.is-mobile #camera-info .coord-value { 
  font-size: var(--text-xs); 
}

body.is-mobile .desktop-controls { 
  display: none; 
}

body.is-mobile .mobile-controls { 
  display: inline; 
}

/* Desktop controls visibility */
.desktop-controls { 
  display: inline; 
}

.mobile-controls { 
  display: none; 
}

/* Chat interface mobile adjustments */
@media (max-width: 640px) {
  .chat-interface {
    right: 10px;
    width: calc(100vw - var(--space-5));
    max-width: none;
    max-height: 90vh;
    border-radius: var(--radius-xl);
  }
  
  .chat-header {
    padding: var(--space-3) var(--space-4);
  }
  
  .chat-header h3 {
    font-size: var(--space-4);
  }
  
  .chat-messages {
    padding: var(--space-3) var(--space-4);
    min-height: 250px;
  }
  
  .chat-input-container {
    padding: var(--space-3) var(--space-4);
  }
  
  .chat-message {
    font-size: 13px;
    padding: var(--space-2) var(--space-3);
  }
  
  .chat-interface.visible {
    transform: translateY(-50%) translateX(0);
  }
}

/* Tablet adjustments */
@media (max-width: 1024px) and (min-width: 641px) {
  .chat-interface {
    width: min(50vw, 450px);
  }
}

/* Hide during UI hidden mode */
body.ui-hidden .chat-interface {
  display: none !important;
}

body.ui-hidden .game-hint {
  display: none !important;
}

body.ui-hidden #crosshair {
  display: none !important;
}

body.ui-hidden #canvas-hint {
  display: none !important;
}

