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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: linear-gradient(135deg, #0f0f23 0%, #1a1a3e 40%, #0d1b3e 100%);
  min-height: 100vh;
  color: #e8e8f0;
  overflow: hidden;
}

.hidden { display: none !important; }
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* ===== LANGUAGE SCREEN ===== */
#languageScreen.active { display: flex; justify-content: center; align-items: center; }

.language-box {
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(24px);
  border-radius: 28px;
  padding: 48px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.06);
  max-width: 500px;
  width: 92%;
}

.logo-big { font-size: 64px; margin-bottom: 8px; }

.language-box h1 {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #667eea, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.language-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 28px;
}

.lang-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  color: white;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
}

.lang-btn:hover {
  background: rgba(102,126,234,0.15);
  border-color: rgba(102,126,234,0.4);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(102,126,234,0.15);
}

.lang-btn .flag { font-size: 36px; }
.lang-btn .name { font-size: 14px; font-weight: 500; opacity: 0.9; }

.lang-switch {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.5);
  padding: 8px 18px;
  border-radius: 20px;
  cursor: pointer;
  margin-top: 24px;
  font-size: 13px;
  transition: all 0.25s;
}

.lang-switch:hover { background: rgba(255,255,255,0.06); color: white; }

/* ===== GOOGLE SIGN-IN ===== */
.google-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: rgba(255,255,255,0.35);
  font-size: 13px;
}

.google-divider::before,
.google-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.08);
}

.btn-google {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 22px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: #e8e8f0;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  margin-bottom: 4px;
}

.btn-google::before {
  content: '';
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%23EA4335' d='M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z'/%3E%3Cpath fill='%234285F4' d='M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z'/%3E%3Cpath fill='%23FBBC05' d='M10.54 28.59A14.5 14.5 0 0 1 9.5 24c0-1.59.28-3.14.76-4.59l-7.98-6.19A23.9 23.9 0 0 0 0 24c0 3.77.87 7.35 2.56 10.56l7.98-5.97z'/%3E%3Cpath fill='%2334A853' d='M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 5.97C6.51 42.62 14.62 48 24 48z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  flex-shrink: 0;
}

.btn-google:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.25);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(255,255,255,0.06);
}

/* ===== LOGIN SCREEN ===== */
#loginScreen.active { display: flex; justify-content: center; align-items: center; }

.login-box {
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(24px);
  border-radius: 28px;
  padding: 48px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.06);
  max-width: 440px;
  width: 92%;
}

.login-box h1 {
  font-size: 40px;
  font-weight: 700;
  margin-bottom: 4px;
  background: linear-gradient(135deg, #667eea, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle { color: rgba(255,255,255,0.5); margin-bottom: 28px; font-size: 16px; }

.form-group { margin-bottom: 14px; }

.form-group input {
  width: 100%;
  padding: 14px 22px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: #fff;
  font-size: 16px;
  transition: all 0.25s;
  font-family: inherit;
}

.form-group input::placeholder { color: rgba(255,255,255,0.3); }

.form-group input:focus {
  outline: none;
  border-color: #667eea;
  background: rgba(102,126,234,0.08);
  box-shadow: 0 0 0 3px rgba(102,126,234,0.12);
}

.buttons { display: flex; gap: 12px; justify-content: center; margin-bottom: 14px; }

.btn-primary, .btn-secondary {
  padding: 14px 28px;
  border-radius: 14px;
  border: none;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 16px rgba(102,126,234,0.25);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(102,126,234,0.35);
}

.btn-secondary {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.12);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.25);
}

