* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100%;
  background-color: #090d16;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #f1f5f9;
  overflow-x: hidden;
}

/* Screen Transitions */
.screen-view {
  display: none;
  width: 100%;
  min-height: 100vh;
  padding: 16px;
  flex-direction: column;
}

.screen-view.active {
  display: flex;
}

/* ========================================================= */
/* STUDIO SCREEN                                             */
/* ========================================================= */
.studio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.studio-title-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.studio-logo {
  font-size: 28px;
}

.studio-header h1 {
  font-size: 18px;
  font-weight: 800;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.studio-sub {
  font-size: 11px;
  color: #94a3b8;
}

.status-badge {
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 9999px;
}

/* Mode Tabs */
.mode-tabs {
  display: flex;
  gap: 8px;
  background: rgba(30, 41, 59, 0.7);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 14px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: #38bdf8;
  color: #0f172a;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.35);
}

/* Tab Contents */
.tab-content {
  display: none;
  margin-bottom: 14px;
}

.tab-content.active {
  display: block;
}

/* Canvas Card */
.canvas-card {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.canvas-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.canvas-title {
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.canvas-mini-btns {
  display: flex;
  gap: 6px;
}

.mini-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.mini-btn.btn-danger {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.3);
}

.canvas-touch-box {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #ffffff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
  touch-action: none;
}

#draw-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.canvas-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #94a3b8;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
  opacity: 0.8;
  transition: opacity 0.3s;
}

.canvas-guide.hidden {
  opacity: 0;
}

/* Palette Bar */
.palette-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.color-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.color-dot.active {
  transform: scale(1.22);
  border-color: #ffffff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
}

#custom-color-input {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  padding: 0;
  background: none;
}

/* Brush Controls */
.brush-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 12px;
}

.tool-switch {
  display: flex;
  gap: 4px;
  background: rgba(15, 23, 42, 0.6);
  padding: 3px;
  border-radius: 8px;
}

.tool-toggle {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.tool-toggle.active {
  background: #38bdf8;
  color: #0f172a;
}

.size-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.size-label {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
}

#brush-size {
  flex: 1;
  accent-color: #38bdf8;
}

#brush-size-display {
  font-size: 11px;
  font-weight: 700;
  color: #cbd5e1;
  min-width: 28px;
}

/* Photo / Camera Card */
.photo-card {
  background: rgba(30, 41, 59, 0.5);
  border: 1px dashed rgba(56, 189, 248, 0.4);
  border-radius: 18px;
  padding: 24px 16px;
  text-align: center;
}

.photo-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.photo-title {
  font-size: 15px;
  font-weight: 800;
  color: #e2e8f0;
  margin-bottom: 6px;
}

.photo-hint {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 16px;
  line-height: 1.4;
}

.camera-btn {
  display: inline-block;
  background: linear-gradient(135deg, #0ea5e9, #3b82f6);
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
  padding: 12px 24px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.4);
}

.photo-preview-wrap {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#photo-preview-img {
  max-width: 220px;
  max-height: 220px;
  border-radius: 12px;
  border: 2px solid #38bdf8;
}

.btn-secondary {
  background: #10b981;
  color: #ffffff;
  border: none;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
}

/* Presets View */
.presets-card {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 14px;
}