.error { color: #ff6b6b; margin-top: 12px; font-size: 14px; min-height: 18px; }

.info-box {
  margin-top: 24px;
  padding: 14px 16px;
  background: rgba(102,126,234,0.08);
  border-radius: 14px;
  border: 1px solid rgba(102,126,234,0.12);
  text-align: left;
  font-size: 13px;
  line-height: 1.6;
}

.info-box p { margin: 4px 0; color: rgba(255,255,255,0.65); }

/* ===== DESKTOP SCREEN ===== */
#desktopScreen { flex-direction: column; }
#desktopScreen.active { display: flex; }

.desktop-header {
  background: rgba(0,0,0,0.25);
  padding: 12px 24px;
  padding-top: max(12px, env(safe-area-inset-top));
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(12px);
}

.header-left .logo { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }

.header-right { display: flex; align-items: center; gap: 10px; }

.user-badge {
  background: rgba(102,126,234,0.15);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  border: 1px solid rgba(102,126,234,0.2);
}

.btn-edit-profile {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.2s;
  opacity: 0.6;
  line-height: 1;
}
.btn-edit-profile:hover { opacity: 1; background: rgba(102,126,234,0.15); }

.btn-logout {
  padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,80,80,0.3);
  background: rgba(255,80,80,0.08);
  color: #ff6b6b;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-logout:hover { background: #ff6b6b; color: white; }

.btn-lang {
  padding: 7px 11px;
  border-radius: 10px;
  border: 1px solid rgba(102,126,234,0.3);
  background: rgba(102,126,234,0.08);
  color: #667eea;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
}

.btn-lang:hover { background: #667eea; color: white; }

.btn-gallery {
  padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid rgba(102,126,234,0.3);
  background: rgba(102,126,234,0.08);
  color: #667eea;
  text-decoration: none;
  font-size: 13px;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-gallery:hover { background: #667eea; color: white; }

.desktop {
  flex: 1;
  padding: 28px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 16px;
  overflow-y: auto;
}

.game-grid { display: flex; flex-wrap: wrap; gap: 16px; align-content: flex-start; }

.game-icon {
  width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 10px;
  border-radius: 16px;
  transition: all 0.2s;
}

.game-icon:hover { background: rgba(255,255,255,0.06); transform: translateY(-4px); }

.icon-wrapper {
  width: 68px;
  height: 68px;
  border-radius: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  position: relative;
}

.game-icon:not(.new-game) .icon-wrapper {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.game-icon.new-game .icon-wrapper {
  background: rgba(255,255,255,0.04);
  border: 2px dashed rgba(255,255,255,0.15);
}

.icon { font-size: 30px; }

.icon-label {
  font-size: 12px;
  text-align: center;
  color: rgba(255,255,255,0.8);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-icon .delete-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,80,80,0.9);
  color: white;
  border: 2px solid rgba(15,15,35,0.8);
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.game-icon:hover .delete-btn { opacity: 1; }

.taskbar {
  background: rgba(0,0,0,0.3);
  padding: 10px 24px;
  border-top: 1px solid rgba(255,255,255,0.06);
  min-height: 20px;
}

/* ===== EDITOR SCREEN ===== */
#editorScreen { flex-direction: column; }
#editorScreen.active { display: flex; }

.editor-header {
  background: rgba(0,0,0,0.25);
  padding: 10px 20px;
  padding-top: max(10px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(12px);
}

.btn-back {
  padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}

.btn-back:hover { background: rgba(255,255,255,0.1); }

.game-name-input {
  flex: 1;
  max-width: 280px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: white;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
}

.game-name-input:focus { outline: none; border-color: #667eea; }

.header-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.btn-share, .btn-versions {
  padding: 7px 14px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-share {
  background: linear-gradient(135deg, #00b894, #00a085);
  color: white;
}

.btn-share:hover { transform: scale(1.04); }

.btn-versions {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: white;
}

.btn-versions:hover { background: rgba(255,165,0,0.15); }

.auto-save { font-size: 12px; color: rgba(255,255,255,0.4); }

/* Editor Body */
.editor-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  max-height: calc(100vh - 56px);
  position: relative;
}

/* Chat Panel */
.chat-panel {
  width: 42%;
  height: 100%;
  max-height: calc(100vh - 56px);
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  background: rgba(0,0,0,0.15);
  border-right: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
}

.chat-header {
  padding: 14px 18px;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chat-header h3 { font-size: 15px; font-weight: 600; }

.btn-close-chat {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,80,80,0.15);
  color: white;
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.btn-close-chat:hover { background: rgba(255,80,80,0.35); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  animation: msgIn 0.25s ease;
}

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

.message.user {
  background: linear-gradient(135deg, #667eea, #764ba2);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  color: white;
}

.message.assistant {
  background: rgba(255,255,255,0.06);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,0.06);
}

.message.assistant pre {
  background: rgba(0,0,0,0.3);
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12px;
  margin: 8px 0;
  border: 1px solid rgba(255,255,255,0.06);
}

.retry-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  padding: 7px 16px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.retry-btn:hover { transform: scale(1.04); }

.chat-input-area {
  display: flex;
  padding: 14px;
  gap: 10px;
  background: rgba(0,0,0,0.15);
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

#chatInput {
  flex: 1;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: #fff;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

#chatInput:focus { border-color: #667eea; background: rgba(102,126,234,0.06); }

.btn-send {
  padding: 11px 16px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #00b894, #00a085);
  color: white;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.quick-actions {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background: rgba(0,0,0,0.08);
  flex-shrink: 0;
}

.quick-actions.hidden { display: none; }

.quick-chip {
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.85);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}

.quick-chip:hover {
  background: rgba(102,126,234,0.18);
  border-color: rgba(102,126,234,0.4);
  transform: translateY(-1px);
}

.quick-chip:active { transform: scale(0.96); }

/* Streaming Indicators */
.message.streaming { min-height: 40px; }

.thinking-indicator {
  display: inline-block;
  color: rgba(255,255,255,0.6);
  font-style: italic;
  animation: pulse 1.5s ease-in-out infinite;
}

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

.building-tag {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  background: rgba(102,126,234,0.15);
  border: 1px solid rgba(102,126,234,0.3);
  border-radius: 8px;
  font-size: 12px;
  color: #a5b4fc;
  animation: pulse 1.2s ease-in-out infinite;
}

.preparing-tag {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  background: rgba(251,191,36,0.12);
  border: 1px solid rgba(251,191,36,0.25);
  border-radius: 8px;
  font-size: 12px;
  color: #fbbf24;
  animation: pulse 1.5s ease-in-out infinite;
}

.game-updated-tag {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  background: rgba(0,184,148,0.15);
  border: 1px solid rgba(0,184,148,0.3);
  border-radius: 8px;
  font-size: 12px;
  color: #6ee7b7;
}

.search-indicator {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 10px;
  background: rgba(255,183,77,0.12);
  border: 1px solid rgba(255,183,77,0.25);
  border-radius: 8px;
  font-size: 12px;
  color: #fbbf24;
  animation: pulse 1.2s ease-in-out infinite;
}

.search-results {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  font-size: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.search-results .search-header {
  color: #fbbf24;
  font-weight: 600;
  margin-bottom: 6px;
}

.search-results ul {
  margin: 4px 0;
  padding-left: 16px;
}

.search-results li {
  margin: 3px 0;
  color: rgba(255,255,255,0.8);
}

.search-results a {
  color: #93c5fd;
  text-decoration: none;
}

.search-results a:hover {
  text-decoration: underline;
}

.search-results .search-raw pre {
  margin: 4px 0;
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  white-space: pre-wrap;
  word-break: break-all;
}

/* Asset Panel */
.btn-assets {
  padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(102,126,234,0.12);
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}
.btn-assets:hover, .btn-assets.active { background: rgba(102,126,234,0.35); border-color: #667eea; }

.asset-panel {
  width: 340px;
  flex: 0 0 340px;
  display: flex;
  flex-direction: column;
  background: rgba(10,10,30,0.97);
  border-right: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
  transition: width 0.3s ease, flex 0.3s ease;
  z-index: 10;
}
.asset-panel.hidden { display: none; }

.asset-panel-header {
  padding: 14px 16px;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.asset-panel-header h3 { font-size: 15px; font-weight: 600; }
.btn-close-assets {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,80,80,0.12);
  color: white; font-size: 16px;
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: background 0.2s;
}
.btn-close-assets:hover { background: rgba(255,80,80,0.35); }

.asset-type-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.asset-tab {
  flex: 1;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: transparent;
  color: rgba(255,255,255,0.55);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.asset-tab.active, .asset-tab:hover {
  background: rgba(102,126,234,0.2);
  border-color: #667eea;
  color: white;
}

.asset-upload-zone {
  margin: 10px 12px;
  border: 2px dashed rgba(102,126,234,0.3);
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.asset-upload-zone:hover, .asset-upload-zone.dragover {
  border-color: #667eea;
  background: rgba(102,126,234,0.08);
}
.asset-upload-zone .upload-icon { font-size: 28px; margin-bottom: 6px; }
.asset-upload-zone p { font-size: 12px; color: rgba(255,255,255,0.65); margin: 3px 0; line-height: 1.4; }
.asset-upload-zone .upload-hint { font-size: 10px; color: rgba(255,255,255,0.35); }

.asset-upload-progress {
  margin: 0 12px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: rgba(255,255,255,0.65);
  flex-shrink: 0;
}
.asset-upload-progress.hidden { display: none; }
.upload-progress-bar {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s;
}

.asset-grid {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 10px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  align-content: start;
}
.asset-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: rgba(255,255,255,0.3);
  font-size: 12px;
  padding: 24px 12px;
  line-height: 1.6;
}

.asset-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}
.asset-card:hover { border-color: #667eea; background: rgba(102,126,234,0.08); }

.asset-thumbnail {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: rgba(0,0,0,0.25);
  display: block;
}
.asset-sound-thumb {
  width: 100%;
  aspect-ratio: 1;
  background: rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}
.asset-card-info {
  padding: 6px 7px 7px;
}
.asset-card-name {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
}
.asset-card-actions {
  display: flex;
  gap: 4px;
}
.asset-use-btn, .asset-del-btn {
  flex: 1;
  padding: 4px 6px;
  border-radius: 6px;
  border: none;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.asset-use-btn {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
}
.asset-use-btn:hover { opacity: 0.85; }
.asset-del-btn {
  background: rgba(255,80,80,0.12);
  border: 1px solid rgba(255,80,80,0.2);
  color: rgba(255,150,150,0.9);
}
.asset-del-btn:hover { background: rgba(255,80,80,0.3); }

/* ── Plan card ─────────────────────────────────────────────────────────────── */
.plan-message {
  max-width: 95% !important;
  background: transparent !important;
  padding: 0 !important;
  border: none !important;
}

.plan-card {
  background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(139,92,246,0.06));
  border: 1px solid rgba(99,102,241,0.35);
  border-radius: 14px;
  padding: 16px 18px;
  animation: planSlideIn 0.35s cubic-bezier(.2,.8,.2,1);
}

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

.plan-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #a5b4fc;
  margin-bottom: 10px;
}

.plan-content {
  font-size: 13.5px;
  line-height: 1.75;
  color: rgba(255,255,255,0.88);
}

.plan-content strong, .plan-heading {
  color: #c4b5fd;
  font-weight: 700;
}

.plan-content code {
  background: rgba(0,0,0,0.3);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  color: #86efac;
  font-family: 'JetBrains Mono', monospace;
}

.plan-bullet {
  display: block;
  padding: 1px 0;
  color: rgba(255,255,255,0.78);
}

.plan-bullet::before { color: #818cf8; }

.plan-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.plan-approve-btn {
  flex: 2;
  padding: 11px 18px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  box-shadow: 0 4px 14px rgba(16,185,129,0.3);
}
.plan-approve-btn:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 6px 20px rgba(16,185,129,0.45);
}
.plan-approve-btn:active { transform: scale(0.98); }

.plan-change-btn {
  flex: 1;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.75);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.plan-change-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.25);
  color: white;
}

/* Search status / result enhancements */
.search-indicator {
  font-size: 12px;
  color: #a5b4fc;
  padding: 6px 10px;
  background: rgba(99,102,241,0.1);
  border-radius: 8px;
  margin: 4px 0;
  border-left: 3px solid #6366f1;
}

/* Injected asset tag in chat input area */
.asset-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(102,126,234,0.2);
  border: 1px solid rgba(102,126,234,0.4);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11px;
  color: #a5b4fc;
  margin-right: 4px;
  vertical-align: middle;
}

/* Preview Panel */
.preview-panel { width: 58%; display: flex; flex-direction: column; }

.preview-header {
  padding: 12px 18px;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.preview-header h3 { font-size: 15px; font-weight: 600; }

.preview-actions { display: flex; gap: 8px; align-items: center; }

.btn-preview-action {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-preview-action:hover { background: rgba(102,126,234,0.15); }

.btn-refresh {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: white;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.btn-refresh:hover { background: rgba(102,126,234,0.15); }

.preview-container { flex: 1; padding: 12px; min-height: 0; overflow: hidden; }

#preview {
  width: 100%;
  height: 100%;
  min-height: 200px;
  border: none;
  border-radius: 12px;
  background: white;
}

/* ===== MODALS ===== */
.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
  background: linear-gradient(135deg, #1a1a30, #252545);
  border-radius: 20px;
  padding: 28px;
  width: 92%;
  max-width: 440px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  text-align: center;
  border: 1px solid rgba(255,255,255,0.06);
  animation: scaleIn 0.2s ease;
}

@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-content h2 { margin-bottom: 14px; font-size: 20px; }
.modal-desc { color: rgba(255,255,255,0.6); margin-bottom: 18px; font-size: 14px; }

.modal-content input {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  color: white;
  font-size: 15px;
  margin-bottom: 16px;
  font-family: inherit;
}

.modal-content input:focus { outline: none; border-color: #667eea; }
.modal-buttons { display: flex; gap: 12px; justify-content: center; }

.btn-danger {
  padding: 12px 24px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s;
}

.btn-danger:hover { transform: scale(1.02); }

.warning { color: #ff6b6b; font-size: 14px; margin-bottom: 14px; }

/* Share Modal */
.share-info { color: rgba(255,255,255,0.6); margin-bottom: 18px; font-size: 14px; }

.share-link-box { display: flex; gap: 10px; margin-bottom: 18px; }

.share-link-box input {
  flex: 1;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  color: white;
  font-size: 13px;
}

.btn-copy {
  padding: 11px 18px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  white-space: nowrap;
}

.copy-status { margin-top: 10px; font-size: 13px; color: #00b894; min-height: 18px; }

.share-buttons { display: flex; gap: 10px; justify-content: center; }

.btn-preview {
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #00b894, #00a085);
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}

.btn-close {
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  color: white;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}

/* ===== LOADING ===== */
.loading {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 14px;
}

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

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ===== DEVICE SELECTION ===== */
#deviceScreen.active { display: flex; justify-content: center; align-items: center; }

.device-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 24px; }

.device-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 14px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.03);
  color: white;
  cursor: pointer;
  transition: all 0.25s;
  font-family: inherit;
}

.device-btn:hover {
  background: rgba(102,126,234,0.15);
  border-color: rgba(102,126,234,0.4);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(102,126,234,0.12);
}

.device-icon { font-size: 44px; margin-bottom: 10px; }
.device-name { font-size: 13px; font-weight: 500; }

/* ===== VERSION HISTORY ===== */
.modal-versions { max-width: 500px; max-height: 80vh; display: flex; flex-direction: column; }

.version-list {
  max-height: 360px;
  overflow-y: auto;
  margin: 14px 0;
  border-radius: 10px;
  background: rgba(0,0,0,0.2);
}

.version-item {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.version-item:hover { background: rgba(255,255,255,0.04); }
.version-item:last-child { border-bottom: none; }
.version-info { flex: 1; text-align: left; }
.version-label { font-size: 13px; color: #fff; margin-bottom: 3px; }
.version-time { font-size: 11px; color: rgba(255,255,255,0.4); }
.version-actions { display: flex; gap: 8px; }

.btn-revert {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(102,126,234,0.3);
  background: rgba(102,126,234,0.1);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-revert:hover { background: rgba(102,126,234,0.25); }

.version-empty { text-align: center; padding: 28px; color: rgba(255,255,255,0.4); font-size: 14px; }

/* ===== PUBLIC TOGGLE ===== */
.public-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  transition: all 0.2s;
}

.public-toggle:hover { background: rgba(255,255,255,0.06); }

.public-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #667eea;
}

.toggle-label { font-size: 12px; color: rgba(255,255,255,0.7); white-space: nowrap; }
.public-toggle input[type="checkbox"]:checked + .toggle-label { color: #667eea; }

.public-toggle-preview { padding: 4px 8px; }
.public-toggle-preview .toggle-label { display: none; }

/* ===== CHAT TOGGLE (mobile) ===== */
.chat-toggle { display: none; }

/* ===== VERSION BADGE ON MESSAGES ===== */
.version-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 165, 0, 0.15);
  border: 1px solid rgba(255, 165, 0, 0.3);
  color: #fbbf24;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  vertical-align: middle;
  user-select: none;
  white-space: nowrap;
}

.version-badge:hover {
  background: rgba(255, 165, 0, 0.25);
  transform: scale(1.05);
}

/* ===== MESSAGE DELETE BUTTON ===== */
.msg-delete-btn {
  display: none;
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 80, 80, 0.3);
  background: rgba(255, 80, 80, 0.1);
  color: #ff6b6b;
  font-size: 11px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
  padding: 0;
}

.message:hover .msg-delete-btn {
  display: flex;
}

.msg-delete-btn:hover {
  background: rgba(255, 80, 80, 0.3);
  transform: scale(1.1);
}

.message.user {
  position: relative;
}

/* ===== VERSION ACTION MENU ===== */
.version-actions-menu {
  display: none;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  padding: 8px;
  background: rgba(30, 30, 60, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  animation: scaleIn 0.15s ease;
  z-index: 10;
}

.version-actions-header {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  padding: 2px 4px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 2px;
}

.version-action-btn {
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.04);
  color: white;
  text-align: left;
  width: 100%;
}

.version-action-btn:hover {
  background: rgba(102, 126, 234, 0.2);
}

.version-action-btn.revert-btn {
  color: #a5b4fc;
}

.version-action-btn.truncate-btn {
  color: #ff6b6b;
}

.version-action-btn.truncate-btn:hover {
  background: rgba(255, 80, 80, 0.15);
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* ===== ENHANCED VERSION MODAL ===== */
.version-chat-preview {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 4px;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.version-type-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 4px;
  vertical-align: middle;
}

.version-type-badge.agent {
  background: rgba(102, 126, 234, 0.15);
  border: 1px solid rgba(102, 126, 234, 0.3);
  color: #a5b4fc;
}

.version-type-badge.backup {
  background: rgba(255, 165, 0, 0.12);
  border: 1px solid rgba(255, 165, 0, 0.25);
  color: #fbbf24;
}

.version-item.version-active {
  background: rgba(102, 126, 234, 0.08);
  border-left: 3px solid #667eea;
  border-radius: 6px;
}

.version-item.version-active .version-label {
  color: #a5b4fc;
}

/* ===== PROFILE MODAL ===== */
.modal-profile { max-width: 500px; max-height: 80vh; display: flex; flex-direction: column; text-align: left; }
.modal-profile h2 { text-align: center; }

.profile-stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 16px 0;
  padding: 14px;
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.06);
  text-align: center;
}

.profile-stat { flex: 1; }

.stat-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: #667eea;
}

.stat-label {
  display: block;
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-game-list {
  flex: 1;
  overflow-y: auto;
  max-height: 300px;
  margin: 8px 0;
  border-radius: 10px;
  background: rgba(0,0,0,0.2);
  min-height: 60px;
}

.profile-game-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  transition: all 0.2s;
}

.profile-game-item:hover { background: rgba(255,255,255,0.04); }
.profile-game-item:last-child { border-bottom: none; }

.profile-game-emoji { font-size: 24px; flex-shrink: 0; }
.profile-game-info { flex: 1; min-width: 0; }

.profile-game-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-game-plays {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
}

.play-btn-small {
  padding: 6px 14px;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  color: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s;
  font-family: inherit;
}

.play-btn-small:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102,126,234,0.3);
}

.profile-empty {
  text-align: center;
  padding: 28px;
  color: rgba(255,255,255,0.4);
  font-size: 14px;
}

.profile-link-inline {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.profile-link-inline:hover {
  text-decoration: underline;
  color: #667eea;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .editor-body { flex-direction: column; }
  .chat-panel, .preview-panel { width: 100%; height: 50%; flex: 0 0 auto; }
}

@media (max-width: 768px) {
  .login-box, .language-box { padding: 28px 20px; width: 95%; }
  .login-box h1 { font-size: 32px; }
  .language-box h1 { font-size: 28px; }
  .logo-big { font-size: 48px; }
  .subtitle { font-size: 13px; }
  .buttons { flex-direction: column; gap: 10px; }
  .btn-primary, .btn-secondary { width: 100%; padding: 12px; }

  .desktop-header { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .header-left .logo { font-size: 15px; }
  .header-right { flex-wrap: wrap; gap: 8px; }
  .user-badge { font-size: 12px; padding: 4px 10px; }
  .btn-logout, .btn-gallery { padding: 5px 10px; font-size: 12px; }

  .desktop { padding: 16px; gap: 12px; justify-content: center; }
  .game-icon { width: 80px; }
  .icon-wrapper { width: 54px; height: 54px; }
  .icon { font-size: 24px; }
  .icon-label { font-size: 11px; max-width: 75px; }

  .editor-header { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .btn-back { padding: 6px 10px; font-size: 12px; }
  .game-name-input { flex: 1; max-width: none; font-size: 15px; }
  .header-actions { display: none; }

  .editor-body { flex-direction: column-reverse; }

  .chat-panel {
    display: none !important;
    position: fixed !important;
    top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 1000 !important;
    background: #0f0f23 !important;
    border-radius: 0 !important;
    flex-direction: column !important;
    flex: 0 0 auto !important;
  }

  .chat-panel.active { display: flex !important; }

  .btn-close-chat { display: flex !important; }

  .chat-header { padding-top: max(14px, env(safe-area-inset-top)) !important; flex-shrink: 0 !important; }

  .chat-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .chat-input-area {
    flex: 0 0 auto !important;
    padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
  }

  .quick-actions {
    flex: 0 0 auto !important;
    padding-bottom: max(8px, env(safe-area-inset-bottom)) !important;
  }

  .preview-panel { width: 100%; height: 100%; min-height: calc(100vh - 50px); }
  .preview-container { flex: 1; padding: 4px; }
  #preview { width: 100%; height: 100%; min-height: calc(100vh - 100px); border-radius: 10px; }

  .asset-panel {
    position: fixed !important;
    top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    width: 100vw !important;
    flex: none !important;
    z-index: 1100 !important;
    border-right: none !important;
  }

  .chat-toggle {
    display: flex !important;
    position: fixed;
    bottom: 20px; right: 20px;
    width: 54px; height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102,126,234,0.4);
    z-index: 999;
    align-items: center;
    justify-content: center;
  }

  .modal-content { padding: 20px; width: 95%; }
  .modal-content h2 { font-size: 18px; }
  .modal-buttons { flex-direction: column; gap: 10px; }
  .modal-buttons button { width: 100%; }
  .share-link-box { flex-direction: column; }
  .share-buttons { flex-direction: column; gap: 8px; }

  .modal-versions { max-width: 95%; max-height: 70vh; }
  .version-list { max-height: 220px; }

  .modal-profile { max-width: 95%; max-height: 70vh; padding: 20px; }
  .profile-stats { gap: 10px; padding: 10px; }
  .stat-value { font-size: 16px; }
  .profile-game-list { max-height: 200px; }
}

@media (max-width: 480px) {
  .login-box, .language-box { padding: 20px 16px; width: 100%; margin: 10px; border-radius: 20px; }
  .login-box h1 { font-size: 26px; }
  .logo-big { font-size: 40px; }
  .form-group input { padding: 12px 16px; }
  .desktop-header { padding: 8px 10px; }
  .desktop { padding: 12px; gap: 10px; }
  .game-icon { width: 72px; }
  .icon-wrapper { width: 48px; height: 48px; }
  .icon { font-size: 20px; }
  .icon-label { font-size: 10px; max-width: 65px; }
  .quick-actions span { display: none; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .login-box { padding: 20px; max-width: 90%; }
  .login-box h1 { font-size: 24px; }
  .editor-body { flex-direction: row !important; }
  .chat-panel { width: 50% !important; height: calc(100vh - 50px) !important; }
  .preview-panel { width: 50% !important; height: calc(100vh - 50px) !important; }
  .quick-actions { display: none; }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media (prefers-contrast: high) {
  .btn-primary, .btn-secondary { border: 2px solid white; }
  .form-group input { border-width: 2px; }
  .message { border: 1px solid rgba(255,255,255,0.3); }
}

/* ===== NO ZOOM ON MOBILE ===== */
* { -webkit-tap-highlight-color: transparent; }
input, textarea { -webkit-user-select: text; user-select: text; }
input, textarea, select { font-size: 16px !important; }
button, a, .game-icon, .device-btn { touch-action: manipulation; }

@media print {
  .btn-logout, .btn-share, .btn-refresh, .quick-actions, .chat-input-area { display: none !important; }
  body { background: white; color: black; }
}

/* ── Streaming overlay ──────────────────────────────────────────────── */
.stream-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.3s;
}
.stream-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.stream-card {
  background: #fff;
  border-radius: 20px;
  padding: 36px 48px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);
  min-width: 280px;
  max-width: 360px;
}
.stream-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 18px;
  border: 4px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: stream-spin 0.8s linear infinite;
}
@keyframes stream-spin {
  to { transform: rotate(360deg); }
}
.stream-status {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 20px;
  line-height: 1.4;
}
.btn-abort-stream {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  color: #64748b;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-abort-stream:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}