.presets-title {
  font-size: 13px;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 10px;
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.preset-card-btn {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.preset-card-btn:active {
  transform: scale(0.96);
  border-color: #38bdf8;
}

.preset-emoji {
  font-size: 26px;
}

.preset-name {
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
}

.preset-tag {
  font-size: 10px;
  color: #38bdf8;
  font-weight: 600;
}

/* Identity Card */
.identity-card {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 14px;
}

.form-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-group label {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
}

.input-group input {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  outline: none;
}

.input-group input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.archetype-select-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.archetype-label {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
}

.archetype-pills {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.arch-pill {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 700;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
}

.arch-pill.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  color: #38bdf8;
}

/* Launch Card & Button */
.launch-card {
  margin-top: auto;
  padding-top: 6px;
}

.btn-launch {
  width: 100%;
  background: linear-gradient(135deg, #f59e0b, #ef4444, #ec4899);
  background-size: 200% 200%;
  animation: rainbow-shift 3s infinite ease;
  border: none;
  color: #ffffff;
  padding: 16px 20px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(239, 68, 68, 0.45);
  transition: transform 0.1s;
}

.btn-launch:active {
  transform: scale(0.97);
}

.launch-icon {
  font-size: 22px;
}

@keyframes rainbow-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}


/* ========================================================= */
/* GAMEPAD REMOTE SCREEN                                     */
/* ========================================================= */
.gamepad-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 16px;
  border-radius: 16px;
  margin-bottom: 20px;
}

.gamepad-badge {
  font-size: 11px;
  font-weight: 800;
  color: #34d399;
  letter-spacing: 0.8px;
}

.gamepad-hero-title {
  font-size: 18px;
  font-weight: 900;
  color: #ffffff;
}

.gamepad-hero-sub {
  font-size: 11px;
  color: #94a3b8;
}

.btn-mini-studio {
  background: rgba(56, 189, 248, 0.2);
  border: 1px solid #38bdf8;
  color: #38bdf8;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.gamepad-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

/* Virtual D-Pad */
.dpad-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.dpad-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.dpad-row {
  display: flex;
  align-items: center;
}

.dpad-btn {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 2px solid rgba(255, 255, 255, 0.18);
  color: #f1f5f9;
  font-size: 24px;
  font-weight: 900;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
  touch-action: none;
}

.dpad-btn:active, .dpad-btn.pressed {
  background: #38bdf8;
  color: #0f172a;
  border-color: #ffffff;
  transform: scale(0.94);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.6);
}

.dpad-center {
  width: 72px;
  height: 72px;
  background: #090d16;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #334155;
}

/* Action Buttons Grid */
.actions-grid {
  width: 100%;
  max-width: 340px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.action-card-btn {
  background: rgba(30, 41, 59, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.15);
  padding: 16px 12px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  touch-action: manipulation;
}

.action-card-btn:active, .action-card-btn.pressed {
  transform: scale(0.94);
}

.action-jump:active, .action-jump.pressed {
  background: #10b981;
  border-color: #ffffff;
}

.action-dance:active, .action-dance.pressed {
  background: #f59e0b;
  border-color: #ffffff;
}

.action-shout:active, .action-shout.pressed {
  background: #38bdf8;
  border-color: #ffffff;
}

.action-flip:active, .action-flip.pressed {
  background: #ec4899;
  border-color: #ffffff;
}

.action-icon {
  font-size: 32px;
}

.action-name {
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
}

.gamepad-footer {
  text-align: center;
  font-size: 12px;
  color: #64748b;
  padding: 12px 0 6px;
}

/* Launch Animation Overlay */
.launch-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 7, 18, 0.95);
  backdrop-filter: blur(12px);
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.launch-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.launch-rocket {
  font-size: 72px;
  animation: rocket-fly 1.8s infinite ease-in-out;
}

.launch-status {
  font-size: 20px;
  font-weight: 900;
  color: #fbbf24;
  margin-top: 16px;
}

.launch-sub {
  font-size: 14px;
  color: #94a3b8;
  margin-top: 6px;
}

@keyframes rocket-fly {
  0% { transform: translateY(20px) scale(0.9); }
  50% { transform: translateY(-30px) scale(1.1); }
  100% { transform: translateY(20px) scale(0.9); }
}

/* Клавиатурный фокус: видимая обводка (доступность) */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible, label:focus-visible {
  outline: 3px solid #38bdf8; outline-offset: 2px;
}

/* Цвета точек палитры и скрытые элементы (переведено из инлайн-стилей draw.html, п.21 аудита) */
.dot-sky { background: #0ea5e9; }
.dot-green { background: #10b981; }
.dot-amber { background: #f59e0b; }
.dot-red { background: #ef4444; }
.dot-violet { background: #8b5cf6; }
.dot-pink { background: #ec4899; }
.dot-orange { background: #f97316; }
.dot-slate { background: #1e293b; }
.dot-white { background: #ffffff; border: 1px solid #94a3b8; }
#camera-file { display: none; }
#photo-preview-wrap { display: none; }
